From: Qi Zheng <qi.zheng@linux.dev>
To: xu.xin16@zte.com.cn, akpm@linux-foundation.org, david@kernel.org,
ljs@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, npache@redhat.com,
ryan.roberts@arm.com, dev.jain@arm.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, wang.yaxin@zte.com.cn
Subject: Re: [PATCH v3 2/2] mm/mm_slot.h: add comments for mm_slot_lookup/insert
Date: Tue, 14 Jul 2026 17:44:25 +0800 [thread overview]
Message-ID: <e3ca51d9-e484-453e-abfa-2cb4840ab141@linux.dev> (raw)
In-Reply-To: <20260714092815120Wv-CFDlLKtsTmda--97Qw@zte.com.cn>
On 7/14/26 9:28 AM, xu.xin16@zte.com.cn wrote:
> From: xu xin <xu.xin16@zte.com.cn>
>
> mm_slot_lookup() and mm_slot_insert() are the only helpers in
> this header that are implemented as macros rather than static inline
> functions. This may look inconsistent without explanation.
>
> Explain they must be macros because hash_for_each_possible()
> needs the table as an array (for sizeof), not a pointer.
>
> Signed-off-by: xu xin <xu.xin16@zte.com.cn>
> ---
> mm/mm_slot.h | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/mm/mm_slot.h b/mm/mm_slot.h
> index 5de3e91d86b4..9b09b68e5742 100644
> --- a/mm/mm_slot.h
> +++ b/mm/mm_slot.h
> @@ -33,6 +33,12 @@ static inline void mm_slot_free(struct kmem_cache *cache, void *objp)
> kmem_cache_free(cache, objp);
> }
>
> +/*
> + * Note: mm_slot_lookup and mm_slot_insert cannot be converted to static inline
> + * functions because the hash helpers (hash_for_each_possible and hash_add) rely
> + * on the actual array argument 'hashtable' for sizeof() instead of pointers.
> + */
Right, that's why I wrote them as macros to begin with.
Reviewed-by: Qi Zheng <qi.zheng@linux.dev>
Thanks,
Qi
> +
> #define mm_slot_lookup(_hashtable, _mm) \
> ({ \
> struct mm_slot *tmp_slot, *mm_slot = NULL; \
next prev parent reply other threads:[~2026-07-14 9:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 1:24 [PATCH v3 0/2] Two small patches to clean up mm/mm_slot.h xu.xin16
2026-07-14 1:26 ` [PATCH v3 1/2] mm/mm_slot.h: add a helper function mm_slot_remove xu.xin16
2026-07-14 1:28 ` [PATCH v3 2/2] mm/mm_slot.h: add comments for mm_slot_lookup/insert xu.xin16
2026-07-14 1:37 ` Barry Song
2026-07-14 9:35 ` Lorenzo Stoakes (ARM)
2026-07-14 9:44 ` Qi Zheng [this message]
2026-07-14 13:26 ` David Hildenbrand (Arm)
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=e3ca51d9-e484-453e-abfa-2cb4840ab141@linux.dev \
--to=qi.zheng@linux.dev \
--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=ljs@kernel.org \
--cc=npache@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.