Re: [PATCH 2/3] mm/slab: add own entry points for kmem_buckets_alloc() family

From: Vlastimil Babka (SUSE)

Date: Mon Nov 30 2026 - 03:38:10 EST


On 11/30/26 09:31, Vlastimil Babka (SUSE) wrote:
> On 11/30/26 04:34, Hao Li wrote:
>> On Tue, Nov 24, 2026 at 05:30:03PM +0100, Vlastimil Babka (SUSE) wrote:
>>>
>>> +void *__kmem_buckets_valloc_noprof(kmem_buckets *b, size_t size,
>>> + unsigned long align, gfp_t flags, int node)
>>> +{
>>> + void *ret;
>>> + const struct slab_alloc_context ac = {
>>> + .caller_addr = _RET_IP_,
>>> + .orig_size = size,
>>> + .alloc_flags = SLAB_ALLOC_DEFAULT,
>>> + };
>>> +
>>> + if (!IS_ENABLED(CONFIG_SLAB_BUCKETS))
>>> + b = NULL;
>>> +
>>> + /*
>>> + * It doesn't really make sense to fallback to vmalloc for sub page
>>> + * requests
>>> + */
>>> + ret = __do_kmalloc_node(b, kmalloc_gfp_adjust(flags, size),
>>> + node, (kmalloc_token_t){}, &ac);
>>> + if (ret || size <= PAGE_SIZE)
>>> + return ret;
>>> +
>>> + return __kvmalloc_fallback(size, align, flags, node,
>>> + __builtin_return_address(0));
>>> +}
>>
>> It looks like __kmalloc_node_noprof, __kmalloc_node_track_caller_noprof, and
>> __kvmalloc_node_noprof are exported without any module users.
>>
>> Could we unexport them, or do we need to export their counterparts as well for
>> consistency?
>
> We must unexport them before hch notices.

But seriously, also we should be careful. How confident are you e.g. in the
case of __kmalloc_node_noprof? It can end up called by anything doing
kmalloc_node() if the size isn't constant, or the compiler fails to
recognize it as such. But I think there are actually many callers that are
not constant?