Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1311512
| Path | csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Alexander Shishkin <alexander.shishkin@linux.intel.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] perf: Synchronously cleanup child events |
| Date | Mon, 18 Jan 2016 13:20:01 +0100 |
| Message-ID | <qSgWR-uP-11@gated-at.bofh.it> (permalink) |
| References | <qRciC-6vV-27@gated-at.bofh.it> <qRdeG-7bt-31@gated-at.bofh.it> <qRgPh-ZC-21@gated-at.bofh.it> |
| X-Extloop1 | 1 |
| X-Ironport-Av | E=Sophos;i="5.22,312,1449561600"; d="scan'208";a="892955404" |
| User-Agent | Notmuch/0.21 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) |
| MIME-Version | 1.0 |
| Content-Type | text/plain |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 69 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Ingo Molnar <mingo@redhat.com>, linux-kernel@vger.kernel.org, vince@deater.net, eranian@google.com, Arnaldo Carvalho de Melo <acme@infradead.org>, Jiri Olsa <jolsa@kernel.org> |
| X-Original-Date | Mon, 18 Jan 2016 14:07:46 +0200 |
| X-Original-Message-ID | <878u3n850t.fsf@ashishki-desk.ger.corp.intel.com> |
| X-Original-References | <20160115130932.GL6357@twins.programming.kicks-ass.net> <1452866861-17680-1-git-send-email-alexander.shishkin@linux.intel.com> <20160115175759.GL3421@worktop> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1311512 |
Show key headers only | View raw
Peter Zijlstra <peterz@infradead.org> writes:
> On Fri, Jan 15, 2016 at 04:07:41PM +0200, Alexander Shishkin wrote:
>> int perf_event_release_kernel(struct perf_event *event)
>> {
>> + struct perf_event *child, *tmp;
>> + LIST_HEAD(child_list);
>>
>> + if (!is_kernel_event(event))
>> + perf_remove_from_owner(event);
>>
>> + event->owner = NULL;
>>
>> + /*
>> + * event::child_mutex nests inside ctx::lock, so move children
>> + * to a safe place first and avoid inversion
>> + */
>> + mutex_lock(&event->child_mutex);
>> + list_splice_init(&event->child_list, &child_list);
>> + mutex_unlock(&event->child_mutex);
>
> I suspect this races against inherit_event(), like:
>
> inherit_event() perf_event_release_kernel()
>
> if (is_orphaned_event(parent_event) /* false */
>
> event->owner = NULL
>
> mutex_lock(child_mutex);
> list_splice
> mutex_unlock(child_mutex);
>
> mutex_lock(child_mutex);
> list_add_tail
> mutex_unlock(child_mutex);
Indeed, this is possible.
>
> Something like this would fix that I think, not sure its the best way
> though...
>
>
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -979,8 +979,8 @@ static void put_ctx(struct perf_event_co
> * Lock order:
> * task_struct::perf_event_mutex
> * perf_event_context::mutex
> - * perf_event_context::lock
> * perf_event::child_mutex;
> + * perf_event_context::lock
> * perf_event::mmap_mutex
> * mmap_sem
> */
This is, actually, the order that we have already:
perf_ioctl(): ctx::mutex
-> perf_event_for_each(): event::child_mutex
-> _perf_event_enable(): ctx::lock
that is, ctx::lock already nests inside event::child_mutex. So what
you're suggesting is an ok solution.
Regards,
--
Alex
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] perf: Cleanup user's child events Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-01-15 12:30 +0100
Re: [PATCH] perf: Cleanup user's child events Peter Zijlstra <peterz@infradead.org> - 2016-01-15 14:00 +0100
Re: [PATCH] perf: Cleanup user's child events Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-01-15 14:10 +0100
Re: [PATCH] perf: Cleanup user's child events Peter Zijlstra <peterz@infradead.org> - 2016-01-15 14:10 +0100
[PATCH] perf: Synchronously cleanup child events Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-01-15 15:10 +0100
Re: [PATCH] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-15 19:00 +0100
Re: [PATCH] perf: Synchronously cleanup child events Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-01-18 13:20 +0100
Re: [PATCH] perf: Synchronously cleanup child events Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-01-18 13:40 +0100
Re: [PATCH] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-18 15:50 +0100
[PATCH v2] perf: Synchronously cleanup child events Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-01-19 16:20 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-19 21:10 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-19 21:10 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-19 23:00 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-20 09:40 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-21 06:00 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-01-20 08:10 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-20 09:10 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-01-22 12:40 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-22 13:20 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-22 13:40 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-22 20:50 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-25 12:50 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-25 16:00 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-25 22:10 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-26 06:10 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-26 17:20 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-26 18:30 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-27 00:40 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Peter Zijlstra <peterz@infradead.org> - 2016-01-27 11:00 +0100
Re: [PATCH v2] perf: Synchronously cleanup child events Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-27 19:00 +0100
Re: [PATCH] perf: Synchronously cleanup child events Ingo Molnar <mingo@kernel.org> - 2016-01-19 08:50 +0100
csiph-web