Re: [PATCH v2] KVM: x86/intr: Explicitly check NMI from guest to eliminate false positives

From: Sean Christopherson
Date: Mon Feb 26 2024 - 21:22:38 EST


On Wed, 06 Dec 2023 11:20:54 +0800, Like Xu wrote:
> Explicitly checking the source of external interrupt is indeed NMI and not
> other types in the kvm_arch_pmi_in_guest(), which prevents perf-kvm false
> positive samples generated in perf/core NMI mode after vm-exit but before
> kvm_before_interrupt() from being incorrectly labelled as guest samples:
>
> # test: perf-record + cpu-cycles:HP (which collects host-only precise samples)
> # Symbol Overhead sys usr guest sys guest usr
> # ....................................... ........ ........ ........ ......... .........
> #
> # Before:
> [g] entry_SYSCALL_64 24.63% 0.00% 0.00% 24.63% 0.00%
> [g] syscall_return_via_sysret 23.23% 0.00% 0.00% 23.23% 0.00%
> [g] files_lookup_fd_raw 6.35% 0.00% 0.00% 6.35% 0.00%
> # After:
> [k] perf_adjust_freq_unthr_context 57.23% 57.23% 0.00% 0.00% 0.00%
> [k] __vmx_vcpu_run 4.09% 4.09% 0.00% 0.00% 0.00%
> [k] vmx_update_host_rsp 3.17% 3.17% 0.00% 0.00% 0.00%
>
> [...]

Applied to kvm-x86 pmu, with the !!in_nmi() fixup squashed. Thanks!

[1/1] KVM: x86/intr: Explicitly check NMI from guest to eliminate false positives
https://github.com/kvm-x86/linux/commit/812d432373f6

--
https://github.com/kvm-x86/linux/tree/next