public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikita Kalyazin <kalyazin@amazon.com>
To: <pbonzini@redhat.com>, <seanjc@google.com>, <corbet@lwn.net>,
	<tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
	<dave.hansen@linux.intel.com>, <hpa@zytor.com>,
	<rostedt@goodmis.org>, <mhiramat@kernel.org>,
	<mathieu.desnoyers@efficios.com>, <kvm@vger.kernel.org>,
	<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-trace-kernel@vger.kernel.org>
Cc: <jthoughton@google.com>, <david@redhat.com>, <peterx@redhat.com>,
	<oleg@redhat.com>, <vkuznets@redhat.com>, <gshan@redhat.com>,
	<graf@amazon.de>, <jgowans@amazon.com>, <roypat@amazon.co.uk>,
	<derekmn@amazon.com>, <nsaenz@amazon.es>, <xmarcalx@amazon.com>,
	<kalyazin@amazon.com>
Subject: [RFC PATCH 4/6] KVM: trace events: add type argument to async pf
Date: Mon, 18 Nov 2024 12:39:46 +0000	[thread overview]
Message-ID: <20241118123948.4796-5-kalyazin@amazon.com> (raw)
In-Reply-To: <20241118123948.4796-1-kalyazin@amazon.com>

With async PF user being added, in order to reuse existing tracepoint
definitions and distinguish async PF user from kernel, a new int
argument `type` is being added that can be either 0 ("kernel") or 1
("user").

For now all of the users of these tracepoints supply 0 ("kernel") as
async PF user are not yet implemented.  In the next commits when they
are implemented, the tracepoints user will set this to 1 ("user") as
necessary.

