Skip to contentSkip to conversation

intel_pstate_get_hwp_cap on wrong CPU

DISCUSSION Sebastian Andrzej Siewior 2 participants 6 messages May 29, 2024 – May 31, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

this just popped up:

| [ 6538.614568] unchecked MSR access error: RDMSR from 0x771 at rIP: 0xffffffff817d2250 (__rdmsr_on_cpu+0x20/0x50)
| [ 6538.625714] Call Trace:
| [ 6538.629156]  <TASK>
| [ 6538.675067]  generic_exec_single+0x58/0x120
| [ 6538.680236]  smp_call_function_single+0xbf/0x110
| [ 6538.696333]  rdmsrl_on_cpu+0x46/0x60
| [ 6538.700894]  intel_pstate_get_hwp_cap+0x1b/0x70
| [ 6538.706420]  intel_pstate_update_limits+0x2a/0x60
| [ 6538.712110]  acpi_processor_notify+0xb7/0x140
| [ 6538.717479]  acpi_ev_notify_dispatch+0x3b/0x60
| [ 6538.722910]  acpi_os_execute_deferred+0xf/0x20
| [ 6538.728346]  process_one_work+0x13d/0x350
| [ 6538.733342]  worker_thread+0x2c2/0x3d0
| [ 6538.743066]  kthread+0xca/0x100
| [ 6538.751844]  ret_from_fork+0x2c/0x40
| [ 6538.761073]  ret_from_fork_asm+0x11/0x20
| [ 6538.765993]  </TASK>
| root@h:~# grep . /sys/devices/system/cpu/intel_pstate/*
| /sys/devices/system/cpu/intel_pstate/max_perf_pct:100
| /sys/devices/system/cpu/intel_pstate/min_perf_pct:36
| /sys/devices/system/cpu/intel_pstate/no_turbo:0
| /sys/devices/system/cpu/intel_pstate/num_pstates:4294967285

^ => -EAGAIN

| /sys/devices/system/cpu/intel_pstate/status:passive | /sys/devices/system/cpu/intel_pstate/turbo_pct:0

|# cpupower frequency-info
|analyzing CPU 0:
|  driver: intel_cpufreq

…

from turbostat:

| CPUID(0): GenuineIntel 0xf CPUID levels
| CPUID(1): family:model:stepping 0x6:3f:4 (6:63:4) microcode 0x1a
| CPUID(0x80000000): max_extended_levels: 0x80000008
| CPUID(1): SSE3 MONITOR SMX EIST TM2 TSC MSR ACPI-TM HT TM
| CPUID(6): APERF, TURBO, DTS, PTM, No-HWP, No-HWPnotify, No-HWPwindow, No-HWPepp, No-HWPpkg, EPB
| cpu4: MSR_IA32_MISC_ENABLE: 0x00850089 (TCC EIST MWAIT PREFETCH TURBO)
| CPUID(7): No-SGX No-Hybrid

This is v6.10.0-rc1.

Sebastian

#1 lore raw

Hi Sebastian,

Quoted 4 lines · Sebastian Andrzej Siewior

Hi,

this just popped up:

Quoted 1 line
[ 6538.614568] unchecked MSR access error: RDMSR from 0x771 at rIP:

Please check if the attached change fixes?

Thanks,
Srinivas

Quoted 44 lines
Quoted 18 lines

0xffffffff817d2250 (__rdmsr_on_cpu+0x20/0x50)

[ 6538.625714] Call Trace:
[ 6538.629156]  <TASK>
[ 6538.675067]  generic_exec_single+0x58/0x120
[ 6538.680236]  smp_call_function_single+0xbf/0x110
[ 6538.696333]  rdmsrl_on_cpu+0x46/0x60
[ 6538.700894]  intel_pstate_get_hwp_cap+0x1b/0x70
[ 6538.706420]  intel_pstate_update_limits+0x2a/0x60
[ 6538.712110]  acpi_processor_notify+0xb7/0x140
[ 6538.717479]  acpi_ev_notify_dispatch+0x3b/0x60
[ 6538.722910]  acpi_os_execute_deferred+0xf/0x20
[ 6538.728346]  process_one_work+0x13d/0x350
[ 6538.733342]  worker_thread+0x2c2/0x3d0
[ 6538.743066]  kthread+0xca/0x100
[ 6538.751844]  ret_from_fork+0x2c/0x40
[ 6538.761073]  ret_from_fork_asm+0x11/0x20
[ 6538.765993]  </TASK>
Quoted 5 lines
root@h:~# grep . /sys/devices/system/cpu/intel_pstate/*
/sys/devices/system/cpu/intel_pstate/max_perf_pct:100
/sys/devices/system/cpu/intel_pstate/min_perf_pct:36
/sys/devices/system/cpu/intel_pstate/no_turbo:0
/sys/devices/system/cpu/intel_pstate/num_pstates:4294967285

^ => -EAGAIN

Quoted 6 lines

/sys/devices/system/cpu/intel_pstate/status:passive /sys/devices/system/cpu/intel_pstate/turbo_pct:0

# cpupower frequency-info
analyzing CPU 0:
 driver: intel_cpufreq

…

from turbostat:

Quoted 9 lines

CPUID(0): GenuineIntel 0xf CPUID levels
CPUID(1): family:model:stepping 0x6:3f:4 (6:63:4) microcode 0x1a CPUID(0x80000000): max_extended_levels: 0x80000008 CPUID(1): SSE3 MONITOR SMX EIST TM2 TSC MSR ACPI-TM HT TM CPUID(6): APERF, TURBO, DTS, PTM, No-HWP, No-HWPnotify, No- HWPwindow, No-HWPepp, No-HWPpkg, EPB
cpu4: MSR_IA32_MISC_ENABLE: 0x00850089 (TCC EIST MWAIT PREFETCH TURBO)
CPUID(7): No-SGX No-Hybrid

Quoted 4 lines

This is v6.10.0-rc1.

Sebastian

From f85a83508ef029bceaf9192cb648d66f32b61d02 Mon Sep 17 00:00:00 2001
From: Srinivas Pandruvada <[email protected]>
Date: Wed, 29 May 2024 15:30:49 -0700
Subject: [PATCH] cpufreq: intel_pstate: Fix unchecked HWP MSR access

HWP MSR 0x771 can be only read on a CPU which supports HWP and enabled. Hence intel_pstate_get_hwp_cap() can only be called when hwp_active is true.

Fixes e8217b4bece3 ("cpufreq: intel_pstate: Update the maximum CPU frequency consistently")
---
 drivers/cpufreq/intel_pstate.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cpufreq/intel_pstate.c +2 -1
index 4b986c044741..65d3f79104bd 100644
@@ -1153,7 +1153,8 @@ static void intel_pstate_update_policies(void)
 static void __intel_pstate_update_max_freq(struct cpudata *cpudata,
 					   struct cpufreq_policy *policy)
 {
-	intel_pstate_get_hwp_cap(cpudata);
+	if (hwp_active)
+		intel_pstate_get_hwp_cap(cpudata);
 
 	policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ?
 			cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
Signature · 1 line
2.25.1
#2 lore raw
Quoted 1 line · srinivas pandruvada

Hi Sebastian,

Hi,

Quoted 7 lines · Sebastian Andrzej Siewior
Quoted 4 lines

Hi,

this just popped up:

Quoted 1 line
[ 6538.614568] unchecked MSR access error: RDMSR from 0x771 at rIP:

Please check if the attached change fixes?

it should based on the callchain. Let me test it in a few…

Would you mind letting
/sys/devices/system/cpu/intel_pstate/num_pstates

reporting something sane? Not 4294967285 but 0 for instance? Would that make sense?

But
…

Quoted 10 lines

From f85a83508ef029bceaf9192cb648d66f32b61d02 Mon Sep 17 00:00:00 2001
From: Srinivas Pandruvada <[email protected]>
Date: Wed, 29 May 2024 15:30:49 -0700
Subject: [PATCH] cpufreq: intel_pstate: Fix unchecked HWP MSR access

HWP MSR 0x771 can be only read on a CPU which supports HWP and enabled. Hence intel_pstate_get_hwp_cap() can only be called when hwp_active is true.

Did Sebastian _Reichel_ report it, too?

Quoted 1 line

Because this my report ;)

Quoted 2 lines
Fixes e8217b4bece3 ("cpufreq: intel_pstate: Update the maximum CPU frequency consistently")

