* tracing child threads with address filtering using intel_pt @ 2018-10-03 0:23 Mansour Alharthi [not found] ` <5267CD8C-A8B1-416E-BCCD-5DD87DCA4FB1@gatech.edu> 0 siblings, 1 reply; 4+ messages in thread From: Mansour Alharthi @ 2018-10-03 0:23 UTC (permalink / raw) To: peterz, mingo, acme; +Cc: linux-kernel Hello all, I am having trouble tracing child threads when using address filtering with intel_pt .. Assume this test code: thread_start(){ ... test(); ... } test(){ printf("test"); } main(){ ... pthread_create(......, thread_start,....); } Tracing the above program with the following command: perf record -v -m 512,10000 -e intel_pt//u -T --switch-events --filter 'filter * @ ./test' -- ./test Returns zero trace for code executed by child thread, i.e. thread_start() and test() functions.. While tracing without the filter does include the threads trace: perf record -v -m 512,10000 -e intel_pt//u -T --switch-events -- ./test Is this intended? or is it a bug? Thanks! Mansour. ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <5267CD8C-A8B1-416E-BCCD-5DD87DCA4FB1@gatech.edu>]
* Re: tracing child threads with address filtering using intel_pt in perf [not found] ` <5267CD8C-A8B1-416E-BCCD-5DD87DCA4FB1@gatech.edu> @ 2018-10-08 11:52 ` Alexander Shishkin 2018-10-08 14:25 ` Alexander Shishkin 0 siblings, 1 reply; 4+ messages in thread From: Alexander Shishkin @ 2018-10-08 11:52 UTC (permalink / raw) To: Alharthi, Mansour A, peterz, acme, mingo, adrian.hunter; +Cc: linux-kernel "Alharthi, Mansour A" <mansourah@gatech.edu> writes: > Hello all, Hi, > Assume this test code: > > thread_start(){ > ... > test(); > ... > } > > test(){ > printf("test"); > } > > main(){ > ... > pthread_create(......, thread_start,....); > } Can you include the complete test case code? > Tracing the above program with the following command: > perf record -v -m 512,10000 -e intel_pt//u -T --switch-events --filter > 'filter * @ ./test' -- ./test Can you run it with -vvv and also include its output? Thanks, -- Alex ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: tracing child threads with address filtering using intel_pt in perf 2018-10-08 11:52 ` tracing child threads with address filtering using intel_pt in perf Alexander Shishkin @ 2018-10-08 14:25 ` Alexander Shishkin 2018-10-09 6:31 ` Mansour Alharthi 0 siblings, 1 reply; 4+ messages in thread From: Alexander Shishkin @ 2018-10-08 14:25 UTC (permalink / raw) To: Alharthi, Mansour A, peterz, acme, mingo, adrian.hunter; +Cc: linux-kernel Alexander Shishkin <alexander.shishkin@linux.intel.com> writes: > "Alharthi, Mansour A" <mansourah@gatech.edu> writes: > >> Hello all, > > Hi, > >> Assume this test code: >> >> thread_start(){ >> ... >> test(); >> ... >> } >> >> test(){ >> printf("test"); >> } >> >> main(){ >> ... >> pthread_create(......, thread_start,....); >> } > > Can you include the complete test case code? > >> Tracing the above program with the following command: >> perf record -v -m 512,10000 -e intel_pt//u -T --switch-events --filter >> 'filter * @ ./test' -- ./test > > Can you run it with -vvv and also include its output? Scratch that. Instead, can you try the below patch and see if it works for you? Thanks, -- Alex From 029a726b63ed6ebef527393704c83dab9c76fb9a Mon Sep 17 00:00:00 2001 From: Alexander Shishkin <alexander.shishkin@linux.intel.com> Date: Mon, 8 Oct 2018 17:16:30 +0300 Subject: [PATCH] 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. Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> --- kernel/events/core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index c80549bf82c6..8cecbd61cd90 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -1254,6 +1254,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 @@ -10058,6 +10059,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.19.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: tracing child threads with address filtering using intel_pt in perf 2018-10-08 14:25 ` Alexander Shishkin @ 2018-10-09 6:31 ` Mansour Alharthi 0 siblings, 0 replies; 4+ messages in thread From: Mansour Alharthi @ 2018-10-09 6:31 UTC (permalink / raw) To: Alexander Shishkin, Alharthi, Mansour A, peterz, acme, mingo, adrian.hunter Cc: linux-kernel Thank you Alex for the prompt response and fix! it works perfectly now.. Mansour.. On 10/08/2018 10:25 AM, Alexander Shishkin wrote: > Alexander Shishkin <alexander.shishkin@linux.intel.com> writes: > >> "Alharthi, Mansour A" <mansourah@gatech.edu> writes: >> >>> Hello all, >> Hi, >> >>> Assume this test code: >>> >>> thread_start(){ >>> ... >>> test(); >>> ... >>> } >>> >>> test(){ >>> printf("test"); >>> } >>> >>> main(){ >>> ... >>> pthread_create(......, thread_start,....); >>> } >> Can you include the complete test case code? >> >>> Tracing the above program with the following command: >>> perf record -v -m 512,10000 -e intel_pt//u -T --switch-events --filter >>> 'filter * @ ./test' -- ./test >> Can you run it with -vvv and also include its output? > Scratch that. Instead, can you try the below patch and see if it works > for you? > > Thanks, > -- > Alex > > From 029a726b63ed6ebef527393704c83dab9c76fb9a Mon Sep 17 00:00:00 2001 > From: Alexander Shishkin <alexander.shishkin@linux.intel.com> > Date: Mon, 8 Oct 2018 17:16:30 +0300 > Subject: [PATCH] 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. > > Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> > --- > kernel/events/core.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/kernel/events/core.c b/kernel/events/core.c > index c80549bf82c6..8cecbd61cd90 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -1254,6 +1254,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 > @@ -10058,6 +10059,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; > } ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-09 6:31 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-10-03 0:23 tracing child threads with address filtering using intel_pt Mansour Alharthi [not found] ` <5267CD8C-A8B1-416E-BCCD-5DD87DCA4FB1@gatech.edu> 2018-10-08 11:52 ` tracing child threads with address filtering using intel_pt in perf Alexander Shishkin 2018-10-08 14:25 ` Alexander Shishkin 2018-10-09 6:31 ` Mansour Alharthi
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).