kvm_vcpu_wakeup only reports the total halt time, which includes both the time spent halt-polling and the time spent blocking. Report the halt-polling time as well, so that the split between polling and waiting can be derived from the tracepoint, e.g. to build histograms equivalent to the halt_poll_success_hist, halt_poll_fail_hist and halt_wait_hist stats with BPF. Signed-off-by: Peng Hao --- include/trace/events/kvm.h | 16 +++++++++------- virt/kvm/kvm_main.c | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h index 07013f88e655..d03e3954ca37 100644 --- a/include/trace/events/kvm.h +++ b/include/trace/events/kvm.h @@ -47,24 +47,26 @@ TRACE_EVENT(kvm_userspace_exit, ); TRACE_EVENT(kvm_vcpu_wakeup, - TP_PROTO(__u64 ns, bool waited, bool valid), - TP_ARGS(ns, waited, valid), + TP_PROTO(__u64 ns, __u64 poll_ns, bool waited, bool valid), + TP_ARGS(ns, poll_ns, waited, valid), TP_STRUCT__entry( - __field( __u64, ns ) - __field( bool, waited ) - __field( bool, valid ) + __field(__u64, ns) + __field(__u64, poll_ns) + __field(bool, waited) + __field(bool, valid) ), TP_fast_assign( __entry->ns = ns; + __entry->poll_ns = poll_ns; __entry->waited = waited; __entry->valid = valid; ), - TP_printk("%s time %lld ns, polling %s", + TP_printk("%s time %lld ns (poll %lld ns), polling %s", __entry->waited ? "wait" : "poll", - __entry->ns, + __entry->ns, __entry->poll_ns, __entry->valid ? "valid" : "invalid") ); diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index cf4cb586f140..fff19e9239d2 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -3888,7 +3888,8 @@ void kvm_vcpu_halt(struct kvm_vcpu *vcpu) } } - trace_kvm_vcpu_wakeup(halt_ns, waited, vcpu_valid_wakeup(vcpu)); + trace_kvm_vcpu_wakeup(halt_ns, ktime_to_ns(ktime_sub(poll_end, start)), + waited, vcpu_valid_wakeup(vcpu)); } EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_vcpu_halt); -- 2.43.7