Re: [BUGFIX][PATCH] Freezer, CPU hotplug, x86 Microcode: Fix taskfreezing failures

From: Srivatsa S. Bhat
Date: Tue Oct 04 2011 - 09:15:22 EST

On 10/04/2011 12:45 PM, Tejun Heo wrote:
> Hello,
> On Mon, Oct 03, 2011 at 10:47:54AM +0200, Borislav Petkov wrote:
>> I think your patch makes sense because re-loading the ucode during
>> a suspend/resume cycle is unnecessary. If one wants to update the
>> microcode, it should happen later when the box is resumed again: you
>> simply put the new microcode image in /lib/firmware/... and on AMD
>> unload/reload the microcode module and on Intel you do either that or
>> use the deprecated microcode_ctl.
> I don't think it changes anything for suspend/resume cycles. They're
> different hooks. The proposed patch changes actual cpu hotplug paths.

I agree with you that my patch modifies the actual cpu hotplug path, which is
not desirable if we are going to do physical cpu hotplug because, even when the
freezer is not active, my patch would prevent us from revising the microcode
even during a pure cpu hotplug operation.

I would like to propose a modified solution to the problem:

Taking a CPU offline:
* Upon a CPU_DEAD notification, just like the code originally did, we free
the kernel's copy of the microcode and invalidate it. So no changes here.

Bringing a CPU online:
* When a CPU_ONLINE or CPU_ONLINE_FROZEN notification is received,
a. If the userspace is not frozen, we request microcode from userspace and
apply it to the cpu.

b. However if we find that the userspace is frozen at that moment, we defer
applying microcode now and register a callback function to be executed
immediately when the userspace gets thawed. This callback function would
request microcode from userspace and apply it to the cpu.

The advantage of this approach over the previous idea I proposed is that we don't
prevent the kernel from invalidating the microcode, thereby ensuring that we
don't break any possible assumptions about microcode.
So, every cpu will get a fresh copy of microcode from userspace, either immediately
or after a while, depending on whether the userspace is frozen or not at that instant.
As a consequence, physical cpu hotplug would also work just fine with this approach.

How does this sound? I'll write up a patch for this and post it for review soon.

Srivatsa S. Bhat <srivatsa.bhat@xxxxxxxxxxxxxxxxxx>
Linux Technology Center,
IBM India Systems and Technology Lab
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at