* [PATCH] 2.4.9 si_swapinfo() speedup
@ 2001-09-10 18:45 Zach Brown
0 siblings, 0 replies; only message in thread
From: Zach Brown @ 2001-09-10 18:45 UTC (permalink / raw)
To: linux-kernel, linux-mm
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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-09-10 18:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-10 18:45 [PATCH] 2.4.9 si_swapinfo() speedup Zach Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox