lkml.org 
[lkml]   [2015]   [Jan]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: question about save_xstate_sig() - WHY DOES THIS WORK?
On 01/27, Rik van Riel wrote:
>
> On 01/27/2015 02:40 PM, Oleg Nesterov wrote:
> >>>
> >>> - Is unlazy_fpu()->__save_init_fpu() safe wrt
> >>> __kernel_fpu_begin() from irq?
>
> It looks like it should be safe, as long as __save_init_fpu()
> knows that the task no longer has the FPU after __kernel_fpu_end(),
> so it does not try to save the kernel FPU state to the user's
> task->thread.fpu.state->xstate

Not sure this is enough, but...

> The caveat here is that __kernel_fpu_begin()/__kernel_fpu_end()
> needs to be kept from running during unlazy_fpu().

Yes,

> This means interrupted_kernel_fpu_idle and/or irq_fpu_usable
> need to check whether preemption is disabled, and lock out
> __kernel_fpu_begin() when preemption is disabled.

But we already have kernel_fpu_disable/enable. unlazy_cpu() can use
it to avoid the race ?

> I can certainly merge unlazy_fpu() and save_init_fpu() into the
> same function, but I am not sure whether or not it should call
> __thread_fpu_end() - it looks like that would be desirable in some
> cases, but not in others...

I _think_ that we never actually want __thread_fpu_end(), although it
doesn't really hurt if !eager. Probably ulazy/save should do

if (!__save_init_fpu())
__thread_fpu_end();

But again, this is minor.

Oleg.



\
 
 \ /
  Last update: 2015-01-29 22:01    [W:0.122 / U:0.536 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site