From: Peter Zijlstra <peterz@infradead.org>
To: jiada_wang@mentor.com
Cc: mingo@redhat.com, linux-kernel@vger.kernel.org,
george_davis@mentor.com, erosca@de.adit-jv.com
Subject: Re: [PATCH v2 1/1] sched/debug: fix potential deadlock when write to sched_features
Date: Tue, 31 Jul 2018 14:36:51 +0200 [thread overview]
Message-ID: <20180731123651.GW2494@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180731121222.26195-1-jiada_wang@mentor.com>
On Tue, Jul 31, 2018 at 09:12:22PM +0900, jiada_wang@mentor.com wrote:
> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
> index 60caf1fb94e0..7b2997d4a349 100644
> --- a/kernel/sched/debug.c
> +++ b/kernel/sched/debug.c
> @@ -87,21 +87,21 @@ struct static_key sched_feat_keys[__SCHED_FEAT_NR] = {
>
> #undef SCHED_FEAT
>
> -static void sched_feat_disable(int i)
> +static void sched_feat_disable_cpuslocked(int i)
> {
> - static_key_disable(&sched_feat_keys[i]);
> + static_key_disable_cpuslocked(&sched_feat_keys[i]);
> }
>
> -static void sched_feat_enable(int i)
> +static void sched_feat_enable_cpuslocked(int i)
> {
> - static_key_enable(&sched_feat_keys[i]);
> + static_key_enable_cpuslocked(&sched_feat_keys[i]);
> }
> #else
> -static void sched_feat_disable(int i) { };
> -static void sched_feat_enable(int i) { };
> +static void sched_feat_disable_cpuslocked(int i) { };
> +static void sched_feat_enable_cpuslocked(int i) { };
> #endif /* HAVE_JUMP_LABEL */
>
> -static int sched_feat_set(char *cmp)
> +static int sched_feat_set_cpuslocked(char *cmp)
> {
> int i;
> int neg = 0;
> @@ -117,10 +117,10 @@ static int sched_feat_set(char *cmp)
>
> if (neg) {
> sysctl_sched_features &= ~(1UL << i);
> - sched_feat_disable(i);
> + sched_feat_disable_cpuslocked(i);
> } else {
> sysctl_sched_features |= (1UL << i);
> - sched_feat_enable(i);
> + sched_feat_enable_cpuslocked(i);
> }
>
> return 0;
> @@ -146,9 +146,11 @@ sched_feat_write(struct file *filp, const char __user *ubuf,
>
> /* Ensure the static_key remains in a consistent state */
> inode = file_inode(filp);
> + cpus_read_lock();
> inode_lock(inode);
> - ret = sched_feat_set(cmp);
> + ret = sched_feat_set_cpuslocked(cmp);
> inode_unlock(inode);
> + cpus_read_unlock();
> if (ret < 0)
> return ret;
>
I've made that..
---
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -89,12 +89,12 @@ struct static_key sched_feat_keys[__SCHE
static void sched_feat_disable(int i)
{
- static_key_disable(&sched_feat_keys[i]);
+ static_key_disable_cpuslocked(&sched_feat_keys[i]);
}
static void sched_feat_enable(int i)
{
- static_key_enable(&sched_feat_keys[i]);
+ static_key_enable_cpuslocked(&sched_feat_keys[i]);
}
#else
static void sched_feat_disable(int i) { };
@@ -146,9 +146,11 @@ sched_feat_write(struct file *filp, cons
/* Ensure the static_key remains in a consistent state */
inode = file_inode(filp);
+ cpus_read_lock();
inode_lock(inode);
ret = sched_feat_set(cmp);
inode_unlock(inode);
+ cpus_read_unlock();
if (ret < 0)
return ret;
next prev parent reply other threads:[~2018-07-31 12:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-31 12:12 jiada_wang
2018-07-31 12:36 ` Peter Zijlstra [this message]
2018-07-31 18:51 ` Davis, George
2018-09-10 10:05 ` [tip:sched/core] sched/debug: Fix potential deadlock when writing " tip-bot for Jiada Wang
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=20180731123651.GW2494@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=erosca@de.adit-jv.com \
--cc=george_davis@mentor.com \
--cc=jiada_wang@mentor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
/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®