From: Zach Brown <zab@osdlab.org>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH] 2.4.9 si_swapinfo() speedup
Date: Mon, 10 Sep 2001 11:45:21 -0700 [thread overview]
Message-ID: <20010910114521.E19051@osdlab.pdx.osdl.net> (raw)
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/
reply other threads:[~2001-09-10 18:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010910114521.E19051@osdlab.pdx.osdl.net \
--to=zab@osdlab.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox