From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>,
Paul Mackerras <paulus@samba.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2 v2] perf_counter: fix for __perf_event_sched_*()
Date: Fri, 25 Sep 2009 13:51:17 +0800 [thread overview]
Message-ID: <4ABC5A55.7000208@cn.fujitsu.com> (raw)
In-Reply-To: <1253695230.7695.122.camel@twins>
Paul Mackerras says:
"Actually, looking at this more closely, it has to be a group leader
anyway since it's at the top level of ctx->group_list. In fact I see
four places where we do:
list_for_each_entry(event, &ctx->group_list, group_entry) {
if (event == event->group_leader)
...
or the equivalent, three of which appear to have been introduced by
afedadf2 ("perf_counter: Optimize sched in/out of counters") back in
May by Peter Z.
As far as I can see the if () is superfluous in each case (a singleton
event will be a group of 1 and will have its group_leader pointing to
itself)."
[Can be found at http://marc.info/?l=linux-kernel&m=125361238901442&w=2]
And Peter Zijlstra point out this is an bugfix:
"The intent was to call event_sched_{in,out}() for single counter groups
because that's cheaper than group_sched_{in,out}(), however..
- as you noticed, I got the condition wrong, it should have read:
list_empty(&event->sibling_list)
- it failed to call group_can_go_on() which deals with ->exclusive.
- it also doesn't call hw_perf_group_sched_in() which might break
power."
[Can be found at http://marc.info/?l=linux-kernel&m=125369523318583&w=2]
Changelog v1->v2:
- fix the title name as Peter Zijlstra's suggestion
- remove the comments and WARN_ON_ONCE() as Peter Zijlstra's suggestion
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
kernel/perf_event.c | 30 ++++++++----------------------
1 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 76ac4db..2a15cd6 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -1030,14 +1030,10 @@ void __perf_event_sched_out(struct perf_event_context *ctx,
update_context_time(ctx);
perf_disable();
- if (ctx->nr_active) {
- list_for_each_entry(event, &ctx->group_list, group_entry) {
- if (event != event->group_leader)
- event_sched_out(event, cpuctx, ctx);
- else
- group_sched_out(event, cpuctx, ctx);
- }
- }
+ if (ctx->nr_active)
+ list_for_each_entry(event, &ctx->group_list, group_entry)
+ group_sched_out(event, cpuctx, ctx);
+
perf_enable();
out:
spin_unlock(&ctx->lock);
@@ -1258,12 +1254,8 @@ __perf_event_sched_in(struct perf_event_context *ctx,
if (event->cpu != -1 && event->cpu != cpu)
continue;
- if (event != event->group_leader)
- event_sched_in(event, cpuctx, ctx, cpu);
- else {
- if (group_can_go_on(event, cpuctx, 1))
- group_sched_in(event, cpuctx, ctx, cpu);
- }
+ if (group_can_go_on(event, cpuctx, 1))
+ group_sched_in(event, cpuctx, ctx, cpu);
/*
* If this pinned group hasn't been scheduled,
@@ -1291,15 +1283,9 @@ __perf_event_sched_in(struct perf_event_context *ctx,
if (event->cpu != -1 && event->cpu != cpu)
continue;
- if (event != event->group_leader) {
- if (event_sched_in(event, cpuctx, ctx, cpu))
+ if (group_can_go_on(event, cpuctx, can_add_hw))
+ if (group_sched_in(event, cpuctx, ctx, cpu))
can_add_hw = 0;
- } else {
- if (group_can_go_on(event, cpuctx, can_add_hw)) {
- if (group_sched_in(event, cpuctx, ctx, cpu))
- can_add_hw = 0;
- }
- }
}
perf_enable();
out:
--
1.6.1.2
next prev parent reply other threads:[~2009-09-25 5:52 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-22 8:47 [PATCH] perf_counter: cleanup for __perf_event_sched_in() Xiao Guangrong
2009-09-22 9:20 ` Paul Mackerras
2009-09-22 9:27 ` Xiao Guangrong
2009-09-22 9:32 ` [PATCH v2] " Xiao Guangrong
2009-09-22 9:39 ` [PATCH] " Paul Mackerras
2009-09-22 11:17 ` Peter Zijlstra
2009-09-23 2:45 ` Xiao Guangrong
2009-09-23 3:32 ` Paul Mackerras
2009-09-23 8:10 ` [PATCH 1/2] perf_counter: cleanup for __perf_event_sched_*() Xiao Guangrong
2009-09-23 8:13 ` [PATCH 2/2] perf_counter: optimize for perf_event_init_task() Xiao Guangrong
2009-09-23 8:43 ` Peter Zijlstra
2009-09-25 1:23 ` Xiao Guangrong
2009-09-23 8:40 ` [PATCH 1/2] perf_counter: cleanup for __perf_event_sched_*() Peter Zijlstra
2009-09-25 1:22 ` Xiao Guangrong
2009-09-25 5:51 ` Xiao Guangrong [this message]
2009-09-25 5:54 ` [PATCH 2/2 v2] optimize for perf_event_init_task() Xiao Guangrong
2009-09-25 8:55 ` Peter Zijlstra
2009-10-01 7:31 ` Ingo Molnar
2009-10-01 7:47 ` [tip:perf/urgent] perf_event: Clean up perf_event_init_task() tip-bot for Xiao Guangrong
2009-09-25 8:55 ` [PATCH 1/2 v2] perf_counter: fix for __perf_event_sched_*() Peter Zijlstra
2009-10-01 7:46 ` [tip:perf/urgent] perf_event: Fix event group handling in __perf_event_sched_*() tip-bot for Xiao Guangrong
2009-09-22 11:12 ` [PATCH] perf_counter: cleanup for __perf_event_sched_in() Peter Zijlstra
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=4ABC5A55.7000208@cn.fujitsu.com \
--to=xiaoguangrong@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=peterz@infradead.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