Re: [PATCH v2 5/8] kernel: convert process/thread iterators to for_each_*_rculock
From: Oleg Nesterov
Date: Mon Sep 07 2026 - 18:44:49 EST
On 09/07, Gregory Price wrote:
>
> On Mon, Sep 07, 2026 at 11:54:41PM +0200, Oleg Nesterov wrote:
> > >
> > > This might be my - admittedly shallow - understanding of scoped_guard,
> > > but does scoped guard handle goto correctly?
> >
> > Yes, it does,
> >
> > > and why it's generally discouraged to mix cleanup.h and goto.
> >
> > Hmm, why? I didn't know...
> >
>
> one of the reasons to use cleanup.h it is to eliminate the "goto
> for exit cleanup" mechanism in the first place (says so in the first
> paragraph of cleanup.h).
>
> Later in the header is explicit says don't mix:
>
> * Lastly, given that the benefit of cleanup helpers is removal of
> * "goto", and that the "goto" statement can jump between scopes, the
> * expectation is that usage of "goto" and cleanup helpers is never
> * mixed in the same function. I.e. for a given routine, convert all
> * resources that need a "goto" cleanup to scope-based cleanup, or
> * convert none of them.
>
> This particular patch only does a partial conversion - so it's a
> bit of an anti-pattern.
Ah, thanks, now I see what you meant.
Perhaps in this sense this particular change is "anti-pattern", even
if "goto out" jumps out of the scope...
To me the code looks better with this change, but of course this is
subjective.
Oleg.