x86, fpu: Don't abuse has_fpu in __kernel_fpu_begin/end()
x86, fpu: Don't abuse has_fpu in __kernel_fpu_begin/end()

Now that we have in_kernel_fpu we can remove __thread_clear_has_fpu()
in __kernel_fpu_begin(). And this allows to replace the asymmetrical
and nontrivial use_eager_fpu + tsk_used_math check in kernel_fpu_end()
with the same __thread_has_fpu() check.

The logic becomes really simple; if _begin() does save() then _end()
needs restore(), this is controlled by __thread_has_fpu(). Otherwise
they do clts/stts unless use_eager_fpu().

Not only this makes begin/end symmetrical and imo more understandable,
potentially this allows to change irq_fpu_usable() to avoid all other
checks except "in_kernel_fpu".

Also, with this patch __kernel_fpu_end() does restore_fpu_checking()
and WARNs if it fails instead of math_state_restore(). I think this
looks better because we no longer need __thread_fpu_begin(), and it
would be better to report the failure in this case.

Signed-off-by: Oleg Nesterov <20b70f0af00562e63758b9ee42012ecc96c58590@redhat.com>
Acked-by: Rik van Riel <a21938f5d463ddf41aa718934c205ca2cce8ebbc@redhat.com>
Cc: b02f0790d66a0f0a6b369873bf6df37420fbe5dd@intel.com
Cc: 0691a664b24b6f15b20cd5aee64b72271db08be1@suse.de
Cc: 69d3ebcf5ee4e7f05a50dc23cd96655b730804b4@redhat.com
Cc: 2cc0d0d76de2e6f37b92deeb83c85cb306fc5dc1@amacapital.net
Cc: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>
Cc: Suresh Siddha <f1717d7a737dbd1ee265018492337a4bb54fe08a@gmail.com>
Link: 0d943601fc23a6b2f8aaa24ee2a323e90c898ca7@redhat.com
Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs