Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1690160 > unrolled thread
| Started by | Alexander Shishkin <alexander.shishkin@linux.intel.com> |
|---|---|
| First post | 2017-07-18 13:20 +0200 |
| Last post | 2017-07-20 10:50 +0200 |
| Articles | 4 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: perf: bisected sampling bug in Linux 4.11-rc1 Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2017-07-18 13:20 +0200
Re: perf: bisected sampling bug in Linux 4.11-rc1 Ingo Molnar <mingo@kernel.org> - 2017-07-18 14:20 +0200
Re: perf: bisected sampling bug in Linux 4.11-rc1 Vince Weaver <vincent.weaver@maine.edu> - 2017-07-20 05:40 +0200
[tip:perf/urgent] perf/core: Fix scheduling regression of pinned groups tip-bot for Alexander Shishkin <tipbot@zytor.com> - 2017-07-20 10:50 +0200
| From | Alexander Shishkin <alexander.shishkin@linux.intel.com> |
|---|---|
| Date | 2017-07-18 13:20 +0200 |
| Subject | Re: perf: bisected sampling bug in Linux 4.11-rc1 |
| Message-ID | <u4yHM-1HH-15@gated-at.bofh.it> |
Vince Weaver <vincent.weaver@maine.edu> writes:
> I was tracking down some regressions in my perf_event_test testsuite.
> Some of the tests broke in the 4.11-rc1 timeframe.
>
> I've bisected one of them, this report is about
> tests/overflow/simul_oneshot_group_overflow
> This test creates an event group containing two sampling events, set
> to overflow to a signal handler (which disables and then refreshes the
> event).
>
> On a good kernel you get the following:
> Event perf::instructions with period 1000000
> Event perf::instructions with period 2000000
> fd 3 overflows: 946 (perf::instructions/1000000)
> fd 4 overflows: 473 (perf::instructions/2000000)
> Ending counts:
> Count 0: 946379875
> Count 1: 946365218
>
> With the broken kernels you get:
> Event perf::instructions with period 1000000
> Event perf::instructions with period 2000000
> fd 3 overflows: 938 (perf::instructions/1000000)
> fd 4 overflows: 318 (perf::instructions/2000000)
> Ending counts:
> Count 0: 946373080
> Count 1: 653373058
>
>
> 487f05e18aa4efacee6357480f293a5afe6593b5 is the first bad commit
>
> commit 487f05e18aa4efacee6357480f293a5afe6593b5
> Author: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Date: Thu Jan 19 18:43:30 2017 +0200
Ok, there was a bug there indeed. This patch should take care of it and
should also be backportable in case it's stable-worthy.
From 187d67c9908cb126656c34546772089c17a8e6c5 Mon Sep 17 00:00:00 2001
From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Date: Tue, 18 Jul 2017 13:53:01 +0300
Subject: [PATCH] perf: Fix scheduling regression of pinned groups
Commit 487f05e18a ("perf/core: Optimize event rescheduling on active
contexts") erronously assumed that event's 'pinned' setting determines
whether the event belongs to a pinned group or not, but in fact, it's
the group leader's pinned state that matters. This was discovered by
Vince in a test case where two instruction counters are grouped, the
group leader is pinned, but the other event is not; in the regressed
case the counters were off by 33% (the difference between events'
periods), but should be the same within the error margin.
This fixes the problem by looking at the group leader's pinning.
Reported-by: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: 487f05e18a ("perf/core: Optimize event rescheduling on active contexts")
Cc: stable@vger.kernel.org
---
kernel/events/core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index bc63f8db1b..1edbaf94dd 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1451,6 +1451,13 @@ static enum event_type_t get_event_type(struct perf_event *event)
lockdep_assert_held(&ctx->lock);
+ /*
+ * It's 'group type', really, because if our group leader is
+ * pinned, so are we.
+ */
+ if (event->group_leader != event)
+ event = event->group_leader;
+
event_type = event->attr.pinned ? EVENT_PINNED : EVENT_FLEXIBLE;
if (!ctx->task)
event_type |= EVENT_CPU;
--
2.11.0
[toc] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2017-07-18 14:20 +0200 |
| Message-ID | <u4zDR-2ih-19@gated-at.bofh.it> |
| In reply to | #1690160 |
* Alexander Shishkin <alexander.shishkin@linux.intel.com> wrote: > Vince Weaver <vincent.weaver@maine.edu> writes: > > > I was tracking down some regressions in my perf_event_test testsuite. > > Some of the tests broke in the 4.11-rc1 timeframe. > > > > I've bisected one of them, this report is about > > tests/overflow/simul_oneshot_group_overflow > > This test creates an event group containing two sampling events, set > > to overflow to a signal handler (which disables and then refreshes the > > event). > > > > On a good kernel you get the following: > > Event perf::instructions with period 1000000 > > Event perf::instructions with period 2000000 > > fd 3 overflows: 946 (perf::instructions/1000000) > > fd 4 overflows: 473 (perf::instructions/2000000) > > Ending counts: > > Count 0: 946379875 > > Count 1: 946365218 > > > > With the broken kernels you get: > > Event perf::instructions with period 1000000 > > Event perf::instructions with period 2000000 > > fd 3 overflows: 938 (perf::instructions/1000000) > > fd 4 overflows: 318 (perf::instructions/2000000) > > Ending counts: > > Count 0: 946373080 > > Count 1: 653373058 > > > > > > 487f05e18aa4efacee6357480f293a5afe6593b5 is the first bad commit > > > > commit 487f05e18aa4efacee6357480f293a5afe6593b5 > > Author: Alexander Shishkin <alexander.shishkin@linux.intel.com> > > Date: Thu Jan 19 18:43:30 2017 +0200 > > Ok, there was a bug there indeed. This patch should take care of it and > should also be backportable in case it's stable-worthy. > > From 187d67c9908cb126656c34546772089c17a8e6c5 Mon Sep 17 00:00:00 2001 > From: Alexander Shishkin <alexander.shishkin@linux.intel.com> > Date: Tue, 18 Jul 2017 13:53:01 +0300 > Subject: [PATCH] perf: Fix scheduling regression of pinned groups Ok, great - if this works then I'll pick up this fix instead of the revert that I've queued up earlier today. Thanks, Ingo
[toc] | [prev] | [next] | [standalone]
| From | Vince Weaver <vincent.weaver@maine.edu> |
|---|---|
| Date | 2017-07-20 05:40 +0200 |
| Message-ID | <u5atH-1s6-5@gated-at.bofh.it> |
| In reply to | #1690217 |
On Tue, 18 Jul 2017, Ingo Molnar wrote: > > Ok, great - if this works then I'll pick up this fix instead of the revert that > I've queued up earlier today. sorry for the delay, I was out of town for a few days. I've tried the patch and it looks like it fixes the test in question and doesn't seem to add any other regressions. Vince
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Alexander Shishkin <tipbot@zytor.com> |
|---|---|
| Date | 2017-07-20 10:50 +0200 |
| Subject | [tip:perf/urgent] perf/core: Fix scheduling regression of pinned groups |
| Message-ID | <u5fjJ-4Py-47@gated-at.bofh.it> |
| In reply to | #1690160 |
Commit-ID: 3bda69c1c3993a2bddbae01397d12bfef6054011
Gitweb: http://git.kernel.org/tip/3bda69c1c3993a2bddbae01397d12bfef6054011
Author: Alexander Shishkin <alexander.shishkin@linux.intel.com>
AuthorDate: Tue, 18 Jul 2017 14:08:34 +0300
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 20 Jul 2017 09:43:02 +0200
perf/core: Fix scheduling regression of pinned groups
Vince Weaver reported:
> I was tracking down some regressions in my perf_event_test testsuite.
> Some of the tests broke in the 4.11-rc1 timeframe.
>
> I've bisected one of them, this report is about
> tests/overflow/simul_oneshot_group_overflow
> This test creates an event group containing two sampling events, set
> to overflow to a signal handler (which disables and then refreshes the
> event).
>
> On a good kernel you get the following:
> Event perf::instructions with period 1000000
> Event perf::instructions with period 2000000
> fd 3 overflows: 946 (perf::instructions/1000000)
> fd 4 overflows: 473 (perf::instructions/2000000)
> Ending counts:
> Count 0: 946379875
> Count 1: 946365218
>
> With the broken kernels you get:
> Event perf::instructions with period 1000000
> Event perf::instructions with period 2000000
> fd 3 overflows: 938 (perf::instructions/1000000)
> fd 4 overflows: 318 (perf::instructions/2000000)
> Ending counts:
> Count 0: 946373080
> Count 1: 653373058
The root cause of the bug is that the following commit:
487f05e18a ("perf/core: Optimize event rescheduling on active contexts")
erronously assumed that event's 'pinned' setting determines whether the
event belongs to a pinned group or not, but in fact, it's the group
leader's pinned state that matters.
This was discovered by Vince in the test case described above, where two instruction
counters are grouped, the group leader is pinned, but the other event is not;
in the regressed case the counters were off by 33% (the difference between events'
periods), but should be the same within the error margin.
Fix the problem by looking at the group leader's pinning.
Reported-by: Vince Weaver <vincent.weaver@maine.edu>
Tested-by: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Fixes: 487f05e18a ("perf/core: Optimize event rescheduling on active contexts")
Link: http://lkml.kernel.org/r/87lgnmvw7h.fsf@ashishki-desk.ger.corp.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/events/core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 9747e42..c9cdbd3 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1452,6 +1452,13 @@ static enum event_type_t get_event_type(struct perf_event *event)
lockdep_assert_held(&ctx->lock);
+ /*
+ * It's 'group type', really, because if our group leader is
+ * pinned, so are we.
+ */
+ if (event->group_leader != event)
+ event = event->group_leader;
+
event_type = event->attr.pinned ? EVENT_PINNED : EVENT_FLEXIBLE;
if (!ctx->task)
event_type |= EVENT_CPU;
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web