Re: [PATCH v2 05/13] mm/slab: make slab_obj_ext() determine object index
From: Harry Yoo
Date: Tue Jul 21 2026 - 02:02:50 EST
On 7/20/26 11:16 PM, Vlastimil Babka (SUSE) wrote:
> All callers perform the same obj_to_index() calculation to pass the
> index. Simplify by passing object pointer instead and determining the
> index by slab_obj_ext().
Nice!
> Reviewed-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>
> Signed-off-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
> ---
Looks good to me,
Reviewed-by: Harry Yoo (Oracle) <harry@xxxxxxxxxx>
with a nit on typo below
> mm/memcontrol.c | 12 +++---------
> mm/slab.h | 19 +++++++++++--------
> mm/slub.c | 22 +++++++---------------
> 3 files changed, 21 insertions(+), 32 deletions(-)
> diff --git a/mm/slab.h b/mm/slab.h
> index 7bd361447c54..64cec02b5016 100644
> --- a/mm/slab.h
> +++ b/mm/slab.h
> @@ -579,7 +579,7 @@ struct slabobj_ext {
> * obj_exts = slab_obj_exts(slab);
> * if (obj_exts) {
> * get_slab_obj_exts(obj_exts);
> - * obj_ext = slab_obj_ext(slab, obj_exts, obj_to_index(s, slab, obj));
> + * obj_ext = slab_obj_ext(s, slab, obj_exts, obj);
> * // do something with obj_ext
> * put_slab_obj_exts(obj_exts);
> * }
> @@ -639,21 +639,24 @@ static inline unsigned int slab_get_stride(struct slab *slab)
> /*
> * slab_obj_ext - get the pointer to the slab object extension metadata
> * associated with an object in a slab.
> + * @s: cache that the slab blongs to
nit: blongs -> belongs
> * @slab: a pointer to the slab struct
> * @obj_exts: a pointer to the object extension vector
> - * @index: an index of the object
> + * @obj: a pointer to the object
> *
> * Returns a pointer to the object extension associated with the object.
> * Must be called within a section covered by get/put_slab_obj_exts().
> */
> -static inline struct slabobj_ext *slab_obj_ext(struct slab *slab,
> - unsigned long obj_exts,
> - unsigned int index)
--
Cheers,
Harry / Hyeonggon
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature