Re: math_state_restore and kernel_fpu_end disable interrupts?

From: Nate Eldredge
Date: Sun Jan 19 2014 - 14:04:59 EST

[Here's my original message, since George's reply didn't quote or reference it: Summary: math_state_restore() always leaves interrupts disabled, and I think this is a bug.]

On Sun, 19 Jan 2014, George Spelvin wrote:


I've been having a problem with ext4 metadata checksums, which use SSE
for large blocks, and traced it to kernel_fpu_end() disabling interrupts,
but had paused to debug this (I assumed well-tested) piece of kernel
code before pushing it harder.

Interesting. I guess it's not surprising this has other effects.

Here's the commit that added the code in question (about 6 years ago):

It's credited to Suresh Siddha, whom I've cc'ed (along with others who signed off). Suresh, if you're still around, could you comment on why math_state_restore always leaves interrupts disabled, regardless of their state on entry? Is there a deep reason or is it a bug?

Assuming it's a bug, here's the obvious patch:

--- linux-source-3.11.0/arch/x86/kernel/traps.c 2013-09-02 14:46:10.000000000 -0600
+++ linux-source-3.11.0-nate/arch/x86/kernel/traps.c 2014-01-19 11:25:32.977221476 -0700
@@ -624,6 +624,9 @@
struct task_struct *tsk = current;

if (!tsk_used_math(tsk)) {
+ unsigned long flags;
+ local_save_flags(flags);
* does a slab alloc which can sleep
@@ -635,7 +638,7 @@
- local_irq_disable();
+ local_irq_restore(flags);


I tested it briefly: the kernel still boots fine, and it fixes the problem I was seeing (BUG() when core dumping on ecryptfs). George, does it help your problem?

Thanks everyone!

(Search October-December LKML archives for "3.11.4: kernel BUG at

Nate Eldredge

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