From: Jarkko Lavinen <jarkko.lavinen@nokia.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, Hugh Dickins <hugh.dickins@tiscali.co.uk>
Subject: Re: [PATCH] mm: Fix nr_good_pages calculation
Date: Thu, 21 Jan 2010 17:13:44 +0200 [thread overview]
Message-ID: <20100121151344.GA31975@angel.research.nokia.com> (raw)
In-Reply-To: <20100120151912.GA27747@angel.research.nokia.com>
Cc to Hugh added.
On Wed, Jan 20, 2010 at 05:19:12PM +0200, Jarkko Lavinen wrote:
> Swapon wastes one page of swap space to no effect.
Perhaps this last page newer used problem needs some more explanation.
On x86 example machine A, swap partition is 15631245 kB. /proc/swaps
says the swap space is 15631236 KB, 9 KB less than the partition size
or two page difference. One page for the swap header, and the other
for what ?
On another x86 macine B, swap partition is 409626 KB, /proc/swaps says
it is 409616 KB, 10 KB difference or two pages and alignment bytes.
Again I can understand the need for one header page, but not two.
However swapon system call intends to use all the space available
except the header. This can be seen from swap_map allocation:
SYSCALL_DEFINE2(swapon, ...
...
maxpages = swp_offset(pte_to_swp_entry(
swp_entry_to_pte(swp_entry(0, ~0UL)))) - 1;
if (maxpages > swap_header->info.last_page)
maxpages = swap_header->info.last_page;
p->highest_bit = maxpages - 1;
...
swap_map = vmalloc(maxpages);
This way the swap_map has entries for the whole swap space
except for the header.
Then the nr_good_pages could be calculted with:
- nr_good_pages = swap_header->info.last_page -
- swap_header->info.nr_badpages -
- 1 /* header page */;
+ nr_good_pages = maxpages - swap_header->info.nr_badpages;
This change corrects the last swap file page never used problem.
If the last_page is ever greater than maxpages, this would also avoid
setting nr_good_pages to too large value.
Jarkko Lacinen
next prev parent reply other threads:[~2010-01-21 15:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-20 15:19 Jarkko Lavinen
2010-01-21 15:13 ` Jarkko Lavinen [this message]
2010-01-31 15:57 ` Hugh Dickins
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=20100121151344.GA31975@angel.research.nokia.com \
--to=jarkko.lavinen@nokia.com \
--cc=akpm@osdl.org \
--cc=hugh.dickins@tiscali.co.uk \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®