perf/x86/intel: use hexidecimal value for cpuid
Subsystems (4)
PATCH 1/1 perf/x86/intel: use hexidecimal value for cpuid
It's easier to use hexidecimal value instead of decimal for reading and following with SDM doc, also align with other cpuid calls.
--- arch/x86/events/intel/core.c | 2 +- arch/x86/events/intel/lbr.c | 2 +- arch/x86/events/intel/pt.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/events/intel/core.c +1 -1
@@ -5903,7 +5903,7 @@ __init int intel_pmu_init(void)* Check whether the Architectural PerfMon supports * Branch Misses Retired hw_event or not. */ -cpuid (10 , &eax.full, &ebx.full, &fixed_mask, &edx.full); +cpuid (0xA , &eax.full, &ebx.full, &fixed_mask, &edx.full);if (eax.split.mask_length <ARCH_PERFMON_EVENTS_COUNT )return -ENODEV ;
arch/x86/events/intel/lbr.c +1 -1
@@ -1506,7 +1506,7 @@ void __init intel_pmu_arch_lbr_init(void)u64 lbr_nr;/* Arch LBR Capabilities */ -cpuid (28 , &eax.full, &ebx.full, &ecx.full, &unused_edx); +cpuid (0x1C , &eax.full, &ebx.full, &ecx.full, &unused_edx); lbr_nr =fls (eax.split.lbr_depth_mask) *8 ;if (!lbr_nr)
arch/x86/events/intel/pt.c +1 -1
@@ -235,7 +235,7 @@ static int __init pt_pmu_hw_init(void) }for (i =0 ; i <PT_CPUID_LEAVES ; i++) { - cpuid_count(20, i, + cpuid_count(0x14, i, &pt_pmu.caps[CPUID_EAX + i*PT_CPUID_REGS_NUM], &pt_pmu.caps[CPUID_EBX + i*PT_CPUID_REGS_NUM], &pt_pmu.caps[CPUID_ECX + i*PT_CPUID_REGS_NUM],
Signature · 1 line
2.39.2
Peter Zijlstra
maintainerQuoted 2 lines · Zhenyu Wang
It's easier to use hexidecimal value instead of decimal for reading and following with SDM doc, also align with other cpuid calls.
*shrug*..
Quoted 12 lines
Signed-off-by Zhenyu Wang <[email protected]>--- arch/x86/events/intel/core.c | 2 +- arch/x86/events/intel/lbr.c | 2 +- arch/x86/events/intel/pt.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)arch/x86/events/intel/core.c +0
-0
arch/x86/events/intel/core.c __init int intel_pmu_init(void) · line 5908
Quoted 7 lines
arch/x86/events/intel/core.c +1
-1@@ -5903,7 +5903,7 @@ __init int intel_pmu_init(void)* Check whether the Architectural PerfMon supports * Branch Misses Retired hw_event or not. */ -cpuid (10 , &eax.full, &ebx.full, &fixed_mask, &edx.full); +cpuid (0xA , &eax.full, &ebx.full, &fixed_mask, &edx.full);if (eax.split.mask_length <ARCH_PERFMON_EVENTS_COUNT )return -ENODEV ;
But now the data type names and the cpuid calls are no longer related.
Quoted 13 lines · Peter Zijlstra
Quoted 2 lines · Zhenyu Wang
It's easier to use hexidecimal value instead of decimal for reading and following with SDM doc, also align with other cpuid calls.
*shrug*..
Quoted 7 lines
Signed-off-by Zhenyu Wang <[email protected]>--- arch/x86/events/intel/core.c | 2 +- arch/x86/events/intel/lbr.c | 2 +- arch/x86/events/intel/pt.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Quoted 14 lines
arch/x86/events/intel/core.c __init int intel_pmu_init(void) · line 5908
Quoted 12 lines
arch/x86/events/intel/core.c +1
-1@@ -5903,7 +5903,7 @@ __init int intel_pmu_init(void)* Check whether the Architectural PerfMon supports * Branch Misses Retired hw_event or not. */ -cpuid (10 , &eax.full, &ebx.full, &fixed_mask, &edx.full); +cpuid (0xA , &eax.full, &ebx.full, &fixed_mask, &edx.full);if (eax.split.mask_length <ARCH_PERFMON_EVENTS_COUNT )return -ENODEV ;But now the data type names and the cpuid calls are no longer related.
oh, right, missed that. How about we change those too e.g union cpuid_0xa_eax?
PATCH v2 1/1 perf/x86: use hexidecimal value for cpuid
In reply to Zhenyu WangIt's easier to use hexidecimal value instead of decimal for reading and following with SDM doc, also align with other cpuid calls. This changes name for both cpuid data type and cpuid calls.
---
v2:
- rename in cpuid data type as well
arch/x86/events/intel/core.c | 10 +++++----- arch/x86/events/intel/lbr.c | 8 ++++---- arch/x86/events/intel/pt.c | 2 +- arch/x86/events/zhaoxin/core.c | 8 ++++---- arch/x86/include/asm/perf_event.h | 12 ++++++------ arch/x86/kvm/cpuid.c | 4 ++-- arch/x86/kvm/vmx/pmu_intel.c | 4 ++-- 7 files changed, 24 insertions(+), 24 deletions(-)
arch/x86/events/intel/core.c +5 -5
@@ -5170,7 +5170,7 @@ static __init void intel_arch_events_quirk(void)static __init void intel_nehalem_quirk (void ) { -union cpuid10_ebx ebx; +union cpuid_0xa_ebx ebx; ebx.full = x86_pmu.events_maskl;if (ebx.split.no_branch_misses_retired) {
@@ -5878,9 +5878,9 @@ __init int intel_pmu_init(void)struct attribute **td_attr = &empty_attrs;struct attribute **mem_attr = &empty_attrs;struct attribute **tsx_attr = &empty_attrs; -union cpuid10_edx edx; -union cpuid10_eax eax; -union cpuid10_ebx ebx; +union cpuid_0xa_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_ebx ebx;unsigned int fixed_mask;bool pmem = false;int version, i;
@@ -5903,7 +5903,7 @@ __init int intel_pmu_init(void)* Check whether the Architectural PerfMon supports * Branch Misses Retired hw_event or not. */ -cpuid (10 , &eax.full, &ebx.full, &fixed_mask, &edx.full); +cpuid (0xA , &eax.full, &ebx.full, &fixed_mask, &edx.full);if (eax.split.mask_length <ARCH_PERFMON_EVENTS_COUNT )return -ENODEV ;
arch/x86/events/intel/lbr.c +4 -4
@@ -1497,16 +1497,16 @@ static bool is_arch_lbr_xsave_available(void)void __init intel_pmu_arch_lbr_init (void ) {struct pmu *pmu =x86_get_pmu (smp_processor_id ()); -union cpuid28_eax eax; -union cpuid28_ebx ebx; -union cpuid28_ecx ecx; +union cpuid_0x1c_eax eax; +union cpuid_0x1c_ebx ebx; +union cpuid_0x1c_ecx ecx;unsigned int unused_edx;bool arch_lbr_xsave;size_t size;u64 lbr_nr;/* Arch LBR Capabilities */ -cpuid (28 , &eax.full, &ebx.full, &ecx.full, &unused_edx); +cpuid (0x1C , &eax.full, &ebx.full, &ecx.full, &unused_edx); lbr_nr =fls (eax.split.lbr_depth_mask) *8 ;if (!lbr_nr)
arch/x86/events/intel/pt.c +1 -1
@@ -235,7 +235,7 @@ static int __init pt_pmu_hw_init(void) }for (i =0 ; i <PT_CPUID_LEAVES ; i++) { - cpuid_count(20, i, + cpuid_count(0x14, i, &pt_pmu.caps[CPUID_EAX + i*PT_CPUID_REGS_NUM], &pt_pmu.caps[CPUID_EBX + i*PT_CPUID_REGS_NUM], &pt_pmu.caps[CPUID_ECX + i*PT_CPUID_REGS_NUM],
arch/x86/events/zhaoxin/core.c +4 -4
@@ -504,9 +504,9 @@ static __init void zhaoxin_arch_events_quirk(void)__init int zhaoxin_pmu_init (void ) { -union cpuid10_edx edx; -union cpuid10_eax eax; -union cpuid10_ebx ebx; +union cpuid_0xa_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_ebx ebx;struct event_constraint *c;unsigned int unused;int version;
@@ -517,7 +517,7 @@ __init int zhaoxin_pmu_init(void)* Check whether the Architectural PerfMon supports * hw_event or not. */ -cpuid (10 , &eax.full, &ebx.full, &unused, &edx.full); +cpuid (0xA , &eax.full, &ebx.full, &unused, &edx.full);if (eax.split.mask_length <ARCH_PERFMON_EVENTS_COUNT -1 )return -ENODEV ;
arch/x86/include/asm/perf_event.h +6 -6
@@ -125,7 +125,7 @@* Intel "Architectural Performance Monitoring" CPUID * detection/enumeration details: */ -union cpuid10_eax { +union cpuid_0xa_eax {struct {unsigned int version_id:8 ;unsigned int num_counters:8 ;
@@ -135,7 +135,7 @@ union cpuid10_eax {unsigned int full; }; -union cpuid10_ebx { +union cpuid_0xa_ebx {struct {unsigned int no_unhalted_core_cycles:1 ;unsigned int no_instructions_retired:1 ;
@@ -148,7 +148,7 @@ union cpuid10_ebx {unsigned int full; }; -union cpuid10_edx { +union cpuid_0xa_edx {struct {unsigned int num_counters_fixed:5 ;unsigned int bit_width_fixed:8 ;
@@ -170,7 +170,7 @@ union cpuid10_edx {/* * Intel Architectural LBR CPUID detection/enumeration details: */ -union cpuid28_eax { +union cpuid_0x1c_eax {struct {/* Supported LBR depth values */ unsigned int lbr_depth_mask:8 ;
@@ -183,7 +183,7 @@ union cpuid28_eax {unsigned int full; }; -union cpuid28_ebx { +union cpuid_0x1c_ebx {struct {/* CPL Filtering Supported */ unsigned int lbr_cpl:1 ;
@@ -195,7 +195,7 @@ union cpuid28_ebx {unsigned int full; }; -union cpuid28_ecx { +union cpuid_0x1c_ecx {struct {/* Mispredict Bit Supported */ unsigned int lbr_mispred:1 ;
arch/x86/kvm/cpuid.c +2 -2
@@ -936,8 +936,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) }break ;case 0xa : {/* Architectural Performance Monitoring */ -union cpuid10_eax eax; -union cpuid10_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_edx edx;if (!static_cpu_has (X86_FEATURE_ARCH_PERFMON )) { entry->eax = entry->ebx = entry->ecx = entry->edx =0 ;
arch/x86/kvm/vmx/pmu_intel.c +2 -2
@@ -507,8 +507,8 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)struct kvm_pmu *pmu =vcpu_to_pmu (vcpu);struct lbr_desc *lbr_desc =vcpu_to_lbr_desc (vcpu);struct kvm_cpuid_entry2 *entry; -union cpuid10_eax eax; -union cpuid10_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_edx edx;u64 perf_capabilities;u64 counter_mask;int i;
Signature · 1 line
2.39.2
PATCH v3 1/1 perf/x86: use hexidecimal value for cpuid
It's easier to use hexidecimal value instead of decimal for reading and following with SDM doc, also align with other cpuid calls. As new cpuid leaf would be added in future, this tries to convert current forms and would take it as convention for new leaf definition.
This changes name for both cpuid type and cpuid calls.
---
v3:
- add more explanation in commit message for purpose of this
- use lowercase number in call to align with current code
v2:
- rename in cpuid data type as well
arch/x86/events/intel/core.c | 10 +++++----- arch/x86/events/intel/lbr.c | 8 ++++---- arch/x86/events/intel/pt.c | 2 +- arch/x86/events/zhaoxin/core.c | 8 ++++---- arch/x86/include/asm/perf_event.h | 12 ++++++------ arch/x86/kvm/cpuid.c | 4 ++-- arch/x86/kvm/vmx/pmu_intel.c | 4 ++-- 7 files changed, 24 insertions(+), 24 deletions(-)
arch/x86/events/intel/core.c +5 -5
@@ -5170,7 +5170,7 @@ static __init void intel_arch_events_quirk(void)static __init void intel_nehalem_quirk (void ) { -union cpuid10_ebx ebx; +union cpuid_0xa_ebx ebx; ebx.full = x86_pmu.events_maskl;if (ebx.split.no_branch_misses_retired) {
@@ -5878,9 +5878,9 @@ __init int intel_pmu_init(void)struct attribute **td_attr = &empty_attrs;struct attribute **mem_attr = &empty_attrs;struct attribute **tsx_attr = &empty_attrs; -union cpuid10_edx edx; -union cpuid10_eax eax; -union cpuid10_ebx ebx; +union cpuid_0xa_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_ebx ebx;unsigned int fixed_mask;bool pmem = false;int version, i;
@@ -5903,7 +5903,7 @@ __init int intel_pmu_init(void)* Check whether the Architectural PerfMon supports * Branch Misses Retired hw_event or not. */ -cpuid (10 , &eax.full, &ebx.full, &fixed_mask, &edx.full); +cpuid (0xa , &eax.full, &ebx.full, &fixed_mask, &edx.full);if (eax.split.mask_length <ARCH_PERFMON_EVENTS_COUNT )return -ENODEV ;
arch/x86/events/intel/lbr.c +4 -4
@@ -1497,16 +1497,16 @@ static bool is_arch_lbr_xsave_available(void)void __init intel_pmu_arch_lbr_init (void ) {struct pmu *pmu =x86_get_pmu (smp_processor_id ()); -union cpuid28_eax eax; -union cpuid28_ebx ebx; -union cpuid28_ecx ecx; +union cpuid_0x1c_eax eax; +union cpuid_0x1c_ebx ebx; +union cpuid_0x1c_ecx ecx;unsigned int unused_edx;bool arch_lbr_xsave;size_t size;u64 lbr_nr;/* Arch LBR Capabilities */ -cpuid (28 , &eax.full, &ebx.full, &ecx.full, &unused_edx); +cpuid (0x1c , &eax.full, &ebx.full, &ecx.full, &unused_edx); lbr_nr =fls (eax.split.lbr_depth_mask) *8 ;if (!lbr_nr)
arch/x86/events/intel/pt.c +1 -1
@@ -235,7 +235,7 @@ static int __init pt_pmu_hw_init(void) }for (i =0 ; i <PT_CPUID_LEAVES ; i++) { - cpuid_count(20, i, + cpuid_count(0x14, i, &pt_pmu.caps[CPUID_EAX + i*PT_CPUID_REGS_NUM], &pt_pmu.caps[CPUID_EBX + i*PT_CPUID_REGS_NUM], &pt_pmu.caps[CPUID_ECX + i*PT_CPUID_REGS_NUM],
arch/x86/events/zhaoxin/core.c +4 -4
@@ -504,9 +504,9 @@ static __init void zhaoxin_arch_events_quirk(void)__init int zhaoxin_pmu_init (void ) { -union cpuid10_edx edx; -union cpuid10_eax eax; -union cpuid10_ebx ebx; +union cpuid_0xa_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_ebx ebx;struct event_constraint *c;unsigned int unused;int version;
@@ -517,7 +517,7 @@ __init int zhaoxin_pmu_init(void)* Check whether the Architectural PerfMon supports * hw_event or not. */ -cpuid (10 , &eax.full, &ebx.full, &unused, &edx.full); +cpuid (0xa , &eax.full, &ebx.full, &unused, &edx.full);if (eax.split.mask_length <ARCH_PERFMON_EVENTS_COUNT -1 )return -ENODEV ;
arch/x86/include/asm/perf_event.h +6 -6
@@ -125,7 +125,7 @@* Intel "Architectural Performance Monitoring" CPUID * detection/enumeration details: */ -union cpuid10_eax { +union cpuid_0xa_eax {struct {unsigned int version_id:8 ;unsigned int num_counters:8 ;
@@ -135,7 +135,7 @@ union cpuid10_eax {unsigned int full; }; -union cpuid10_ebx { +union cpuid_0xa_ebx {struct {unsigned int no_unhalted_core_cycles:1 ;unsigned int no_instructions_retired:1 ;
@@ -148,7 +148,7 @@ union cpuid10_ebx {unsigned int full; }; -union cpuid10_edx { +union cpuid_0xa_edx {struct {unsigned int num_counters_fixed:5 ;unsigned int bit_width_fixed:8 ;
@@ -170,7 +170,7 @@ union cpuid10_edx {/* * Intel Architectural LBR CPUID detection/enumeration details: */ -union cpuid28_eax { +union cpuid_0x1c_eax {struct {/* Supported LBR depth values */ unsigned int lbr_depth_mask:8 ;
@@ -183,7 +183,7 @@ union cpuid28_eax {unsigned int full; }; -union cpuid28_ebx { +union cpuid_0x1c_ebx {struct {/* CPL Filtering Supported */ unsigned int lbr_cpl:1 ;
@@ -195,7 +195,7 @@ union cpuid28_ebx {unsigned int full; }; -union cpuid28_ecx { +union cpuid_0x1c_ecx {struct {/* Mispredict Bit Supported */ unsigned int lbr_mispred:1 ;
arch/x86/kvm/cpuid.c +2 -2
@@ -967,8 +967,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) }break ;case 0xa : {/* Architectural Performance Monitoring */ -union cpuid10_eax eax; -union cpuid10_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_edx edx;if (!static_cpu_has (X86_FEATURE_ARCH_PERFMON )) { entry->eax = entry->ebx = entry->ecx = entry->edx =0 ;
arch/x86/kvm/vmx/pmu_intel.c +2 -2
@@ -512,8 +512,8 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)struct kvm_pmu *pmu =vcpu_to_pmu (vcpu);struct lbr_desc *lbr_desc =vcpu_to_lbr_desc (vcpu);struct kvm_cpuid_entry2 *entry; -union cpuid10_eax eax; -union cpuid10_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_edx edx;u64 perf_capabilities;u64 counter_mask;int i;
Signature · 1 line
2.39.2
Re: [PATCH v3] perf/x86: use hexidecimal value for cpuid
Quoted 6 lines · Zhenyu Wang
It's easier to use hexidecimal value instead of decimal for reading and following with SDM doc, also align with other cpuid calls. As new cpuid leaf would be added in future, this tries to convert current forms and would take it as convention for new leaf definition.
This changes name for both cpuid type and cpuid calls.
It seems the patch touches 3 CPUIDs, 0xa, 0x1c and 0x14, right? The patch also crosses several different subsystems and drivers. I think it may be better to divide the patch by CPUID. Each patch to handle one CPUID. It's easier for review.
Also, can you please add a macro for the CPUID leaf number? Please refer ARCH_PERFMON_EXT_LEAF (0x23).
Thanks,
Kan
Quoted 215 lines
Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Mark Rutland <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Kan Liang <[email protected]>Cc CodyYao-oc <[email protected]>Signed-off-by Zhenyu Wang <[email protected]>---
v3:
- add more explanation in commit message for purpose of this
- use lowercase number in call to align with current codev2:
- rename in cpuid data type as wellarch/x86/events/intel/core.c | 10 +++++----- arch/x86/events/intel/lbr.c | 8 ++++---- arch/x86/events/intel/pt.c | 2 +- arch/x86/events/zhaoxin/core.c | 8 ++++---- arch/x86/include/asm/perf_event.h | 12 ++++++------ arch/x86/kvm/cpuid.c | 4 ++-- arch/x86/kvm/vmx/pmu_intel.c | 4 ++-- 7 files changed, 24 insertions(+), 24 deletions(-)arch/x86/events/intel/core.c +5
-5@@ -5170,7 +5170,7 @@ static __init void intel_arch_events_quirk(void)static __init void intel_nehalem_quirk (void ) { -union cpuid10_ebx ebx; +union cpuid_0xa_ebx ebx; ebx.full = x86_pmu.events_maskl;if (ebx.split.no_branch_misses_retired) {@@ -5878,9 +5878,9 @@ __init int intel_pmu_init(void)struct attribute **td_attr = &empty_attrs;struct attribute **mem_attr = &empty_attrs;struct attribute **tsx_attr = &empty_attrs; -union cpuid10_edx edx; -union cpuid10_eax eax; -union cpuid10_ebx ebx; +union cpuid_0xa_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_ebx ebx;unsigned int fixed_mask;bool pmem = false;int version, i;@@ -5903,7 +5903,7 @@ __init int intel_pmu_init(void)* Check whether the Architectural PerfMon supports * Branch Misses Retired hw_event or not. */ -cpuid (10 , &eax.full, &ebx.full, &fixed_mask, &edx.full); +cpuid (0xa , &eax.full, &ebx.full, &fixed_mask, &edx.full);if (eax.split.mask_length <ARCH_PERFMON_EVENTS_COUNT )return -ENODEV ;arch/x86/events/intel/lbr.c +4
-4@@ -1497,16 +1497,16 @@ static bool is_arch_lbr_xsave_available(void)void __init intel_pmu_arch_lbr_init (void ) {struct pmu *pmu =x86_get_pmu (smp_processor_id ()); -union cpuid28_eax eax; -union cpuid28_ebx ebx; -union cpuid28_ecx ecx; +union cpuid_0x1c_eax eax; +union cpuid_0x1c_ebx ebx; +union cpuid_0x1c_ecx ecx;unsigned int unused_edx;bool arch_lbr_xsave;size_t size;u64 lbr_nr;/* Arch LBR Capabilities */ -cpuid (28 , &eax.full, &ebx.full, &ecx.full, &unused_edx); +cpuid (0x1c , &eax.full, &ebx.full, &ecx.full, &unused_edx); lbr_nr =fls (eax.split.lbr_depth_mask) *8 ;if (!lbr_nr)arch/x86/events/intel/pt.c +1
-1@@ -235,7 +235,7 @@ static int __init pt_pmu_hw_init(void) }for (i =0 ; i <PT_CPUID_LEAVES ; i++) { - cpuid_count(20, i, + cpuid_count(0x14, i, &pt_pmu.caps[CPUID_EAX + i*PT_CPUID_REGS_NUM], &pt_pmu.caps[CPUID_EBX + i*PT_CPUID_REGS_NUM], &pt_pmu.caps[CPUID_ECX + i*PT_CPUID_REGS_NUM],arch/x86/events/zhaoxin/core.c +4
-4@@ -504,9 +504,9 @@ static __init void zhaoxin_arch_events_quirk(void)__init int zhaoxin_pmu_init (void ) { -union cpuid10_edx edx; -union cpuid10_eax eax; -union cpuid10_ebx ebx; +union cpuid_0xa_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_ebx ebx;struct event_constraint *c;unsigned int unused;int version;@@ -517,7 +517,7 @@ __init int zhaoxin_pmu_init(void)* Check whether the Architectural PerfMon supports * hw_event or not. */ -cpuid (10 , &eax.full, &ebx.full, &unused, &edx.full); +cpuid (0xa , &eax.full, &ebx.full, &unused, &edx.full);if (eax.split.mask_length <ARCH_PERFMON_EVENTS_COUNT -1 )return -ENODEV ;arch/x86/include/asm/perf_event.h +6
-6@@ -125,7 +125,7 @@* Intel "Architectural Performance Monitoring" CPUID * detection/enumeration details: */ -union cpuid10_eax { +union cpuid_0xa_eax {struct {unsigned int version_id:8 ;unsigned int num_counters:8 ;@@ -135,7 +135,7 @@ union cpuid10_eax {unsigned int full; }; -union cpuid10_ebx { +union cpuid_0xa_ebx {struct {unsigned int no_unhalted_core_cycles:1 ;unsigned int no_instructions_retired:1 ;@@ -148,7 +148,7 @@ union cpuid10_ebx {unsigned int full; }; -union cpuid10_edx { +union cpuid_0xa_edx {struct {unsigned int num_counters_fixed:5 ;unsigned int bit_width_fixed:8 ;@@ -170,7 +170,7 @@ union cpuid10_edx {/* * Intel Architectural LBR CPUID detection/enumeration details: */ -union cpuid28_eax { +union cpuid_0x1c_eax {struct {/* Supported LBR depth values */ unsigned int lbr_depth_mask:8 ;@@ -183,7 +183,7 @@ union cpuid28_eax {unsigned int full; }; -union cpuid28_ebx { +union cpuid_0x1c_ebx {struct {/* CPL Filtering Supported */ unsigned int lbr_cpl:1 ;@@ -195,7 +195,7 @@ union cpuid28_ebx {unsigned int full; }; -union cpuid28_ecx { +union cpuid_0x1c_ecx {struct {/* Mispredict Bit Supported */ unsigned int lbr_mispred:1 ;arch/x86/kvm/cpuid.c +2
-2@@ -967,8 +967,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) }break ;case 0xa : {/* Architectural Performance Monitoring */ -union cpuid10_eax eax; -union cpuid10_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_edx edx;if (!static_cpu_has (X86_FEATURE_ARCH_PERFMON )) { entry->eax = entry->ebx = entry->ecx = entry->edx =0 ;arch/x86/kvm/vmx/pmu_intel.c +2
-2@@ -512,8 +512,8 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)struct kvm_pmu *pmu =vcpu_to_pmu (vcpu);struct lbr_desc *lbr_desc =vcpu_to_lbr_desc (vcpu);struct kvm_cpuid_entry2 *entry; -union cpuid10_eax eax; -union cpuid10_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_edx edx;u64 perf_capabilities;u64 counter_mask;int i;
Re: [PATCH v3] perf/x86: use hexidecimal value for cpuid
Quoted 1 line · Kan
sorry that I missed this one in my inbox...
Quoted 6 lines · Zhenyu Wang
Quoted 5 lines
It's easier to use hexidecimal value instead of decimal for reading and following with SDM doc, also align with other cpuid calls. As new cpuid leaf would be added in future, this tries to convert current forms and would take it as convention for new leaf definition.
Quoted 6 lines
Quoted 1 line
This changes name for both cpuid type and cpuid calls.
It seems the patch touches 3 CPUIDs,
0xa,0x1cand0x14, right? The patch also crosses several different subsystems and drivers. I think it may be better to divide the patch by CPUID. Each patch to handle one CPUID. It's easier for review.
ok, I can do that.
Quoted 4 lines
Also, can you please add a macro for the CPUID leaf number? Please refer
ARCH_PERFMON_EXT_LEAF(0x23).
As originally the purpose of this change is to use hex value in cpuid call and struct name, good to see that use for 0x23. If define every macro for these, e.g ARCH_PERFMON_LEAF(0xa), PT_LEAF(0x14), LBR_LEAF(0x1c), struct name needs change too? As in context of what source file you're reading, you already get idea what these cpuid numbers are for what kind of leaf...
Quoted 216 lines
Quoted 216 lines
Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Mark Rutland <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Kan Liang <[email protected]>Cc CodyYao-oc <[email protected]>Signed-off-by Zhenyu Wang <[email protected]>---
v3:
- add more explanation in commit message for purpose of this
- use lowercase number in call to align with current codev2:
- rename in cpuid data type as wellarch/x86/events/intel/core.c | 10 +++++----- arch/x86/events/intel/lbr.c | 8 ++++---- arch/x86/events/intel/pt.c | 2 +- arch/x86/events/zhaoxin/core.c | 8 ++++---- arch/x86/include/asm/perf_event.h | 12 ++++++------ arch/x86/kvm/cpuid.c | 4 ++-- arch/x86/kvm/vmx/pmu_intel.c | 4 ++-- 7 files changed, 24 insertions(+), 24 deletions(-)arch/x86/events/intel/core.c +5
-5@@ -5170,7 +5170,7 @@ static __init void intel_arch_events_quirk(void)static __init void intel_nehalem_quirk (void ) { -union cpuid10_ebx ebx; +union cpuid_0xa_ebx ebx; ebx.full = x86_pmu.events_maskl;if (ebx.split.no_branch_misses_retired) {@@ -5878,9 +5878,9 @@ __init int intel_pmu_init(void)struct attribute **td_attr = &empty_attrs;struct attribute **mem_attr = &empty_attrs;struct attribute **tsx_attr = &empty_attrs; -union cpuid10_edx edx; -union cpuid10_eax eax; -union cpuid10_ebx ebx; +union cpuid_0xa_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_ebx ebx;unsigned int fixed_mask;bool pmem = false;int version, i;@@ -5903,7 +5903,7 @@ __init int intel_pmu_init(void)* Check whether the Architectural PerfMon supports * Branch Misses Retired hw_event or not. */ -cpuid (10 , &eax.full, &ebx.full, &fixed_mask, &edx.full); +cpuid (0xa , &eax.full, &ebx.full, &fixed_mask, &edx.full);if (eax.split.mask_length <ARCH_PERFMON_EVENTS_COUNT )return -ENODEV ;arch/x86/events/intel/lbr.c +4
-4@@ -1497,16 +1497,16 @@ static bool is_arch_lbr_xsave_available(void)void __init intel_pmu_arch_lbr_init (void ) {struct pmu *pmu =x86_get_pmu (smp_processor_id ()); -union cpuid28_eax eax; -union cpuid28_ebx ebx; -union cpuid28_ecx ecx; +union cpuid_0x1c_eax eax; +union cpuid_0x1c_ebx ebx; +union cpuid_0x1c_ecx ecx;unsigned int unused_edx;bool arch_lbr_xsave;size_t size;u64 lbr_nr;/* Arch LBR Capabilities */ -cpuid (28 , &eax.full, &ebx.full, &ecx.full, &unused_edx); +cpuid (0x1c , &eax.full, &ebx.full, &ecx.full, &unused_edx); lbr_nr =fls (eax.split.lbr_depth_mask) *8 ;if (!lbr_nr)arch/x86/events/intel/pt.c +1
-1@@ -235,7 +235,7 @@ static int __init pt_pmu_hw_init(void) }for (i =0 ; i <PT_CPUID_LEAVES ; i++) { - cpuid_count(20, i, + cpuid_count(0x14, i, &pt_pmu.caps[CPUID_EAX + i*PT_CPUID_REGS_NUM], &pt_pmu.caps[CPUID_EBX + i*PT_CPUID_REGS_NUM], &pt_pmu.caps[CPUID_ECX + i*PT_CPUID_REGS_NUM],arch/x86/events/zhaoxin/core.c +4
-4@@ -504,9 +504,9 @@ static __init void zhaoxin_arch_events_quirk(void)__init int zhaoxin_pmu_init (void ) { -union cpuid10_edx edx; -union cpuid10_eax eax; -union cpuid10_ebx ebx; +union cpuid_0xa_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_ebx ebx;struct event_constraint *c;unsigned int unused;int version;@@ -517,7 +517,7 @@ __init int zhaoxin_pmu_init(void)* Check whether the Architectural PerfMon supports * hw_event or not. */ -cpuid (10 , &eax.full, &ebx.full, &unused, &edx.full); +cpuid (0xa , &eax.full, &ebx.full, &unused, &edx.full);if (eax.split.mask_length <ARCH_PERFMON_EVENTS_COUNT -1 )return -ENODEV ;arch/x86/include/asm/perf_event.h +6
-6@@ -125,7 +125,7 @@* Intel "Architectural Performance Monitoring" CPUID * detection/enumeration details: */ -union cpuid10_eax { +union cpuid_0xa_eax {struct {unsigned int version_id:8 ;unsigned int num_counters:8 ;@@ -135,7 +135,7 @@ union cpuid10_eax {unsigned int full; }; -union cpuid10_ebx { +union cpuid_0xa_ebx {struct {unsigned int no_unhalted_core_cycles:1 ;unsigned int no_instructions_retired:1 ;@@ -148,7 +148,7 @@ union cpuid10_ebx {unsigned int full; }; -union cpuid10_edx { +union cpuid_0xa_edx {struct {unsigned int num_counters_fixed:5 ;unsigned int bit_width_fixed:8 ;@@ -170,7 +170,7 @@ union cpuid10_edx {/* * Intel Architectural LBR CPUID detection/enumeration details: */ -union cpuid28_eax { +union cpuid_0x1c_eax {struct {/* Supported LBR depth values */ unsigned int lbr_depth_mask:8 ;@@ -183,7 +183,7 @@ union cpuid28_eax {unsigned int full; }; -union cpuid28_ebx { +union cpuid_0x1c_ebx {struct {/* CPL Filtering Supported */ unsigned int lbr_cpl:1 ;@@ -195,7 +195,7 @@ union cpuid28_ebx {unsigned int full; }; -union cpuid28_ecx { +union cpuid_0x1c_ecx {struct {/* Mispredict Bit Supported */ unsigned int lbr_mispred:1 ;arch/x86/kvm/cpuid.c +2
-2@@ -967,8 +967,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) }break ;case 0xa : {/* Architectural Performance Monitoring */ -union cpuid10_eax eax; -union cpuid10_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_edx edx;if (!static_cpu_has (X86_FEATURE_ARCH_PERFMON )) { entry->eax = entry->ebx = entry->ecx = entry->edx =0 ;arch/x86/kvm/vmx/pmu_intel.c +2
-2@@ -512,8 +512,8 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)struct kvm_pmu *pmu =vcpu_to_pmu (vcpu);struct lbr_desc *lbr_desc =vcpu_to_lbr_desc (vcpu);struct kvm_cpuid_entry2 *entry; -union cpuid10_eax eax; -union cpuid10_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_edx edx;u64 perf_capabilities;u64 counter_mask;int i;
Re: [PATCH v3] perf/x86: use hexidecimal value for cpuid
Quoted 26 lines · Zhenyu Wang
Quoted 1 line · Kan
sorry that I missed this one in my inbox...
Quoted 6 lines · Zhenyu Wang
Quoted 5 lines
It's easier to use hexidecimal value instead of decimal for reading and following with SDM doc, also align with other cpuid calls. As new cpuid leaf would be added in future, this tries to convert current forms and would take it as convention for new leaf definition.
Quoted 6 lines
Quoted 1 line
This changes name for both cpuid type and cpuid calls.
It seems the patch touches 3 CPUIDs,
0xa,0x1cand0x14, right? The patch also crosses several different subsystems and drivers. I think it may be better to divide the patch by CPUID. Each patch to handle one CPUID. It's easier for review.ok, I can do that.
Quoted 4 lines
Also, can you please add a macro for the CPUID leaf number? Please refer
ARCH_PERFMON_EXT_LEAF(0x23).
Quoted 7 lines
As originally the purpose of this change is to use hex value in cpuid call and struct name, good to see that use for
0x23. If define every macro for these, e.gARCH_PERFMON_LEAF(0xa),PT_LEAF(0x14),LBR_LEAF(0x1c), struct name needs change too? As in context of what source file you're reading, you already get idea what these cpuid numbers are for what kind of leaf...
No, only the hex value is good enough for an union name.
What I want is a consistent style for the leaf definition of the entire X86 perf code.
For a union, e.g., cpuid_$hex_eax
For the leaf, e.g., #define __meaning_name_macro __hex
I think AMD has already done it. See EXT_PERFMON_DEBUG_FEATURES and union cpuid_0x80000022_ebx.
If we have the same style, the code style will be consistent.
Thanks,
Kan
Quoted 216 lines
Quoted 216 lines
Quoted 216 lines
Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Mark Rutland <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Kan Liang <[email protected]>Cc CodyYao-oc <[email protected]>Signed-off-by Zhenyu Wang <[email protected]>---
v3:
- add more explanation in commit message for purpose of this
- use lowercase number in call to align with current codev2:
- rename in cpuid data type as wellarch/x86/events/intel/core.c | 10 +++++----- arch/x86/events/intel/lbr.c | 8 ++++---- arch/x86/events/intel/pt.c | 2 +- arch/x86/events/zhaoxin/core.c | 8 ++++---- arch/x86/include/asm/perf_event.h | 12 ++++++------ arch/x86/kvm/cpuid.c | 4 ++-- arch/x86/kvm/vmx/pmu_intel.c | 4 ++-- 7 files changed, 24 insertions(+), 24 deletions(-)arch/x86/events/intel/core.c +5
-5@@ -5170,7 +5170,7 @@ static __init void intel_arch_events_quirk(void)static __init void intel_nehalem_quirk (void ) { -union cpuid10_ebx ebx; +union cpuid_0xa_ebx ebx; ebx.full = x86_pmu.events_maskl;if (ebx.split.no_branch_misses_retired) {@@ -5878,9 +5878,9 @@ __init int intel_pmu_init(void)struct attribute **td_attr = &empty_attrs;struct attribute **mem_attr = &empty_attrs;struct attribute **tsx_attr = &empty_attrs; -union cpuid10_edx edx; -union cpuid10_eax eax; -union cpuid10_ebx ebx; +union cpuid_0xa_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_ebx ebx;unsigned int fixed_mask;bool pmem = false;int version, i;@@ -5903,7 +5903,7 @@ __init int intel_pmu_init(void)* Check whether the Architectural PerfMon supports * Branch Misses Retired hw_event or not. */ -cpuid (10 , &eax.full, &ebx.full, &fixed_mask, &edx.full); +cpuid (0xa , &eax.full, &ebx.full, &fixed_mask, &edx.full);if (eax.split.mask_length <ARCH_PERFMON_EVENTS_COUNT )return -ENODEV ;arch/x86/events/intel/lbr.c +4
-4@@ -1497,16 +1497,16 @@ static bool is_arch_lbr_xsave_available(void)void __init intel_pmu_arch_lbr_init (void ) {struct pmu *pmu =x86_get_pmu (smp_processor_id ()); -union cpuid28_eax eax; -union cpuid28_ebx ebx; -union cpuid28_ecx ecx; +union cpuid_0x1c_eax eax; +union cpuid_0x1c_ebx ebx; +union cpuid_0x1c_ecx ecx;unsigned int unused_edx;bool arch_lbr_xsave;size_t size;u64 lbr_nr;/* Arch LBR Capabilities */ -cpuid (28 , &eax.full, &ebx.full, &ecx.full, &unused_edx); +cpuid (0x1c , &eax.full, &ebx.full, &ecx.full, &unused_edx); lbr_nr =fls (eax.split.lbr_depth_mask) *8 ;if (!lbr_nr)arch/x86/events/intel/pt.c +1
-1@@ -235,7 +235,7 @@ static int __init pt_pmu_hw_init(void) }for (i =0 ; i <PT_CPUID_LEAVES ; i++) { - cpuid_count(20, i, + cpuid_count(0x14, i, &pt_pmu.caps[CPUID_EAX + i*PT_CPUID_REGS_NUM], &pt_pmu.caps[CPUID_EBX + i*PT_CPUID_REGS_NUM], &pt_pmu.caps[CPUID_ECX + i*PT_CPUID_REGS_NUM],arch/x86/events/zhaoxin/core.c +4
-4@@ -504,9 +504,9 @@ static __init void zhaoxin_arch_events_quirk(void)__init int zhaoxin_pmu_init (void ) { -union cpuid10_edx edx; -union cpuid10_eax eax; -union cpuid10_ebx ebx; +union cpuid_0xa_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_ebx ebx;struct event_constraint *c;unsigned int unused;int version;@@ -517,7 +517,7 @@ __init int zhaoxin_pmu_init(void)* Check whether the Architectural PerfMon supports * hw_event or not. */ -cpuid (10 , &eax.full, &ebx.full, &unused, &edx.full); +cpuid (0xa , &eax.full, &ebx.full, &unused, &edx.full);if (eax.split.mask_length <ARCH_PERFMON_EVENTS_COUNT -1 )return -ENODEV ;arch/x86/include/asm/perf_event.h +6
-6@@ -125,7 +125,7 @@* Intel "Architectural Performance Monitoring" CPUID * detection/enumeration details: */ -union cpuid10_eax { +union cpuid_0xa_eax {struct {unsigned int version_id:8 ;unsigned int num_counters:8 ;@@ -135,7 +135,7 @@ union cpuid10_eax {unsigned int full; }; -union cpuid10_ebx { +union cpuid_0xa_ebx {struct {unsigned int no_unhalted_core_cycles:1 ;unsigned int no_instructions_retired:1 ;@@ -148,7 +148,7 @@ union cpuid10_ebx {unsigned int full; }; -union cpuid10_edx { +union cpuid_0xa_edx {struct {unsigned int num_counters_fixed:5 ;unsigned int bit_width_fixed:8 ;@@ -170,7 +170,7 @@ union cpuid10_edx {/* * Intel Architectural LBR CPUID detection/enumeration details: */ -union cpuid28_eax { +union cpuid_0x1c_eax {struct {/* Supported LBR depth values */ unsigned int lbr_depth_mask:8 ;@@ -183,7 +183,7 @@ union cpuid28_eax {unsigned int full; }; -union cpuid28_ebx { +union cpuid_0x1c_ebx {struct {/* CPL Filtering Supported */ unsigned int lbr_cpl:1 ;@@ -195,7 +195,7 @@ union cpuid28_ebx {unsigned int full; }; -union cpuid28_ecx { +union cpuid_0x1c_ecx {struct {/* Mispredict Bit Supported */ unsigned int lbr_mispred:1 ;arch/x86/kvm/cpuid.c +2
-2@@ -967,8 +967,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) }break ;case 0xa : {/* Architectural Performance Monitoring */ -union cpuid10_eax eax; -union cpuid10_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_edx edx;if (!static_cpu_has (X86_FEATURE_ARCH_PERFMON )) { entry->eax = entry->ebx = entry->ecx = entry->edx =0 ;arch/x86/kvm/vmx/pmu_intel.c +2
-2@@ -512,8 +512,8 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)struct kvm_pmu *pmu =vcpu_to_pmu (vcpu);struct lbr_desc *lbr_desc =vcpu_to_lbr_desc (vcpu);struct kvm_cpuid_entry2 *entry; -union cpuid10_eax eax; -union cpuid10_edx edx; +union cpuid_0xa_eax eax; +union cpuid_0xa_edx edx;u64 perf_capabilities;u64 counter_mask;int i;