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=-5.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 7D44CC433EF for ; Tue, 21 Sep 2021 23:47:47 +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 404CC60F70 for ; Tue, 21 Sep 2021 23:47:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 404CC60F70 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=U9tPNFZKMy94yEYeAJ1vgb1RGdCtyootovU1JjeGy7o=; b=Z3LRJ6U4pfoWT0 Dq4fo24J1ITr4kJEs1teAh8/r74bhRJuQroIiTgJCRfMg5RhK1jh7dnkKXLvMwSrSPsj5ShnGzvQW BKNfMiRzezR0ywwWxTMvBYrZm/qxAp7gGk68F7lV/pr0Vl9QjFO7AnZ597HYZLQq7nTRpLKmX3Eik JUpJMI8HB+v+mH+ZZaQ6JXz73n0VXctOwteQiE1+46eifd8HSCPpr+lhbHbYbdjE66ARA8YgFh1+S d5YNt47TZLYGcdHLjq/Gs5NlkL0DOIqZWjcSbkViodeLeq33TA4AdqgVABSaLrtwdDAAxw0TRF6JJ 646NpPVcF1CfVY2AHDNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSpS0-006Fxq-Uw; Tue, 21 Sep 2021 23:45:25 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSpRx-006FxB-IA for linux-arm-kernel@lists.infradead.org; Tue, 21 Sep 2021 23:45:22 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 73FB460F6D; Tue, 21 Sep 2021 23:45:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632267921; bh=4Bdk7t7Ff4sxxY+JAbnfv4+PRj6aM+D+XVagYS8TOp0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LFrEbKVQKJl47R1ka/rgx6b6MDMPN0zdxTWT50HGMGD8V7B3FQ4iZBqvyz7SAIy0E YfoXQNGfQvipOuROtu5wwEUgve5Wk0HLb7JBYekEFGpHA/tdnkdXKEyzGLNF51lwQ3 g9zdycLNbYgwUJZFgxzGv3wKDCwWZrS8iFnQgogx2238RiAfXz3azwCHiBfLgpKyZU P94utw1KHIZW3stUoWYDe/uJBX3l/VG5yf9X1TKiFqJDZcDLyytABkapFcypcUtPV1 x45rwCx7gP1Qs/+v75EXbl0HkS2RqnsdpbJ9+ziQnM2NE4JIlHZCcZ9ep4MAqkC3TV rR2zwqmzebsEw== Date: Wed, 22 Sep 2021 01:45:18 +0200 From: Frederic Weisbecker To: Thomas Gleixner Cc: Valentin Schneider , 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 , Steven Rostedt , Daniel Bristot de Oliveira , Sebastian Andrzej Siewior , "Paul E. McKenney" , Josh Triplett , Mathieu Desnoyers , Davidlohr Bueso , Lai Jiangshan , Joel Fernandes , Anshuman Khandual , Vincenzo Frascino , Steven Price , Ard Biesheuvel , Boqun Feng , Mike Galbraith Subject: Re: rcu/tree: Protect rcu_rdp_is_offloaded() invocations on RT Message-ID: <20210921234518.GB100318@lothringen> References: <20210811201354.1976839-1-valentin.schneider@arm.com> <20210811201354.1976839-4-valentin.schneider@arm.com> <874kae6n3g.ffs@tglx> <87pmt163al.ffs@tglx> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87pmt163al.ffs@tglx> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210921_164521_684391_7937B980 X-CRM114-Status: GOOD ( 18.67 ) 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 Tue, Sep 21, 2021 at 11:12:50PM +0200, Thomas Gleixner wrote: > Valentin reported warnings about suspicious RCU usage on RT kernels. Those > happen when offloading of RCU callbacks is enabled: > > WARNING: suspicious RCU usage > 5.13.0-rt1 #20 Not tainted > ----------------------------- > kernel/rcu/tree_plugin.h:69 Unsafe read of RCU_NOCB offloaded state! > > rcu_rdp_is_offloaded (kernel/rcu/tree_plugin.h:69 kernel/rcu/tree_plugin.h:58) > rcu_core (kernel/rcu/tree.c:2332 kernel/rcu/tree.c:2398 kernel/rcu/tree.c:2777) > rcu_cpu_kthread (./include/linux/bottom_half.h:32 kernel/rcu/tree.c:2876) > > The reason is that rcu_rdp_is_offloaded() is invoked without one of the > required protections on RT enabled kernels because local_bh_disable() does > not disable preemption on RT. > > Valentin proposed to add a local lock to the code in question, but that's > suboptimal in several aspects: > > 1) local locks add extra code to !RT kernels for no value. > > 2) All possible callsites have to audited and amended when affected > possible at an outer function level due to lock nesting issues. > > 3) As the local lock has to be taken at the outer functions it's required > to release and reacquire them in the inner code sections which might > voluntary schedule, e.g. rcu_do_batch(). > > Both callsites of rcu_rdp_is_offloaded() which trigger this check invoke > rcu_rdp_is_offloaded() in the variable declaration section right at the top > of the functions. But the actual usage of the result is either within a > section which provides the required protections or after such a section. > > So the obvious solution is to move the invocation into the code sections > which provide the proper protections, which solves the problem for RT and > does not have any impact on !RT kernels. Also while at it, I'm asking again: traditionally softirqs could assume that manipulating a local state was safe against !irq_count() code fiddling with the same state on the same CPU. Now with preemptible softirqs, that assumption can be broken anytime. RCU was fortunate enough to have a warning for that. But who knows how many issues like this are lurking? Thanks. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel