All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org, Borislav Petkov <bp@alien8.de>,
	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 v2 5/7] perf: Introduce address range filtering
Date: Thu, 28 Apr 2016 19:09:02 +0200	[thread overview]
Message-ID: <20160428170902.GS3408@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1461771888-10409-6-git-send-email-alexander.shishkin@linux.intel.com>

On Wed, Apr 27, 2016 at 06:44:46PM +0300, Alexander Shishkin wrote:
> +/*
> + * In order to contain the amount of racy and tricky in the address filter
> + * configuration management, it is a two part process:
> + *
> + * (p1) when userspace mappings change as a result of (1) or (2) or (3) below,
> + *      we update the addresses of corresponding vmas in
> + *	event::addr_filters_offs array and bump the event::addr_filters_gen;
> + * (p2) when an event is scheduled in (pmu::add), it calls
> + *      perf_event_addr_filters_sync() which calls pmu::addr_filters_sync()
> + *      if the generation has changed since the previous call.
> + *
> + * If (p1) happens while the event is active, we restart it to force (p2).

Tiny nit; restart only does ::stop(),::start(), which doesn't go through
::add().

> + *
> + * (1) perf_addr_filters_apply(): adjusting filters' offsets based on
> + *     pre-existing mappings, called once when new filters arrive via SET_FILTER
> + *     ioctl;
> + * (2) perf_addr_filters_adjust(): adjusting filters' offsets based on newly
> + *     registered mapping, called for every new mmap(), with mm::mmap_sem down
> + *     for reading;
> + * (3) perf_event_addr_filters_exec(): clearing filters' offsets in the process
> + *     of exec.
> + */

> +static unsigned long perf_addr_filter_apply(struct perf_addr_filter *filter,
> +					    struct mm_struct *mm)
> +{
> +	struct vm_area_struct *vma;
> +
> +	for (vma = mm->mmap; vma->vm_next; vma = vma->vm_next) {

Doesn't this miss the very last vma? That is, I was expecting:

	for (vma = mm->mmap; vma; vma = vma->vm_next) {

> +		struct file *file = vma->vm_file;
> +		unsigned long off = vma->vm_pgoff << PAGE_SHIFT;
> +		unsigned long vma_size = vma->vm_end - vma->vm_start;
> +
> +		if (!file)
> +			continue;
> +
> +		if (!perf_addr_filter_match(filter, file, off, vma_size))
> +			continue;
> +
> +		return vma->vm_start;
> +	}
> +
> +	return 0;
> +}

  reply	other threads:[~2016-04-28 17:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27 15:44 [PATCH v2 0/7] perf: Introduce address range filtering Alexander Shishkin
2016-04-27 15:44 ` [PATCH v2 1/7] perf: Move set_filter() from behind EVENT_TRACING Alexander Shishkin
2016-05-05  9:45   ` [tip:perf/core] perf/core: Move set_filter() out of CONFIG_EVENT_TRACING tip-bot for Alexander Shishkin
2016-04-27 15:44 ` [PATCH v2 2/7] perf/x86/intel/pt: Move MSR bit definitions to a private header Alexander Shishkin
2016-05-05  9:45   ` [tip:perf/core] perf/x86/intel/pt: Move PT specific " tip-bot for Alexander Shishkin
2016-04-27 15:44 ` [PATCH v2 3/7] perf/x86/intel/pt: IP filtering register/cpuid bits Alexander Shishkin
2016-05-05  9:46   ` [tip:perf/core] perf/x86/intel/pt: Add IP filtering register/CPUID bits tip-bot for Alexander Shishkin
2016-04-27 15:44 ` [PATCH v2 4/7] perf: Extend perf_event_aux_ctx() to optionally iterate through more events Alexander Shishkin
2016-05-05  9:46   ` [tip:perf/core] perf/core: " tip-bot for Alexander Shishkin
2016-04-27 15:44 ` [PATCH v2 5/7] perf: Introduce address range filtering Alexander Shishkin
2016-04-28 17:09   ` Peter Zijlstra [this message]
2016-04-29 18:12   ` Mathieu Poirier
2016-04-30  4:59     ` Alexander Shishkin
2016-05-02 14:31       ` Mathieu Poirier
2016-05-03  8:56   ` Peter Zijlstra
2016-05-05  9:46   ` [tip:perf/core] perf/core: " tip-bot for Alexander Shishkin
2016-04-27 15:44 ` [PATCH v2 6/7] perf/x86/intel/pt: Add support for address range filtering in PT Alexander Shishkin
2016-05-05  9:47   ` [tip:perf/core] " tip-bot for Alexander Shishkin
2016-04-27 15:44 ` [PATCH v2 7/7] perf: Let userspace know if pmu supports address filters Alexander Shishkin
2016-05-05  9:47   ` [tip:perf/core] perf/core: Let userspace know if the PMU " tip-bot for 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=20160428170902.GS3408@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@infradead.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=vince@deater.net \
    --cc=x86@kernel.org \
    /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.