From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758904AbbA2VvH (ORCPT ); Thu, 29 Jan 2015 16:51:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44779 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756172AbbA2VvD (ORCPT ); Thu, 29 Jan 2015 16:51:03 -0500 Date: Thu, 29 Jan 2015 22:49:48 +0100 From: Oleg Nesterov To: Rik van Riel Cc: Dave Hansen , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Fenghua Yu , the arch/x86 maintainers , linux-kernel Subject: Re: [PATCH 2/3] x86, fpu: unlazy_fpu: don't do __thread_fpu_end() if use_eager_fpu() Message-ID: <20150129214948.GA1045@redhat.com> References: <54C2A245.4010307@redhat.com> <20150129210723.GA31584@redhat.com> <20150129210816.GC31584@redhat.com> <54CAA7F6.2000206@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54CAA7F6.2000206@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: > > On 01/29/2015 04:08 PM, Oleg Nesterov wrote: > > unlazy_fpu()->__thread_fpu_end() doesn't look right if use_eager_fpu(). > > Unconditional __thread_fpu_end() is only correct if we know that this > > thread can't return to user-mode and use FPU. > > > > Fortunately it has only 2 callers. fpu_copy() checks use_eager_fpu(), > > and init_fpu(current) can be only called by the coredumping thread via > > regset->get(). But it is exported to modules, and imo this should be > > fixed anyway. > > What about xfpregs_set? > > It looks like that code copies an entire FPU state in > from userspace, and expects the kernel to start using > that new FPU state. > > This is called from the ptrace code. Yes. But in this case tsk != current, and we ensure that __switch_to() was finished. wait_task_inactive(). > When we switch to the traced task, the __thread_fpu_end() > that was called from init_fpu() ensures that > switch_fpu_begin() will actually load the new FPU state > from memory into the registers, and we will not take > the fpu_lazy_restore() branch. No. in this case we rely on "tsk->thread.fpu.last_cpu = ~0" which disables fpu_lazy_restore(). > What am I missing? Or me ;) Oleg.