Skip to contentSkip to conversation

CPU hotplug,x86 Microcode: Don't request microcode from userspace unnecessarily

PATCH Superseded Srivatsa S. Bhat 5 participants 8 messages Oct 8, 2011 – Oct 11, 2011 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CPU hotplug,x86 Microcode: Don't request microcode from userspace unnecessarily

Requesting the microcode from userspace *every time* when onlining CPUs (during a CPU hotplug operation) is unnecessary.

So, this patch ensures that once the kernel gets the microcode after booting, it is not freed nor invalidated when a CPU goes offline, so that it can be reused when that CPU comes back online, without requesting userspace for it again. As a result, the CPU hotplug operations become faster as well.

---

 arch/x86/kernel/microcode_core.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
arch/x86/kernel/microcode_core.c +7 -1
index f924280..3fd0189 100644
@@ -483,7 +483,13 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
 		sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);
 		pr_debug("CPU%d removed\n", cpu);
 		break;
-	case CPU_DEAD:
+
+	/* When a CPU goes offline, don't free up or invalidate the copy of
+	 * the microcode in kernel memory, so that we can reuse it when the
+	 * CPU comes back online without unnecessarily requesting the userspace
+	 * for it again.
+	 */
+
 	case CPU_UP_CANCELED_FROZEN:
 		/* The CPU refused to come up during a system resume */
 		microcode_fini_cpu(cpu);
#1 lore raw
Quoted 11 lines · Srivatsa S. Bhat

Requesting the microcode from userspace *every time* when onlining CPUs (during a CPU hotplug operation) is unnecessary.

So, this patch ensures that once the kernel gets the microcode after booting, it is not freed nor invalidated when a CPU goes offline, so that it can be reused when that CPU comes back online, without requesting userspace for it again. As a result, the CPU hotplug operations become faster as well.

Good, thanks. Just a minor nitpick below.

Quoted 11 lines

---

 arch/x86/kernel/microcode_core.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
arch/x86/kernel/microcode_core.c +0 -0
index f924280..3fd0189 100644
@@ -483,7 +483,13 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
 		sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);

arch/x86/kernel/microcode_core.c mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu) · line 492

Quoted 10 lines
arch/x86/kernel/microcode_core.c +7 -1
 		pr_debug("CPU%d removed\n", cpu);
 		break;
-	case CPU_DEAD:
+
+	/* When a CPU goes offline, don't free up or invalidate the copy of
+	 * the microcode in kernel memory, so that we can reuse it when the
+	 * CPU comes back online without unnecessarily requesting the userspace
+	 * for it again.
+	 */
+

Kernel comment style is in this format:

/*
* Blabla
* blublu
*/

@Ingo, can you please adjust it in-flight when applying?

Thanks.

Signature · 8 lines
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551
#2 lore raw
Quoted 39 lines · Borislav Petkov
Quoted 11 lines · Srivatsa S. Bhat

Requesting the microcode from userspace *every time* when onlining CPUs (during a CPU hotplug operation) is unnecessary.

So, this patch ensures that once the kernel gets the microcode after booting, it is not freed nor invalidated when a CPU goes offline, so that it can be reused when that CPU comes back online, without requesting userspace for it again. As a result, the CPU hotplug operations become faster as well.

Good, thanks. Just a minor nitpick below.

Quoted 11 lines

---

 arch/x86/kernel/microcode_core.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
arch/x86/kernel/microcode_core.c +0 -0
index f924280..3fd0189 100644
@@ -483,7 +483,13 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
 		sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);

arch/x86/kernel/microcode_core.c mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu) · line 492

Quoted 10 lines
arch/x86/kernel/microcode_core.c +7 -1
 		pr_debug("CPU%d removed\n", cpu);
 		break;
-	case CPU_DEAD:
+
+	/* When a CPU goes offline, don't free up or invalidate the copy of
+	 * the microcode in kernel memory, so that we can reuse it when the
+	 * CPU comes back online without unnecessarily requesting the userspace
+	 * for it again.
+	 */
+

Kernel comment style is in this format:

Quoted 5 lines

/*
* Blabla
* blublu
*/

Oh, ok.. Thank you for pointing it out.

Quoted 1 line

@Ingo, can you please adjust it in-flight when applying?

I'll post the patch with the correct comment style, if that would make things easier.

Signature · 4 lines
Regards,
Srivatsa S. Bhat  <[email protected]>
Linux Technology Center,
IBM India Systems and Technology Lab
#3 lore raw

PATCH RESEND 1/1 CPU hotplug,x86 Microcode: Don't request microcode from userspace unnecessarily

Requesting the microcode from userspace *every time* when onlining CPUs (during a CPU hotplug operation) is unnecessary.

