From: Andi Kleen <ak@linux.intel.com>
To: jbaron@redhat.com
Cc: linux-kernel@vger.kernel.org
Subject: racy jump label users
Date: Fri, 22 Mar 2013 12:55:51 -0700 [thread overview]
Message-ID: <20130322195551.GQ19692@tassilo.jf.intel.com> (raw)
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
--
ak@linux.intel.com -- Speaking for myself only
next reply other threads:[~2013-03-22 19:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-22 19:55 Andi Kleen [this message]
2013-04-18 18:26 ` Jason Baron
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=20130322195551.GQ19692@tassilo.jf.intel.com \
--to=ak@linux.intel.com \
--cc=jbaron@redhat.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
all inboxes | Powered by JetHome®