From 5c3746a0fe380ae7ec5ee0e4aaef19b68b51d903 Mon Sep 17 00:00:00 2001 From: xu xin Date: Tue, 14 Jul 2026 09:28:15 +0800 Subject: [PATCH] mm/mm_slot.h: add comments for mm_slot_lookup/insert 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. Link: https://lore.kernel.org/20260714092815120Wv-CFDlLKtsTmda--97Qw@zte.com.cn Signed-off-by: xu xin Reviewed-by: Barry Song Acked-by: David Hildenbrand (Arm) Reviewed-by: Qi Zheng Reviewed-by: Lorenzo Stoakes (ARM) Reviewed-by: SJ Park Reviewed-by: Zi Yan Cc: Baolin Wang Cc: Chengming Zhou Cc: Dev Jain Cc: Lance Yang Cc: Nico Pache Cc: Ryan Roberts Cc: Wang Yaxin Signed-off-by: Andrew Morton --- 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; \