Re: [PATCH] btf: Simplify BTF logic with use of __free(btf_put)

Alexei Starovoitov
2025-08-01T15:29:03Z

On Fri, Aug 1, 2025 at 8:19 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Fri, 1 Aug 2025 08:12:08 -0700
> Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote:
>
> >
> > You can use it in kernel/trace/trace_output.c, of course,
>
> I guess that means I should just use the DEFINE_FREE() in that file
> directly and not in the btf.h header file?

yes. I don't want this to proliferate and people spam us
with this kind of "cleanups".

> > but I really think it's a step back in maintainability.
> > All this cleanup.h is not a silver bullet. It needs to be used sparingly.
>
> I have my reservations about the cleanup.h code too. But the more I use it,
> the more I like it. My biggest worry is guard() leak. That is, having a
> lock or interrupt/preemption disabled for longer than they need to be,
> because code was added at the end of the function after the protection is
> needed.

guard() is ok. We use it too,
but __free() is imo garbage. It's essence of what's wrong with C++