From: Namhyung Kim <namhyung@kernel.org>
To: Thomas Richter <tmricht@linux.ibm.com>
Cc: "linux-perf-use." <linux-perf-users@vger.kernel.org>
Subject: Re: Question to perf record command
Date: Fri, 29 Sep 2023 23:32:00 -0700 [thread overview]
Message-ID: <CAM9d7cjTRE6D8hHfCrmFWE3fDfds+RAMYevuCNM2t_c3S5-T3A@mail.gmail.com> (raw)
In-Reply-To: <3a212e80-b00b-f44b-3d2c-6e221d8cc1ac@linux.ibm.com>
Hello,
On Fri, Sep 29, 2023 at 2:56 AM Thomas Richter <tmricht@linux.ibm.com> wrote:
>
> I have a question regarding command perf record.
>
> Command ./perf record -R -e cycles -vvv -C0 -- true
> sets up perf_event_open system call with CPU == 0 and PID == -1.
>
> According to the documentation, this applies to all processes on CPU 0
> and not just the process named true.
>
> Is this indended? I thought process true should be traced when running on
> CPU 0. Shouldn't the perf_event_open() system call in called with
> CPU set to 0 and PID set to PID of process true?
It's intended. When you specify CPU targets (-a or -C options),
it'd profile ALL processes on those CPUs. The command line
task just controls when it terminates the sampling. For example,
we often use sleep command to profile all processes for the
specified time.
$ perf record -a -- sleep 1
Thanks,
Namhyung
>
> Tracing output:
> # ./perf record -R -e cycles -vvv -C0 -- true
> DEBUGINFOD_URLS=
> nr_cblocks: 0
> affinity: SYS
> mmap flush: 1
> comp level: 0
> perf record opening and mmapping events
> Opening: cycles
> ------------------------------------------------------------
> perf_event_attr:
> type 0 (PERF_TYPE_HARDWARE)
> size 136
> config 0 (PERF_COUNT_HW_CPU_CYCLES)
> { sample_period, sample_freq } 4000
> sample_type IP|TID|TIME|ID|CPU|PERIOD|RAW
> read_format ID|LOST
> disabled 1
> inherit 1
> freq 1
> sample_id_all 1
> exclude_guest 1
> ------------------------------------------------------------
> sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 5
> ....
>
>
> When command invocation is
> # ./perf record -R -e cycles -vvv -- true
>
> the forked process named true (PID 13092) is traced on all CPUs:
> [root@a35lp67 perf]# ./perf record -R -e cycles -vvv -- true
> DEBUGINFOD_URLS=
> nr_cblocks: 0
> affinity: SYS
> mmap flush: 1
> comp level: 0
> perf record opening and mmapping events
> Opening: cycles
> ------------------------------------------------------------
> perf_event_attr:
> type 0 (PERF_TYPE_HARDWARE)
> size 136
> config 0 (PERF_COUNT_HW_CPU_CYCLES)
> { sample_period, sample_freq } 4000
> sample_type IP|TID|TIME|CPU|PERIOD|RAW
> read_format ID|LOST
> disabled 1
> inherit 1
> mmap 1
> comm 1
> freq 1
> enable_on_exec 1
> task 1
> sample_id_all 1
> exclude_guest 1
> mmap2 1
> comm_exec 1
> ksymbol 1
> bpf_event 1
> ------------------------------------------------------------
> sys_perf_event_open: pid 13092 cpu 0 group_fd -1 flags 0x8 = 5
> sys_perf_event_open: pid 13092 cpu 1 group_fd -1 flags 0x8 = 6
> sys_perf_event_open: pid 13092 cpu 2 group_fd -1 flags 0x8 = 7
> sys_perf_event_open: pid 13092 cpu 3 group_fd -1 flags 0x8 = 9
> sys_perf_event_open: pid 13092 cpu 4 group_fd -1 flags 0x8 = 10
> sys_perf_event_open: pid 13092 cpu 5 group_fd -1 flags 0x8 = 11
> sys_perf_event_open: pid 13092 cpu 6 group_fd -1 flags 0x8 = 12
> sys_perf_event_open: pid 13092 cpu 7 group_fd -1 flags 0x8 = 13
> mmap size 528384B
> ....
>
> --
> Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
> --
> Vorsitzender des Aufsichtsrats: Gregor Pillen
> Geschäftsführung: David Faller
> Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
>
prev parent reply other threads:[~2023-09-30 6:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-29 9:56 Question to perf record command Thomas Richter
2023-09-30 6:32 ` Namhyung Kim [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAM9d7cjTRE6D8hHfCrmFWE3fDfds+RAMYevuCNM2t_c3S5-T3A@mail.gmail.com \
--to=namhyung@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=tmricht@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).