Sebastian

#3 lore raw

Hi,

Quoted 13 lines · Sebastian Andrzej Siewior
Quoted 1 line · srinivas pandruvada

Hi Sebastian,

Hi,

Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 5 lines

Hi,

this just popped up:

Quoted 2 lines
[ 6538.614568] unchecked MSR access error: RDMSR from 0x771 at

rIP:

Please check if the attached change fixes?

Quoted 9 lines

it should based on the callchain. Let me test it in a few…

Would you mind letting /sys/devices/system/cpu/intel_pstate/num_pstates

reporting something sane? Not 4294967285 but 0 for instance? Would that
make sense?

It should be some good value, usually less than 50. Do you see this high number without even triggering condition, which caused warning?

In your system, firmware changed performance notifying via ACPI. That method is deprecated for a while. You are using Haswell, which has this support. But deprecated from Skylake.

Quoted 14 lines

…

Quoted 13 lines

From f85a83508ef029bceaf9192cb648d66f32b61d02 Mon Sep 17 00:00:00 2001
From: Srinivas Pandruvada <[email protected]>
Date: Wed, 29 May 2024 15:30:49 -0700
Subject: [PATCH] cpufreq: intel_pstate: Fix unchecked HWP MSR access

HWP MSR 0x771 can be only read on a CPU which supports HWP and enabled.
Hence intel_pstate_get_hwp_cap() can only be called when hwp_active is
true.

Quoted 3 lines
Quoted 1 line

Did Sebastian _Reichel_ report it, too?

My mistake. I picked up wrong Sebastian. Sorry.

Thanks,
Srinivas

Quoted 12 lines
Quoted 3 lines

Closes:
https://lore.kernel.org/linux-pm/[email protected]/

Because this my report ;)

Quoted 4 lines
Fixes e8217b4bece3 ("cpufreq: intel_pstate: Update the maximum CPU

frequency consistently")
Signed-off-by: Srinivas Pandruvada
<[email protected]>

Sebastian

author Tested-by
#4 lore raw
Quoted 9 lines · srinivas pandruvada
Quoted 7 lines

Would you mind letting /sys/devices/system/cpu/intel_pstate/num_pstates

reporting something sane? Not 4294967285 but 0 for instance? Would that
make sense?

It should be some good value, usually less than 50. Do you see this high number without even triggering condition, which caused warning?

Nope, without the error I see 22. I think this went "-EIO + -EIO -1" which ended up as what I reported by chance. Never mind then.

Quoted 3 lines

In your system, firmware changed performance notifying via ACPI. That method is deprecated for a while. You are using Haswell, which has this support. But deprecated from Skylake.

Okay. Anything I should change?

Quoted 2 lines
Quoted 1 line

Did Sebastian _Reichel_ report it, too?

My mistake. I picked up wrong Sebastian. Sorry.

Ah okay. Then

because it does not do read the MSR in the code path I reported.

Quoted 2 lines

Thanks,
Srinivas

Sebastian

#5 lore raw

Hi,

Quoted 16 lines · Sebastian Andrzej Siewior
Quoted 11 lines · srinivas pandruvada
Quoted 8 lines

Would you mind letting /sys/devices/system/cpu/intel_pstate/num_pstates

reporting something sane? Not 4294967285 but 0 for instance? Would
that
make sense?

It should be some good value, usually less than 50. Do you see this high number without even triggering condition, which caused warning?

Nope, without the error I see 22. I think this went "-EIO + -EIO -1" which ended up as what I reported by chance. Never mind then.

Quoted 7 lines
Quoted 5 lines

In your system, firmware changed performance notifying via ACPI. That
method is deprecated for a while. You are using Haswell, which has this
support. But deprecated from Skylake.

Okay. Anything I should change?

You can't on these models.

Quoted 9 lines
Quoted 3 lines
Quoted 2 lines

Did Sebastian _Reichel_ report it, too?

My mistake. I picked up wrong Sebastian. Sorry.

Ah okay. Then

because it does not do read the MSR in the code path I reported.

Thanks. I will post the patch to the mailing list with the correction.

-Srinivas

Quoted 4 lines
Quoted 2 lines

Thanks,
Srinivas

Sebastian