From: Andi Kleen <ak@linux.intel.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@kernel.org>,
Stephane Eranian <eranian@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
Vince Weaver <vince@deater.net>, Ingo Molnar <mingo@kernel.org>
Subject: Re: pmu::read() called erroneously in v4.13-rc{3,4}
Date: Thu, 10 Aug 2017 12:03:55 -0700 [thread overview]
Message-ID: <20170810190355.GL3946@tassilo.jf.intel.com> (raw)
In-Reply-To: <20170810173551.GD12812@leverpostej>
> [ 230.909172] ------------[ cut here ]------------
> [ 230.913796] WARNING: CPU: 1 PID: 3637 at arch/x86/events/core.c:75 x86_perf_event_update+0xbd/0xd0
> [ 230.922739] Modules linked in:
> [ 230.925798] CPU: 1 PID: 3637 Comm: wrong-counter Tainted: G W 4.13.0-rc4+ #230
> [ 230.934132] Hardware name: LENOVO 7484A3G/LENOVO, BIOS 5CKT54AUS 09/07/2009
> [ 230.941080] task: ffff9ad5b0232640 task.stack: ffffb2f001aac000
> [ 230.946989] RIP: 0010:x86_perf_event_update+0xbd/0xd0
> [ 230.952038] RSP: 0018:ffffb2f001aaf978 EFLAGS: 00010282
> [ 230.957257] RAX: 0000000000000020 RBX: ffffb2f001aafa48 RCX: 0000000000000000
> [ 230.964378] RDX: 0000000000000001 RSI: ffff9ad5a9d33400 RDI: ffff9ad5a9d32800
> [ 230.971498] RBP: ffffb2f001aaf9a0 R08: 0000000000000000 R09: 0000000000000028
> [ 230.978622] R10: ffff9ad5b0232640 R11: ffff9ad5a9cd4840 R12: 0000000000000002
> [ 230.985745] R13: 0000000000000018 R14: 0000000000000001 R15: ffff9ad5a9d32800
> [ 230.992866] FS: 0000000000000000(0000) GS:ffff9ad5bec80000(0000) knlGS:0000000000000000
> [ 231.000939] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [ 231.006680] CR2: 00007f26cba069d0 CR3: 0000000085a0a000 CR4: 00000000000406e0
> [ 231.013802] Call Trace:
> [ 231.016254] x86_pmu_read+0x9/0x10
> [ 231.019656] perf_output_read+0x19f/0x410
> [ 231.023665] ? __alloc_pages_nodemask+0xe8/0x1f0
> [ 231.028274] perf_event_read_event+0xd2/0x110
> [ 231.032628] ? x86_pmu_del+0x3e/0x130
> [ 231.036290] ? __intel_pmu_enable_all.isra.12+0x27/0x90
> [ 231.041512] ? intel_pmu_enable_all+0xb/0x10
> [ 231.045779] ? x86_pmu_enable+0x25e/0x2f0
> [ 231.049787] ? group_sched_out+0x8c/0xd0
> [ 231.053708] ? perf_pmu_enable+0x22/0x30
> [ 231.057629] ? update_group_times+0x13/0x40
> [ 231.061812] ? list_del_event+0x66/0xc0
> [ 231.065647] perf_event_exit_task+0x2fa/0x380
I suspect the problem is that exit schedules before it calls
perf_event_exit_task.
We could just move it up to the beginning of exit. Untested
patch here. Does that help?
diff --git a/kernel/exit.c b/kernel/exit.c
index 516acdb0e0ec..9a6f5f299588 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -779,6 +779,14 @@ void __noreturn do_exit(long code)
int group_dead;
TASKS_RCU(int tasks_rcu_i);
+ /*
+ * Flush inherited counters to the parent - before the parent
+ * gets woken up by child-exit notifications.
+ *
+ * because of cgroup mode, must be called before cgroup_exit()
+ */
+ perf_event_exit_task(tsk);
+
profile_task_exit(tsk);
kcov_task_exit(tsk);
@@ -878,14 +886,6 @@ void __noreturn do_exit(long code)
exit_task_work(tsk);
exit_thread(tsk);
- /*
- * Flush inherited counters to the parent - before the parent
- * gets woken up by child-exit notifications.
- *
- * because of cgroup mode, must be called before cgroup_exit()
- */
- perf_event_exit_task(tsk);
-
sched_autogroup_exit_task(tsk);
cgroup_exit(tsk);
next prev parent reply other threads:[~2017-08-10 19:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-10 17:35 pmu::read() called erroneously in v4.13-rc{3,4} Mark Rutland
2017-08-10 19:03 ` Andi Kleen [this message]
2017-08-11 9:32 ` Mark Rutland
2017-08-11 11:18 ` Mark Rutland
2017-08-21 14:46 ` Jiri Olsa
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=20170810190355.GL3946@tassilo.jf.intel.com \
--to=ak@linux.intel.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=vince@deater.net \
/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).