All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Hao <flyingpenghao@gmail.com>
To: pbonzini@redhat.com, seanjc@google.com
Cc: kvm@vger.kernel.org
Subject: [RFC PATCH 1/3] KVM: Add the halt-polling time to the kvm_vcpu_wakeup tracepoint
Date: Mon, 16 Nov 2026 11:27:46 +0800	[thread overview]
Message-ID: <20261116032748.54582-2-flyingpeng@tencent.com> (raw)
In-Reply-To: <20261116032748.54582-1-flyingpeng@tencent.com>

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 <flyingpeng@tencent.com>
---
 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


  reply	other threads:[~2026-11-16  3:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  3:27 [RFC PATCH 0/3] KVM: Rework how halt-polling stats and per-VM debugfs use memory Peng Hao
2026-11-16  3:27 ` Peng Hao [this message]
2026-11-16  3:27 ` [RFC PATCH 2/3] KVM: Add a module param to disable the per-VM debugfs directories Peng Hao
2026-11-16  3:43   ` sashiko-bot
2026-11-16  3:27 ` [RFC PATCH 3/3] KVM: Move the halt-polling histograms out of struct kvm_vcpu_stat Peng Hao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261116032748.54582-2-flyingpeng@tencent.com \
    --to=flyingpenghao@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.