Re: [PATCH RFC 1/4] mm, slab: move memcg charging to post-alloc hook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 12, 2024 at 11:52:46AM -0700, Roman Gushchin wrote:
> On Fri, Mar 01, 2024 at 06:07:08PM +0100, Vlastimil Babka wrote:
> > @@ -1926,71 +1939,51 @@ static bool __memcg_slab_pre_alloc_hook(struct kmem_cache *s,
> >  			return false;
> >  	}
> >  
> > -	if (obj_cgroup_charge(objcg, flags, objects * obj_full_size(s)))
> > +	if (obj_cgroup_charge(objcg, flags, size * obj_full_size(s)))
> >  		return false;
> >  
> > -	*objcgp = objcg;
> > +	for (i = 0; i < size; i++) {
> > +		slab = virt_to_slab(p[i]);
> 
> Not specific to this change, but I wonder if it makes sense to introduce virt_to_slab()
> variant without any extra checks for this and similar cases, where we know for sure
> that p resides on a slab page. What do you think?

You'd only save a single test_bit() ... is it really worth doing?
Cache misses are the expensive thing, not instructions.  And debugging
time: if somehow p[i] becomes not-on-a-slab-anymore, getting a NULL
pointer splat here before we go any further might be worth all the CPU
time wasted doing that test_bit().




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux