All of lore.kernel.org
 help / color / mirror / Atom feed
* Cannot use address filtering with user register sampling
@ 2022-08-25  0:14 Hongtao Yu
  2022-08-26 14:28 ` Liang, Kan
  0 siblings, 1 reply; 5+ messages in thread
From: Hongtao Yu @ 2022-08-25  0:14 UTC (permalink / raw)
  To: linux-perf-users

Hi,
 
I was exploring address filtering together with user reg sampling on Intel Skylake hardware. The idea behind it is to make reg sampling more selectively. Unfortunately, I hit ` This CPU does not support address filtering` error. The command I ran is:
 
   perf record -e br_inst_retired.all_branches:uppp --user-regs=DI --filter 'filter * @/bin/ls'  ls
 
   This CPU does not support address filtering
 
IIUC, the br_inst_retired event is also hardware-based, similarly with the intel_pt event. But the latter works with address filtering while the former doesn’t. What is rational behind this?
 
Thanks,
Hongtao
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cannot use address filtering with user register sampling
  2022-08-25  0:14 Cannot use address filtering with user register sampling Hongtao Yu
@ 2022-08-26 14:28 ` Liang, Kan
  2022-08-26 22:03   ` Hongtao Yu
  0 siblings, 1 reply; 5+ messages in thread
From: Liang, Kan @ 2022-08-26 14:28 UTC (permalink / raw)
  To: Hongtao Yu, linux-perf-users



On 2022-08-24 8:14 p.m., Hongtao Yu wrote:
> Hi,
>  
> I was exploring address filtering together with user reg sampling on Intel Skylake hardware. The idea behind it is to make reg sampling more selectively. Unfortunately, I hit ` This CPU does not support address filtering` error. The command I ran is:
>  
>    perf record -e br_inst_retired.all_branches:uppp --user-regs=DI --filter 'filter * @/bin/ls'  ls
>  
>    This CPU does not support address filtering
>  
> IIUC, the br_inst_retired event is also hardware-based, similarly with the intel_pt event. But the latter works with address filtering while the former doesn’t. What is rational behind this?

The --filter only supports the tracepoint event(s) or or a hardware
trace, e.g., Intel PT. They trace and dump each single instruction. You
can use the --filter option to choose and only retrieve the
data/instructions you are interested.

Perf record -e br_inst_retired.all_branches event does sampling. I would
recommend you to use "-c" option to control the event period.(The number
of events that triggers a single sample.) For example, -c1000 means 1000
events occur then the HW dumps a sample (only for the 1000th event).
e.g.,
    perf record -e br_inst_retired.all_branches:uppp --user-regs=DI
-c1000 ls

Then you can use the post-processing tools, e.g., perf report or perf
script, to filter and output the results.
e.g.,
   perf script --dsos ls -F+uregs


Thanks,
Kan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cannot use address filtering with user register sampling
  2022-08-26 14:28 ` Liang, Kan
@ 2022-08-26 22:03   ` Hongtao Yu
  2022-08-28 16:30     ` Ian Rogers
  0 siblings, 1 reply; 5+ messages in thread
From: Hongtao Yu @ 2022-08-26 22:03 UTC (permalink / raw)
  To: Liang, Kan, linux-perf-users; +Cc: Wenlei He

Thanks for the information and suggestions!
 
We’ve already been using the -c options to adjust our sampling scale. The new need we are having is that we’d like to sample a particular part of the program instead of the whole program. Since the hardware address filter doesn’t apply here, I’m wondering if it is practical to achieve the selective sampling on software level when processing hardware interrupts, to avoid generating tons of useless trace data. For example, perf could do such filtering based on a section in the binary image that specifies the interesting part of program to sample.
 
Thanks,
Hongtao


From: Liang, Kan <kan.liang@linux.intel.com>
Sent: Friday, August 26, 2022 7:28 AM
To: Hongtao Yu <Hongtao.Yu@outlook.com>; linux-perf-users@vger.kernel.org <linux-perf-users@vger.kernel.org>
Subject: Re: Cannot use address filtering with user register sampling 
 


On 2022-08-24 8:14 p.m., Hongtao Yu wrote:
> Hi,
>  
> I was exploring address filtering together with user reg sampling on Intel Skylake hardware. The idea behind it is to make reg sampling more selectively. Unfortunately, I hit ` This CPU does not support address filtering` error. The command I ran is:
>  
>    perf record -e br_inst_retired.all_branches:uppp --user-regs=DI --filter 'filter * @/bin/ls'  ls
>  
>    This CPU does not support address filtering
>  
> IIUC, the br_inst_retired event is also hardware-based, similarly with the intel_pt event. But the latter works with address filtering while the former doesn’t. What is rational behind this?

The --filter only supports the tracepoint event(s) or or a hardware
trace, e.g., Intel PT. They trace and dump each single instruction. You
can use the --filter option to choose and only retrieve the
data/instructions you are interested.

Perf record -e br_inst_retired.all_branches event does sampling. I would
recommend you to use "-c" option to control the event period.(The number
of events that triggers a single sample.) For example, -c1000 means 1000
events occur then the HW dumps a sample (only for the 1000th event).
e.g.,
    perf record -e br_inst_retired.all_branches:uppp --user-regs=DI
-c1000 ls

Then you can use the post-processing tools, e.g., perf report or perf
script, to filter and output the results.
e.g.,
   perf script --dsos ls -F+uregs


Thanks,
Kan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cannot use address filtering with user register sampling
  2022-08-26 22:03   ` Hongtao Yu
@ 2022-08-28 16:30     ` Ian Rogers
  2022-08-29  4:50       ` Hongtao Yu
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Rogers @ 2022-08-28 16:30 UTC (permalink / raw)
  To: Hongtao Yu; +Cc: Liang, Kan, linux-perf-users, Wenlei He

On Fri, Aug 26, 2022 at 3:03 PM Hongtao Yu <Hongtao.Yu@outlook.com> wrote:
>
> Thanks for the information and suggestions!
>
> We’ve already been using the -c options to adjust our sampling scale. The new need we are having is that we’d like to sample a particular part of the program instead of the whole program. Since the hardware address filter doesn’t apply here, I’m wondering if it is practical to achieve the selective sampling on software level when processing hardware interrupts, to avoid generating tons of useless trace data. For example, perf could do such filtering based on a section in the binary image that specifies the interesting part of program to sample.

It is possible to write BPF programs that will drop samples. There is
an example in the tests:
https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/tools/perf/tests/bpf-script-example.c

Thanks,
Ian

> Thanks,
> Hongtao
>
>
> From: Liang, Kan <kan.liang@linux.intel.com>
> Sent: Friday, August 26, 2022 7:28 AM
> To: Hongtao Yu <Hongtao.Yu@outlook.com>; linux-perf-users@vger.kernel.org <linux-perf-users@vger.kernel.org>
> Subject: Re: Cannot use address filtering with user register sampling
>
>
>
> On 2022-08-24 8:14 p.m., Hongtao Yu wrote:
> > Hi,
> >
> > I was exploring address filtering together with user reg sampling on Intel Skylake hardware. The idea behind it is to make reg sampling more selectively. Unfortunately, I hit ` This CPU does not support address filtering` error. The command I ran is:
> >
> >    perf record -e br_inst_retired.all_branches:uppp --user-regs=DI --filter 'filter * @/bin/ls'  ls
> >
> >    This CPU does not support address filtering
> >
> > IIUC, the br_inst_retired event is also hardware-based, similarly with the intel_pt event. But the latter works with address filtering while the former doesn’t. What is rational behind this?
>
> The --filter only supports the tracepoint event(s) or or a hardware
> trace, e.g., Intel PT. They trace and dump each single instruction. You
> can use the --filter option to choose and only retrieve the
> data/instructions you are interested.
>
> Perf record -e br_inst_retired.all_branches event does sampling. I would
> recommend you to use "-c" option to control the event period.(The number
> of events that triggers a single sample.) For example, -c1000 means 1000
> events occur then the HW dumps a sample (only for the 1000th event).
> e.g.,
>     perf record -e br_inst_retired.all_branches:uppp --user-regs=DI
> -c1000 ls
>
> Then you can use the post-processing tools, e.g., perf report or perf
> script, to filter and output the results.
> e.g.,
>    perf script --dsos ls -F+uregs
>
>
> Thanks,
> Kan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cannot use address filtering with user register sampling
  2022-08-28 16:30     ` Ian Rogers
@ 2022-08-29  4:50       ` Hongtao Yu
  0 siblings, 0 replies; 5+ messages in thread
From: Hongtao Yu @ 2022-08-29  4:50 UTC (permalink / raw)
  To: Ian Rogers; +Cc: Liang, Kan, linux-perf-users, Wenlei He

Thanks for the pointer. This is so cool! IIUC, perf can take in a piece of C code that can implement a filter of samples. I'm wondering if there's any documentation about the specification of the C code.

Thanks,
Hongtao


From: Ian Rogers <irogers@google.com>
Sent: Sunday, August 28, 2022 9:30 AM
To: Hongtao Yu <Hongtao.Yu@outlook.com>
Cc: Liang, Kan <kan.liang@linux.intel.com>; linux-perf-users@vger.kernel.org <linux-perf-users@vger.kernel.org>; Wenlei He <wenlei@fb.com>
Subject: Re: Cannot use address filtering with user register sampling 
 
On Fri, Aug 26, 2022 at 3:03 PM Hongtao Yu <Hongtao.Yu@outlook.com> wrote:
>
> Thanks for the information and suggestions!
>
> We’ve already been using the -c options to adjust our sampling scale. The new need we are having is that we’d like to sample a particular part of the program instead of the whole program. Since the hardware address filter doesn’t apply here, I’m wondering if it is practical to achieve the selective sampling on software level when processing hardware interrupts, to avoid generating tons of useless trace data. For example, perf could do such filtering based on a section in the binary image that specifies the interesting part of program to sample.

It is possible to write BPF programs that will drop samples. There is
an example in the tests:
https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Facme%2Flinux.git%2Ftree%2Ftools%2Fperf%2Ftests%2Fbpf-script-example.c&amp;data=05%7C01%7C%7Cf9c51874388f436c2e7308da8912aa36%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637973010500861646%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=yw5nGV7e3W3haHSpi4dhid0UfaEcNFIRxMUCZWuWQVQ%3D&amp;reserved=0

Thanks,
Ian

> Thanks,
> Hongtao
>
>
> From: Liang, Kan <kan.liang@linux.intel.com>
> Sent: Friday, August 26, 2022 7:28 AM
> To: Hongtao Yu <Hongtao.Yu@outlook.com>; linux-perf-users@vger.kernel.org <linux-perf-users@vger.kernel.org>
> Subject: Re: Cannot use address filtering with user register sampling
>
>
>
> On 2022-08-24 8:14 p.m., Hongtao Yu wrote:
> > Hi,
> >
> > I was exploring address filtering together with user reg sampling on Intel Skylake hardware. The idea behind it is to make reg sampling more selectively. Unfortunately, I hit ` This CPU does not support address filtering` error. The command I ran is:
> >
> >    perf record -e br_inst_retired.all_branches:uppp --user-regs=DI --filter 'filter * @/bin/ls'  ls
> >
> >    This CPU does not support address filtering
> >
> > IIUC, the br_inst_retired event is also hardware-based, similarly with the intel_pt event. But the latter works with address filtering while the former doesn’t. What is rational behind this?
>
> The --filter only supports the tracepoint event(s) or or a hardware
> trace, e.g., Intel PT. They trace and dump each single instruction. You
> can use the --filter option to choose and only retrieve the
> data/instructions you are interested.
>
> Perf record -e br_inst_retired.all_branches event does sampling. I would
> recommend you to use "-c" option to control the event period.(The number
> of events that triggers a single sample.) For example, -c1000 means 1000
> events occur then the HW dumps a sample (only for the 1000th event).
> e.g.,
>     perf record -e br_inst_retired.all_branches:uppp --user-regs=DI
> -c1000 ls
>
> Then you can use the post-processing tools, e.g., perf report or perf
> script, to filter and output the results.
> e.g.,
>    perf script --dsos ls -F+uregs
>
>
> Thanks,
> Kan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-29  4:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-25  0:14 Cannot use address filtering with user register sampling Hongtao Yu
2022-08-26 14:28 ` Liang, Kan
2022-08-26 22:03   ` Hongtao Yu
2022-08-28 16:30     ` Ian Rogers
2022-08-29  4:50       ` Hongtao Yu

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.