Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1386317ybk; Thu, 14 May 2020 07:46:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysJeAG7g22USzzoRaZYodlkDP1JBC7guQVP5XJedU8oyRKzt8g5HkDXmT0BiyBmVKB9uOH X-Received: by 2002:a05:6402:849:: with SMTP id b9mr4451775edz.226.1589467579667; Thu, 14 May 2020 07:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589467579; cv=none; d=google.com; s=arc-20160816; b=wujhcP6+gDJ1DiC7Y7TKAwy2VWNQ0j1eW89nTR3ZyF5QeTTocM2+p1fqSdaGMRWaCb rznNjgx75wgbP6mPmkyoActo+/w9AYeS8v0X31ar668zk2VmZS6m10OUVqYj0chjBDFD CSlM3WB5tCJNMW7lNXV/s1e2zh3dAVWqtjJLyeaiNHNPWL/cuoBnkpbapoXT2W29nD+M j2qF/41hmltlyxr+FXsR86At2ZbgVkUnrnd3DMnQJY/n0Wy0fuVhyt+lmsILmokRuTLc mBonSDiG5mf9JnzCqwsdUWjxhETs6r/4gY0cqZQuW9+ytqjAHffBkOAmovub1kUhHMqA EMUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=wpc75SBQmAsZ2JpWJ4GsvozhmQrQYAJqcnObKE59aB4=; b=PI4hSXcUPT+1zXj7LU6E+5GppKYl0wo0QOzzpHmFzSfbMe0wkoAQ6mDo6f4ICxzscN xwXghLZrQuf8nXVMDH10XNt9ElFKhdAUlOQ4Z2mGsY+PGgvghLZ+S/mHbQR/+VjI1oe+ 8v04kJO0Uc0ILd3CY7vS/Q95yYMZabmMYyjubjE/7vlL+R87m8eJ1wSuirLfmg+CYeVU PFVGiS/3UhcRff5eDhNqLlaayBslCnI605IHXh8t7HXl88iQd4JtENYzGoB2Pe9evfcn lfwyHBAgxOr6BQZjoVmWilHYSpTfb2hl11VNuVE03RgIyLHnnsnALN8TtvIiwlWnSvVp EyjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e6si2056445ejr.380.2020.05.14.07.45.56; Thu, 14 May 2020 07:46:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727939AbgENOoG (ORCPT + 99 others); Thu, 14 May 2020 10:44:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726067AbgENOoF (ORCPT ); Thu, 14 May 2020 10:44:05 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87384C061A0C for ; Thu, 14 May 2020 07:44:05 -0700 (PDT) Received: from p5de0bf0b.dip0.t-ipconnect.de ([93.224.191.11] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jZF5A-0000sf-Em; Thu, 14 May 2020 16:43:32 +0200 Received: by nanos.tec.linutronix.de (Postfix, from userid 1000) id 916191004CE; Thu, 14 May 2020 16:43:31 +0200 (CEST) From: Thomas Gleixner To: Joel Fernandes Cc: LKML , x86@kernel.org, "Paul E. McKenney" , Andy Lutomirski , Alexandre Chartre , Frederic Weisbecker , Paolo Bonzini , Sean Christopherson , Masami Hiramatsu , Petr Mladek , Steven Rostedt , Boris Ostrovsky , Juergen Gross , Brian Gerst , Mathieu Desnoyers , Josh Poimboeuf , Will Deacon Subject: Re: [patch V4 part 3 11/29] rcu: Provide rcu_irq_exit_preempt() In-Reply-To: <20200514024116.GA231286@google.com> References: <20200505134354.774943181@linutronix.de> <20200505134904.364456424@linutronix.de> <20200514024116.GA231286@google.com> Date: Thu, 14 May 2020 16:43:31 +0200 Message-ID: <87blmqziek.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Joel, Joel Fernandes writes: > On Tue, May 05, 2020 at 03:44:05PM +0200, Thomas Gleixner wrote: > Could you let me know which patch or part in the multi-part series is > using it? You found it :) >> +void rcu_irq_exit_preempt(void) >> +{ >> + lockdep_assert_irqs_disabled(); >> + rcu_nmi_exit(); >> + >> + RCU_LOCKDEP_WARN(__this_cpu_read(rcu_data.dynticks_nesting) <= 0, >> + "RCU dynticks_nesting counter underflow/zero!"); > > Makes sense. > >> + RCU_LOCKDEP_WARN(__this_cpu_read(rcu_data.dynticks_nmi_nesting) <= 0, >> + "RCU dynticks_nmi_nesting counter underflow/zero!"); > > This new function will be called only from the outer-most IRQ that > interrupted kernel mode (process context). Right? If so, a better (more > specific) check for the second RCU_LOCKDEP_WARN above is: > > RCU_LOCKDEP_WARN(__this_cpu_read(rcu_data.dynticks_nmi_nesting) != DYNTICK_IRQ_NONIDLE, > "Bad RCU dynticks_nmi_nesting counter\n"); > > That will make sure, it is only called from outer-most rcu_irq_exit() and > interrupting kernel mode. Makes sense. > Or, if [1] is merged, then we could just combine the checks into one check. > RCU_LOCKDEP_WARN(__this_cpu_read(rcu_data.dynticks_nesting) != 1, > "Bad RCU dynticks_nmi_nesting counter\n"); > >> + RCU_LOCKDEP_WARN(rcu_dynticks_curr_cpu_in_eqs(), >> + "RCU in extended quiescent state!"); > > Makes sense. > > BTW, I wonder if a better place to do this "don't enter scheduler while RCU > is not watching" is rcu_note_context_switch()... I actually want to catch even the case where we don't schedule, i.e. if (ret_to_kernel) { if (interrupts_on_after_return((regs)) { if (IS_ENABLED(CONFIG_PREEMPTION)) { if (!preempt_count()) { /* Preemption is possible ... */ rcu_irq_exit_preempt(); if (need_resched()) schedule_preempt_irq(); that catches any exit where preemption is possible and RCU is not watching after rcu_irq_exit(). It does not matter whether need-resched is set here or not. Any interrupt/exception could set it. Yes, I'm paranoid :) Thanks, tglx