Re: [PATCH v4 5/6] KVM: x86/vPMU: Reuse perf_event to avoid unnecessary pmc_reprogram_counter

From: Like Xu
Date: Thu Nov 14 2019 - 02:13:35 EST


Hi Wanpeng,

On 2019/11/14 11:51, Wanpeng Li wrote:
On Mon, 28 Oct 2019 at 21:06, Like Xu <like.xu@xxxxxxxxxxxxxxx> wrote:

The perf_event_create_kernel_counter() in the pmc_reprogram_counter() is
a heavyweight and high-frequency operation, especially when host disables
the watchdog (maximum 21000000 ns) which leads to an unacceptable latency

Why when host disables the watchdog,
perf_event_create_kernel_counter() is more heavyweight and
high-frequency operation?

Wanpeng


- Fist, let me assume you do have experienced the fact that the perf behavior on guest for multiple hardware events is extremely sluggish when you disable watchdog on host. The setting of host watchdog is
the uncontrollability the patch series wants to eliminate for vPMU users.

- Disabling host watchdog brings higher frequency is imprecise. In legacy vPMU code, the operation is high-frequency regardless of the host watchdog setting. The exact frequency depends on perf sampling frequency and guest pmu driver pattern.

- The sched_clock() time consumed by perf_event_create_kernel_counter() is tested on various x86 platforms and the values suddenly become larger when and only when host disables watchdog. Sometimes watchdog damages the accuracy. In the early stages of exploration, we found if host disables watchdog, the synchronize_rcu() from account_event() in perf_event_alloc() becomes much more heavyweight and it seems to be a general necessary mechanism. The deeper reason behind this is undefined.

Thanks,
Like Xu