Skip to contentSkip to conversation

x86: Fix thermal throttling reporting after kexec

PATCH In review Andi Kleen 3 participants 8 messages Sep 24, 2015 – Oct 11, 2015 x86

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 x86: Fix thermal throttling reporting after kexec

From: Andi Kleen <[email protected]>

The per CPU thermal vector init code checks if the thermal vector is already installed and complains and bails out if it is.

This happens after kexec, as kernel shut down does not clear the thermal vector APIC register.

This causes two problems:

So we always do not fully initialize thermal reports after kexec. The CPU is still likely initialized, as the previous kernel should have done it. But we don't set up the software pointer to the thermal vector, so reporting may end up with a unknown thermal interrupt message.

Also it complains for every logical CPU, even though the value is actually derived from BP only.

The problem is that we end up with one message per CPU, so on larger systems it becomes very noisy and messes up the otherwise nicely formatted CPU bootup numbers in the kernel log.

Just remove the check. I checked the code and there's no valid code paths where the thermal init code for a CPU could be called multiple times.

---
 arch/x86/kernel/cpu/mcheck/therm_throt.c | 8 --------
 1 file changed, 8 deletions(-)
arch/x86/kernel/cpu/mcheck/therm_throt.c +0 -8
index 1af51b1..2c5aaf8 100644
@@ -503,14 +503,6 @@ void intel_init_thermal(struct cpuinfo_x86 *c)
 		return;
 	}
 
