Re: [PATCH] mm/slab.c: use 'ac' from the caller

From: Matthew Wilcox
Date: Tue Apr 20 2021 - 23:11:10 EST


On Wed, Apr 21, 2021 at 10:25:17AM +0800, Yejune Deng wrote:
> @@ -3045,12 +3044,7 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
> }
>
> STATS_INC_ALLOCMISS(cachep);
> - objp = cache_alloc_refill(cachep, flags);
> - /*
> - * the 'ac' may be updated by cache_alloc_refill(),
> - * and kmemleak_erase() requires its correct value.
> - */
> - ac = cpu_cache_get(cachep);
> + objp = cache_alloc_refill(cachep, ac, flags);

I think passing 'ac' in is fine (probably? I don't know this code
deeply), but deleting this call to 'ac' is clearly wrong. The comment
even tells you that! I just verified the code, and the comment is
correct.