Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <ljs@kernel.org>
To: xu.xin16@zte.com.cn
Cc: akpm@linux-foundation.org, david@kernel.org, ziy@nvidia.com,
	 baolin.wang@linux.alibaba.com, baohua@kernel.org,
	lance.yang@linux.dev, usama.arif@linux.dev,
	 chengming.zhou@linux.dev, qi.zheng@linux.dev,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com,
	 wang.yaxin@zte.com.cn
Subject: Re: [PATCH] mm/mm_slot.h: add a helper function mm_slot_remove
Date: Mon, 13 Jul 2026 08:38:38 +0100	[thread overview]
Message-ID: <alST91EgYhtjkaAY@lucifer> (raw)
In-Reply-To: <202607131344540423N-vjn1y68X614fkeZemP@zte.com.cn>

On Mon, Jul 13, 2026 at 01:44:54PM +0800, xu.xin16@zte.com.cn wrote:
> > > No functional change is intended.
> > >
> > > Signed-off-by: xu xin <xu.xin16@zte.com.cn>
> >
> > In general it's fine but I want more :) see below.
> >
> > >
> > >
> > > diff --git a/mm/mm_slot.h b/mm/mm_slot.h
> > > index 83f18ed1c4bd..bc3b9ae8fdbc 100644
> > > --- a/mm/mm_slot.h
> > > +++ b/mm/mm_slot.h
> > > @@ -52,4 +52,11 @@ static inline void mm_slot_free(struct kmem_cache *cache, void *objp)
> > >  	hash_add(_hashtable, &_mm_slot->hash, (unsigned long)_mm);	       \
> > >  })
> > >
> >
> > mm_slot.h also inexplicably implements mm_slot_lookup() and mm_slot_insert() as
> > macros. Can you change these to static inline functions in the respin?
>
> Sorry, I looked into turning mm_slot_lookup() and mm_slot_insert() into
> static inline functions, but unfortunately it’s not possible because
> they rely on hash_for_each_possible() and hash_add(), which expect an
> actual array instead of pointer so that sizeof() can determine the
> hash table size. Passing a struct hlist_head * would make sizeof() return
> the pointer size instead of the array size, leading to incorrect bucket
> indexing and memory corruption.

Ah that's fair enough then, explains why they're macros there :)


>
> >
> > Also rename the horrible names from _foo -> foo too please.
> >
> > And we don't really need 'mm_slot' in the var name for a slot just 'slot' works
> > fine.
>
> Ok, I can clean up these stuff.

Thanks!

>
> >
> > > +static inline void mm_slot_remove(struct mm_slot *_mm_slot)
> >
> > Yeah this name is gross just 'slot' please.
> >
> > > +{
> > > +	hash_del(&_mm_slot->hash);
> > > +	list_del(&_mm_slot->mm_node);
> > > +}
> > > +
> > > +
> > >  #endif /* _LINUX_MM_SLOT_H */
> >
> > Thanks, Lorenzo
> >

Cheers, Lorenzo


      reply	other threads:[~2026-07-13  7:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10  5:15 [PATCH] mm/mm_slot.h: add a helper function mm_slot_remove xu.xin16
2026-07-10 12:17 ` Lorenzo Stoakes
2026-07-11  4:30   ` Matthew Wilcox
2026-07-11  6:37     ` Lorenzo Stoakes
2026-07-13  5:44   ` xu.xin16
2026-07-13  7:38     ` Lorenzo Stoakes [this message]

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=alST91EgYhtjkaAY@lucifer \
    --to=ljs@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=chengming.zhou@linux.dev \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=lance.yang@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=npache@redhat.com \
    --cc=qi.zheng@linux.dev \
    --cc=ryan.roberts@arm.com \
    --cc=usama.arif@linux.dev \
    --cc=wang.yaxin@zte.com.cn \
    --cc=xu.xin16@zte.com.cn \
    --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