Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf: Copy parent's address filter offsets on clone

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: Mansour Alharthi <malharthi9@gatech.edu>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Tested-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Fixes: 375637bc5249 ("perf/core: Introduce address range filtering")
Link: http://lkml.kernel.org/r/20190215115655.63469-2-alexander.shishkin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Alexander Shishkin and committed by
Arnaldo Carvalho de Melo
18736eef cd358012

+15
+15
kernel/events/core.c
··· 1255 1255 * perf_event_context::lock 1256 1256 * perf_event::mmap_mutex 1257 1257 * mmap_sem 1258 + * perf_addr_filters_head::lock 1258 1259 * 1259 1260 * cpu_hotplug_lock 1260 1261 * pmus_lock ··· 10311 10310 if (!event->addr_filters_offs) { 10312 10311 err = -ENOMEM; 10313 10312 goto err_per_task; 10313 + } 10314 + 10315 + /* 10316 + * Clone the parent's vma offsets: they are valid until exec() 10317 + * even if the mm is not shared with the parent. 10318 + */ 10319 + if (event->parent) { 10320 + struct perf_addr_filters_head *ifh = perf_event_addr_filters(event); 10321 + 10322 + raw_spin_lock_irq(&ifh->lock); 10323 + memcpy(event->addr_filters_offs, 10324 + event->parent->addr_filters_offs, 10325 + pmu->nr_addr_filters * sizeof(unsigned long)); 10326 + raw_spin_unlock_irq(&ifh->lock); 10314 10327 } 10315 10328 10316 10329 /* force hw sync on the address filters */