[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3bce547c-cde8-4779-b7cc-2da025db9484@linux.intel.com>
Date: Mon, 11 Aug 2025 13:35:36 +0800
From: "Mi, Dapeng" <dapeng1.mi@...ux.intel.com>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Kan Liang <kan.liang@...ux.intel.com>, linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org, Kevin Tian <kevin.tian@...el.com>,
Dapeng Mi <dapeng1.mi@...el.com>
Subject: Re: [PATCH 4/5] perf tools kvm: Use "cycles" to sample guest for "kvm
record" on Intel
On 8/9/2025 6:10 AM, Namhyung Kim wrote:
> 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.
Sure. Thanks.
>
> Thanks,
> Namhyung
>
>
Powered by blists - more mailing lists