From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: Daniel J Blueman <daniel.blueman@gmail.com>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] RCU: don't turn off lockdep when find suspicious rcu_dereference_check() usage
Date: Thu, 3 Jun 2010 11:30:40 -0700 [thread overview]
Message-ID: <20100603183040.GA2385@linux.vnet.ibm.com> (raw)
In-Reply-To: <4C07743C.7030204@cn.fujitsu.com>
On Thu, Jun 03, 2010 at 05:22:04PM +0800, Li Zefan wrote:
> Paul E. McKenney wrote:
> > On Tue, Jun 01, 2010 at 02:06:13PM +0100, Daniel J Blueman wrote:
> >> Hi Paul,
> >>
> >> With 2.6.35-rc1 and your patch in the context below, we still see
> >> "include/linux/cgroup.h:534 invoked rcu_dereference_check() without
> >> protection!", so need this additional patch:
> >>
> >> Acquire read-side RCU lock around task_group() calls, addressing
> >> "include/linux/cgroup.h:534 invoked rcu_dereference_check() without
> >> protection!" warning.
> >>
> >> Signed-off-by: Daniel J Blueman <daniel.blueman@gmail.com>
> >
> > Thank you, Daniel! I have queued this for 2.6.35.
> >
> > I had to apply the patch by hand due to line wrapping. Could you please
> > check your email-agent settings? This simple patch was no problem to
> > hand apply, but for a larger patch this process would be both tedious
> > and error prone.
> >
> > Thanx, Paul
> >
> >> diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
> >> index 217e4a9..50ec9ea 100644
> >> --- a/kernel/sched_fair.c
> >> +++ b/kernel/sched_fair.c
> >> @@ -1241,6 +1241,7 @@ static int wake_affine(struct sched_domain *sd,
> >> struct task_struct *p, int sync)
> >> * effect of the currently running task from the load
> >> * of the current CPU:
> >> */
> >> + rcu_read_lock();
> >> if (sync) {
> >> tg = task_group(current);
> >> weight = current->se.load.weight;
> >> @@ -1250,6 +1251,7 @@ static int wake_affine(struct sched_domain *sd,
> >> struct task_struct *p, int sync)
> >> }
> >>
> >> tg = task_group(p);
> >> + rcu_read_unlock();
>
> Hmmm.. I think it's not safe to access tg after rcu_read_unlock.
It does indeed look unsafe. How about the following on top of this patch?
> >> weight = p->se.load.weight;
> >>
> >> imbalance = 100 + (sd->imbalance_pct - 100) / 2;
Seems worth reviewing the other uses of task_group():
1. set_task_rq() -- only a runqueue and a sched_rt_entity leave
the RCU read-side critical section. Runqueues do persist.
I don't claim to understand the sched_rt_entity life cycle.
2. __sched_setscheduler() -- not clear to me that this one is
protected to begin with. If it is somehow correctly protected,
it discards the RCU-protected pointer immediately, so is OK
otherwise.
3. cpu_cgroup_destroy() -- ditto.
4. cpu_shares_read_u64() -- ditto.
5. print_task() -- protected by rcu_read_lock() and discards the
RCU-protected pointer immediately, so this one is OK.
Any task_group() experts able to weigh in on #2, #3, and #4?
Thanx, Paul
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 50ec9ea..224ef98 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -1251,7 +1251,6 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)
}
tg = task_group(p);
- rcu_read_unlock();
weight = p->se.load.weight;
imbalance = 100 + (sd->imbalance_pct - 100) / 2;
@@ -1268,6 +1267,7 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)
balanced = !this_load ||
100*(this_load + effective_load(tg, this_cpu, weight, weight)) <=
imbalance*(load + effective_load(tg, prev_cpu, 0, weight));
+ rcu_read_unlock();
/*
* If the currently running task will sleep within
next prev parent reply other threads:[~2010-06-03 18:31 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-01 13:06 [PATCH] RCU: don't turn off lockdep when find suspicious rcu_dereference_check() usage Daniel J Blueman
2010-06-02 14:56 ` Paul E. McKenney
2010-06-02 15:24 ` Daniel J Blueman
2010-06-03 9:22 ` Li Zefan
2010-06-03 18:30 ` Paul E. McKenney [this message]
2010-06-04 2:44 ` Li Zefan
2010-06-04 4:10 ` Paul E. McKenney
2010-06-04 8:54 ` Daniel J Blueman
-- strict thread matches above, loose matches on Subject: below --
2010-03-08 1:26 INFO: suspicious rcu_dereference_check() usage - include/linux/cgroup.h:492 invoked rcu_dereference_check() without protection! Miles Lane
2010-03-11 3:28 ` Paul E. McKenney
2010-04-12 18:44 ` Eric Paris
2010-04-12 18:47 ` Peter Zijlstra
2010-04-14 10:47 ` Peter Zijlstra
2010-04-19 18:26 ` Eric Paris
2010-04-19 23:01 ` Paul E. McKenney
2010-04-20 1:25 ` Eric Paris
2010-04-20 3:04 ` Paul E. McKenney
2010-04-20 8:23 ` [PATCH] RCU: don't turn off lockdep when find suspicious rcu_dereference_check() usage Lai Jiangshan
2010-04-20 8:36 ` Peter Zijlstra
2010-04-20 12:31 ` Eric Paris
2010-04-20 13:28 ` Paul E. McKenney
[not found] ` <j2ya44ae5cd1004200545q6be4ec82o18ae99d93e8c29c7@mail.gmail.com>
2010-04-20 13:52 ` Paul E. McKenney
2010-04-20 15:38 ` Miles Lane
2010-04-21 6:04 ` Borislav Petkov
2010-04-21 21:45 ` Paul E. McKenney
2010-04-21 21:35 ` Paul E. McKenney
2010-04-21 21:48 ` Paul E. McKenney
2010-04-21 21:57 ` Eric Dumazet
2010-04-21 22:14 ` Paul E. McKenney
2010-04-21 23:26 ` Eric W. Biederman
2010-04-22 14:56 ` Vivek Goyal
2010-04-22 16:01 ` Paul E. McKenney
2010-04-23 12:50 ` Miles Lane
2010-04-23 19:42 ` Paul E. McKenney
2010-04-23 22:59 ` Miles Lane
2010-04-24 5:35 ` Miles Lane
2010-04-25 2:36 ` Paul E. McKenney
2010-04-25 2:34 ` Paul E. McKenney
2010-04-25 7:45 ` Johannes Berg
2010-04-25 7:49 ` David Miller
2010-04-26 2:07 ` Paul E. McKenney
2010-04-25 15:49 ` Miles Lane
2010-04-25 20:20 ` Miles Lane
2010-04-26 16:09 ` Paul E. McKenney
2010-04-26 18:35 ` Eric W. Biederman
2010-04-27 4:27 ` Paul E. McKenney
2010-04-27 16:22 ` Paul E. McKenney
2010-04-27 16:33 ` Eric Dumazet
2010-04-27 17:58 ` Miles Lane
2010-04-27 23:31 ` Paul E. McKenney
2010-04-27 23:42 ` David Miller
2010-04-27 23:52 ` Paul E. McKenney
[not found] ` <p2ka44ae5cd1004281358n86ce29d2tbece16b2fb974dab@mail.gmail.com>
2010-04-28 21:37 ` Paul E. McKenney
2010-05-01 17:26 ` Miles Lane
2010-05-01 21:55 ` Paul E. McKenney
2010-05-02 2:00 ` Miles Lane
2010-05-02 4:11 ` Paul E. McKenney
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=20100603183040.GA2385@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=daniel.blueman@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.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