Re: [PATCH v3 04/19] mm: slub: implement SLUB version of obj_to_index()

From: Roman Gushchin
Date: Wed May 20 2020 - 17:00:59 EST


On Wed, May 20, 2020 at 03:51:45PM +0200, Vlastimil Babka wrote:
> On 4/22/20 10:46 PM, Roman Gushchin wrote:
> > This commit implements SLUB version of the obj_to_index() function,
> > which will be required to calculate the offset of obj_cgroup in the
> > obj_cgroups vector to store/obtain the objcg ownership data.
> >
> > To make it faster, let's repeat the SLAB's trick introduced by
> > commit 6a2d7a955d8d ("[PATCH] SLAB: use a multiply instead of a
> > divide in obj_to_index()") and avoid an expensive division.
> >
> > Signed-off-by: Roman Gushchin <guro@xxxxxx>
> > Acked-by: Christoph Lameter <cl@xxxxxxxxx>
> > Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx>
>
> There's already a slab_index() doing the same without the trick, with only
> SLUB_DEBUG callers. Maybe just improve it and perhaps rename? (obj_to_index()
> seems more descriptive). The difference is that it takes the result of
> page_addr() instead of doing that, as it's being called in a loop on objects
> from a single page, so you'd have to perhaps split to obj_to_index(page) and
> __obj_to_index(addr) or something.

Good point! How about this one?

--