Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1308811pxb; Tue, 17 Aug 2021 08:38:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlifcRaRwhXwAHnNx9rduv8tYOfGCGvrzhrgu0/faOZprfe/U/+BjC993leJm6O+hwii4r X-Received: by 2002:aa7:d04c:: with SMTP id n12mr4802522edo.342.1629214702600; Tue, 17 Aug 2021 08:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629214702; cv=none; d=google.com; s=arc-20160816; b=kKb2Mys3lldhqLQrJx+O2+2BDJ0QFMNCXxSaINZRmYxO36lQF3/ud7SUlWid/+owV8 Dzx8mBas+xJVP0H3u0/WWjEmC4C3/tgztidDqdsu+ZlJfKfauTNXDBMy49vBwwJf/Lw4 aoQZjtOf8wTgSlzzzWugyjwwQ8fIz/J40jnoA+k3yTXR8V1D4N2D9eW3bVdiaQdZIfp0 USJ+TVH/ldcr7vLxdoYOQHSBs+Kq5uXbgSVWz+Ysvr15/Qw65rLYe9ocyeNh6le/c0qc RFQ0DUsGn+PfoepBQofBddJt7DAGR+lOv1ezN0O4orBPerX9/HIT5k507cgu1vgME/oh jh/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature :dkim-signature:date; bh=lbCgA2enmhNewVF4yvWuDdNewPyqFXG/EN/DoydyHAw=; b=HzuVyecdWlSBj5Vizi55VCrFUHBUqg8eOstZrUHxqH4M3mrliJgV+j1erZi8rWNKMu RtZyBYVISdFuOuu/g1ZPgeUbifPI0uSJv7l2OkmHXs+hbV2l+WHF9nDC+ulCCt3Eagw6 YPHMPCamyE4IeawDDEuJDJRKtYAMx5u3O2Ot9MrWmVe0fFbjC4ptkiIYuaybbtA/GxoU YHLIuoDkLthA4CAEItCjRxamsuCNl6jD7B8HsWTOKiXGt/a2zuA9uh/yGmoauBID6/2K A1bZZ606yN7qmDmSNPbqGU8UyHZBh+f0z/WpCfjntEwVd7e36DqmG/EzDsiq2MESz1WB Oe9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZIF+gIl7; dkim=neutral (no key) header.i=@linutronix.de; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si3333364ejj.278.2021.08.17.08.37.55; Tue, 17 Aug 2021 08:38:22 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZIF+gIl7; dkim=neutral (no key) header.i=@linutronix.de; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236489AbhHQPgx (ORCPT + 99 others); Tue, 17 Aug 2021 11:36:53 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:33102 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231893AbhHQPgu (ORCPT ); Tue, 17 Aug 2021 11:36:50 -0400 Date: Tue, 17 Aug 2021 17:36:13 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1629214575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lbCgA2enmhNewVF4yvWuDdNewPyqFXG/EN/DoydyHAw=; b=ZIF+gIl7Dqcdkh2AlPk/szyV/ljbbc6P5Zc33T7O2L6wxyj6K6f854zQlzp0Lhf62aneeq vRSSzd0iwyRqCs0CRo2WY8JiTqhxp0mWtlqQ3G9WvAh6ePzkFK8NtkWq3eeGVNzLckdcPg z0/6ghGXlJq3b96KlS6XqAyV6RkITu6va/pithfpxk+trF65V0DqfByIjuKj6K1bd4AGZz WSXlUdRS7kV5Oq2+uyHJwVBQ7QTMXrI+syd9lRMMFHiFlN7vsMYeN3KrDzNaNlEV8DYbth ZvtwyEaeEbKCyQgIXMn37RzIdareNM40OxmnY0OtYR1jKq9FIcK7SrpYwkLgDA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1629214575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lbCgA2enmhNewVF4yvWuDdNewPyqFXG/EN/DoydyHAw=; b=gen8UXdF1J1gIaJN2QWJWg0rbkFVNLTMc89v0qICwoAifOaOi0xqfF6KLlF51fIczw7pc+ 4Ch9KaHOJxAa7BBg== From: Sebastian Andrzej Siewior To: Valentin Schneider Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rcu@vger.kernel.org, linux-rt-users@vger.kernel.org, Catalin Marinas , Will Deacon , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Steven Rostedt , Daniel Bristot de Oliveira , "Paul E. McKenney" , Frederic Weisbecker , Josh Triplett , Mathieu Desnoyers , Davidlohr Bueso , Lai Jiangshan , Joel Fernandes , Anshuman Khandual , Vincenzo Frascino , Steven Price , Ard Biesheuvel , Boqun Feng , Mike Galbraith Subject: Re: [PATCH v3 3/4] rcu/nocb: Protect NOCB state via local_lock() under PREEMPT_RT Message-ID: <20210817153613.l5f66czar6pajexo@linutronix.de> References: <20210811201354.1976839-1-valentin.schneider@arm.com> <20210811201354.1976839-4-valentin.schneider@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210811201354.1976839-4-valentin.schneider@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-08-11 21:13:53 [+0100], Valentin Schneider wrote: > diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h > index 0ff5e4fb933e..11c4ff00afde 100644 > --- a/kernel/rcu/tree_plugin.h > +++ b/kernel/rcu/tree_plugin.h > @@ -21,6 +21,17 @@ static inline int rcu_lockdep_is_held_nocb(struct rcu_data *rdp) > return lockdep_is_held(&rdp->nocb_lock); > } > > +static inline int rcu_lockdep_is_held_nocb_local(struct rcu_data *rdp) > +{ > + return lockdep_is_held( > +#ifdef CONFIG_PREEMPT_RT > + &rdp->nocb_local_lock.lock > +#else > + &rdp->nocb_local_lock > +#endif > + ); > +} Now that I see it and Paul asked for it, please just use !RT version. return lockdep_is_held(&rdp->nocb_local_lock); and RT will work, too. > static inline bool rcu_current_is_nocb_kthread(struct rcu_data *rdp) > { > /* Race on early boot between thread creation and assignment */ > @@ -1629,6 +1664,22 @@ static void rcu_nocb_unlock_irqrestore(struct rcu_data *rdp, > } > } > > +/* > + * The invocation of rcu_core() within the RCU core kthreads remains preemptible > + * under PREEMPT_RT, thus the offload state of a CPU could change while > + * said kthreads are preempted. Prevent this from happening by protecting the > + * offload state with a local_lock(). > + */ > +static void rcu_nocb_local_lock(struct rcu_data *rdp) > +{ > + local_lock(&rcu_data.nocb_local_lock); > +} > + > +static void rcu_nocb_local_unlock(struct rcu_data *rdp) > +{ > + local_unlock(&rcu_data.nocb_local_lock); > +} > + Do you need to pass rdp given that it is not used? > /* Lockdep check that ->cblist may be safely accessed. */ > static void rcu_lockdep_assert_cblist_protected(struct rcu_data *rdp) > { Sebastian