* Re: [Question] How to sample PERF_TYPE_HARDWARE
2021-02-16 7:50 ` Namhyung Kim
@ 2021-02-18 1:22 ` rainkin
2021-02-18 2:04 ` rainkin
1 sibling, 0 replies; 5+ messages in thread
From: rainkin @ 2021-02-18 1:22 UTC (permalink / raw)
To: Namhyung Kim; +Cc: linux-perf-users
Hi Namhyung,
Thanks for your reply.
Let me make my goal more clear:
record the number of occurring branches instructions
(PERF_COUNT_HW_BRANCH_INSTRUCTIONS) every N cycles
(PERF_COUNT_HW_CPU_CYCLES).
> perf record -e branches -c N
I use strace to capture the syscall invoked by the above command:
perf_event_open({type=PERF_TYPE_HARDWARE, size=PERF_ATTR_SIZE_VER6,
config=PERF_COUNT_HW_BRANCH_INSTRUCTIONS, sample_period=100000,
sample_type=PERF_SAMPLE_IP|PERF_SAMPLE_TID|PERF_SAMPLE_TIME|PERF_SAMPLE_ID|PERF_SAMPLE_CPU,
read_format=PERF_FORMAT_ID, disabled=1, inherit=1, pinned=0,
exclusive=0, exclusive_user=0, exclude_kernel=0, exclude_hv=0,
exclude_idle=0, mmap=0, comm=0, freq=0, inherit_stat=0,
enable_on_exec=0, task=0, watermark=0, precise_ip=0 /* arbitrary skid
*/, mmap_data=0, sample_id_all=1, exclude_host=0, exclude_guest=1,
exclude_callchain_kernel=0, exclude_callchain_user=0, mmap2=0,
comm_exec=0, use_clockid=0, context_switch=0, write_backward=0,
namespaces=0, wakeup_events=0, config1=0, config2=0,
sample_regs_user=0, sample_regs_intr=0, aux_watermark=0,
sample_max_stack=0, aux_sample_size=0}, -1, 10, -1,
PERF_FLAG_FD_CLOEXEC) = 15
In my understanding ,WHAT this command actually does is recording
IP,TID, and so on
(sample_type=PERF_SAMPLE_IP|PERF_SAMPLE_TID|PERF_SAMPLE_TIME|PERF_SAMPLE_ID|PERF_SAMPLE_CPU)
every N (here N = 100000) branches
(config=PERF_COUNT_HW_BRANCH_INSTRUCTIONS). Thus this cannot meet my
goal.
Thanks,
Rainkin
Namhyung Kim <namhyung@gmail.com> 于2021年2月16日周二 下午3:50写道:
>
> Hello,
>
> On Mon, Feb 8, 2021 at 12:50 PM rainkin <rainkin1993@gmail.com> wrote:
> >
> > Hello~
> >
> > My goal is to record the number of occurring PERF_TYPE_HARDWARE events
> > (e.g., branches) every N events.
> >
> > In my understanding, the "perf stat -e branches -I N " command is not
> > sampling, it is actually count model which records branches every N
> > millisecond. Thus perf stat does not meet my goal.
> >
> > For the "perf record -e cycles -b" command, it does sampling, which
> > records a LBR sample every N cycles events. However, it seems that
> > "perf record" does not support sampling PERF_TYPE_HARDWARE.
>
> The 'cycles' is a PERF_TYPE_HARDWARE event.
>
> >
> > I also look at the syscall perf_event_open, but still cannot find any
> > documentation about how to sample PERF_TYPE_HARDWARE.
> >
> > Does anyone know how to do that?Any suggestions is helpful for me :)
>
> perf record -e branches -c N
>
> ?
>
> Thanks,
> Namhyung
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Question] How to sample PERF_TYPE_HARDWARE
2021-02-16 7:50 ` Namhyung Kim
2021-02-18 1:22 ` rainkin
@ 2021-02-18 2:04 ` rainkin
2021-02-19 7:09 ` Namhyung Kim
1 sibling, 1 reply; 5+ messages in thread
From: rainkin @ 2021-02-18 2:04 UTC (permalink / raw)
To: Namhyung Kim; +Cc: linux-perf-users
Hi Namhyung,
Thanks for your reply.
Let me make my goal more clear: record the number of occurring branch
instructions (PERF_COUNT_HW_BRANCH_INSTRUCTIONS) every N cycles
(PERF_COUNT_HW_CPU_CYCLES).
For the command you mentioned : perf record -e branches -c N
I use strace to capture the syscall invoked by the above command:
perf_event_open({type=PERF_TYPE_HARDWARE, size=PERF_ATTR_SIZE_VER6,
config=PERF_COUNT_HW_BRANCH_INSTRUCTIONS, sample_period=100000,
sample_type=PERF_SAMPLE_IP|PERF_SAMPLE_TID|PERF_SAMPLE_TIME|PERF_SAMPLE_ID|PERF_SAMPLE_CPU,
read_format=PERF_FORMAT_ID, disabled=1, inherit=1, pinned=0,
exclusive=0, exclusive_user=0, exclude_kernel=0, exclude_hv=0,
exclude_idle=0, mmap=0, comm=0, freq=0, inherit_stat=0,
enable_on_exec=0, task=0, watermark=0, precise_ip=0 /* arbitrary skid
*/, mmap_data=0, sample_id_all=1, exclude_host=0, exclude_guest=1,
exclude_callchain_kernel=0, exclude_callchain_user=0, mmap2=0,
comm_exec=0, use_clockid=0, context_switch=0, write_backward=0,
namespaces=0, wakeup_events=0, config1=0, config2=0,
sample_regs_user=0, sample_regs_intr=0, aux_watermark=0,
sample_max_stack=0, aux_sample_size=0}, -1, 10, -1,
PERF_FLAG_FD_CLOEXEC)
In my understanding ,WHAT this command actually does is recording
IP,TID, and so on
(sample_type=PERF_SAMPLE_IP|PERF_SAMPLE_TID|PERF_SAMPLE_TIME|PERF_SAMPLE_ID|PERF_SAMPLE_CPU)
every N (here N = 100000) branches
(config=PERF_COUNT_HW_BRANCH_INSTRUCTIONS). Thus this cannot meet my
goal.
Thanks,
Rainkin
^ permalink raw reply [flat|nested] 5+ messages in thread