Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 547690a5 authored by Alexander Shishkin's avatar Alexander Shishkin Committed by Yabin Cui
Browse files

UPSTREAM: perf: Copy parent's address filter offsets on clone



(Upstream commit 18736eef12137c59f60cc9f56dc5bea05c92e0eb).

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.

Reported-by: default avatarMansour Alharthi <malharthi9@gatech.edu>
Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
Tested-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Fixes: 375637bc ("perf/core: Introduce address range filtering")
Link: http://lkml.kernel.org/r/20190215115655.63469-2-alexander.shishkin@linux.intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>

Bug: 140266694
Change-Id: I14af7095b0712ee6fc427eafc3d3486f0fc1b07c
Signed-off-by: default avatarYabin Cui <yabinc@google.com>
parent 93b40c1d
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -1259,6 +1259,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
@@ -10141,6 +10142,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;
	}