[PATCH v2 2/5] KVM: selftests: Add timing_info bit support in vmx_pmu_caps_test

Dapeng Mi posted 5 patches 2 months, 2 weeks ago
[PATCH v2 2/5] KVM: selftests: Add timing_info bit support in vmx_pmu_caps_test
Posted by Dapeng Mi 2 months, 2 weeks ago
A new bit PERF_CAPABILITIES[17] called "PEBS_TIMING_INFO" bit is added
to indicated if PEBS supports to record timing information in a new
"Retried Latency" field.

Since KVM requires user can only set host consistent PEBS capabilities,
otherwise the PERF_CAPABILITIES setting would fail, so add
pebs_timing_info bit into "immutable_caps" to block host inconsistent
PEBS configuration and cause errors.

Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Tested-by: Yi Lai <yi1.lai@intel.com>
---
 tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c b/tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c
index a1f5ff45d518..f8deea220156 100644
--- a/tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c
+++ b/tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c
@@ -29,7 +29,7 @@ static union perf_capabilities {
 		u64 pebs_baseline:1;
 		u64	perf_metrics:1;
 		u64	pebs_output_pt_available:1;
-		u64	anythread_deprecated:1;
+		u64	pebs_timing_info:1;
 	};
 	u64	capabilities;
 } host_cap;
@@ -44,6 +44,7 @@ static const union perf_capabilities immutable_caps = {
 	.pebs_arch_reg = 1,
 	.pebs_format = -1,
 	.pebs_baseline = 1,
+	.pebs_timing_info = 1,
 };
 
 static const union perf_capabilities format_caps = {
-- 
2.34.1
Re: [PATCH v2 2/5] KVM: selftests: Add timing_info bit support in vmx_pmu_caps_test
Posted by Sean Christopherson 3 weeks, 4 days ago
On Fri, Jul 18, 2025, Dapeng Mi wrote:
> A new bit PERF_CAPABILITIES[17] called "PEBS_TIMING_INFO" bit is added
> to indicated if PEBS supports to record timing information in a new
> "Retried Latency" field.
> 
> Since KVM requires user can only set host consistent PEBS capabilities,
> otherwise the PERF_CAPABILITIES setting would fail, so add
> pebs_timing_info bit into "immutable_caps" to block host inconsistent
> PEBS configuration and cause errors.

Please explain the removal of anythread_deprecated.  AFAICT, something like this
is accurate:

Opportunistically drop the anythread_deprecated bit.  It isn't and likely
never was a PERF_CAPABILITIES flag, the test's definition snuck in when
the union was copy+pasted from the kernel's definition.

> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
> Tested-by: Yi Lai <yi1.lai@intel.com>
> ---
>  tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c b/tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c
> index a1f5ff45d518..f8deea220156 100644
> --- a/tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c
> +++ b/tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c
> @@ -29,7 +29,7 @@ static union perf_capabilities {
>  		u64 pebs_baseline:1;
>  		u64	perf_metrics:1;
>  		u64	pebs_output_pt_available:1;
> -		u64	anythread_deprecated:1;
> +		u64	pebs_timing_info:1;
>  	};
>  	u64	capabilities;
>  } host_cap;
> @@ -44,6 +44,7 @@ static const union perf_capabilities immutable_caps = {
>  	.pebs_arch_reg = 1,
>  	.pebs_format = -1,
>  	.pebs_baseline = 1,
> +	.pebs_timing_info = 1,
>  };
>  
>  static const union perf_capabilities format_caps = {
> -- 
> 2.34.1
>
Re: [PATCH v2 2/5] KVM: selftests: Add timing_info bit support in vmx_pmu_caps_test
Posted by Mi, Dapeng 3 weeks, 4 days ago
On 9/11/2025 6:03 AM, Sean Christopherson wrote:
> On Fri, Jul 18, 2025, Dapeng Mi wrote:
>> A new bit PERF_CAPABILITIES[17] called "PEBS_TIMING_INFO" bit is added
>> to indicated if PEBS supports to record timing information in a new
>> "Retried Latency" field.
>>
>> Since KVM requires user can only set host consistent PEBS capabilities,
>> otherwise the PERF_CAPABILITIES setting would fail, so add
>> pebs_timing_info bit into "immutable_caps" to block host inconsistent
>> PEBS configuration and cause errors.
> Please explain the removal of anythread_deprecated.  AFAICT, something like this
> is accurate:
>
> Opportunistically drop the anythread_deprecated bit.  It isn't and likely
> never was a PERF_CAPABILITIES flag, the test's definition snuck in when
> the union was copy+pasted from the kernel's definition.

Yes, would add this in next version. Thanks.


>
>> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
>> Tested-by: Yi Lai <yi1.lai@intel.com>
>> ---
>>  tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c b/tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c
>> index a1f5ff45d518..f8deea220156 100644
>> --- a/tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c
>> +++ b/tools/testing/selftests/kvm/x86/vmx_pmu_caps_test.c
>> @@ -29,7 +29,7 @@ static union perf_capabilities {
>>  		u64 pebs_baseline:1;
>>  		u64	perf_metrics:1;
>>  		u64	pebs_output_pt_available:1;
>> -		u64	anythread_deprecated:1;
>> +		u64	pebs_timing_info:1;
>>  	};
>>  	u64	capabilities;
>>  } host_cap;
>> @@ -44,6 +44,7 @@ static const union perf_capabilities immutable_caps = {
>>  	.pebs_arch_reg = 1,
>>  	.pebs_format = -1,
>>  	.pebs_baseline = 1,
>> +	.pebs_timing_info = 1,
>>  };
>>  
>>  static const union perf_capabilities format_caps = {
>> -- 
>> 2.34.1
>>