[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240610175756.GU8774@noisy.programming.kicks-ass.net>
Date: Mon, 10 Jun 2024 19:57:56 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>,
Steven Rostedt <rostedt@...dmis.org>,
Sam Sun <samsun1006219@...il.com>, x86@...nel.org,
syzkaller-bugs@...glegroups.com, xrivendell7@...il.com
Subject: Re: [patch 2/4] jump_label: Fix concurrency issues in
static_key_slow_dec()
On Mon, Jun 10, 2024 at 02:46:36PM +0200, Thomas Gleixner wrote:
> @@ -247,20 +247,25 @@ EXPORT_SYMBOL_GPL(static_key_disable);
>
> static bool static_key_slow_try_dec(struct static_key *key)
> {
> + int v;
>
> /*
> + * Go into the slow path if key::enabled is less than or equal than
> + * one. One is valid to shut down the key, anything less than one
> + * is an imbalance, which is handled at the call site.
> + *
> + * That includes the special case of '-1' which is set in
> + * static_key_slow_inc_cpuslocked(), but that's harmless as it is
> + * fully serialized in the slow path below. By the time this task
> + * acquires the jump label lock the value is back to one and the
> + * retry under the lock must succeed.
Harmless yes, but it really should not happen to begin with. If this
happens it means someone wants to disable a key that is in the middle of
getting enabled for the first time.
I'm tempted to want a WARN here instead. Hmm?
> */
> + v = atomic_read(&key->enabled);
> + do {
> + if (v <= 1)
> + return false;
> + } while (!likely(atomic_try_cmpxchg(&key->enabled, &v, v - 1)));
> +
> return true;
> }
Powered by blists - more mailing lists