* Re: [PATCH v3 2/2] mm/mm_slot.h: add comments for mm_slot_lookup/insert
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)
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Barry Song @ 2026-07-14 1:37 UTC (permalink / raw)
To: xu.xin16
Cc: akpm, david, ljs, ziy, baolin.wang, lance.yang, usama.arif,
chengming.zhou, qi.zheng, npache, ryan.roberts, dev.jain,
linux-mm, linux-kernel, wang.yaxin
On Tue, Jul 14, 2026 at 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>
Thanks!
Reviewed-by: Barry Song <baohua@kernel.org>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v3 2/2] mm/mm_slot.h: add comments for mm_slot_lookup/insert
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
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-07-14 9:35 UTC (permalink / raw)
To: xu.xin16
Cc: akpm, david, ziy, baolin.wang, baohua, lance.yang, usama.arif,
chengming.zhou, qi.zheng, npache, ryan.roberts, dev.jain,
linux-mm, linux-kernel, wang.yaxin
On Tue, Jul 14, 2026 at 09:28:15AM +0800, 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>
LGTM, so:
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> ---
> 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.
> + */
> +
> #define mm_slot_lookup(_hashtable, _mm) \
> ({ \
> struct mm_slot *tmp_slot, *mm_slot = NULL; \
> --
> 2.25.1
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v3 2/2] mm/mm_slot.h: add comments for mm_slot_lookup/insert
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
2026-07-14 13:26 ` David Hildenbrand (Arm)
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Qi Zheng @ 2026-07-14 9:44 UTC (permalink / raw)
To: xu.xin16, akpm, david, ljs, ziy, baolin.wang, baohua, lance.yang,
usama.arif, chengming.zhou, npache, ryan.roberts, dev.jain
Cc: linux-mm, linux-kernel, wang.yaxin
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; \
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v3 2/2] mm/mm_slot.h: add comments for mm_slot_lookup/insert
2026-07-14 1:28 ` [PATCH v3 2/2] mm/mm_slot.h: add comments for mm_slot_lookup/insert xu.xin16
` (2 preceding siblings ...)
2026-07-14 9:44 ` Qi Zheng
@ 2026-07-14 13:26 ` David Hildenbrand (Arm)
2026-07-15 0:25 ` SJ Park
2026-07-15 1:10 ` Zi Yan
5 siblings, 0 replies; 9+ messages in thread
From: David Hildenbrand (Arm) @ 2026-07-14 13:26 UTC (permalink / raw)
To: xu.xin16, akpm, ljs, ziy, baolin.wang, baohua, lance.yang,
usama.arif, chengming.zhou, qi.zheng, npache, ryan.roberts,
dev.jain
Cc: linux-mm, linux-kernel, wang.yaxin
On 7/14/26 03:28, 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>
> ---
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v3 2/2] mm/mm_slot.h: add comments for mm_slot_lookup/insert
2026-07-14 1:28 ` [PATCH v3 2/2] mm/mm_slot.h: add comments for mm_slot_lookup/insert xu.xin16
` (3 preceding siblings ...)
2026-07-14 13:26 ` David Hildenbrand (Arm)
@ 2026-07-15 0:25 ` SJ Park
2026-07-15 1:10 ` Zi Yan
5 siblings, 0 replies; 9+ messages in thread
From: SJ Park @ 2026-07-15 0:25 UTC (permalink / raw)
To: xu.xin16
Cc: SJ Park, akpm, david, ljs, ziy, baolin.wang, baohua, lance.yang,
usama.arif, chengming.zhou, qi.zheng, npache, ryan.roberts,
dev.jain, linux-mm, linux-kernel, wang.yaxin
On Tue, 14 Jul 2026 09:28:15 +0800 (CST) <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.
Thank you for adding the explanation!
>
> Signed-off-by: xu xin <xu.xin16@zte.com.cn>
Reviewed-by: SJ Park <sj@kernel.org>
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v3 2/2] mm/mm_slot.h: add comments for mm_slot_lookup/insert
2026-07-14 1:28 ` [PATCH v3 2/2] mm/mm_slot.h: add comments for mm_slot_lookup/insert xu.xin16
` (4 preceding siblings ...)
2026-07-15 0:25 ` SJ Park
@ 2026-07-15 1:10 ` Zi Yan
5 siblings, 0 replies; 9+ messages in thread
From: Zi Yan @ 2026-07-15 1:10 UTC (permalink / raw)
To: xu.xin16, akpm, david, ljs, baolin.wang, baohua, lance.yang,
usama.arif, chengming.zhou, qi.zheng, npache, ryan.roberts,
dev.jain
Cc: linux-mm, linux-kernel, wang.yaxin
On Mon Jul 13, 2026 at 9:28 PM EDT, 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(+)
>
LGTM. Thanks.
Reviewed-by: Zi Yan <ziy@nvidia.com>
--
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 9+ messages in thread