From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752861AbbCWMVf (ORCPT ); Mon, 23 Mar 2015 08:21:35 -0400 Received: from terminus.zytor.com ([198.137.202.10]:41200 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752830AbbCWMV1 (ORCPT ); Mon, 23 Mar 2015 08:21:27 -0400 Date: Mon, 23 Mar 2015 05:20:59 -0700 From: tip-bot for Oleg Nesterov Message-ID: Cc: dave.hansen@intel.com, sbsiddha@gmail.com, quentin.casasnovas@oracle.com, torvalds@linux-foundation.org, bp@suse.de, linux-kernel@vger.kernel.org, hpa@zytor.com, riel@redhat.com, fenghua.yu@intel.com, mingo@kernel.org, tglx@linutronix.de, luto@amacapital.net, oleg@redhat.com, priikone@iki.fi Reply-To: hpa@zytor.com, linux-kernel@vger.kernel.org, quentin.casasnovas@oracle.com, bp@suse.de, sbsiddha@gmail.com, torvalds@linux-foundation.org, dave.hansen@intel.com, priikone@iki.fi, oleg@redhat.com, luto@amacapital.net, tglx@linutronix.de, mingo@kernel.org, fenghua.yu@intel.com, riel@redhat.com In-Reply-To: <20150311173429.GD5032@redhat.com> References: <20150311173429.GD5032@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/fpu] x86/fpu: Introduce restore_init_xstate() Git-Commit-ID: 8f4d81863ba4e8dfee93bd50840f1099a296251f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 8f4d81863ba4e8dfee93bd50840f1099a296251f Gitweb: http://git.kernel.org/tip/8f4d81863ba4e8dfee93bd50840f1099a296251f Author: Oleg Nesterov AuthorDate: Wed, 11 Mar 2015 18:34:29 +0100 Committer: Ingo Molnar CommitDate: Mon, 23 Mar 2015 10:13:58 +0100 x86/fpu: Introduce restore_init_xstate() Extract the "use_eager_fpu()" code from drop_init_fpu() into a new, simple helper restore_init_xstate(). The next patch adds another user. - It is not clear why we do not check use_fxsr() like fpu_restore_checking() does. eager_fpu_init_bp() calls setup_init_fpu_buf() too, and we have the "eagerfpu=on" kernel option. - Ignoring the fact that init_xstate_buf is "struct xsave_struct *", not "union thread_xstate *", it is not clear why we can not simply use fpu_restore_checking() and avoid the code duplication. - It is not clear why we can't call setup_init_fpu_buf() unconditionally to always create init_xstate_buf(). Then do_device_not_available() path (at least) could use restore_init_xstate() too. It doesn't need to init fpu->state, its content doesn't matter until unlazy_fpu()/__switch_to()/etc which overwrites this memory anyway. Signed-off-by: Oleg Nesterov Signed-off-by: Borislav Petkov Cc: Andy Lutomirski Cc: Dave Hansen Cc: Fenghua Yu Cc: Linus Torvalds Cc: Pekka Riikonen Cc: Quentin Casasnovas Cc: Rik van Riel Cc: Suresh Siddha Link: http://lkml.kernel.org/r/20150311173429.GD5032@redhat.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/fpu-internal.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h index c58c930..7d2f7fa 100644 --- a/arch/x86/include/asm/fpu-internal.h +++ b/arch/x86/include/asm/fpu-internal.h @@ -401,16 +401,20 @@ static inline void drop_fpu(struct task_struct *tsk) preempt_enable(); } +static inline void restore_init_xstate(void) +{ + if (use_xsave()) + xrstor_state(init_xstate_buf, -1); + else + fxrstor_checking(&init_xstate_buf->i387); +} + static inline void drop_init_fpu(struct task_struct *tsk) { if (!use_eager_fpu()) drop_fpu(tsk); - else { - if (use_xsave()) - xrstor_state(init_xstate_buf, -1); - else - fxrstor_checking(&init_xstate_buf->i387); - } + else + restore_init_xstate(); } /*