Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf: Add generic exclude_guest support

Only KVM knows the exact time when a guest is entering/exiting. Expose
two interfaces to KVM to switch the ownership of the PMU resources.

All the pinned events must be scheduled in first. Extend the
perf_event_sched_in() helper to support extra flag, e.g., EVENT_GUEST.

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-3-seanjc@google.com

authored by

Kan Liang and committed by
Peter Zijlstra
b9e52b11 b825444b

+8 -7
+8 -7
kernel/events/core.c
··· 2870 2870 2871 2871 static void perf_event_sched_in(struct perf_cpu_context *cpuctx, 2872 2872 struct perf_event_context *ctx, 2873 - struct pmu *pmu) 2873 + struct pmu *pmu, 2874 + enum event_type_t event_type) 2874 2875 { 2875 - ctx_sched_in(&cpuctx->ctx, pmu, EVENT_PINNED); 2876 + ctx_sched_in(&cpuctx->ctx, pmu, EVENT_PINNED | event_type); 2876 2877 if (ctx) 2877 - ctx_sched_in(ctx, pmu, EVENT_PINNED); 2878 - ctx_sched_in(&cpuctx->ctx, pmu, EVENT_FLEXIBLE); 2878 + ctx_sched_in(ctx, pmu, EVENT_PINNED | event_type); 2879 + ctx_sched_in(&cpuctx->ctx, pmu, EVENT_FLEXIBLE | event_type); 2879 2880 if (ctx) 2880 - ctx_sched_in(ctx, pmu, EVENT_FLEXIBLE); 2881 + ctx_sched_in(ctx, pmu, EVENT_FLEXIBLE | event_type); 2881 2882 } 2882 2883 2883 2884 /* ··· 2934 2933 else if (event_type & EVENT_PINNED) 2935 2934 ctx_sched_out(&cpuctx->ctx, pmu, EVENT_FLEXIBLE); 2936 2935 2937 - perf_event_sched_in(cpuctx, task_ctx, pmu); 2936 + perf_event_sched_in(cpuctx, task_ctx, pmu, 0); 2938 2937 2939 2938 for_each_epc(epc, &cpuctx->ctx, pmu, 0) 2940 2939 perf_pmu_enable(epc->pmu); ··· 4152 4151 ctx_sched_out(&cpuctx->ctx, NULL, EVENT_FLEXIBLE); 4153 4152 } 4154 4153 4155 - perf_event_sched_in(cpuctx, ctx, NULL); 4154 + perf_event_sched_in(cpuctx, ctx, NULL, 0); 4156 4155 4157 4156 perf_ctx_sched_task_cb(cpuctx->task_ctx, task, true); 4158 4157