From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC30FC432BE for ; Tue, 17 Aug 2021 15:36:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB53560FD7 for ; Tue, 17 Aug 2021 15:36:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236694AbhHQPgx (ORCPT ); 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7319C4338F for ; Tue, 17 Aug 2021 15:38:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A40A560EE4 for ; Tue, 17 Aug 2021 15:38:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A40A560EE4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4RKaASSN+dbw9fw+lbqRtOEjLbW5d+KF76JewMlfrBI=; b=iJkQMHkKmo43h6 T9hDp0YX6+K39CXIRMYJASrOefyEdO+1iORPp+wk8WzbSvwGFN33OeAVQ/ZpmtVGYHANsysh9xfC1 AU2+9Eg+h/q9uF2AhUPoCx32ym6yz07xTuFQg1O87uy2TZOvV91y3sDOv6wFfXwKA3x66wxa5JHTZ fNRRS6D5dmCy+/6cr1iknIHqnXGYRf54qx2w0ekrfAuGQ2ieEd2/4Az5ex2OJtkSdlx5/qNvJ4vC8 ezesj69spdSRhOgNOr+5MZEl6EBRo7NvmZ21YKQQdPeBPd1+iaqAH0EGxXfTbjn17s1qPLGl2QdiE 5fEpuR70XhcunD3GuZmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mG18a-002onz-Je; Tue, 17 Aug 2021 15:36:24 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mG18T-002onG-Fr for linux-arm-kernel@lists.infradead.org; Tue, 17 Aug 2021 15:36:21 +0000 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-Disposition: inline In-Reply-To: <20210811201354.1976839-4-valentin.schneider@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210817_083617_736754_C218E9FB X-CRM114-Status: GOOD ( 14.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel