Re: [PATCH v3 4/6] mm/slub: distinguish and print stack traces in debugfs files
From: Vlastimil Babka
Date: Wed Apr 06 2022 - 09:57:02 EST
On 4/5/22 23:40, David Rientjes wrote:
>> @@ -5116,9 +5117,13 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,
>> {
>> long start, end, pos;
>> struct location *l;
>> - unsigned long caddr;
>> + unsigned long caddr, chandle;
>> unsigned long age = jiffies - track->when;
>> + depot_stack_handle_t handle = 0;
>>
>> +#ifdef CONFIG_STACKDEPOT
>> + handle = READ_ONCE(track->handle);
>> +#endif
>> start = -1;
>> end = t->count;
>>
>> @@ -5133,7 +5138,8 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,
>> break;
>>
>> caddr = t->loc[pos].addr;
>> - if (track->addr == caddr) {
>> + chandle = t->loc[pos].handle;
>> + if ((track->addr == caddr) && (handle == chandle)) {
>>
>> l = &t->loc[pos];
>> l->count++;
>> @@ -5158,6 +5164,8 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,
>>
>> if (track->addr < caddr)
>> end = pos;
>> + else if (track->addr == caddr && handle < chandle)
>> + end = pos;
>> else
>> start = pos;
>> }
>
> Does this need to properly handle the case where handle == NULL?
Hm I can't think of how much more properly is possible. If objects have same
track->addr (which is the immediate caller) and also same NULL handle, they
will be counted together. I think it's the best we can do?