From: Peter Zijlstra <peterz@infradead.org>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: paulmck@linux.vnet.ibm.com, Ingo Molnar <mingo@elte.hu>,
eric.dumazet@gmail.com, shaohua.li@intel.com, ak@linux.intel.com,
mhocko@suse.cz, alex.shi@intel.com, efault@gmx.de,
linux-kernel@vger.kernel.org, Paul Turner <pjt@google.com>,
Stephane Eranian <eranian@google.com>
Subject: Re: [GIT PULL rcu/next] RCU commits for 3.1
Date: Mon, 07 Nov 2011 16:15:02 +0100 [thread overview]
Message-ID: <1320678902.18053.63.camel@twins> (raw)
In-Reply-To: <4EAF5B68.8090005@cn.fujitsu.com>
So far nobody seems to have stated if this is an actual problem or just
shutting up lockdep-prove-rcu? I very much suspect the latter, in which
case I really utterly hate the patch because it adds instructions to
fast-paths just to kill a debug warning.
On Tue, 2011-11-01 at 10:37 +0800, Li Zefan wrote:
>
> With the following patch, we should see no rcu warning from perf, but as I
> don't know the internel of perf, I guess we have to defer to Peter and
> Stephane. ;)
>
> I have two doubts:
>
> - in perf_cgroup_sched_out/in(), we retrieve the task's cgroup twice in the function
> and it's callee perf_cgroup_switch(), but the task can move to another cgroup between
> two calls, so they might return two different cgroup pointers. Does it matter?
>
> - in perf_cgroup_switch():
>
> cpuctx->cgrp = perf_cgroup_from_task(task);
>
> but seems the cgroup is not pinned, so cpuctx->cgrp can be invalid in later use.
>
> ---
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index d1a1bee..f5e05ce 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -302,7 +302,10 @@ static inline void update_cgrp_time_from_event(struct perf_event *event)
> if (!is_cgroup_event(event))
> return;
>
> + rcu_read_lock();
> cgrp = perf_cgroup_from_task(current);
> + rcu_read_unlock();
> +
> /*
> * Do not update time when cgroup is not active
> */
This looks like shutting things up, because what protects the use of
cgrp after rcu_read_unlock() ?
Similar to the below, this is a stupid patch to shut things up, no
actual problem there, just making a hot path slow.
> @@ -325,9 +328,11 @@ perf_cgroup_set_timestamp(struct task_struct *task,
> if (!task || !ctx->nr_cgroups)
> return;
>
> + rcu_read_lock();
> cgrp = perf_cgroup_from_task(task);
> info = this_cpu_ptr(cgrp->info);
> info->timestamp = ctx->timestamp;
> + rcu_read_unlock();
> }
This seems to actually protect the cgrp usage, but is that needed?
It looks to be superfluous, since
perf_cgroup_attach_task()->__perf_cgroup_move()->perf_cgroup_switch()
will hold ctx->lock when it switches a task from one cgroup to another
and perf_cgroup_set_timestamp() should only ever be called while holding
the ctx->lock since that is what is used to serialize the timestamps.
> #define PERF_CGROUP_SWOUT 0x1 /* cgroup switch out every event */
> @@ -406,6 +411,8 @@ static inline void perf_cgroup_sched_out(struct task_struct *task,
> struct perf_cgroup *cgrp1;
> struct perf_cgroup *cgrp2 = NULL;
>
> + rcu_read_lock();
> +
> /*
> * we come here when we know perf_cgroup_events > 0
> */
> @@ -418,6 +425,8 @@ static inline void perf_cgroup_sched_out(struct task_struct *task,
> if (next)
> cgrp2 = perf_cgroup_from_task(next);
>
> + rcu_read_unlock();
> +
> /*
> * only schedule out current cgroup events if we know
> * that we are switching to a different cgroup. Otherwise,
This only hides a warning and leaves a race.
> @@ -433,6 +442,8 @@ static inline void perf_cgroup_sched_in(struct task_struct *prev,
> struct perf_cgroup *cgrp1;
> struct perf_cgroup *cgrp2 = NULL;
>
> + rcu_read_lock();
> +
> /*
> * we come here when we know perf_cgroup_events > 0
> */
> @@ -441,6 +452,8 @@ static inline void perf_cgroup_sched_in(struct task_struct *prev,
> /* prev can never be NULL */
> cgrp2 = perf_cgroup_from_task(prev);
>
> + rcu_read_unlock();
> +
> /*
> * only need to schedule in cgroup events if we are changing
> * cgroup during ctxsw. Cgroup events were not scheduled
>
idem.
So no, this patch utterly sucks, it adds code to hot paths just to quiet
debug warnings in two cases and the remaining two cases annotates a
warning away while leaving an actual problem unfixed.
next prev parent reply other threads:[~2011-11-07 15:19 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20110930204503.GA32687@linux.vnet.ibm.com>
[not found] ` <20111001152514.GA16930@elte.hu>
[not found] ` <20111003055302.GA23527@elte.hu>
[not found] ` <20111003161335.GA2403@linux.vnet.ibm.com>
2011-10-04 7:46 ` [GIT PULL rcu/next] RCU commits for 3.1 Ingo Molnar
2011-10-24 10:05 ` Paul E. McKenney
2011-10-24 11:48 ` Paul E. McKenney
2011-10-26 20:30 ` Ingo Molnar
2011-10-27 7:59 ` Paul E. McKenney
2011-10-27 8:00 ` Ingo Molnar
2011-10-28 2:34 ` Li Zefan
2011-10-29 18:27 ` Paul E. McKenney
2011-10-31 8:09 ` Li Zefan
2011-10-31 9:32 ` Paul E. McKenney
2011-11-01 2:37 ` Li Zefan
2011-11-02 19:23 ` Paul E. McKenney
2011-11-02 19:55 ` Stephane Eranian
2011-11-03 12:50 ` Stephane Eranian
2011-11-04 8:44 ` Li Zefan
2011-11-04 9:02 ` Stephane Eranian
2011-11-07 14:24 ` Stephane Eranian
2011-11-07 14:41 ` Eric Dumazet
2011-11-07 14:44 ` Stephane Eranian
2011-11-07 15:15 ` Peter Zijlstra [this message]
2011-11-07 16:16 ` Stephane Eranian
2011-11-07 16:35 ` Peter Zijlstra
2011-11-07 16:56 ` Paul E. McKenney
2011-11-07 17:09 ` Peter Zijlstra
2011-11-07 17:55 ` Paul E. McKenney
2011-11-08 13:10 ` Stephane Eranian
2011-11-07 17:11 ` Peter Zijlstra
2011-11-07 17:12 ` Stephane Eranian
2011-11-07 17:26 ` Peter Zijlstra
2011-11-07 17:50 ` Stephane Eranian
2011-11-07 17:53 ` Paul E. McKenney
2011-11-07 17:53 ` 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=1320678902.18053.63.camel@twins \
--to=peterz@infradead.org \
--cc=ak@linux.intel.com \
--cc=alex.shi@intel.com \
--cc=efault@gmx.de \
--cc=eranian@google.com \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=mhocko@suse.cz \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.com \
--cc=pjt@google.com \
--cc=shaohua.li@intel.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;
as well as URLs for NNTP newsgroup(s).