Re: [PATCH v2 02/13] mm/slub: skip handle_failed_objexts_alloc() with profiling disabled

"Vlastimil Babka (SUSE)" <[email protected]>
Newsgroups org.kernel.vger.cgroups,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
On 7/21/26 07:51, Harry Yoo wrote:
> 
> 
> On 7/20/26 11:16 PM, Vlastimil Babka (SUSE) wrote:
>> The function might get called with memory allocation profiling disabled,
>> when the obj_ext array is allocated for objcg pointers only. The
>> handling is however unnecessary in that case, so skip it.
>> 
>> This would otherwise become a real bug later, as pointed out by sashiko.
>> For now it's just an optimization.
>> 
>> Link: https://sashiko.dev/#/patchset/[email protected]?part=10
>> Signed-off-by: Vlastimil Babka (SUSE) <[email protected]>
>> ---
>>  mm/slub.c | 7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>> 
>> diff --git a/mm/slub.c b/mm/slub.c
>> index 76acb78f2655..95fa6fbad11a 100644
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -2101,15 +2101,16 @@ static inline bool mark_failed_objexts_alloc(struct slab *slab)
>>  static inline void handle_failed_objexts_alloc(unsigned long obj_exts,
>>  			struct slabobj_ext *vec, unsigned int objects)
>>  {
>> +	if (!mem_alloc_profiling_enabled())
>> +		return;
> 
> This looks racy.

Indeed, not sure how I convinced myself it's ok.

> Can we instead do this later in the series depending on
> slab_obj_ext_has_codetag_key's value?

Yeah.

>>  	/*
>>  	 * If vector previously failed to allocate then we have live
>>  	 * objects with no tag reference. Mark all references in this
>>  	 * vector as empty to avoid warnings later on.
>>  	 */
>>  	if (obj_exts == OBJEXTS_ALLOC_FAIL) {
>> -		unsigned int i;
>> -
>> -		for (i = 0; i < objects; i++)
>> +		for (unsigned int i = 0; i < objects; i++)
>>  			set_codetag_empty(&vec[i].ref);
>>  	}
>>  }
>> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.