So, this patch ensures that once the kernel gets the microcode after booting, it is not freed nor invalidated when a CPU goes offline, so that it can be reused when that CPU comes back online, without requesting userspace for it again. As a result, the CPU hotplug operations become faster as well.

---

 arch/x86/kernel/microcode_core.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
arch/x86/kernel/microcode_core.c +8 -1
index f924280..33c8a67 100644
@@ -483,7 +483,14 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
 		sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);
 		pr_debug("CPU%d removed\n", cpu);
 		break;
-	case CPU_DEAD:
+
+	/*
+	 * When a CPU goes offline, don't free up or invalidate the copy of
+	 * the microcode in kernel memory, so that we can reuse it when the
+	 * CPU comes back online without unnecessarily requesting the userspace
+	 * for it again.
+	 */
+
 	case CPU_UP_CANCELED_FROZEN:
 		/* The CPU refused to come up during a system resume */
 		microcode_fini_cpu(cpu);
#4 lore raw
Quoted 8 lines · Srivatsa S. Bhat

Requesting the microcode from userspace *every time* when onlining CPUs (during a CPU hotplug operation) is unnecessary.

So, this patch ensures that once the kernel gets the microcode after booting, it is not freed nor invalidated when a CPU goes offline, so that it can be reused when that CPU comes back online, without requesting userspace for it again. As a result, the CPU hotplug operations become faster as well.

Quoted 4 lines

Fine by me. I wonder who should take this?

Rafael

Quoted 29 lines

---

 arch/x86/kernel/microcode_core.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
arch/x86/kernel/microcode_core.c +8 -1
index f924280..33c8a67 100644
@@ -483,7 +483,14 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
 		sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);
 		pr_debug("CPU%d removed\n", cpu);
 		break;
-	case CPU_DEAD:
+
+	/*
+	 * When a CPU goes offline, don't free up or invalidate the copy of
+	 * the microcode in kernel memory, so that we can reuse it when the
+	 * CPU comes back online without unnecessarily requesting the userspace
+	 * for it again.
+	 */
+
 	case CPU_UP_CANCELED_FROZEN:
 		/* The CPU refused to come up during a system resume */
 		microcode_fini_cpu(cpu);
#5 lore raw
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines · Srivatsa S. Bhat

Requesting the microcode from userspace *every time* when onlining CPUs (during a CPU hotplug operation) is unnecessary.

So, this patch ensures that once the kernel gets the microcode after booting, it is not freed nor invalidated when a CPU goes offline, so that it can be reused when that CPU comes back online, without requesting userspace for it again. As a result, the CPU hotplug operations become faster as well.

Quoted 6 lines
Quoted 4 lines

Fine by me. I wonder who should take this?

Ingo, most probably. ucode stuff goes in through -tip.

Signature · 8 lines
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551
#6 lore raw
Quoted 10 lines · Borislav Petkov
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines · Srivatsa S. Bhat

Requesting the microcode from userspace *every time* when onlining CPUs (during a CPU hotplug operation) is unnecessary.

So, this patch ensures that once the kernel gets the microcode after booting, it is not freed nor invalidated when a CPU goes offline, so that it can be reused when that CPU comes back online, without requesting userspace for it again. As a result, the CPU hotplug operations become faster as well.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Fine by me. I wonder who should take this?

Ingo, most probably. ucode stuff goes in through -tip.

OK, so

Thanks,
Rafael

Acked-by on v1 1/1
#7 lore raw
In reply to Srivatsa S. Bhat
Quoted 8 lines · Srivatsa S. Bhat

Requesting the microcode from userspace *every time* when onlining CPUs (during a CPU hotplug operation) is unnecessary.

So, this patch ensures that once the kernel gets the microcode after booting, it is not freed nor invalidated when a CPU goes offline, so that it can be reused when that CPU comes back online, without requesting userspace for it again. As a result, the CPU hotplug operations become faster as well.

Quoted 4 lines

Thanks,

Andreas

Quoted 26 lines
 arch/x86/kernel/microcode_core.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
arch/x86/kernel/microcode_core.c +8 -1
index f924280..33c8a67 100644
@@ -483,7 +483,14 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
 		sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);
 		pr_debug("CPU%d removed\n", cpu);
 		break;
-	case CPU_DEAD:
+
+	/*
+	 * When a CPU goes offline, don't free up or invalidate the copy of
+	 * the microcode in kernel memory, so that we can reuse it when the
+	 * CPU comes back online without unnecessarily requesting the userspace
+	 * for it again.
+	 */
+
 	case CPU_UP_CANCELED_FROZEN:
 		/* The CPU refused to come up during a system resume */
 		microcode_fini_cpu(cpu);