linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org, jolsa@redhat.com,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Mansour Alharthi <malharthi9@gatech.edu>
Subject: [PATCH v0 1/2] perf: Copy parent's address filter offsets on clone
Date: Fri, 15 Feb 2019 13:56:54 +0200	[thread overview]
Message-ID: <20190215115655.63469-2-alexander.shishkin@linux.intel.com> (raw)
In-Reply-To: <20190215115655.63469-1-alexander.shishkin@linux.intel.com>

When a child event is allocated in the inherit_event() path, the VMA
based filter offsets are not copied from the parent, even though the
address space mapping of the new task remains the same, which leads
to no trace for the new task until exec.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: 375637bc5249 ("perf/core: Introduce address range filtering")
Reported-by: Mansour Alharthi <malharthi9@gatech.edu>
---
 kernel/events/core.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 5aeb4c74fb99..2d89efc0a3e0 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1255,6 +1255,7 @@ static void put_ctx(struct perf_event_context *ctx)
  *	      perf_event_context::lock
  *	    perf_event::mmap_mutex
  *	    mmap_sem
+ *	      perf_addr_filters_head::lock
  *
  *    cpu_hotplug_lock
  *      pmus_lock
@@ -10312,6 +10313,20 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
 			goto err_per_task;
 		}
 
+		/*
+		 * Clone the parent's vma offsets: they are valid until exec()
+		 * even if the mm is not shared with the parent.
+		 */
+		if (event->parent) {
+			struct perf_addr_filters_head *ifh = perf_event_addr_filters(event);
+
+			raw_spin_lock_irq(&ifh->lock);
+			memcpy(event->addr_filters_offs,
+			       event->parent->addr_filters_offs,
+			       pmu->nr_addr_filters * sizeof(unsigned long));
+			raw_spin_unlock_irq(&ifh->lock);
+		}
+
 		/* force hw sync on the address filters */
 		event->addr_filters_gen = 1;
 	}
-- 
2.20.1


  reply	other threads:[~2019-02-15 11:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-15 11:56 [PATCH v0 0/2] perf: Address range filtering fixes Alexander Shishkin
2019-02-15 11:56 ` Alexander Shishkin [this message]
2019-02-15 18:10   ` [PATCH v0 1/2] perf: Copy parent's address filter offsets on clone Arnaldo Carvalho de Melo
2019-02-22 12:56     ` Alexander Shishkin
2019-02-22 14:54       ` Arnaldo Carvalho de Melo
2019-02-28  7:57   ` [tip:perf/core] " tip-bot for Alexander Shishkin
2019-02-15 11:56 ` [PATCH v0 2/2] perf, pt, coresight: Fix address filters for vmas with non-zero offset Alexander Shishkin
2019-02-15 14:54   ` Arnaldo Carvalho de Melo
2019-02-15 17:38     ` Mathieu Poirier
2019-02-28  7:58   ` [tip:perf/core] " 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=20190215115655.63469-2-alexander.shishkin@linux.intel.com \
    --to=alexander.shishkin@linux.intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=malharthi9@gatech.edu \
    --cc=mingo@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).