Re: [PATCH slab/for-next-fixes v3 3/4] lib/alloc_tag: introduce mem_alloc_profiling_permanently_disabled()
From: Vlastimil Babka (SUSE)
Date: Mon Jul 13 2026 - 12:15:41 EST
On 7/13/26 17:43, Suren Baghdasaryan wrote:
> On Mon, Jul 13, 2026 at 7:29 AM Harry Yoo (Oracle) <harry@xxxxxxxxxx> wrote:
>>
>> mem_alloc_profiling_enabled() tells whether memalloc profiling is
>> currently enabled. However, even when this function returns false,
>> it can be enabled later.
>>
>> However, this is not enough. Some optimizations can be applied only when
>> memalloc profiling is permanently disabled. For example, to skip the
>> creation of KMALLOC_NO_OBJ_EXT caches at boot time, mem_profiling must
>> be set to "never", "0" w/ debugging on, or have been shutdown so that
>> it can no longer be enabled.
>>
>> Introduce mem_alloc_profiling_permanently_disabled() for this purpose.
>
> nit: I would call it mem_alloc_profiling_supported() but this name would do.
I wouldn't like that name, because _supported to me sounds like those
CONFIG_ARCH_SUPPORTS... things and not something that was just disabled.
I suggested mem_alloc_profiling_unavailable(), but it's not ideal either,
naming is hard.
>>
>> Fixes: 4b8736964640 ("mm/slab: add allocation accounting into slab allocation and free paths")
>> Cc: stable@xxxxxxxxxxxxxxx
>> Signed-off-by: Harry Yoo (Oracle) <harry@xxxxxxxxxx>
>
> Acked-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>
>
>> ---
>> include/linux/alloc_tag.h | 3 +++
>> lib/alloc_tag.c | 9 +++++++++
>> 2 files changed, 12 insertions(+)
>>
>> diff --git a/include/linux/alloc_tag.h b/include/linux/alloc_tag.h
>> index 068ba2e77c5d..6ed9f82e639f 100644
>> --- a/include/linux/alloc_tag.h
>> +++ b/include/linux/alloc_tag.h
>> @@ -134,6 +134,8 @@ static inline bool mem_alloc_profiling_enabled(void)
>> &mem_alloc_profiling_key);
>> }
>>
>> +bool mem_alloc_profiling_permanently_disabled(void);
>> +
>> static inline struct alloc_tag_counters alloc_tag_read(struct alloc_tag *tag)
>> {
>> struct alloc_tag_counters v = { 0, 0 };
>> @@ -239,6 +241,7 @@ static inline bool alloc_tag_is_inaccurate(struct alloc_tag *tag)
>>
>> #define DEFINE_ALLOC_TAG(_alloc_tag)
>> static inline bool mem_alloc_profiling_enabled(void) { return false; }
>> +static inline bool mem_alloc_profiling_permanently_disabled(void) { return true; }
>> static inline void alloc_tag_add(union codetag_ref *ref, struct alloc_tag *tag,
>> size_t bytes) {}
>> static inline void alloc_tag_sub(union codetag_ref *ref, size_t bytes) {}
>> diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
>> index d9be1cf5187d..e5b218176c5a 100644
>> --- a/lib/alloc_tag.c
>> +++ b/lib/alloc_tag.c
>> @@ -26,6 +26,15 @@ static bool mem_profiling_support = true;
>> static bool mem_profiling_support;
>> #endif
>>
>> +/*
>> + * Memory allocation profiling is permanently disabled and cannot be enabled.
>> + * Must be called after setup_early_mem_profiling().
>> + */
>> +bool mem_alloc_profiling_permanently_disabled(void)
>> +{
>> + return !mem_profiling_support;
>> +}
>> +
>> static struct codetag_type *alloc_tag_cttype;
>>
>> #ifdef CONFIG_ARCH_MODULE_NEEDS_WEAK_PER_CPU
>>
>> --
>> 2.53.0
>>