Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1386616

Re: [PATCH v1 4/5] perf: Introduce address range filtering

From Alexander Shishkin <alexander.shishkin@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH v1 4/5] perf: Introduce address range filtering
Date 2016-04-25 18:10 +0200
Message-ID <rrRfb-hZ-1@gated-at.bofh.it> (permalink)
References <rqoRX-2Wv-3@gated-at.bofh.it> <rqoRY-2Wv-33@gated-at.bofh.it> <rqE0G-6O2-29@gated-at.bofh.it> <rqLYe-4HV-13@gated-at.bofh.it> <rrOAH-6uE-33@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Peter Zijlstra <peterz@infradead.org> writes:

> On Fri, Apr 22, 2016 at 07:19:11PM +0300, Alexander Shishkin wrote:
>> +static int perf_event_restart(struct perf_event *event)
>> +{
>> +	struct stop_event_data sd = {
>> +		.event		= event,
>> +		.restart	= 1,
>> +	};
>> +	int ret = 0;
>> +
>> +	do {
>> +		if (READ_ONCE(event->state) != PERF_EVENT_STATE_ACTIVE)
>> +			return 0;
>> +
>> +		/* matches smp_wmb() in event_sched_in() */
>> +		smp_rmb();
>> +
>> +		ret = cpu_function_call(READ_ONCE(event->oncpu),
>> +					__perf_event_stop, &sd);
>> +	} while (ret == -EAGAIN);
>> +
>> +	return ret;
>> +}
>
> A few concerns with this;

(awesome, and now I see where the comments are actually needed)

>  - if I understand things right; this will loose a bit of trace when
>    people tickle the ioctl(), right? This might want a note of sorts,

I don't actually see how, if they're doing the ioctl() on an enabled
event, it'll generate unfiltered data until it gets scheduled out or it
receives this cross call, which will apply the new filters. The
__perf_event_stop(), which restarts the event will run on the target
cpu, so it doesn't race with the workload.

>  - you need to handle event->oncpu == -1,

Ok, we're in practice ignoring this but it deserves a comment. The
cpu_function_call() here should return -ENXIO in this case and we'll
just fall through, which is fine, because that means that the event is
inactive and the filters will apply when it goes active again.

>  - can we race with an actual stop, and accidentally re-enable the
>    thing? If not, this might be a good place for a comment explaining
>    how.

We can (mmap in workload vs munmap(AUX) in trace consumer), but the
event's start will fail in perf_aux_output_begin() because of
rb::aux_mmap_count being zero. The actual stop is only used in aux
unmapping, so like this we should be covered.

Thanks,
--
Alex

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v1 4/5] perf: Introduce address range filtering Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-21 17:40 +0200
  Re: [PATCH v1 4/5] perf: Introduce address range filtering Peter Zijlstra <peterz@infradead.org> - 2016-04-22 09:50 +0200
    Re: [PATCH v1 4/5] perf: Introduce address range filtering Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-22 18:20 +0200
      Re: [PATCH v1 4/5] perf: Introduce address range filtering Peter Zijlstra <peterz@infradead.org> - 2016-04-25 15:00 +0200
        Re: [PATCH v1 4/5] perf: Introduce address range filtering Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-25 17:50 +0200
      Re: [PATCH v1 4/5] perf: Introduce address range filtering Peter Zijlstra <peterz@infradead.org> - 2016-04-25 15:20 +0200
        Re: [PATCH v1 4/5] perf: Introduce address range filtering Peter Zijlstra <peterz@infradead.org> - 2016-04-25 15:40 +0200
        Re: [PATCH v1 4/5] perf: Introduce address range filtering Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-25 18:10 +0200
      Re: [PATCH v1 4/5] perf: Introduce address range filtering Peter Zijlstra <peterz@infradead.org> - 2016-04-25 15:30 +0200
        Re: [PATCH v1 4/5] perf: Introduce address range filtering Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-25 18:10 +0200
      Re: [PATCH v1 4/5] perf: Introduce address range filtering Peter Zijlstra <peterz@infradead.org> - 2016-04-25 16:20 +0200
        Re: [PATCH v1 4/5] perf: Introduce address range filtering Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-25 18:10 +0200
      Re: [PATCH v1 4/5] perf: Introduce address range filtering Peter Zijlstra <peterz@infradead.org> - 2016-04-25 16:30 +0200
        Re: [PATCH v1 4/5] perf: Introduce address range filtering Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-25 18:20 +0200
        Re: [PATCH v1 4/5] perf: Introduce address range filtering Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-26 16:40 +0200

csiph-web