From: Peter Zijlstra <peterz@infradead.org>
To: Vince Weaver <vincent.weaver@maine.edu>
Cc: Ingo Molnar <mingo@kernel.org>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: perf: perf_fuzzer quickly locks up on 4.15-rc7
Date: Tue, 9 Jan 2018 14:36:51 +0100 [thread overview]
Message-ID: <20180109133651.GB2369@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180109132602.GA2369@hirez.programming.kicks-ass.net>
On Tue, Jan 09, 2018 at 02:26:02PM +0100, Peter Zijlstra wrote:
> OK, so I'm running on an IVB-EP with PTI enabled. I insta triggered a
> lockdep splat
---
Subject: perf: Fix lock inversion between perf,trace,cpuhp
From: Peter Zijlstra <peterz@infradead.org>
Date: Tue Jan 9 13:10:30 CET 2018
Lockdep gifted us:
perf_trace_init()
#0 mutex_lock(&event_mutex)
perf_trace_event_init()
perf_trace_event_reg()
tp_event->class->reg() := tracepoint_probe_register
#1 mutex_lock(&tracepoints_mutex)
trace_point_add_func()
#2 static_key_enable()
#2 do_cpu_up()
perf_event_init_cpu()
#3 mutex_lock(&pmus_lock)
#4 mutex_lock(&ctx->mutex)
perf_event_task_disable()
mutex_lock(¤t->perf_event_mutex)
#4 ctx = perf_event_ctx_lock()
#5 perf_event_for_each_child()
do_exit()
task_work_run()
__fput()
perf_release()
perf_event_release_kernel()
#4 mutex_lock(&ctx->mutex)
#5 mutex_lock(&event->child_mutex)
free_event()
_free_event()
event->destroy() := perf_trace_destroy
#0 mutex_lock(&event_mutex);
Fix that by moving the free_event() out from under the locks.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
kernel/events/core.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1231,6 +1231,10 @@ static void put_ctx(struct perf_event_co
* perf_event_context::lock
* perf_event::mmap_mutex
* mmap_sem
+ *
+ * cpu_hotplug_lock
+ * pmus_lock
+ * cpuctx->mutex / perf_event_context::mutex
*/
static struct perf_event_context *
perf_event_ctx_lock_nested(struct perf_event *event, int nesting)
@@ -4196,6 +4200,7 @@ int perf_event_release_kernel(struct per
{
struct perf_event_context *ctx = event->ctx;
struct perf_event *child, *tmp;
+ LIST_HEAD(free_list);
/*
* If we got here through err_file: fput(event_file); we will not have
@@ -4268,8 +4273,7 @@ int perf_event_release_kernel(struct per
struct perf_event, child_list);
if (tmp == child) {
perf_remove_from_context(child, DETACH_GROUP);
- list_del(&child->child_list);
- free_event(child);
+ list_move(&child->child_list, &free_list);
/*
* This matches the refcount bump in inherit_event();
* this can't be the last reference.
@@ -4284,6 +4288,11 @@ int perf_event_release_kernel(struct per
}
mutex_unlock(&event->child_mutex);
+ list_for_each_entry_safe(child, tmp, &free_list, child_list) {
+ list_del(&child->child_list);
+ free_event(child);
+ }
+
no_ctx:
put_event(event); /* Must be the 'last' reference */
return 0;
next prev parent reply other threads:[~2018-01-09 13:37 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-08 16:12 perf: perf_fuzzer quickly locks up on 4.15-rc7 Vince Weaver
2018-01-08 17:30 ` Ingo Molnar
2018-01-08 20:29 ` Vince Weaver
2018-01-09 10:25 ` Peter Zijlstra
2018-01-09 13:26 ` Peter Zijlstra
2018-01-09 13:36 ` Peter Zijlstra [this message]
2018-01-09 13:44 ` Vince Weaver
2018-01-09 15:12 ` Peter Zijlstra
2018-01-09 15:24 ` Vince Weaver
2018-01-09 15:33 ` Peter Zijlstra
2018-01-09 15:56 ` Vince Weaver
2018-01-09 16:05 ` Peter Zijlstra
2018-01-09 17:07 ` Josh Poimboeuf
2018-01-11 5:25 ` Josh Poimboeuf
2018-01-11 19:00 ` Vince Weaver
2018-01-11 19:21 ` Josh Poimboeuf
2018-01-11 19:50 ` Peter Zijlstra
2018-01-11 19:57 ` Vince Weaver
2018-01-11 20:43 ` Vince Weaver
2018-05-01 13:29 ` perf: fuzzer causes stack going in wrong direction warnings Vince Weaver
2018-05-01 13:58 ` Josh Poimboeuf
2018-05-01 19:59 ` Vince Weaver
2018-05-01 22:04 ` Josh Poimboeuf
2018-05-02 20:50 ` Josh Poimboeuf
2018-05-04 14:35 ` Vince Weaver
2018-05-04 16:25 ` Josh Poimboeuf
2018-05-04 17:00 ` Vince Weaver
2018-05-05 15:38 ` Vince Weaver
2018-05-05 18:29 ` Josh Poimboeuf
2018-05-06 23:49 ` Josh Poimboeuf
2018-05-10 13:48 ` Peter Zijlstra
2018-05-10 14:27 ` Josh Poimboeuf
2018-05-10 23:16 ` Josh Poimboeuf
2018-01-09 16:16 ` perf: perf_fuzzer quickly locks up on 4.15-rc7 Ingo Molnar
2018-01-09 16:20 ` Peter Zijlstra
2018-01-09 17:18 ` Vince Weaver
2018-01-10 15:28 ` Vince Weaver
2018-01-09 16:14 ` Peter Zijlstra
2018-01-09 17:53 ` Steven Rostedt
2018-01-09 18:02 ` Peter Zijlstra
2018-01-09 18:09 ` Steven Rostedt
2018-01-09 19:53 ` Peter Zijlstra
2018-01-11 9:13 ` Peter Zijlstra
2018-01-11 15:26 ` Vince Weaver
2018-01-11 15:38 ` Peter Zijlstra
2018-01-11 16:41 ` Vince Weaver
2018-01-11 16:58 ` Vince Weaver
2018-01-11 17:03 ` Peter Zijlstra
2018-01-11 18:04 ` Vince Weaver
2018-01-11 18:20 ` Vince Weaver
2018-01-11 19:01 ` Peter Zijlstra
2018-01-11 19:11 ` Peter Zijlstra
2018-01-11 20:15 ` Vince Weaver
2018-01-11 20:40 ` Vince Weaver
2018-01-11 20:57 ` Peter Zijlstra
2018-01-12 19:48 ` Vince Weaver
2018-01-11 20:42 ` Peter Zijlstra
2018-01-11 15:29 ` 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=20180109133651.GB2369@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=vincent.weaver@maine.edu \
/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).