linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pedro Falcato <pfalcato@suse.de>
To: Ye Liu <ye.liu@linux.dev>
Cc: Dev Jain <dev.jain@arm.com>, Hu Song <husong@kylinos.cn>,
	 Vlastimil Babka <vbabka@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	 Christoph Lameter <cl@gentwo.org>,
	David Rientjes <rientjes@google.com>,
	 Roman Gushchin <roman.gushchin@linux.dev>,
	Harry Yoo <harry.yoo@oracle.com>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/slub: Use folio_nr_pages() in __free_slab()
Date: Tue, 9 Sep 2025 15:52:03 +0100	[thread overview]
Message-ID: <v5jeb6pbpkikzhjuno6pq65y6cdq76ucj5ebotakwpvzbmjl5h@7dtdjmqjxmp5> (raw)
In-Reply-To: <e058c588-2fa3-4763-bcc2-06b6fb6eddab@linux.dev>

On Tue, Sep 09, 2025 at 04:59:37PM +0800, Ye Liu wrote:
> 
> 在 2025/9/9 16:46, Dev Jain 写道:
> >
> > On 09/09/25 1:18 pm, Hu Song wrote:
> >> Use folio_nr_pages() helper instead of manual calculation (1 << order)
> >> for better code readability and maintainability.
> >>
> >> Signed-off-by: Hu Song <husong@kylinos.cn>
> >> ---
> >>   mm/slub.c | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/mm/slub.c b/mm/slub.c
> >> index d257141896c9..eba25461641a 100644
> >> --- a/mm/slub.c
> >> +++ b/mm/slub.c
> >> @@ -2719,7 +2719,7 @@ static void __free_slab(struct kmem_cache *s, struct slab *slab)
> >>   {
> >>       struct folio *folio = slab_folio(slab);
> >>       int order = folio_order(folio);
> >> -    int pages = 1 << order;
> >> +    int pages = folio_nr_pages(folio);
> >>         __slab_clear_pfmemalloc(slab);
> >>       folio->mapping = NULL;
> >
> > I don't know, the current version is more readable to me. We literally
> > compute the order before, so we do a simple 1 << order. I'll leave it
> > to the rest.
> >
> >
> Is the reason for calculating 'order' first because it's needed later.

Yes, we use it 6 lines down.

-- 
Pedro


  reply	other threads:[~2025-09-09 14:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-09  7:48 Hu Song
2025-09-09  8:00 ` Oscar Salvador
2025-09-09  8:30   ` Ye Liu
2025-09-09  8:46 ` Dev Jain
2025-09-09  8:59   ` Ye Liu
2025-09-09 14:52     ` Pedro Falcato [this message]
2025-09-09 14:29 ` Matthew Wilcox

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=v5jeb6pbpkikzhjuno6pq65y6cdq76ucj5ebotakwpvzbmjl5h@7dtdjmqjxmp5 \
    --to=pfalcato@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=cl@gentwo.org \
    --cc=dev.jain@arm.com \
    --cc=harry.yoo@oracle.com \
    --cc=husong@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=vbabka@suse.cz \
    --cc=ye.liu@linux.dev \
    /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