lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100121151344.GA31975@angel.research.nokia.com>
Date:	Thu, 21 Jan 2010 17:13:44 +0200
From:	Jarkko Lavinen <jarkko.lavinen@...ia.com>
To:	Andrew Morton <akpm@...l.org>
Cc:	linux-kernel@...r.kernel.org,
	Hugh Dickins <hugh.dickins@...cali.co.uk>
Subject: Re: [PATCH] mm: Fix nr_good_pages calculation

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