Re: [PATCH v2 04/16] mm/slab: introduce slab_alloc_context
From: Vlastimil Babka (SUSE)
Date: Fri Jun 12 2026 - 05:52:08 EST
On 6/12/26 05:10, Hao Li wrote:
> On Wed, Jun 10, 2026 at 05:40:06PM +0200, Vlastimil Babka (SUSE) wrote:
>> @@ -5389,13 +5401,18 @@ void *_kmalloc_nolock_noprof(DECL_TOKEN_PARAMS(size, token), gfp_t gfp_flags, in
>> if (ret)
>> goto success;
>>
>> + struct slab_alloc_context ac = {
>> + .caller_addr = _RET_IP_,
>> + .orig_size = orig_size,
>> + };
>
> It might be better to move this to the beginning of the function, to avoid
> patch09 jump to `success` before ac is initialized.
Hm right, didn't compilers actually complain about goto skipping over
declarations? But neither gcc nor clang do for me, hm. Will move, thanks.
>> +
>> /*
>> * Do not call slab_alloc_node(), since trylock mode isn't
>> * compatible with slab_pre_alloc_hook/should_failslab and
>> * kfence_alloc. Hence call __slab_alloc_node() (at most twice)
>> * and slab_post_alloc_hook() directly.
>> */
>> - ret = __slab_alloc_node(s, alloc_gfp, node, _RET_IP_, orig_size);
>> + ret = __slab_alloc_node(s, alloc_gfp, node, &ac);
>>
>> /*
>> * It's possible we failed due to trylock as we preempted someone with
>> @@ -7237,10 +7254,13 @@ static bool __kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags,
>> int i;
>>
>> if (IS_ENABLED(CONFIG_SLUB_TINY) || kmem_cache_debug(s)) {
>> + struct slab_alloc_context ac = {
>> + .caller_addr = _RET_IP_,
>> + .orig_size = s->object_size,
>> + };
>> for (i = 0; i < size; i++) {
>>
>> - p[i] = ___slab_alloc(s, flags, NUMA_NO_NODE, _RET_IP_,
>> - s->object_size);
>> + p[i] = ___slab_alloc(s, flags, NUMA_NO_NODE, &ac);
>> if (unlikely(!p[i]))
>> goto error;
>>
>>
>> --
>> 2.54.0
>>