From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755552AbbCFPi3 (ORCPT ); Fri, 6 Mar 2015 10:38:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37405 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754456AbbCFPi1 (ORCPT ); Fri, 6 Mar 2015 10:38:27 -0500 Date: Fri, 6 Mar 2015 16:36:22 +0100 From: Oleg Nesterov To: David Vrabel Cc: Ingo Molnar , Dave Hansen , Borislav Petkov , Andy Lutomirski , Linus Torvalds , Pekka Riikonen , Rik van Riel , Suresh Siddha , LKML , "Yu, Fenghua" , Quentin Casasnovas Subject: Re: [PATCH 1/1] x86/fpu: math_state_restore() should not blindly disable irqs Message-ID: <20150306153622.GA26939@redhat.com> References: <54F74F59.5070107@intel.com> <20150305195127.GA12657@redhat.com> <20150305195149.GB12657@redhat.com> <20150305201101.GA21571@gmail.com> <20150305212532.GA16890@redhat.com> <20150306075833.GA623@gmail.com> <20150306132634.GA20693@redhat.com> <20150306134601.GA11718@gmail.com> <20150306140154.GA22811@redhat.com> <54F9C112.3010604@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54F9C112.3010604@citrix.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 03/06, David Vrabel wrote: > > On 06/03/15 14:01, Oleg Nesterov wrote: > > > Not sure I understand it correctly after the first quick look, but > > > > 1. It conflicts with the recent changes in tip/x86/fpu > > > > 2. fpu_ini() initializes current->thread.fpu.state. This looks unneeded, > > the kernel threads no longer have FPU context and do not abuse CPU. > > > > 3. I can be easily wrong, but it looks buggy... Note that > > arch_dup_task_struct() doesn't allocate child->fpu.state if > > !tsk_used_math(parent). > > ...yes. It's bit-rotted a bit. > > > No, I do not think this patch is a good idea. Perhaps I am wrong, but I > > think we need other changes. And they should start from init_fpu(). > > But the general principle of avoiding the allocation in the #NM handler > and hence avoiding the need to re-enable IRQs is still a good idea, yes? This needs more discussion, but in short so far I think that fpu_alloc() from #NM exception is fine if user_mode(regs) == T. Just do_device_not_available() should simply do conditional_sti(), I think. Perhaps it can even enable irqs unconditionally, but we need to verify that this is 100% correct. And I agree that "if (!tsk_used_math(tsk))" code in math_state_restore() should be removed. But not to avoid the allocation, and this needs other changes. Oleg.