Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753261AbbGQE3U (ORCPT ); Fri, 17 Jul 2015 00:29:20 -0400 Received: from e31.co.us.ibm.com ([32.97.110.149]:52825 "EHLO e31.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750735AbbGQE3T (ORCPT ); Fri, 17 Jul 2015 00:29:19 -0400 X-Helo: d03dlp02.boulder.ibm.com X-MailFrom: paulmck@linux.vnet.ibm.com X-RcptTo: linux-kernel@vger.kernel.org Date: Thu, 16 Jul 2015 21:29:07 -0700 From: "Paul E. McKenney" To: Andy Lutomirski Cc: Sasha Levin , =?iso-8859-1?Q?Fr=E9d=E9ric?= Weisbecker , "linux-kernel@vger.kernel.org" , Peter Zijlstra , X86 ML , Rik van Riel Subject: Re: Reconciling rcu_irq_enter()/rcu_nmi_enter() with context tracking Message-ID: <20150717042907.GZ3717@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15071704-8236-0000-0000-00000D38E217 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2990 Lines: 64 On Thu, Jul 16, 2015 at 06:53:15PM -0700, Andy Lutomirski wrote: > For reasons that mystify me a bit, we currently track context tracking > state separately from rcu's watching state. This results in strange > artifacts: nothing generic cause IRQs to enter CONTEXT_KERNEL, and we > can nest exceptions inside the IRQ handler (an example would be > wrmsr_safe failing), and, in -next, we splat a warning: > > https://gist.github.com/sashalevin/a006a44989312f6835e7 > > I'm trying to make context tracking more exact, which will fix this > issue (the particular splat that Sasha hit shouldn't be possible when > I'm done), but I think it would be nice to unify all of this stuff. > Would it be plausible for us to guarantee that RCU state is always in > sync with context tracking state? If so, we could maybe simplify > things and have fewer state variables. A noble goal. Might even be possible, and maybe even advantageous. But it is usually easier to say than to do. RCU really does need to make some adjustments when the state changes, as do the other subsystems. It might or might not be possible to do the transitions atomically. And if the transitions are not atomic, there will still be weird code paths where (say) the processor is considered non-idle, but RCU doesn't realize it yet. Such a code path could not safely use rcu_read_lock(), so you still need RCU to be able to scream if someone tries it. Contrariwise, if there is a code path where the processor is considered idle, but RCU thinks it is non-idle, that code path can stall grace periods. (Yes, not a problem if the code path is short enough. At least if the underlying VCPU is making progres...) Still, I cannot prove that it is impossible, and if it is possible, then as you say, there might well be benefits. > Doing this for NMIs might be weird. Would it make sense to have a > CONTEXT_NMI that's somehow valid even if the NMI happened while > changing context tracking state. Face it, NMIs are weird. ;-) > Thoughts? As it stands, I think we might already be broken for real: > > Syscall -> user_exit. Perf NMI hits *during* user_exit. Perf does > copy_from_user_nmi, which can fault, causing do_page_fault to get > called, which calls exception_enter(), which can't be a good thing. > > RCU is okay (sort of) because of rcu_nmi_enter, but this seems very fragile. Actually, I see more cases where people forget irq_enter() than rcu_nmi_enter(). "We will just nip in quickly and do something without actually letting the irq system know. Oh, and we want some event tracing in that code path." Boom! > Thoughts? As it stands, I need to do something because -tip and thus > -next spews occasional warnings. Tell me more? Thanx, Paul -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/