On 2024-06-17 11:00 a.m., Peter Zijlstra wrote: >>> only the >>> 'normal' sched-out should stop time. >> If the guest is the only case which we want to keep the time for, I >> think we may use a straightforward check as below. >> >> stop = !(event_type & EVENT_GUEST) && ctx == &cpuctx->ctx; > So I think I was trying to get stop true when there weren't in fact > events on, that is when we got in without EVENT_ALL bits, but perhaps > that case isn't relevant. It should be irrelevant. Here I think we just need to make sure that the guest is not the reason for stopping the time if there is an active time. For the others, there is nothing changed. The __this_cpu_read(perf_in_guest) check will guarantee that both guest time and host time sync when any updates occur in the guest mode. Thanks, Kan