linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: linux-mm@kvack.org, David Rientjes <rientjes@google.com>,
	Christoph Lameter <cl@linux.com>,
	Hyeonggon Yoo <42.hyeyoo@gmail.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Kees Cook <keescook@chromium.org>,
	Alice Ryhl <aliceryhl@google.com>,
	Boqun Feng <boqun.feng@gmail.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	patches@lists.linux.dev
Subject: Re: [PATCH v2] slab, rust: extend kmalloc() alignment guarantees to remove Rust padding
Date: Wed, 3 Jul 2024 13:32:31 +0100	[thread overview]
Message-ID: <ZoVE34S2fOyUdZYg@casper.infradead.org> (raw)
In-Reply-To: <20240703072520.45837-2-vbabka@suse.cz>

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)


  parent reply	other threads:[~2024-07-03 12:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-03  7:25 Vlastimil Babka
2024-07-03  8:12 ` Alice Ryhl
2024-07-03 12:32 ` Matthew Wilcox [this message]
2024-07-03 12:57   ` Vlastimil Babka

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=ZoVE34S2fOyUdZYg@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=42.hyeyoo@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=boqun.feng@gmail.com \
    --cc=cl@linux.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=patches@lists.linux.dev \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=vbabka@suse.cz \
    /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