From: Jason Baron <jbaron@akamai.com>
To: Andi Kleen <ak@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: racy jump label users
Date: Thu, 18 Apr 2013 14:26:06 -0400 [thread overview]
Message-ID: <51703ABE.5080104@akamai.com> (raw)
In-Reply-To: <20130322195551.GQ19692@tassilo.jf.intel.com>
Hi Andi,
Agreed. However, other users of 'static_key_enabled()', provide their own
locking. For example, in kernel/tracepoint.c, 'static_key_enabled()',
relies on
the tracepoints_mutex. Were there any other users that are problematic?
I agree a 'setstate' would be nice. Maybe something like:
static_key_slow_set_true();
static_key_slow_set_false();
Thanks,
-Jason
On 03/22/2013 03:55 PM, Andi Kleen wrote:
> Jason,
>
> I noticed that a lot of the jump label users are racy,
> because they implement something like this
>
> static void sched_feat_disable(int i)
> {
> if (static_key_enabled(&sched_feat_keys[i]))
> static_key_slow_dec(&sched_feat_keys[i]);
> }
>
> static void sched_feat_enable(int i)
> {
> if (!static_key_enabled(&sched_feat_keys[i]))
> static_key_slow_inc(&sched_feat_keys[i]);
> }
>
> with no extra locking, controlled by sysfs. If two
> CPUs do this in parallel the reference can be set multiple
> times, which gives very unexpected semantics for a sysfs boolean.
>
> Most likely you need a static_key_slow_setstate()
> that does the check and set inside the jump label lock.
>
> I understand that for inside kernel use reference
> counts are the right semantics, but they are not so
> good for sysfs interfaces.
>
> -Andi
>
prev parent reply other threads:[~2013-04-18 18:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-22 19:55 Andi Kleen
2013-04-18 18:26 ` Jason Baron [this message]
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=51703ABE.5080104@akamai.com \
--to=jbaron@akamai.com \
--cc=ak@linux.intel.com \
--cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome