From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753058AbbCGKct (ORCPT ); Sat, 7 Mar 2015 05:32:49 -0500 Received: from mail-wi0-f180.google.com ([209.85.212.180]:43429 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750933AbbCGKcp (ORCPT ); Sat, 7 Mar 2015 05:32:45 -0500 Date: Sat, 7 Mar 2015 11:32:40 +0100 From: Ingo Molnar To: Linus Torvalds Cc: Oleg Nesterov , Dave Hansen , Borislav Petkov , Andy Lutomirski , 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: <20150307103240.GA9378@gmail.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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Linus Torvalds wrote: > On Thu, Mar 5, 2015 at 11:58 PM, Ingo Molnar wrote: > > > > math_state_restore() was historically called with irqs disabled, > > because that's how the hardware generates the trap, and also because > > back in the days it was possible for it to be an asynchronous > > interrupt and interrupt handlers run with irqs off. > > > > These days it's always an instruction trap, and furthermore it does > > inevitably complex things such as memory allocation and signal > > processing, which is not done with irqs disabled. > > > > So keep irqs enabled. > > I agree with the "keep irqs enabled". > > However, I do *not* agree with the actual patch, which doesn't do that at all. > > @@ -844,8 +844,9 @@ void math_state_restore(void) > > { > > struct task_struct *tsk = current; > > > > + local_irq_enable(); > > + > > There's a big difference between "keep interrupts enabled" (ok) and > "explicitly enable interrupts in random contexts" (*NOT* ok). Agreed, so I thought that we already kind of did that: if (!tsk_used_math(tsk)) { local_irq_enable(); But yeah, my patch brought that to a whole new level by always doing it, without starting with adding a warning first. > > So get rid of the "local_irq_enable()" entirely, and replace it with a > > WARN_ON_ONCE(irqs_disabled()); Yeah, agreed absolutely - sorry about scaring (or annoying) you with a Signed-off-by patch, that was silly from me. > and let's just fix the cases where this actually gets called with > interrupts off. [...] Yes. I was a bit blinded by the 'easy to backport' aspect, so I concentrated on that, but it's more important to not break stuff. > @@ -959,7 +949,7 @@ void __init trap_init(void) > set_system_intr_gate(X86_TRAP_OF, &overflow); > set_intr_gate(X86_TRAP_BR, bounds); > set_intr_gate(X86_TRAP_UD, invalid_op); > - set_intr_gate(X86_TRAP_NM, device_not_available); > + set_trap_gate(X86_TRAP_NM, device_not_available); So I wasn't this brave. Historically modern x86 entry code ran with irqs off, because that's what the hardware gave us on most entry types. I'm not 100% sure we are ready to allow preemption of sensitive entry code on CONFIG_PREEMPT=y kernels. But we could try. Thanks, Ingo