Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp498828ybk; Wed, 20 May 2020 05:09:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyH4R25fZGmCqyQq5AAE9gn2LdrjXVPcBe2w5tAQ6Ru+KzlnQmutDLqUMjGdQNBpETwd+mx X-Received: by 2002:a17:906:379a:: with SMTP id n26mr3289255ejc.513.1589976551457; Wed, 20 May 2020 05:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589976551; cv=none; d=google.com; s=arc-20160816; b=PJCN2i4yIiDEdN7Opo3G0QOq0/awYWZ5jNAs5k2+gR6eVfSOPuZBk/fM3qjpDuS9t1 TLOU2cO+9RwLMDOyfsSzK7HPD+fTGygxkR/u8cZnfqSLfwU4nTCFYL3bi3AI+oohyuQs fbmVAWM0D4H3kK+F7K75R3En3+7vS3pBRyQhn5QYHujQ5jDPPR9ficuCjOAo42HrtbjW 4rnwkjYKxJL/tK22NSoBSD2U3VngRabKHnFv9rKAQxoQZ1brR0HDrxvIN3pC9Rf5XSBN A4g62x8ZTtU0RELYuJJZ3p2LikK1XvgYvC7I1zaW5qKjQsOFEgwoFsM0QWqZdvhJY9sw MhHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=9Z3TMoC9qERtw3NpJPwWwBDdU32YAUyQZhv9iKisSf0=; b=x95UZ3o6Em7HZ74bz685LVstg26lEDdU/TfJ9t/pKIRY4NLfrKHdxNApHllBcXOfM8 UiYn76WorDmT3sy2/2/Tg51XaYbauxGhIvkM68EFwgG1uLyetna+qHHboI45Gn0vTTMy F/E1YBKDF7Ybj+dm/mGRSCle8c6N1/8m0RJu5rXtFSgvpX9pSJpcYjcgXxt8YvWi7ohQ OKYCLpH6Muu6cwsJ356LWE/zyiBPmUmUEcr8If63VLuJeC6qpaJ3nS933vGUCUArNX0h UCeDrWCwLirTNVQ9vfintyWjdjQL5PGU+t9QjXjitnzQx531C62zNSGinwLUpE14s/H1 qaaQ== 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 c20si1212257edn.476.2020.05.20.05.08.47; Wed, 20 May 2020 05:09:11 -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 S1726899AbgETMGS (ORCPT + 99 others); Wed, 20 May 2020 08:06:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbgETMGS (ORCPT ); Wed, 20 May 2020 08:06:18 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A6CEC061A0E; Wed, 20 May 2020 05:06:18 -0700 (PDT) Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1jbNU8-0007FV-Jb; Wed, 20 May 2020 14:06:08 +0200 Date: Wed, 20 May 2020 14:06:08 +0200 From: Sebastian Andrzej Siewior To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Steven Rostedt , Will Deacon , Thomas Gleixner , "Paul E . McKenney" , Linus Torvalds , Lai Jiangshan , Josh Triplett , Mathieu Desnoyers , rcu@vger.kernel.org Subject: Re: [PATCH 3/8] srcu: Use local_lock() for per-CPU struct srcu_data access Message-ID: <20200520120608.mwros5jurmidxxfv@linutronix.de> References: <20200519201912.1564477-1-bigeasy@linutronix.de> <20200519201912.1564477-4-bigeasy@linutronix.de> <20200520102407.GF317569@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200520102407.GF317569@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-05-20 12:24:07 [+0200], Peter Zijlstra wrote: > On Tue, May 19, 2020 at 10:19:07PM +0200, Sebastian Andrzej Siewior wrote: > > > diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c > > index 0c71505f0e19c..8d2b5f75145d7 100644 > > --- a/kernel/rcu/srcutree.c > > +++ b/kernel/rcu/srcutree.c > > @@ -25,6 +25,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "rcu.h" > > #include "rcu_segcblist.h" > > @@ -735,6 +736,7 @@ static void srcu_flip(struct srcu_struct *ssp) > > smp_mb(); /* D */ /* Pairs with C. */ > > } > > > > +static DEFINE_LOCAL_LOCK(sda_lock); > > /* > > * If SRCU is likely idle, return true, otherwise return false. > > * > > @@ -765,13 +767,13 @@ static bool srcu_might_be_idle(struct srcu_struct *ssp) > > unsigned long tlast; > > > > /* If the local srcu_data structure has callbacks, not idle. */ > > - local_irq_save(flags); > > + local_lock_irqsave(sda_lock, flags); > > sdp = this_cpu_ptr(ssp->sda); > > if (rcu_segcblist_pend_cbs(&sdp->srcu_cblist)) { > > - local_irq_restore(flags); > > + local_unlock_irqrestore(sda_lock, flags); > > return false; /* Callbacks already present, so not idle. */ > > } > > - local_irq_restore(flags); > > + local_unlock_irqrestore(sda_lock, flags); > > Would it perhaps make sense to stick the local_lock in struct srcu_data ? In that case we would need something for pointer stability before the lock is acquired. I remember Paul looked at that patch a few years ago and he said that that disabling interrupts here is important and matches the other part instance where the interrupts are disabled. Looking at it now, it seems that there is just pointer stability but I can't tell if rcu_segcblist_pend_cbs() needs more than just this. Sebastian