[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wiq_0O+KT0x8OL5_rV2FkvxHNOWNxU=HKknmDGXin_r_w@mail.gmail.com>
Date: Fri, 15 Sep 2023 15:10:54 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>,
Alexey Dobriyan <adobriyan@...il.com>,
linux-kernel@...r.kernel.org,
Linus Walleij <linus.walleij@...aro.org>,
akpm@...ux-foundation.org
Subject: Re: Buggy __free(kfree) usage pattern already in tree
On Fri, 15 Sept 2023 at 14:50, Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> Call it "cond_guard()", and make the syntax otherwise be the same as
> "scoped_guard()", iow, using a unique ID for the guard name.
I *think* you don't even need a new "cond_guard()" macro.
This might be as simple as having our current scoped_guard() macro
have the conditional
"scope.lock && !done"
instead of just the current "!done".
Then you introduce "trylock" variants that conditionally set "lock = 1".
I dunno. Maybe there's something really obvious I'm missing, but I
really think that gives us the option to literally do just
scoped_guard(try_mutex, ..somelock..) {
...
}
and all it requires is for us to declare a "try_mutex" lock guard class.
Ok, so the current DEFINE_LOCK_GUARD_x() macros clearly set .lock to 1
unconditionally, so there's a small matter of extending the lock side
to be conditional...
"SMOP".
Linus
Powered by blists - more mailing lists