Re: [PATCH] Make math_state_restore() save and restore the interrupt flag
From: Linus Torvalds
Date: Sat Feb 01 2014 - 14:28:39 EST
On Thu, Jan 30, 2014 at 11:33 PM, Suresh Siddha <sbsiddha@xxxxxxxxx> wrote:
>
> a. delayed dynamic allocation of FPU state area was not a good idea
> (from me). Given most of the future cases will be anyway using eager
> FPU (because of processor features like xsaveopt etc, applications
> implicitly using FPU because of optimizations in commonly used
> libraries etc), we should probably go back to allocation of FPU state
> area during thread creation for everyone (including non-eager cases).
Yes, I suspect that will help some, and probably fix this particular bug.
That said, regardless of the allocation issue, I do think that it's
stupid for kernel_fpu_{begin,end} to save the math state if
"used_math" was not set. So I do think__kernel_fpu_end() as-s is
buggy and stupid. So I do think we should *either* say
(a) "we don't want to restore at all, because once the kernel starts
using math, it might do so a lot, and saving/restoring is a bad idea":
void __kernel_fpu_end(void)
{
stts();
}
*or*
(b) make the use_eager_fpu() case check tsk_used_math() (in which
case we had better already have an allocation!)
void __kernel_fpu_end(void)
{
if (use_eager_fpu()) {
struct task_struct *me = current;
if (tsk_used_math(me) && likely(!restore_fpu_checking(me)))
return;
}
stts();
}
Quite frankly, I'd almost lean towards (a). Comments? Does anybody
have any loads where the kernel does a lot of fpu stuff (ie network
encryption using the hw engines or something)? I'd really like to hear
if it makes a difference..
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/