Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2071588imm; Sat, 23 Jun 2018 08:50:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI9EQLefHqzdg6FicLFNAbsl//UXwqTYFUdfW23IWW/+24woOIkNfCUBDmDljQni7+mskZo X-Received: by 2002:a62:f206:: with SMTP id m6-v6mr6239279pfh.171.1529769000152; Sat, 23 Jun 2018 08:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529769000; cv=none; d=google.com; s=arc-20160816; b=RpuAgIQSuZks5hdePpNj21kwKfDr7gtkE+f6PfdTakaF7I4Jfcai2aS6ve5eoH6sO5 5U5u09bGwJ21e5BdmEn7Ocwk9GkXOMNUnLIhlxjuWXkprJCSH4dhmU9qPvQX3tpyexaK /AR9mywnisdgXLb4ZW5n+2xOhQ5Z1C+KQeZLuPw1eJ1YABy/+WDLI/s2AmA4LeVN9R7U VcrSJMJOvx16P8PIz8vfytYy3nPt8tg9E6Vcq4VI8sYRclWzTshMLbnEUSomFT+ibSnn cgB18fYu6eMhDVaQs3HUnCYRJmWQEZh+zoBEQxagfaiqpVwWEIkXHXKKvp5OXMPdCdfa nmQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=YuPLt/7/oh+wOiwqa+nGoDs/Jhwjt7xxdRIM7rzj8zI=; b=CfVQnIAj5a90K9jHFwkcfJG5pzL1MAmOVDt/QmPaU73FFxr+OKPBKQI5FkzCdSFJ2s d0Xl3M9THTHLd6StcGi7a5ATtr119xm3IdqcssAdekbdPzyTlcExBCR7Amw7e6r5LW/A z3DyR62XcZ2RKcUHtI8oNViZ543rybWrEIFtPvFpN3pohrEsYGN8yN99TpBjhDDXbNIL 2uKEZU8tlM5rXA2s2pP8XYOF+LxvxQoJXweoui4BdLGQT2J3oQbMDzkSrOd+1KHx1mtF q7RvqBo9EJ7kMkzWWdHrd9pgnVem9JqyxbLsYssKWanISxzMPIbfOfrGySqRpFCn2Lpr BdNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=J47pcLjP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o7-v6si3366290pga.531.2018.06.23.08.49.46; Sat, 23 Jun 2018 08:50:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=J47pcLjP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751775AbeFWPsn (ORCPT + 99 others); Sat, 23 Jun 2018 11:48:43 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:35346 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751474AbeFWPsl (ORCPT ); Sat, 23 Jun 2018 11:48:41 -0400 Received: by mail-pg0-f66.google.com with SMTP id i7-v6so4240181pgp.2 for ; Sat, 23 Jun 2018 08:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YuPLt/7/oh+wOiwqa+nGoDs/Jhwjt7xxdRIM7rzj8zI=; b=J47pcLjPPuu1tL16hC9UblggMXssIMTeetbq9KE8o7WkiF5zujnFQpZC7HkBsXK6Gm 7oKlRCF0qn57Do9Nqf/3wv8TcSEBfAy2+hUecRz5BYcv8LtyK4/0Re7xCIYNlEjKU2GB WndWO3rVx+1t5QJLIopWHz93fpjFsF/442Xj8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YuPLt/7/oh+wOiwqa+nGoDs/Jhwjt7xxdRIM7rzj8zI=; b=f5/ZcOsyTBOSB8IO7ajHS2S+2pe/IHAB9CnP9eCN2YMpFRz6D+R+PL/Ullc+d37EOz QM2ajz0gmGEdSssVyaf6Tn2PsHpI+T28Q/zk+3fL0ayOSw1Md10HjK+s9dmfgjkIxkI7 mnTzBVLxs85z8GkfziGCQUJz0OKP9twnRIYzhH2GP9dtk8phvmVSc6tAJIpu5jx/s/vx 9RUWj8mtWRQfUGMvH6xH0rjOv9D+XV91QJtC8No3zKkDQI50HZnxP1JpVe7yer0QPwFf ZHaIw/ZXfWVM+ht3AaXG08e3Jn2lv3LXPq6raXZ6BdFjLBdNpRNaJBrl+bFwqowYDnAd nw/Q== X-Gm-Message-State: APt69E0DChBm5kgwLMYylgl7qjrsrIL1mkMazdASb0wjGPgT4KPiRpx5 qwHeBgbKv5A+xxZhctMH2A/H7094elY= X-Received: by 2002:a65:5cc8:: with SMTP id b8-v6mr5198869pgt.85.1529768920899; Sat, 23 Jun 2018 08:48:40 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id e5-v6sm6252531pgf.0.2018.06.23.08.48.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 23 Jun 2018 08:48:40 -0700 (PDT) Date: Sat, 23 Jun 2018 08:48:39 -0700 From: Joel Fernandes To: "Paul E. McKenney" Cc: Steven Rostedt , Byungchul Park , Byungchul Park , jiangshanlai@gmail.com, josh@joshtriplett.org, Mathieu Desnoyers , linux-kernel@vger.kernel.org, kernel-team@lge.com, luto@kernel.org Subject: Re: [RFC 2/2] rcu: Remove ->dynticks_nmi_nesting from struct rcu_dynticks Message-ID: <20180623154839.GA12939@joelaf.mtv.corp.google.com> References: <1529484440-20634-2-git-send-email-byungchul.park@lge.com> <20180620145814.GQ3593@linux.vnet.ibm.com> <20180620164902.GW3593@linux.vnet.ibm.com> <20180622055659.GA255098@joelaf.mtv.corp.google.com> <20180622132843.GN3593@linux.vnet.ibm.com> <20180622181916.GA13628@joelaf.mtv.corp.google.com> <20180622205813.GV3593@linux.vnet.ibm.com> <20180622170042.4adfbe21@gandalf.local.home> <20180622211600.GX3593@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180622211600.GX3593@linux.vnet.ibm.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 22, 2018 at 02:16:00PM -0700, Paul E. McKenney wrote: > On Fri, Jun 22, 2018 at 05:00:42PM -0400, Steven Rostedt wrote: > > On Fri, 22 Jun 2018 13:58:13 -0700 > > "Paul E. McKenney" wrote: > > > > > Something like this: > > > > > > IRQ entered > > > > > > And never exited. Ever. I actually saw this in 2011. > > > > I still believe this was actually a bug. And perhaps you made the RCU > > code robust enough to handle this bug ;-) > > Welcome to my world! > > But I recall it being used in several places, so if it was a bug, it > was an intentional bug. Probably the worst kind. > > Sort of like nested NMIs and interrupts within NMI handlers. ;-) > > > > Or something like this: > > > > > > IRQ exited > > > > > > Without a corresponding IRQ enter. > > > > > > The current code handles both of these situations, at least assuming > > > that the interrupt entry/exit happens during a non-idle period. > > > > > > > > So why this function-call structure? Well, you see, NMI handlers can > > > > > take what appear to RCU to be normal interrupts... > > > > > > > > > > (And I just added that fun fact to Requirements.html.) > > > > > > > > Yes, I'll definitely go through all the interrupt requirements in the doc and > > > > thanks for referring me to it. > > > > > > My concern may well be obsolete. It would be good if it was! ;-) > > > > I'd love to mandate that irq_enter() must be paired with irq_exit(). I > > don't really see any rationale for it to be otherwise. If there is a > > case, perhaps it needs to be fixed. > > Given that the usermode helpers now look to be common code using > workqueues, kthreads, and calls to do_execve(), it might well be that > the days of half-interrupts are behind us. > > But how to actually validate this? My offer of adding a WARN_ON_ONCE() > and waiting a few years still stands, but perhaps you have a better > approach. Hi Paul, I am Ok with adding a warning for a couple of releases if you and others are Ok with it, how about something like this? Feel free to use the diff as a starting point or a different approach if you/others prefer something else. Thanks. ---8<----------------------- diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 8788ddbc0d13..176de74f5027 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -767,6 +767,21 @@ void rcu_idle_enter(void) */ void rcu_user_enter(void) { + struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks); + + /* + * Add warning to ensure: no known instances of entering userspace from + * IRQ/NMI handlers exist today. Currently special crowbarring of the + * dynticks_nmi_nesting and maintaining of this separate counter when + * dynticks_nesting exists, is done in order to handle entering of + * userspace from an IRQ context and never returning. Lets track it for + * a couple of kernel releases and then if the warning doesn't occur, + * we can try to simplify the code and combine/eliminate the counters. + * See: http://lkml.kernel.org/r/20180622181422.GT3593@linux.vnet.ibm.com + */ + WARN_ON_ONCE(rdtp->dynticks_nmi_nesting && + rdtp->dynticks_nmi_nesting != DYNTICK_IRQ_NONIDLE); + lockdep_assert_irqs_disabled(); rcu_eqs_enter(true); }