-	/* Check whether a vector already exists */
-	if (h & APIC_VECTOR_MASK) {
-		printk(KERN_DEBUG
-		       "CPU%d: Thermal LVT vector (%#x) already installed\n",
-		       cpu, (h & APIC_VECTOR_MASK));
-		return;
-	}
-
 	/* early Pentium M models use different method for enabling TM2 */
 	if (cpu_has(c, X86_FEATURE_TM2)) {
 		if (c->x86 == 6 && (c->x86_model == 9 || c->x86_model == 13)) {
Signature · 1 line
2.4.3
#1 lore raw
Quoted 6 lines · Andi Kleen

The per CPU thermal vector init code checks if the thermal vector is already installed and complains and bails out if it is.

This happens after kexec, as kernel shut down does not clear the thermal vector APIC register.

So the obvious question is, why don't we do that.

Quoted 3 lines

Just remove the check. I checked the code and there's no valid code paths where the thermal init code for a CPU could be called multiple times.

I'm not against removing that check as it does not really add value, but we still should clear the APIC register at shut down, right?

Thanks,

tglx

#2 lore raw
Quoted 9 lines · Thomas Gleixner
Quoted 6 lines · Andi Kleen

The per CPU thermal vector init code checks if the thermal vector is already installed and complains and bails out if it is.

This happens after kexec, as kernel shut down does not clear the thermal vector APIC register.

So the obvious question is, why don't we do that.

It wouldn't help if the previous kernel is some older kernel.

Quoted 7 lines
Quoted 4 lines

Just remove the check. I checked the code and there's no valid code paths where the thermal init code for a CPU could be called multiple times.

I'm not against removing that check as it does not really add value, but we still should clear the APIC register at shut down, right?

The vector register is really harmless by itself and apart from bogus checking it's not really affecting anyone. It may make more sense to disable thermal reporting on shut down though.

I can add that, although it would only be useful for the more theoretical case when you boot non Linux after kexec (as normal Linux always reenables it anyways)

But the check should still be removed imho.

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only
#3 lore raw
Quoted 6 lines · Andi Kleen
Quoted 5 lines · Thomas Gleixner
Quoted 4 lines · Andi Kleen

The per CPU thermal vector init code checks if the thermal vector is already installed and complains and bails out if it is.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

This happens after kexec, as kernel shut down does not clear the thermal vector APIC register.

So the obvious question is, why don't we do that.

It wouldn't help if the previous kernel is some older kernel.

I know.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

Just remove the check. I checked the code and there's no valid code paths where the thermal init code for a CPU could be called multiple times.

I'm not against removing that check as it does not really add value, but we still should clear the APIC register at shut down, right?

Quoted 7 lines

The vector register is really harmless by itself and apart from bogus checking it's not really affecting anyone. It may make more sense to disable thermal reporting on shut down though.

I can add that, although it would only be useful for the more theoretical case when you boot non Linux after kexec (as normal Linux always reenables it anyways)

I see it under the correctness aspect. Mop up before you shut down.

Quoted 1 line

But the check should still be removed imho.

As I said before: I have no objections against that.

Thanks,

tglx

author
#4 lore raw
Quoted 1 line

I see it under the correctness aspect. Mop up before you shut down.

Ok. I suspect if you want to clean up all registers there's much more to do.

BTW there's a small danger in it: if we ever crash accessing on of those registers panic may end up looping.

-Andi

#5 lore raw
Quoted 7 lines · Andi Kleen
Quoted 1 line

I see it under the correctness aspect. Mop up before you shut down.

Ok. I suspect if you want to clean up all registers there's much more to do.

BTW there's a small danger in it: if we ever crash accessing on of those registers panic may end up looping.

I thought more about it. Since this is per logical CPU state the cleanup cannot be done in a normal shutdown callback (which only runs on one CPU), but needs some kind of global IPI/NMI.

IPI could deadlock, so it would need to be NMI.

KVM already has one, but would need to re-organize that into first into a generic callback infrastructure.

I don't think so much change is worth it for this one somewhat dubious case. NMI code is also tricky and it's probably better to keep the shut down paths as simple and reliable as possible. Do you agree?

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only
#6 lore raw
Quoted 15 lines · Andi Kleen
Quoted 7 lines · Andi Kleen
Quoted 1 line

I see it under the correctness aspect. Mop up before you shut down.

Ok. I suspect if you want to clean up all registers there's much more to do.

BTW there's a small danger in it: if we ever crash accessing on of those registers panic may end up looping.

I thought more about it. Since this is per logical CPU state the cleanup cannot be done in a normal shutdown callback (which only runs on one CPU), but needs some kind of global IPI/NMI.

IPI could deadlock, so it would need to be NMI.

Quoted 7 lines

KVM already has one, but would need to re-organize that into first into a generic callback infrastructure.

I don't think so much change is worth it for this one somewhat dubious case. NMI code is also tricky and it's probably better to keep the shut down paths as simple and reliable as possible. Do you agree?

Yes. Makes sense.

Thanks for analysing it.

tglx

#7 lore raw

Andi,

Quoted 19 lines · Thomas Gleixner
Quoted 18 lines · Andi Kleen
Quoted 7 lines · Andi Kleen
Quoted 1 line

I see it under the correctness aspect. Mop up before you shut down.

Ok. I suspect if you want to clean up all registers there's much more to do.

BTW there's a small danger in it: if we ever crash accessing on of those registers panic may end up looping.

I thought more about it. Since this is per logical CPU state the cleanup cannot be done in a normal shutdown callback (which only runs on one CPU), but needs some kind of global IPI/NMI.

IPI could deadlock, so it would need to be NMI.

KVM already has one, but would need to re-organize that into first into a generic callback infrastructure.

Quoted 8 lines
Quoted 4 lines

I don't think so much change is worth it for this one somewhat dubious case. NMI code is also tricky and it's probably better to keep the shut down paths as simple and reliable as possible. Do you agree?

Yes. Makes sense.

Thanks for analysing it.

I wanted to pick this up, but then I noticed that it actually belongs to X86 MCE INFRASTRUCTURE which is maintained by Tony and Borislav.

Can you please resend to them? It would be nice if you could add the discussion about not cleaning it up in the changelog.

Thanks and sorry for noticing so late,

tglx