Messages in this thread Patch in this message |  | | Date | Mon, 10 Sep 2001 11:45:21 -0700 | From | Zach Brown <> | Subject | [PATCH] 2.4.9 si_swapinfo() speedup |
| |
the attached patch makes si_swapinfo() use the swapfile.c global page accounting rather than walking the swapfiles to find the total and free numbers. Some folks have seen si_swapinfo() take an absurd amount of time..
Rik hints at rumours of the global accounting being questionable in some cases, perhaps more use of it would motivate that to be fixed :)
compiles, but totally untested.
- z
--- linux-2.4.9/mm/swapfile.c.swapinfo Mon Sep 10 11:06:05 2001 +++ linux-2.4.9/mm/swapfile.c Mon Sep 10 11:40:22 2001 @@ -877,27 +877,12 @@ void si_swapinfo(struct sysinfo *val) { - unsigned int i; - unsigned long freeswap = 0; - unsigned long totalswap = 0; + swap_list_lock(); - for (i = 0; i < nr_swapfiles; i++) { - unsigned int j; - if ((swap_info[i].flags & SWP_WRITEOK) != SWP_WRITEOK) - continue; - for (j = 0; j < swap_info[i].max; ++j) { - switch (swap_info[i].swap_map[j]) { - case SWAP_MAP_BAD: - continue; - case 0: - freeswap++; - default: - totalswap++; - } - } - } - val->freeswap = freeswap; - val->totalswap = totalswap; + val->totalswap = total_swap_pages; + val->freeswap = nr_swap_pages; + + swap_list_unlock(); return; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |