From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Eric Lin <eric.lin@sifive.com>
Cc: Eduardo Habkost <ehabkost@gmail.com>,
Namhyung Kim <namhyung@kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Jiri Olsa <jolsa@redhat.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Mark Rutland <mark.rutland@arm.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Yao Jin <yao.jin@linux.intel.com>,
Greentime Hu <greentime.hu@sifive.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Vincent Chen <vincent.chen@sifive.com>
Subject: Re: About perf tool set exclude_guest = 1 on guest environment
Date: Thu, 20 Jan 2022 12:47:27 -0300 [thread overview]
Message-ID: <YemED+3SzJQR+tZq@kernel.org> (raw)
In-Reply-To: <CAPqJEFqJpnq1TF-ZA7Worsy2Yx6au-KHBPkCN0cSnQuyGbwsfw@mail.gmail.com>
Em Thu, Jan 20, 2022 at 09:35:59PM +0800, Eric Lin escreveu:
> On Wed, Jan 19, 2022 at 1:02 PM Namhyung Kim <namhyung@kernel.org> wrote:
> > On Mon, Jan 17, 2022 at 8:05 PM Eric Lin <eric.lin@sifive.com> wrote:
> > > Currently, I run the perf command 'perf record -e branches:u ls' and
> > > 'perf record -e branches ls'. It will set exclude_guest = 1 as below:
> > >
> > > # perf record -e branches:u ls
> > > # perf evlist -v
> > > branches:u: .., exclude_kernel: 1, exclude_hv: 1,, exclude_guest: 1, ..
> > >
> > > # perf record -e branches ls
> > > # perf evlist -v
> > > branches: ..., exclude_guest: 1, ...
> > >
> > > As I understand it, set exclude_guest =1 will not include guest counting.
> > > May I ask if I run the above commands as a guest user, should the
> > > architecture implementation ignore this exclude_guest flags and still
> > > make perf can count guest events in Linux kernel?
> >
> > So do you want to run the command in the host?
> > Then you can use both 'H' and 'G' modifiers like
> >
> > # perf record -e branches:HG ls
> >
> > or (for user-mode only)
> >
> > # perf record -e branches:uHG ls
> >
>
> Actually, I want to run the commands in the guest.
> But when I run the commands "perf record -e branches:u ls" and "perf
> record -e branches ls", it will set exclude_guet = 1.
> According to the documentation[1] exclude_guest definition, it should
> not count guest events.
> So, if I run these commands as a guest user can I get the profile data?
>
> [1] https://man7.org/linux/man-pages/man2/perf_event_open.2.html
The tool shouldn't know that it is running in a guest, right?
And the kernel, running on a guest should exclude its guests if
attr.exclude_guest is set, not itself and its non-guest userland.
So, before delving into how the kernel running on guest _actually_
handles attr.exclude_guest=1 behaves, what are the results you are
getting from running perf on a guest?
Lemme see...
On a fedora:35 guest:
[root@fedora ~]# perf record ls
anaconda-ks.cfg perf.data
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.014 MB perf.data (3 samples) ]
[root@fedora ~]# perf evlist -v
cpu-clock:pppH: type: 1, size: 128, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1
[root@fedora ~]#
IIRC there is some extra magic to allow 'cycles' to be seen on the
guest, but apart from that it seems to work.
Eduardo, can you help us here?
- Arnaldo
next prev parent reply other threads:[~2022-01-21 9:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-18 4:05 Eric Lin
2022-01-19 5:01 ` Namhyung Kim
2022-01-20 13:35 ` Eric Lin
2022-01-20 15:47 ` Arnaldo Carvalho de Melo [this message]
2022-02-18 2:31 ` Eric Lin
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=YemED+3SzJQR+tZq@kernel.org \
--to=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=ehabkost@gmail.com \
--cc=eric.lin@sifive.com \
--cc=greentime.hu@sifive.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=paul.walmsley@sifive.com \
--cc=peterz@infradead.org \
--cc=vincent.chen@sifive.com \
--cc=yao.jin@linux.intel.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
Powered by JetHome