Skip to contentSkip to conversation

i386/cpu: Expand MAX_FIXED_COUNTERS from 3 to 4 to for Icelake

PATCH In review Like Xu 2 participants 4 messages Mar 17, 2020 – Mar 26, 2020

lore
Share & tools
lore

Like Xu

author
#0 lore raw

PATCH 1/1 i386/cpu: Expand MAX_FIXED_COUNTERS from 3 to 4 to for Icelake

In the Intel SDM, "Table 18-2. Association of Fixed-Function Performance Counters with Architectural Performance Events", we may have a new fixed counter 'TOPDOWN.SLOTS' (since Icelake), which counts the number of available slots for an unhalted logical processor. Check commit 6017608936 in the kernel tree.

---
 target/i386/cpu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/cpu.h +1 -1
index 576f309bbf..ec2b67d425 100644
@@ -1185,7 +1185,7 @@ typedef struct {
 #define CPU_NB_REGS CPU_NB_REGS32
 #endif
 
-#define MAX_FIXED_COUNTERS 3
+#define MAX_FIXED_COUNTERS 4
 #define MAX_GP_COUNTERS    (MSR_IA32_PERF_STATUS - MSR_P6_EVNTSEL0)
 
 #define TARGET_INSN_START_EXTRA_WORDS 1
Signature · 1 line
2.21.1
author
#1 lore raw

Anyone to help review this change?

Thanks,
Like Xu

Quoted 25 lines · Like Xu

In the Intel SDM, "Table 18-2. Association of Fixed-Function Performance Counters with Architectural Performance Events", we may have a new fixed counter 'TOPDOWN.SLOTS' (since Icelake), which counts the number of available slots for an unhalted logical processor. Check commit 6017608936 in the kernel tree.

---
  target/i386/cpu.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/cpu.h +1 -1
index 576f309bbf..ec2b67d425 100644
@@ -1185,7 +1185,7 @@ typedef struct {
  #define CPU_NB_REGS CPU_NB_REGS32
  #endif
 
-#define MAX_FIXED_COUNTERS 3
+#define MAX_FIXED_COUNTERS 4
  #define MAX_GP_COUNTERS    (MSR_IA32_PERF_STATUS - MSR_P6_EVNTSEL0)
 
  #define TARGET_INSN_START_EXTRA_WORDS 1
#2 lore raw
In reply to Like Xu
Quoted 17 lines · Like Xu

In the Intel SDM, "Table 18-2. Association of Fixed-Function Performance Counters with Architectural Performance Events", we may have a new fixed counter 'TOPDOWN.SLOTS' (since Icelake), which counts the number of available slots for an unhalted logical processor. Check commit 6017608936 in the kernel tree.

---
 target/i386/cpu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/cpu.h +0 -0
index 576f309bbf..ec2b67d425 100644

target/i386/cpu.h typedef struct { · line 1191

Quoted 8 lines
target/i386/cpu.h +1 -1
@@ -1185,7 +1185,7 @@ typedef struct {
 #define CPU_NB_REGS CPU_NB_REGS32
 #endif
 
-#define MAX_FIXED_COUNTERS 3
+#define MAX_FIXED_COUNTERS 4
 #define MAX_GP_COUNTERS    (MSR_IA32_PERF_STATUS - MSR_P6_EVNTSEL0)
 
 #define TARGET_INSN_START_EXTRA_WORDS 1

Hi Like, the problem with this patch is that it breaks live migration; the vmstate_msr_architectural_pmu record hardcodes MAX_FIXED_COUNTERS as the number of registers.

So it's more complicated, you need to add a new subsection (following vmstate_msr_architectural_pmu) and transmit it only if the 4th counter is nonzero (instead of the more complicated check in pmu_enable_needed).
Just to be safe, I'd make the new subsection hold 16 counters and bump
MAX_FIXED_COUNTERS to 16.

Thanks,

Paolo

author
#3 lore raw
Quoted 31 lines · Paolo Bonzini
Quoted 17 lines · Like Xu

In the Intel SDM, "Table 18-2. Association of Fixed-Function Performance Counters with Architectural Performance Events", we may have a new fixed counter 'TOPDOWN.SLOTS' (since Icelake), which counts the number of available slots for an unhalted logical processor. Check commit 6017608936 in the kernel tree.

---
  target/i386/cpu.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/cpu.h +0 -0
index 576f309bbf..ec2b67d425 100644

target/i386/cpu.h typedef struct { · line 1191

Quoted 8 lines
target/i386/cpu.h +1 -1
@@ -1185,7 +1185,7 @@ typedef struct {
  #define CPU_NB_REGS CPU_NB_REGS32
  #endif
 
-#define MAX_FIXED_COUNTERS 3
+#define MAX_FIXED_COUNTERS 4
  #define MAX_GP_COUNTERS    (MSR_IA32_PERF_STATUS - MSR_P6_EVNTSEL0)
 
  #define TARGET_INSN_START_EXTRA_WORDS 1

Hi Like, the problem with this patch is that it breaks live migration; the vmstate_msr_architectural_pmu record hardcodes MAX_FIXED_COUNTERS as the number of registers.

Quoted 5 lines

So it's more complicated, you need to add a new subsection (following vmstate_msr_architectural_pmu) and transmit it only if the 4th counter is nonzero (instead of the more complicated check in pmu_enable_needed).
Just to be safe, I'd make the new subsection hold 16 counters and bump
MAX_FIXED_COUNTERS to 16.

The new MAX_FIXED_COUNTERS looks good to me and
and let me follow up this live migration issue.

Thanks,
Like Xu

Quoted 6 lines

Thanks,

Paolo