Signed-off-by: Nikita Kalyazin <kalyazin@amazon.com>
---
 arch/x86/kvm/mmu/mmu.c     |  4 +--
 arch/x86/kvm/x86.c         |  4 +--
 include/trace/events/kvm.h | 50 ++++++++++++++++++++++++--------------
 virt/kvm/async_pf.c        |  2 +-
 4 files changed, 37 insertions(+), 23 deletions(-)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index f0dbc3c68e5c..004e068cabae 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -4395,9 +4395,9 @@ static int __kvm_faultin_pfn(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault
 		return RET_PF_CONTINUE; /* *pfn has correct page already */
 
 	if (!fault->prefetch && kvm_can_do_async_pf(vcpu)) {
-		trace_kvm_try_async_get_page(fault->addr, fault->gfn);
+		trace_kvm_try_async_get_page(fault->addr, fault->gfn, 0);
 		if (kvm_find_async_pf_gfn(vcpu, fault->gfn)) {
-			trace_kvm_async_pf_repeated_fault(fault->addr, fault->gfn);
+			trace_kvm_async_pf_repeated_fault(fault->addr, fault->gfn, 0);
 			kvm_make_request(KVM_REQ_APF_HALT, vcpu);
 			return RET_PF_RETRY;
 		} else if (kvm_arch_setup_async_pf(vcpu, fault)) {
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 800493739043..0a04de5dbada 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -13408,7 +13408,7 @@ bool kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu,
 {
 	struct x86_exception fault;
 
-	trace_kvm_async_pf_not_present(work->arch.token, work->cr2_or_gpa);
+	trace_kvm_async_pf_not_present(work->arch.token, work->cr2_or_gpa, 0);
 	kvm_add_async_pf_gfn(vcpu, work->arch.gfn);
 
 	if (kvm_can_deliver_async_pf(vcpu) &&
@@ -13447,7 +13447,7 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu,
 		work->arch.token = ~0; /* broadcast wakeup */
 	else
 		kvm_del_async_pf_gfn(vcpu, work->arch.gfn);
-	trace_kvm_async_pf_ready(work->arch.token, work->cr2_or_gpa);
+	trace_kvm_async_pf_ready(work->arch.token, work->cr2_or_gpa, 0);
 
 	if ((work->wakeup_all || work->notpresent_injected) &&
 	    kvm_pv_async_pf_enabled(vcpu) &&
diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h
index 74e40d5d4af4..a7731b62863b 100644
--- a/include/trace/events/kvm.h
+++ b/include/trace/events/kvm.h
@@ -256,90 +256,104 @@ TRACE_EVENT(kvm_fpu,
 );
 
 #ifdef CONFIG_KVM_ASYNC_PF
+#define kvm_async_pf_type_symbol	\
+	{0, "kernel"},		\
+	{1, "user"}
+
 DECLARE_EVENT_CLASS(kvm_async_get_page_class,
 
-	TP_PROTO(u64 gva, u64 gfn),
+	TP_PROTO(u64 gva, u64 gfn, int type),
 
-	TP_ARGS(gva, gfn),
+	TP_ARGS(gva, gfn, type),
 
 	TP_STRUCT__entry(
 		__field(__u64, gva)
 		__field(u64, gfn)
+		__field(int, type)
 	),
 
 	TP_fast_assign(
 		__entry->gva = gva;
 		__entry->gfn = gfn;
+		__entry->type = type;
 	),
 
-	TP_printk("gva = %#llx, gfn = %#llx", __entry->gva, __entry->gfn)
+	TP_printk("gva = %#llx, gfn = %#llx, type = %s", __entry->gva,
+		__entry->gfn, __print_symbolic(__entry->type,
+		kvm_async_pf_type_symbol))
 );
 
 DEFINE_EVENT(kvm_async_get_page_class, kvm_try_async_get_page,
 
-	TP_PROTO(u64 gva, u64 gfn),
+	TP_PROTO(u64 gva, u64 gfn, int type),
 
-	TP_ARGS(gva, gfn)
+	TP_ARGS(gva, gfn, type)
 );
 
 DEFINE_EVENT(kvm_async_get_page_class, kvm_async_pf_repeated_fault,
 
-	TP_PROTO(u64 gva, u64 gfn),
+	TP_PROTO(u64 gva, u64 gfn, int type),
 
-	TP_ARGS(gva, gfn)
+	TP_ARGS(gva, gfn, type)
 );
 
 DECLARE_EVENT_CLASS(kvm_async_pf_nopresent_ready,
 
-	TP_PROTO(u64 token, u64 gva),
+	TP_PROTO(u64 token, u64 gva, int type),
 
-	TP_ARGS(token, gva),
+	TP_ARGS(token, gva, type),
 
 	TP_STRUCT__entry(
 		__field(__u64, token)
 		__field(__u64, gva)
+		__field(int, type)
 	),
 
 	TP_fast_assign(
 		__entry->token = token;
 		__entry->gva = gva;
+		__entry->type = type;
 	),
 
-	TP_printk("token %#llx gva %#llx", __entry->token, __entry->gva)
+	TP_printk("token %#llx gva %#llx type %s", __entry->token, __entry->gva,
+		__print_symbolic(__entry->type, kvm_async_pf_type_symbol))
 
 );
 
 DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_not_present,
 
-	TP_PROTO(u64 token, u64 gva),
+	TP_PROTO(u64 token, u64 gva, int type),
 
-	TP_ARGS(token, gva)
+	TP_ARGS(token, gva, type)
 );
 
 DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_ready,
 
-	TP_PROTO(u64 token, u64 gva),
+	TP_PROTO(u64 token, u64 gva, int type),
 
-	TP_ARGS(token, gva)
+	TP_ARGS(token, gva, type)
 );
 
 TRACE_EVENT(
 	kvm_async_pf_completed,
-	TP_PROTO(unsigned long address, u64 gva),
-	TP_ARGS(address, gva),
+	TP_PROTO(unsigned long address, u64 gva, int type),
+	TP_ARGS(address, gva, type),
 
 	TP_STRUCT__entry(
 		__field(unsigned long, address)
 		__field(u64, gva)
+		__field(int, type)
 		),
 
 	TP_fast_assign(
 		__entry->address = address;
 		__entry->gva = gva;
+		__entry->type = type;
 		),
 
-	TP_printk("gva %#llx address %#lx",  __entry->gva,
-		  __entry->address)
+	TP_printk("gva %#llx address %#lx type %s",  __entry->gva,
+		  __entry->address, __print_symbolic(__entry->type,
+		  kvm_async_pf_type_symbol))
 );
 
 #endif
diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c
index 99a63bad0306..77c689a9b585 100644
--- a/virt/kvm/async_pf.c
+++ b/virt/kvm/async_pf.c
@@ -92,7 +92,7 @@ static void async_pf_execute(struct work_struct *work)
 	if (!IS_ENABLED(CONFIG_KVM_ASYNC_PF_SYNC) && first)
 		kvm_arch_async_page_present_queued(vcpu);
 
-	trace_kvm_async_pf_completed(addr, cr2_or_gpa);
+	trace_kvm_async_pf_completed(addr, cr2_or_gpa, 0);
 
 	__kvm_vcpu_wake_up(vcpu);
 }
-- 
2.40.1


  parent reply	other threads:[~2024-11-18 12:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-18 12:39 [RFC PATCH 0/6] KVM: x86: async PF user Nikita Kalyazin
2024-11-18 12:39 ` [RFC PATCH 1/6] Documentation: KVM: add userfault KVM exit flag Nikita Kalyazin
2024-11-18 12:39 ` [RFC PATCH 2/6] Documentation: KVM: add async pf user doc Nikita Kalyazin
2024-11-18 12:39 ` [RFC PATCH 3/6] KVM: x86: add async ioctl support Nikita Kalyazin
2024-11-18 12:39 ` Nikita Kalyazin [this message]
2024-11-18 12:39 ` [RFC PATCH 5/6] KVM: x86: async_pf_user: add infrastructure Nikita Kalyazin
2024-11-18 12:39 ` [RFC PATCH 6/6] KVM: x86: async_pf_user: hook to fault handling and add ioctl Nikita Kalyazin
2024-11-19  1:26 ` [RFC PATCH 0/6] KVM: x86: async PF user James Houghton
2024-11-19 16:19   ` Nikita Kalyazin
2025-02-11 21:17 ` Sean Christopherson
2025-02-12 18:14   ` Nikita Kalyazin
2025-02-19 15:17     ` Sean Christopherson
2025-02-20 18:29       ` Nikita Kalyazin
2025-02-20 18:49         ` Sean Christopherson
2025-02-21 11:02           ` Nikita Kalyazin
2025-02-26  0:58             ` Sean Christopherson
2025-02-26 17:07               ` Nikita Kalyazin
2025-02-27 16:44                 ` Sean Christopherson
2025-02-27 18:24                   ` Nikita Kalyazin
2025-02-27 23:47                     ` Sean Christopherson

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=20241118123948.4796-5-kalyazin@amazon.com \
    --to=kalyazin@amazon.com \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=david@redhat.com \
    --cc=derekmn@amazon.com \
    --cc=graf@amazon.de \
    --cc=gshan@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jgowans@amazon.com \
    --cc=jthoughton@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=nsaenz@amazon.es \
    --cc=oleg@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=roypat@amazon.co.uk \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=xmarcalx@amazon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox