All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 4/5] SVM: sync VM-exit perf counters with known VM-exit reasons
Date: Fri, 3 Dec 2021 13:06:04 +0100	[thread overview]
Message-ID: <c94bc336-fdee-43af-540e-06e0904d8db7@suse.com> (raw)
In-Reply-To: <57038a1c-671b-f0f9-1bf1-0ff9bae6e2dc@suse.com>

This has gone out of sync over time, resulting in NPF and XSETBV exits
incrementing the same counter. Introduce a simplistic mechanism to
hopefully keep things in better sync going forward.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
Given their large (and growing) number, I wonder whether we shouldn't
fold "SVMexits" and "vmexits". They can't both be active at the same
time.

I wasn't sure about the #ifdef: Using CONFIG_PERF_COUNTERS there would
seem slightly odd next to a construct which specifically abstracts away
this aspect.

--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2644,6 +2644,10 @@ void svm_vmexit_handler(struct cpu_user_
         goto out;
     }
 
+    /* Note: "+2" to account for VMEXIT_NPF_PERFC. */
+#ifdef SVM_PERF_EXIT_REASON_SIZE
+    BUILD_BUG_ON(SVM_PERF_EXIT_REASON_SIZE != VMEXIT_LAST + 2);
+#endif
     perfc_incra(svmexits, exit_reason);
 
     hvm_maybe_deassert_evtchn_irq();
--- a/xen/include/asm-x86/hvm/svm/vmcb.h
+++ b/xen/include/asm-x86/hvm/svm/vmcb.h
@@ -302,6 +302,7 @@ enum VMEXIT_EXITCODE
     VMEXIT_MWAIT_CONDITIONAL= 140, /* 0x8c */
     VMEXIT_XSETBV           = 141, /* 0x8d */
     VMEXIT_RDPRU            = 142, /* 0x8e */
+#define VMEXIT_LAST VMEXIT_RDPRU
     VMEXIT_NPF              = 1024, /* 0x400, nested paging fault */
     VMEXIT_INVALID          =  -1
 };
--- a/xen/include/asm-x86/perfc_defn.h
+++ b/xen/include/asm-x86/perfc_defn.h
@@ -11,8 +11,8 @@ PERFCOUNTER_ARRAY(exceptions,
 PERFCOUNTER_ARRAY(vmexits,              "vmexits", VMX_PERF_EXIT_REASON_SIZE)
 PERFCOUNTER_ARRAY(cause_vector,         "cause vector", VMX_PERF_VECTOR_SIZE)
 
-#define VMEXIT_NPF_PERFC 141
-#define SVM_PERF_EXIT_REASON_SIZE (1+141)
+#define VMEXIT_NPF_PERFC 143
+#define SVM_PERF_EXIT_REASON_SIZE (VMEXIT_NPF_PERFC + 1)
 PERFCOUNTER_ARRAY(svmexits,             "SVMexits", SVM_PERF_EXIT_REASON_SIZE)
 
 #endif /* CONFIG_HVM */



  parent reply	other threads:[~2021-12-03 12:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03 12:02 [PATCH 0/5] perfc: assorted adjustments Jan Beulich
2021-12-03 12:03 ` [PATCH 1/5] perfc: conditionalize credit/credit2 counters Jan Beulich
2021-12-03 16:30   ` Luca Fancellu
2021-12-03 12:04 ` [PATCH 2/5] x86/perfc: conditionalize HVM and shadow counters Jan Beulich
2021-12-17 14:35   ` Andrew Cooper
2021-12-03 12:05 ` [PATCH 3/5] VMX: sync VM-exit perf counters with known VM-exit reasons Jan Beulich
2021-12-17 15:00   ` Andrew Cooper
2021-12-21 10:27     ` Jan Beulich
2021-12-03 12:06 ` Jan Beulich [this message]
2021-12-17 15:02   ` [PATCH 4/5] SVM: " Andrew Cooper
2021-12-21  7:52     ` Jan Beulich
2021-12-03 12:07 ` [PATCH 5/5] xenperf: name "newer" hypercalls Jan Beulich
2021-12-17 15:07   ` Andrew Cooper

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=c94bc336-fdee-43af-540e-06e0904d8db7@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /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.