On 2024-10-14 9:52 a.m., Peter Zijlstra wrote: > On Thu, Aug 01, 2024 at 04:58:23AM +0000, Mingwei Zhang wrote: >> @@ -5962,6 +5976,8 @@ void perf_guest_enter(void) >> perf_ctx_enable(cpuctx->task_ctx, EVENT_GUEST); >> } >> >> + perf_switch_interrupt(true, guest_lvtpc); >> + >> __this_cpu_write(perf_in_guest, true); >> >> unlock: >> @@ -5980,6 +5996,8 @@ void perf_guest_exit(void) >> if (WARN_ON_ONCE(!__this_cpu_read(perf_in_guest))) >> goto unlock; >> >> + perf_switch_interrupt(false, 0); >> + >> perf_ctx_disable(&cpuctx->ctx, EVENT_GUEST); >> ctx_sched_in(&cpuctx->ctx, EVENT_GUEST); >> perf_ctx_enable(&cpuctx->ctx, EVENT_GUEST); > > This seems to suggest the method is named wrong, it should probably be > guest_enter() or somsuch. > The ctx_sched_in() is to schedule in the host context after the guest_exit(). The EVENT_GUEST is to indicate the guest ctx switch. The name may brings some confusion. Maybe I can add a wrap function perf_host_enter() to include the above codes. Thanks, Kan