]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
perf: Add APIs to load/put guest mediated PMU context
authorKan Liang <kan.liang@linux.intel.com>
Sat, 6 Dec 2025 00:16:43 +0000 (16:16 -0800)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 17 Dec 2025 12:31:05 +0000 (13:31 +0100)
commit42457a7fb6cacca83be4deaf202ac3e45830daf2
tree3216c0a657d386407280f60e84662f9e6a203c05
parent4593b4b6e218a0f21afbacc8124cf469d2d04094
perf: Add APIs to load/put guest mediated PMU context

Add exported APIs to load/put a guest mediated PMU context.  KVM will
load the guest PMU shortly before VM-Enter, and put the guest PMU shortly
after VM-Exit.

On the perf side of things, schedule out all exclude_guest events when the
guest context is loaded, and schedule them back in when the guest context
is put.  I.e. yield the hardware PMU resources to the guest, by way of KVM.

Note, perf is only responsible for managing host context.  KVM is
responsible for loading/storing guest state to/from hardware.

[sean: shuffle patches around, write changelog]
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Mingwei Zhang <mizhang@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Xudong Hao <xudong.hao@intel.com>
Link: https://patch.msgid.link/20251206001720.468579-8-seanjc@google.com
include/linux/perf_event.h
kernel/events/core.c