* [PATCH v2 1/3] VMX: sync VM-exit perf counters with known VM-exit reasons
2022-01-05 13:56 [PATCH v2 0/3] x86/perfc: assorted adjustments Jan Beulich
@ 2022-01-05 13:57 ` Jan Beulich
2022-01-30 3:08 ` Tian, Kevin
2022-01-05 13:58 ` [PATCH v2 2/3] SVM: " Jan Beulich
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Jan Beulich @ 2022-01-05 13:57 UTC (permalink / raw)
To: xen-devel
Cc: Andrew Cooper, Wei Liu, Roger Pau Monné, Kevin Tian, Jun Nakajima
This has gone out of sync over time. Introduce a simplistic mechanism to
hopefully keep things in sync going forward.
Also limit the array index to just the "basic exit reason" part, which is
what the pseudo-enumeration covers.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: Use sentinel comment only.
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -3869,7 +3869,7 @@ void vmx_vmexit_handler(struct cpu_user_
else
HVMTRACE_ND(VMEXIT, 0, 1/*cycles*/, exit_reason, regs->eip);
- perfc_incra(vmexits, exit_reason);
+ perfc_incra(vmexits, (uint16_t)exit_reason);
/* Handle the interrupt we missed before allowing any more in. */
switch ( (uint16_t)exit_reason )
--- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h
+++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h
@@ -219,6 +219,7 @@ static inline void pi_clear_sn(struct pi
#define EXIT_REASON_PML_FULL 62
#define EXIT_REASON_XSAVES 63
#define EXIT_REASON_XRSTORS 64
+/* Remember to also update VMX_PERF_EXIT_REASON_SIZE! */
/*
* Interruption-information format
--- a/xen/arch/x86/include/asm/perfc_defn.h
+++ b/xen/arch/x86/include/asm/perfc_defn.h
@@ -6,7 +6,7 @@ PERFCOUNTER_ARRAY(exceptions,
#ifdef CONFIG_HVM
-#define VMX_PERF_EXIT_REASON_SIZE 56
+#define VMX_PERF_EXIT_REASON_SIZE 65
#define VMX_PERF_VECTOR_SIZE 0x20
PERFCOUNTER_ARRAY(vmexits, "vmexits", VMX_PERF_EXIT_REASON_SIZE)
PERFCOUNTER_ARRAY(cause_vector, "cause vector", VMX_PERF_VECTOR_SIZE)
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v2 1/3] VMX: sync VM-exit perf counters with known VM-exit reasons
2022-01-05 13:57 ` [PATCH v2 1/3] VMX: sync VM-exit perf counters with known VM-exit reasons Jan Beulich
@ 2022-01-30 3:08 ` Tian, Kevin
0 siblings, 0 replies; 9+ messages in thread
From: Tian, Kevin @ 2022-01-30 3:08 UTC (permalink / raw)
To: Beulich, Jan, xen-devel
Cc: Cooper, Andrew, Wei Liu, Pau Monné, Roger, Nakajima, Jun
> From: Beulich
> Sent: Wednesday, January 5, 2022 9:58 PM
>
> This has gone out of sync over time. Introduce a simplistic mechanism to
> hopefully keep things in sync going forward.
>
> Also limit the array index to just the "basic exit reason" part, which is
> what the pseudo-enumeration covers.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
> ---
> v2: Use sentinel comment only.
>
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -3869,7 +3869,7 @@ void vmx_vmexit_handler(struct cpu_user_
> else
> HVMTRACE_ND(VMEXIT, 0, 1/*cycles*/, exit_reason, regs->eip);
>
> - perfc_incra(vmexits, exit_reason);
> + perfc_incra(vmexits, (uint16_t)exit_reason);
>
> /* Handle the interrupt we missed before allowing any more in. */
> switch ( (uint16_t)exit_reason )
> --- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h
> +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h
> @@ -219,6 +219,7 @@ static inline void pi_clear_sn(struct pi
> #define EXIT_REASON_PML_FULL 62
> #define EXIT_REASON_XSAVES 63
> #define EXIT_REASON_XRSTORS 64
> +/* Remember to also update VMX_PERF_EXIT_REASON_SIZE! */
>
> /*
> * Interruption-information format
> --- a/xen/arch/x86/include/asm/perfc_defn.h
> +++ b/xen/arch/x86/include/asm/perfc_defn.h
> @@ -6,7 +6,7 @@ PERFCOUNTER_ARRAY(exceptions,
>
> #ifdef CONFIG_HVM
>
> -#define VMX_PERF_EXIT_REASON_SIZE 56
> +#define VMX_PERF_EXIT_REASON_SIZE 65
> #define VMX_PERF_VECTOR_SIZE 0x20
> PERFCOUNTER_ARRAY(vmexits, "vmexits",
> VMX_PERF_EXIT_REASON_SIZE)
> PERFCOUNTER_ARRAY(cause_vector, "cause vector",
> VMX_PERF_VECTOR_SIZE)
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 2/3] SVM: sync VM-exit perf counters with known VM-exit reasons
2022-01-05 13:56 [PATCH v2 0/3] x86/perfc: assorted adjustments Jan Beulich
2022-01-05 13:57 ` [PATCH v2 1/3] VMX: sync VM-exit perf counters with known VM-exit reasons Jan Beulich
@ 2022-01-05 13:58 ` Jan Beulich
2022-02-22 9:21 ` Roger Pau Monné
2022-01-05 13:59 ` [PATCH v2 3/3] x86/perfc: fold HVM's VM-exit counter arrays Jan Beulich
2022-02-18 8:41 ` Ping: [PATCH v2 0/3] x86/perfc: assorted adjustments Jan Beulich
3 siblings, 1 reply; 9+ messages in thread
From: Jan Beulich @ 2022-01-05 13:58 UTC (permalink / raw)
To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Roger Pau Monné
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>
---
v2: Use sentinel comments only.
--- a/xen/arch/x86/include/asm/hvm/svm/vmcb.h
+++ b/xen/arch/x86/include/asm/hvm/svm/vmcb.h
@@ -302,7 +302,9 @@ enum VMEXIT_EXITCODE
VMEXIT_MWAIT_CONDITIONAL= 140, /* 0x8c */
VMEXIT_XSETBV = 141, /* 0x8d */
VMEXIT_RDPRU = 142, /* 0x8e */
+ /* Remember to also update VMEXIT_NPF_PERFC! */
VMEXIT_NPF = 1024, /* 0x400, nested paging fault */
+ /* Remember to also update SVM_PERF_EXIT_REASON_SIZE! */
VMEXIT_INVALID = -1
};
--- a/xen/arch/x86/include/asm/perfc_defn.h
+++ b/xen/arch/x86/include/asm/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 */
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] SVM: sync VM-exit perf counters with known VM-exit reasons
2022-01-05 13:58 ` [PATCH v2 2/3] SVM: " Jan Beulich
@ 2022-02-22 9:21 ` Roger Pau Monné
0 siblings, 0 replies; 9+ messages in thread
From: Roger Pau Monné @ 2022-02-22 9:21 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel, Andrew Cooper, Wei Liu
On Wed, Jan 05, 2022 at 02:58:11PM +0100, Jan Beulich wrote:
> 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>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Thanks, Roger.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 3/3] x86/perfc: fold HVM's VM-exit counter arrays
2022-01-05 13:56 [PATCH v2 0/3] x86/perfc: assorted adjustments Jan Beulich
2022-01-05 13:57 ` [PATCH v2 1/3] VMX: sync VM-exit perf counters with known VM-exit reasons Jan Beulich
2022-01-05 13:58 ` [PATCH v2 2/3] SVM: " Jan Beulich
@ 2022-01-05 13:59 ` Jan Beulich
2022-02-22 9:40 ` Roger Pau Monné
2022-02-18 8:41 ` Ping: [PATCH v2 0/3] x86/perfc: assorted adjustments Jan Beulich
3 siblings, 1 reply; 9+ messages in thread
From: Jan Beulich @ 2022-01-05 13:59 UTC (permalink / raw)
To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Roger Pau Monné
Only one of them can be in use at a time, so make the whole set union-
like. While doing the rename in SVM code, combine the two perf_incra(),
generalizing the range upwards of VMEXIT_NPF.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: New.
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2644,7 +2644,10 @@ void svm_vmexit_handler(struct cpu_user_
goto out;
}
- perfc_incra(svmexits, exit_reason);
+ perfc_incra(vmexits,
+ exit_reason < VMEXIT_NPF
+ ? exit_reason
+ : exit_reason - VMEXIT_NPF + VMEXIT_NPF_PERFC);
hvm_maybe_deassert_evtchn_irq();
@@ -2973,7 +2976,6 @@ void svm_vmexit_handler(struct cpu_user_
break;
case VMEXIT_NPF:
- perfc_incra(svmexits, VMEXIT_NPF_PERFC);
if ( cpu_has_svm_decode )
v->arch.hvm.svm.cached_insn_len = vmcb->guest_ins_len & 0xf;
rc = vmcb->exitinfo1 & PFEC_page_present
--- a/xen/arch/x86/include/asm/perfc_defn.h
+++ b/xen/arch/x86/include/asm/perfc_defn.h
@@ -7,13 +7,13 @@ PERFCOUNTER_ARRAY(exceptions,
#ifdef CONFIG_HVM
#define VMX_PERF_EXIT_REASON_SIZE 65
-#define VMX_PERF_VECTOR_SIZE 0x20
-PERFCOUNTER_ARRAY(vmexits, "vmexits", VMX_PERF_EXIT_REASON_SIZE)
-PERFCOUNTER_ARRAY(cause_vector, "cause vector", VMX_PERF_VECTOR_SIZE)
-
#define VMEXIT_NPF_PERFC 143
#define SVM_PERF_EXIT_REASON_SIZE (VMEXIT_NPF_PERFC + 1)
-PERFCOUNTER_ARRAY(svmexits, "SVMexits", SVM_PERF_EXIT_REASON_SIZE)
+PERFCOUNTER_ARRAY(vmexits, "vmexits",
+ MAX(VMX_PERF_EXIT_REASON_SIZE, SVM_PERF_EXIT_REASON_SIZE))
+
+#define VMX_PERF_VECTOR_SIZE 0x20
+PERFCOUNTER_ARRAY(cause_vector, "cause vector", VMX_PERF_VECTOR_SIZE)
#endif /* CONFIG_HVM */
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] x86/perfc: fold HVM's VM-exit counter arrays
2022-01-05 13:59 ` [PATCH v2 3/3] x86/perfc: fold HVM's VM-exit counter arrays Jan Beulich
@ 2022-02-22 9:40 ` Roger Pau Monné
2022-02-22 9:59 ` Jan Beulich
0 siblings, 1 reply; 9+ messages in thread
From: Roger Pau Monné @ 2022-02-22 9:40 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel, Andrew Cooper, Wei Liu
On Wed, Jan 05, 2022 at 02:59:03PM +0100, Jan Beulich wrote:
> Only one of them can be in use at a time, so make the whole set union-
> like. While doing the rename in SVM code, combine the two perf_incra(),
> generalizing the range upwards of VMEXIT_NPF.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> v2: New.
>
> --- a/xen/arch/x86/hvm/svm/svm.c
> +++ b/xen/arch/x86/hvm/svm/svm.c
> @@ -2644,7 +2644,10 @@ void svm_vmexit_handler(struct cpu_user_
> goto out;
> }
>
> - perfc_incra(svmexits, exit_reason);
> + perfc_incra(vmexits,
> + exit_reason < VMEXIT_NPF
> + ? exit_reason
> + : exit_reason - VMEXIT_NPF + VMEXIT_NPF_PERFC);
Should we assert that the index used here < SVM_PERF_EXIT_REASON_SIZE?
Just so that adding new exit reasons without increasing
SVM_PERF_EXIT_REASON_SIZE is not likely to go unnoticed?
Thanks, Roger.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] x86/perfc: fold HVM's VM-exit counter arrays
2022-02-22 9:40 ` Roger Pau Monné
@ 2022-02-22 9:59 ` Jan Beulich
0 siblings, 0 replies; 9+ messages in thread
From: Jan Beulich @ 2022-02-22 9:59 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: xen-devel, Andrew Cooper, Wei Liu
On 22.02.2022 10:40, Roger Pau Monné wrote:
> On Wed, Jan 05, 2022 at 02:59:03PM +0100, Jan Beulich wrote:
>> Only one of them can be in use at a time, so make the whole set union-
>> like. While doing the rename in SVM code, combine the two perf_incra(),
>> generalizing the range upwards of VMEXIT_NPF.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Thanks.
>> --- a/xen/arch/x86/hvm/svm/svm.c
>> +++ b/xen/arch/x86/hvm/svm/svm.c
>> @@ -2644,7 +2644,10 @@ void svm_vmexit_handler(struct cpu_user_
>> goto out;
>> }
>>
>> - perfc_incra(svmexits, exit_reason);
>> + perfc_incra(vmexits,
>> + exit_reason < VMEXIT_NPF
>> + ? exit_reason
>> + : exit_reason - VMEXIT_NPF + VMEXIT_NPF_PERFC);
>
> Should we assert that the index used here < SVM_PERF_EXIT_REASON_SIZE?
>
> Just so that adding new exit reasons without increasing
> SVM_PERF_EXIT_REASON_SIZE is not likely to go unnoticed?
But that's what the comments are for that the previous patch adds.
Jan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Ping: [PATCH v2 0/3] x86/perfc: assorted adjustments
2022-01-05 13:56 [PATCH v2 0/3] x86/perfc: assorted adjustments Jan Beulich
` (2 preceding siblings ...)
2022-01-05 13:59 ` [PATCH v2 3/3] x86/perfc: fold HVM's VM-exit counter arrays Jan Beulich
@ 2022-02-18 8:41 ` Jan Beulich
3 siblings, 0 replies; 9+ messages in thread
From: Jan Beulich @ 2022-02-18 8:41 UTC (permalink / raw)
To: Andrew Cooper, Roger Pau Monné; +Cc: Wei Liu, xen-devel
On 05.01.2022 14:56, Jan Beulich wrote:
> Addressing some observations made while reviewing other patches.
>
> 1: VMX: sync VM-exit perf counters with known VM-exit reasons
> 2: SVM: sync VM-exit perf counters with known VM-exit reasons
> 3: x86/perfc: fold HVM's VM-exit counter arrays
Patch 1 has gone in a little while ago. Would be nice for the other
two to also be acked, or for adjustment requests to be voiced.
Thanks, Jan
^ permalink raw reply [flat|nested] 9+ messages in thread