Re: [PATCH] ref_tracker: add stack_depot_save() failure handling to ref_tracker_alloc()

From: Eric Dumazet
Date: Tue May 30 2023 - 06:07:17 EST


On Tue, May 30, 2023 at 11:52 AM Tetsuo Handa
<penguin-kernel@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On 2023/05/30 16:22, Eric Dumazet wrote:
> >>> Therefore, assume that stack_depot_save(GFP_KERNEL | __GFP_NOFAIL) from
> >>> ref_tracker_alloc() can silently fail, and emit "unreliable refcount
> >>> tracker." message.
> >
> > Note: I never assumed stack_depot_save() would enforce/use NOFAIL.
>
> Hmm, I misread this function.
>
> if (gfp & __GFP_DIRECT_RECLAIM)
> gfp_mask |= __GFP_NOFAIL; // Or'ing to "gfp_mask" than "gfp".
> *trackerp = tracker = kzalloc(sizeof(*tracker), gfp_mask); // <= This is "gfp_mask".
> tracker->alloc_stack_handle = stack_depot_save(entries, nr_entries, gfp); // <= This is "gfp".
>
> So, stack_depot_save(GFP_KERNEL | __GFP_NOFAIL) is not happening.

Yes.1

>
> Then, question becomes whether we want tracker->alloc_stack_handle != NULL or not.
> If tracker->alloc_stack_handle == NULL is still useful, this patch will be useless...
>

I think it is useful to have the tracker (as Jakub hinted).
It is better than nothing.
We even might be able to allocate memory later for the
free_stack_handle which could give us
developers enough clues for bug hunting.

Thanks.