From: Namhyung Kim <namhyung@kernel.org>
To: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Kevin Tian <kevin.tian@intel.com>,
Dapeng Mi <dapeng1.mi@intel.com>
Subject: Re: [PATCH 4/5] perf tools kvm: Use "cycles" to sample guest for "kvm record" on Intel
Date: Fri, 8 Aug 2025 15:10:48 -0700 [thread overview]
Message-ID: <aJZ16DZXNI1pvt5-@google.com> (raw)
In-Reply-To: <154b59ee-0858-4caf-9972-3679db0a0c49@linux.intel.com>
On Thu, Aug 07, 2025 at 11:08:11AM +0800, Mi, Dapeng wrote:
>
> On 8/7/2025 8:08 AM, Namhyung Kim wrote:
> > On Tue, Aug 05, 2025 at 08:46:32AM +0800, Dapeng Mi wrote:
> >> After KVM supports PEBS for guest on Intel platforms
> >> (https://lore.kernel.org/all/20220411101946.20262-1-likexu@tencent.com/),
> >> host loses the capability to sample guest with PEBS since all PEBS related
> >> MSRs are switched to guest value after vm-entry, like IA32_DS_AREA MSR is
> >> switched to guest GVA at vm-entry. This would lead to "perf kvm record"
> >> fails to sample guest on Intel platforms since "cycles:P" event is used to
> >> sample guest by default as below case shows.
> > Do you mean we cannot use "cycles:PG" for perf kvm record?
>
> Yes. Here is the output on Intel Sapphire rapids.
>
> sudo ./perf record -e cycles:PG -a
> ^C[ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.801 MB perf.data ]
>
> No guest records are captured with PEBS, and guest PEBS records can be
> sampled only without PEBS.
>
> sudo ./perf record -e cycles:G -a
> ^C[ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.798 MB perf.data (60 samples) ]
>
>
> >
> >> sudo perf kvm record -a
> >> ^C[ perf record: Woken up 1 times to write data ]
> >> [ perf record: Captured and wrote 0.787 MB perf.data.guest ]
> >>
> >> So to ensure guest record can be sampled successfully, use "cycles"
> >> instead of "cycles:P" to sample guest record by default on Intel
> >> platforms. With this patch, the guest record can be sampled
> >> successfully.
> >>
> >> sudo perf kvm record -a
> >> ^C[ perf record: Woken up 1 times to write data ]
> >> [ perf record: Captured and wrote 0.783 MB perf.data.guest (23 samples) ]
> > What if user already gave some events in the command line? I think you
> > need to check if "-e" or "--event" (and "--pfm-events" too) is in the
> > argv[] before adding these.
>
> kvm_add_default_arch_event() would detect if user already sets events explicitly. If so, it won't add "cycles" event any more. Thanks.
Oh, ok. I can see you called parse_options to check the option.
You'd better to check "--pfm-events" as well.
Thanks,
Namhyung
next prev parent reply other threads:[~2025-08-08 22:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 0:46 [PATCH 0/5] Perf kvm commands bug fix Dapeng Mi
2025-08-05 0:46 ` [PATCH 1/5] perf tools kvm: Add missed memory allocation check and free Dapeng Mi
2025-08-06 23:40 ` Namhyung Kim
2025-08-07 2:51 ` Mi, Dapeng
2025-08-05 0:46 ` [PATCH 2/5] perf tools kvm: Fix the potential out of range memory access issue Dapeng Mi
2025-08-06 23:53 ` Namhyung Kim
2025-08-07 2:52 ` Mi, Dapeng
2025-08-05 0:46 ` [PATCH 3/5] perf tools: Add helper x86__is_intel_cpu() Dapeng Mi
2025-08-05 0:46 ` [PATCH 4/5] perf tools kvm: Use "cycles" to sample guest for "kvm record" on Intel Dapeng Mi
2025-08-07 0:08 ` Namhyung Kim
2025-08-07 3:08 ` Mi, Dapeng
2025-08-08 22:10 ` Namhyung Kim [this message]
2025-08-11 5:35 ` Mi, Dapeng
2025-08-05 0:46 ` [PATCH 5/5] perf tools kvm: Use "cycles" to sample guest for "kvm top" " Dapeng Mi
2025-08-05 0:57 ` Mi, Dapeng
2025-08-05 11:32 ` Aditya Bodkhe
2025-08-06 0:31 ` Mi, Dapeng
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=aJZ16DZXNI1pvt5-@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dapeng1.mi@intel.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=irogers@google.com \
--cc=kan.liang@linux.intel.com \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/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 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.