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: <ZoVE34S2fOyUdZYg@casper.infradead.org>
Date: Wed, 3 Jul 2024 13:32:31 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Vlastimil Babka <vbabka@...e.cz>
Cc: linux-mm@...ck.org, David Rientjes <rientjes@...gle.com>,
	Christoph Lameter <cl@...ux.com>,
	Hyeonggon Yoo <42.hyeyoo@...il.com>,
	Roman Gushchin <roman.gushchin@...ux.dev>,
	Kees Cook <keescook@...omium.org>,
	Alice Ryhl <aliceryhl@...gle.com>,
	Boqun Feng <boqun.feng@...il.com>, rust-for-linux@...r.kernel.org,
	linux-kernel@...r.kernel.org, patches@...ts.linux.dev
Subject: Re: [PATCH v2] slab, rust: extend kmalloc() alignment guarantees to
 remove Rust padding

On Wed, Jul 03, 2024 at 09:25:21AM +0200, Vlastimil Babka wrote:
> -	if (is_power_of_2(size))
> -		align = max(align, size);
> +	if (flags & SLAB_KMALLOC)
> +		align = max(align, 1U << (ffs(size) - 1));

hmm ... maybe this would be faster:

	if (flags & SLAB_KMALLOC) {
		u32 tmp = size & (size - 1);
		align = max(align, size - tmp);
	}

(if size is 2^n, tmp is 0.  otherwise, tmp is size with the lowest bit
clear, so size-tmp is the largest POT that divides size evenly)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