From: "Darrick J. Wong" <djwong@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>,
Chandan Babu R <chandanbabu@kernel.org>,
Matthew Wilcox <willy@infradead.org>,
xfs <linux-xfs@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
x86@kernel.org
Subject: Re: Are jump labels broken on 6.11-rc1?
Date: Wed, 7 Aug 2024 08:05:03 -0700 [thread overview]
Message-ID: <20240807150503.GF6051@frogsfrogsfrogs> (raw)
In-Reply-To: <87wmks2xhi.ffs@tglx>
On Wed, Aug 07, 2024 at 04:55:53PM +0200, Thomas Gleixner wrote:
> On Wed, Aug 07 2024 at 16:34, Peter Zijlstra wrote:
> > On Wed, Aug 07, 2024 at 04:03:12PM +0200, Thomas Gleixner wrote:
> >
> >> > + if (static_key_dec(key, true)) // dec-not-one
> >>
> >> Eeew.
> >
> > :-) I knew you'd hate on that
>
> So you added it just to make me grumpy enough to fix it for you, right?
FWIW with peter's 'ugly' patch applied, fstests didn't cough up any
static key complaints overnight.
> >> +/*
> >> + * Fastpath: Decrement if the reference count is greater than one
> >> + *
> >> + * Returns false, if the reference count is 1 or -1 to force the caller
> >> + * into the slowpath.
> >> + *
> >> + * The -1 case is to handle a decrement during a concurrent first enable,
> >> + * which sets the count to -1 in static_key_slow_inc_cpuslocked(). As the
> >> + * slow path is serialized the caller will observe 1 once it acquired the
> >> + * jump_label_mutex, so the slow path can succeed.
> >> + */
> >> +static bool static_key_dec_not_one(struct static_key *key)
> >> +{
> >> + int v = static_key_dec(key, true);
> >> +
> >> + return v != 1 && v != -1;
> >
> > if (v < 0)
> > return false;
>
> Hmm. I think we should do:
>
> #define KEY_ENABLE_IN_PROGRESS -1
>
> or even a more distinct value like (INT_MIN / 2)
>
> and replace all the magic -1 numbers with it. Then the check becomes
> explicit:
>
> if (v == KEY_ENABLE_IN_PROGRESS)
> return false;
>
> > /*
> > * Notably, 0 (underflow) returns true such that it bails out
> > * without doing anything.
> > */
> > return v != 1;
> >
> > Perhaps?
>
> Sure.
>
> >> +}
> >> +
> >> +/*
> >> + * Slowpath: Decrement and test whether the refcount hit 0.
> >> + *
> >> + * Returns true if the refcount hit zero, i.e. the previous value was one.
> >> + */
> >> +static bool static_key_dec_and_test(struct static_key *key)
> >> +{
> >> + int v = static_key_dec(key, false);
> >> +
> >> + lockdep_assert_held(&jump_label_mutex);
> >> + return v == 1;
> >> }
> >
> > But yeah, this is nicer!
>
> :)
It probably goes without saying that if either of you send a cleaned up
patch with all these changes baked in, I will test it for you all. :)
--D
>
> Thanks,
>
> tglx
>
next prev parent reply other threads:[~2024-08-07 15:05 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-30 3:38 Are jump labels broken on 6.11-rc1? Darrick J. Wong
2024-07-30 7:30 ` Chandan Babu R
2024-07-30 13:26 ` Peter Zijlstra
2024-07-30 13:59 ` Darrick J. Wong
2024-07-31 0:19 ` Darrick J. Wong
2024-07-31 3:10 ` Darrick J. Wong
2024-07-31 5:33 ` Darrick J. Wong
2024-07-31 10:55 ` Peter Zijlstra
2024-07-31 11:07 ` [tip: locking/urgent] jump_label: Fix the fix, brown paper bags galore tip-bot2 for Peter Zijlstra
2024-08-05 14:35 ` Are jump labels broken on 6.11-rc1? Darrick J. Wong
2024-08-06 9:44 ` Peter Zijlstra
2024-08-06 10:38 ` Peter Zijlstra
2024-08-06 22:01 ` Darrick J. Wong
2024-08-07 14:03 ` Thomas Gleixner
2024-08-07 14:34 ` Peter Zijlstra
2024-08-07 14:55 ` Thomas Gleixner
2024-08-07 15:05 ` Darrick J. Wong [this message]
2024-08-07 22:51 ` Darrick J. Wong
2024-08-27 3:35 ` Darrick J. Wong
2024-09-05 8:12 ` Peter Zijlstra
2024-09-05 9:16 ` Peter Zijlstra
2024-09-16 16:08 ` Darrick J. Wong
2024-09-19 23:41 ` Darrick J. Wong
2024-09-06 14:41 ` [tip: locking/urgent] jump_label: Fix static_key_slow_dec() yet again tip-bot2 for Peter Zijlstra
2024-09-10 20:16 ` Mark Brown
2024-09-21 13:52 ` Mark Rutland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240807150503.GF6051@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=chandanbabu@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=willy@infradead.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.