[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140624171819.GQ3213@twins.programming.kicks-ass.net>
Date: Tue, 24 Jun 2014 19:18:19 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
Robert Richter <rric@...nel.org>,
Frederic Weisbecker <fweisbec@...il.com>,
Mike Galbraith <efault@....de>,
Paul Mackerras <paulus@...ba.org>,
Stephane Eranian <eranian@...gle.com>,
Andi Kleen <ak@...ux.intel.com>
Subject: Re: [RFC v2 5/7] perf: add a pmu capability for "exclusive" events
On Wed, Jun 11, 2014 at 06:41:48PM +0300, Alexander Shishkin wrote:
> +static bool exclusive_event_ok(struct perf_event *event,
> + struct perf_event_context *ctx)
> +{
> + struct perf_event *iter_event;
> +
> + if (!(event->pmu->capabilities & PERF_PMU_CAP_EXCLUSIVE))
> + return true;
> +
> + list_for_each_entry(iter_event, &ctx->event_list, event_entry) {
> + if (exclusive_event_match(iter_event, event))
> + return false;
> + }
This list iteration needs either rcu or ctx->lock or ctx->mutex, and the
two callsites below don't have either afaict.
> +
> + return true;
> +}
> +
> /**
> * sys_perf_event_open - open a performance event, associate it to a task/cpu
> *
> @@ -7261,6 +7287,11 @@ SYSCALL_DEFINE5(perf_event_open,
> goto err_alloc;
> }
>
> + if (!exclusive_event_ok(event, ctx)) {
> + err = -EBUSY;
> + goto err_context;
> + }
> +
> if (task) {
> put_task_struct(task);
> task = NULL;
> @@ -7427,6 +7458,13 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
> goto err_free;
> }
>
> + if (!exclusive_event_ok(event, ctx)) {
> + perf_unpin_context(ctx);
> + put_ctx(ctx);
> + err = -EBUSY;
> + goto err_free;
> + }
> +
> WARN_ON_ONCE(ctx->parent_ctx);
> mutex_lock(&ctx->mutex);
> perf_install_in_context(ctx, event, cpu);
> --
> 2.0.0
>
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists