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] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.1111231501030.24794@chino.kir.corp.google.com>
Date:	Wed, 23 Nov 2011 15:06:37 -0800 (PST)
From:	David Rientjes <rientjes@...gle.com>
To:	zhihua che <zhihua.che@...il.com>
cc:	Christoph Lameter <cl@...ux.com>,
	Pekka Enberg <penberg@...helsinki.fi>,
	linux-kernel@...r.kernel.org
Subject: Re: Fwd: Slub Allocator: Why get_order(size * MAX_OBJS_PER_PAGE) -
 1 in function slab_order()?

On Wed, 23 Nov 2011, zhihua che wrote:

> I know what you mean, that is, a slab can only store no more than
> MAX_OBJS_PER_PAGE, actually 0x7FFF, objects.
> 
> But  get_order(size * MAX_OBJS_PER_PAGE) already returns the order
> which reserves no_more_than size * MAX_OBJS_PER_PAGE memory.  Right?
> 

Yes, but it reserves too much memory if the conditional is true.

> So I think there is no need to subtract one.
> 

If we didn't subtract one, then the order of a slab page would allow for 
_more_ than MAX_OBJS_PER_PAGE to be allocated and that's not allowed 
because of the restrictions in struct page.

Consider a page size of 4K and an object size of 8 bytes.  
get_order(8 * 32767) would be 6, so that's a 4K * 2^6 = 256K slab page 
without the subtraction and could allocate (256K * 1024 / 8) = 32768 which 
is greater than MAX_OBJS_PER_PAGE and not allowed.

So we subtract one so the compound slab page is guaranteed to allocate 
less than MAX_OBJS_PER_PAGE.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