From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758090AbbA2VWi (ORCPT ); Thu, 29 Jan 2015 16:22:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33778 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755237AbbA2VWg (ORCPT ); Thu, 29 Jan 2015 16:22:36 -0500 Date: Thu, 29 Jan 2015 22:21:23 +0100 From: Oleg Nesterov To: Rik van Riel Cc: "H. Peter Anvin" , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Fenghua Yu , the arch/x86 maintainers , linux-kernel Subject: Re: [PATCH RFC] x86,fpu: merge save_init_fpu & unlazy_fpu Message-ID: <20150129212123.GA31892@redhat.com> References: <54C2A245.4010307@redhat.com> <20150124202021.GA1285@redhat.com> <54C6CD64.10208@redhat.com> <20150127194030.GA29879@redhat.com> <54C7F4BB.5020509@redhat.com> <20150129204534.GA30530@redhat.com> <20150129160017.6758dd40@cuia.bos.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150129160017.6758dd40@cuia.bos.redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/29, Rik van Riel wrote: > > The functions save_init_fpu and unlazy_fpu do essentially the > same thing: Yes ;) Could you look at 1-3 I sent ? > Callers of init_fpu do want __thread_fpu_end, so move the call to > __thread_fpu_end into init_fpu. I don't think so... Contrary, I think this __thread_fpu_end() is simply wrong. > static inline void save_init_fpu(struct task_struct *tsk) > { > - WARN_ON_ONCE(!__thread_has_fpu(tsk)); > - > - if (use_eager_fpu()) { > - __save_fpu(tsk); > - return; > - } > - > preempt_disable(); > - __save_init_fpu(tsk); > - __thread_fpu_end(tsk); > + if (__thread_has_fpu(tsk)) { > + if (use_eager_fpu()) > + __save_fpu(tsk); > + else > + __save_init_fpu(tsk); See the changelog in 2/3. I think we still need __thread_fpu_end() if __save_init_fpu() returns 0. In this case (_I think_) the state of FPU doesn't match the saved state. IOW, "save_init" == "save" + "init" (I guess), and that "init" can (say) reset some control register to default value. > + } else if (!use_eager_fpu()) > + tsk->thread.fpu_counter = 0; See 1/3, I think this should be simply removed. > @@ -245,8 +233,10 @@ int init_fpu(struct task_struct *tsk) > int ret; > > if (tsk_used_math(tsk)) { > - if (cpu_has_fpu && tsk == current) > - unlazy_fpu(tsk); > + if (cpu_has_fpu && tsk == current) { > + save_init_fpu(tsk); > + __thread_fpu_end(tsk); See above. Oleg.