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/[email protected]
Signed-off-by: xu xin <[email protected]>
Reviewed-by: Barry Song <[email protected]>
Acked-by: David Hildenbrand (Arm) <[email protected]>
Reviewed-by: Qi Zheng <[email protected]>
Reviewed-by: Lorenzo Stoakes (ARM) <[email protected]>
Reviewed-by: SJ Park <[email protected]>
Reviewed-by: Zi Yan <[email protected]>
Cc: Baolin Wang <[email protected]>
Cc: Chengming Zhou <[email protected]>
Cc: Dev Jain <[email protected]>
Cc: Lance Yang <[email protected]>
Cc: Nico Pache <[email protected]>
Cc: Ryan Roberts <[email protected]>
Cc: Wang Yaxin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
xu xin authored and Andrew Morton committed 2026-08-06 18:57:04 -07:00
1 parent eed8da1ff6
commit 5c3746a0fe
1 file changed
+6
+6
View File
@@ -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; \