All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org, vince@deater.net,
	eranian@google.com, Arnaldo Carvalho de Melo <acme@infradead.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>
Subject: Re: [PATCH v1 4/5] perf: Introduce address range filtering
Date: Mon, 25 Apr 2016 19:02:32 +0300	[thread overview]
Message-ID: <87twip8ynb.fsf@ashishki-desk.ger.corp.intel.com> (raw)
In-Reply-To: <20160425131013.GD3448@twins.programming.kicks-ass.net>

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

  parent reply	other threads:[~2016-04-25 16:03 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21 15:16 [PATCH v1 0/5] perf: Introduce address range filtering Alexander Shishkin
2016-04-21 15:16 ` [PATCH v1 1/5] perf: Move set_filter() from behind EVENT_TRACING Alexander Shishkin
2016-04-21 15:17 ` [PATCH v1 2/5] perf/x86/intel/pt: IP filtering register/cpuid bits Alexander Shishkin
2016-04-21 17:48   ` Borislav Petkov
2016-04-21 18:55     ` Thomas Gleixner
2016-04-21 19:17       ` Peter Zijlstra
2016-04-21 20:39         ` Borislav Petkov
2016-04-21 20:37       ` Borislav Petkov
2016-04-22  7:58         ` Thomas Gleixner
2016-04-22  9:34           ` Borislav Petkov
2016-04-21 15:17 ` [PATCH v1 3/5] perf: Extend perf_event_aux_ctx() to optionally iterate through more events Alexander Shishkin
2016-04-21 15:17 ` [PATCH v1 4/5] perf: Introduce address range filtering Alexander Shishkin
2016-04-22  7:45   ` Peter Zijlstra
2016-04-22 16:19     ` Alexander Shishkin
2016-04-25 12:57       ` Peter Zijlstra
2016-04-25 15:41         ` Alexander Shishkin
2016-04-25 13:10       ` Peter Zijlstra
2016-04-25 13:36         ` Peter Zijlstra
2016-04-25 16:02         ` Alexander Shishkin [this message]
2016-04-25 13:19       ` Peter Zijlstra
2016-04-25 16:03         ` Alexander Shishkin
2016-04-25 14:14       ` Peter Zijlstra
2016-04-25 16:07         ` Alexander Shishkin
2016-04-25 14:25       ` Peter Zijlstra
2016-04-25 16:14         ` Alexander Shishkin
2016-04-26 14:35         ` Alexander Shishkin
2016-04-21 15:17 ` [PATCH v1 5/5] perf/x86/intel/pt: Add support for address range filtering in PT Alexander Shishkin

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=87twip8ynb.fsf@ashishki-desk.ger.corp.intel.com \
    --to=alexander.shishkin@linux.intel.com \
    --cc=acme@infradead.org \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.