Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: sashiko-reviews@lists.linux.dev
Cc: sashiko-bot@kernel.org, "Muchun Song" <songmuchun@bytedance.com>,
	"Alexander Potapenko" <glider@google.com>,
	"Marco Elver" <elver@google.com>,
	"Dmitry Vyukov" <dvyukov@google.com>,
	"Chris Down" <chris@chrisdown.name>,
	"David Hildenbrand" <david@kernel.org>,
	"Liam R . Howlett" <liam@infradead.org>,
	"Vlastimil Babka" <vbabka@kernel.org>,
	"Mike Rapoport" <rppt@kernel.org>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Michal Hocko" <mhocko@suse.com>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Brendan Jackman" <brendan.jackman@linux.dev>,
	"Zi Yan" <ziy@nvidia.com>, "Muchun Song" <muchun.song@linux.dev>,
	"Joerg Roedel" <joerg.roedel@amd.com>,
	"Lu Baolu" <baolu.lu@linux.intel.com>,
	"Pranjal Shrivastava" <praan@google.com>,
	Ketan <ketan.kishore@oss.qualcomm.com>,
	"Mostafa Saleh" <smostafa@google.com>,
	"Sang-Heon Jeon" <ekffu200098@gmail.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	kasan-dev@googlegroups.com, linux-mm@kvack.org
Subject: Re: [PATCH v2 2/7] mm/page_ext: fix client data alignment
Date: Tue, 17 Nov 2026 11:46:35 -0800	[thread overview]
Message-ID: <20261117114635.37d4c1f7f1b38cc4ce7fb886@linux-foundation.org> (raw)
In-Reply-To: <sashiko-outbox-219498@kernel.org>

On Tue, 17 Nov 2026 19:36:23 +0000 sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] mm/page_ext: 4-byte alignment cap in
>   page_ext_data_alignment() on 32-bit
> --
> 
> commit 4ecca9da35d7e4448f4270965043775293174eda
> Author: Muchun Song <muchun.song@linux.dev>
> 
> mm/page_ext: fix client data alignment
> 
> This commit aligns page_ext client offsets and rounds the final entry size to
> the largest active client alignment.
> 
> > diff --git a/mm/page_ext.c b/mm/page_ext.c
> > index b679a8c1f7d7e..dbc1bfa258f15 100644
> > --- a/mm/page_ext.c
> > +++ b/mm/page_ext.c
> > @@ -116,8 +116,22 @@ static int __init setup_early_page_ext(char *str)
> >  }
> >  early_param("early_page_ext", setup_early_page_ext);
> >  
> > +static inline size_t page_ext_data_alignment(size_t size)
> > +{
> > +	if (!size)
> > +		return 1;
> > +
> > +	/*
> > +	 * A type's size is a multiple of its natural alignment. The lowest
> > +	 * set bit of the size is therefore at least that alignment. Cap it
> > +	 * at unsigned long alignment to avoid excessive per-page padding.
> > +	 */
> > +	return min_t(size_t, 1UL << __ffs(size), __alignof__(unsigned long));
> > +}
> 
> [blah blah]
>

Yeah, but the whole expression is quite reader-hostile, as min/max
things often are.

How about doing

	/* comment */
	if (this1)
		return that1;
	/* comment */
	if (this2)
		return that2;
	/* comment */
	if (this3)
		return that3;

?

The code generation will probably be just as good and it's __init-time
stuff anyway.



  reply	other threads:[~2026-11-17 19:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 12:06 [PATCH v2 0/7] KMSAN: Move per-page metadata out of struct page Muchun Song
2026-11-17 12:06 ` [PATCH v2 1/7] kmsan: encapsulate per-page metadata access Muchun Song
2026-11-17 12:06 ` [PATCH v2 2/7] mm/page_ext: fix client data alignment Muchun Song
2026-11-17 19:36   ` sashiko-bot
2026-11-17 19:46     ` Andrew Morton [this message]
2026-11-17 12:06 ` [PATCH v2 3/7] mm/page_ext: always use vmalloc for section page extensions Muchun Song
2026-11-17 12:06 ` [PATCH v2 4/7] mm/page_ext: use common allocation and initialization entry points Muchun Song
2026-11-17 12:06 ` [PATCH v2 5/7] mm/page_ext: allocate page extensions early for SPARSEMEM Muchun Song
2026-11-18  0:06   ` Chris Down
2026-11-17 12:06 ` [PATCH v2 6/7] mm/page_ext: inline unchecked page extension lookup Muchun Song
2026-11-17 12:06 ` [PATCH v2 7/7] kmsan: fix metadata loss during HugeTLB struct page reinitialization Muchun Song
2026-11-18  0:06 ` [PATCH v2 0/7] KMSAN: Move per-page metadata out of struct page Chris Down

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=20261117114635.37d4c1f7f1b38cc4ce7fb886@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=baolu.lu@linux.intel.com \
    --cc=brendan.jackman@linux.dev \
    --cc=chris@chrisdown.name \
    --cc=corbet@lwn.net \
    --cc=david@kernel.org \
    --cc=dvyukov@google.com \
    --cc=ekffu200098@gmail.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=hannes@cmpxchg.org \
    --cc=joerg.roedel@amd.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=ketan.kishore@oss.qualcomm.com \
    --cc=liam@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=praan@google.com \
    --cc=rdunlap@infradead.org \
    --cc=rppt@kernel.org \
    --cc=sashiko-bot@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=skhan@linuxfoundation.org \
    --cc=smostafa@google.com \
    --cc=songmuchun@bytedance.com \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=ziy@nvidia.com \
    /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