Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp344462rdf; Tue, 21 Nov 2023 04:33:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEYwt6eRnFE/SaxBf1nV0cmdpfh5ABwYnNbtB4domMqoEiR5k8c5oV67cc9Fg/s56aeGYN X-Received: by 2002:a05:6870:3c84:b0:1f0:3d9c:173a with SMTP id gl4-20020a0568703c8400b001f03d9c173amr12773148oab.56.1700570019151; Tue, 21 Nov 2023 04:33:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700570019; cv=none; d=google.com; s=arc-20160816; b=SGSgr8XJ6mdOzjLrzqBrSkyCnTO85n+6MjJI9Aa+VEjw+j2Wil2uDiXCpR1a7hBf2A yKu69na1X9+YVvJXmlrXUS6vFv8wq1q2hWCuaJaGbzqjdExFNnIWWNtU1OxHL4kEOP+X AXu3vXmWpAoUOM5fDSssf0PI2pSqkJEKnC+pj7k13Hf5lCOut9qdiHUSnpeiY58FOHjk hCrBDYZ9+smw3y/gkkhhrguq6wTRc2ujoklZ7+Bdyq2S4jEBN5dcKbxlssaO7os/y6F5 LVYU6DISr/kIsx6VGI8lv5KKYvaadIGBUcdY0vnGhPLgDCe68uhVLIW26yo3d2uMiLlA lbzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:dkim-signature:dkim-signature:date; bh=Fh9e3GaErBHGJCOCbK/EGCyKE1R80+6heNDm0N0TMWA=; fh=Pa6SlUslf/f1Ae3GVotnGcr03UJLXuxUQewZcI/xZ9c=; b=x2f0m3zzOqid2XYhQiSb4qkIA2iYCZdWq4cNbS6+UcrYPsqpHpgk85o9xFhnAVTOxX lJ9fnvbsdkVGCAI1/dNGadcIbKXYIX8oKfK6zeD4yWGrgy0/nZSR4uMMDUSkqEiacS3Z O09aqHrgTuFGMPNol9LOAeLjonkvHteYbmdUpns3UFpc+q2+1FhcD0nyQciWdaqzhsSR VIPr1EtbWxE4UOvHBtxTzc59+TG6JKy5lc54BsuIrPiIwlILJTL6SoVOX4kb7rWb8i5V /JoU5wzoOuwMZap6asbcs4VsVkj2RuQVnTkiabujHJa9AWzgNRBmmoUQWh8V0WztenTB m2SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wRATZsQk; dkim=neutral (no key) header.i=@linutronix.de header.b=x+PC4P4B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id fi31-20020a056a00399f00b0068fd7cb5864si10734045pfb.263.2023.11.21.04.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 04:33:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wRATZsQk; dkim=neutral (no key) header.i=@linutronix.de header.b=x+PC4P4B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 55AEB802E8BD; Tue, 21 Nov 2023 04:33:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234682AbjKUMd1 (ORCPT + 99 others); Tue, 21 Nov 2023 07:33:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229954AbjKUMd0 (ORCPT ); Tue, 21 Nov 2023 07:33:26 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9459C11C; Tue, 21 Nov 2023 04:33:19 -0800 (PST) Date: Tue, 21 Nov 2023 13:33:15 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1700569997; 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; bh=Fh9e3GaErBHGJCOCbK/EGCyKE1R80+6heNDm0N0TMWA=; b=wRATZsQk4Ria7Rl7ltcBbbJTT3Ilc9PeqBCPZJtujOZ9ckY4Js7fjsSeJU9HwCP6aSCSh2 Lz+cmtIpDw014hyQGiwFtek83644Yn9ATk2kff11HAdoTCSi9jjk9ZEnksd+0cew2jHMzO omoQiROzwzTLF9lpFXV1K6OGM8qB3U5BN4i2ndTscIr5ATXpb4ZK3cK0oFZs+eh/KESx+J Le/+rhkhh5EbMxWAVS45j7aAJ4vl/CDvxzLlBi6FpXdnNa7J9pojdjVjhrukpu0G21zKx3 AithaSGpHvriir/YVHTnrGR4PuURPQrb08QoYGGVTeUyMip7oO03TlImdsv34g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1700569997; 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; bh=Fh9e3GaErBHGJCOCbK/EGCyKE1R80+6heNDm0N0TMWA=; b=x+PC4P4BkaQPUae8UReQEYwUBsiT86OWBEWK14JS9Wj7In+IcXfjZsDaduUOuer4mu7mdd SuLm2Cxb4bdaQnCA== From: Sebastian Andrzej Siewior To: Peter Zijlstra Cc: Boqun Feng , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, "Paul E. McKenney" , Frederic Weisbecker , Ingo Molnar , Joel Fernandes , John Ogness , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , Neeraj Upadhyay , Steven Rostedt , Thomas Gleixner , Waiman Long , Will Deacon , Zqiang Subject: [REPOST PATCH] srcu: Use try-lock lockdep annotation for NMI-safe access. Message-ID: <20231121123315.egrgopGN@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 21 Nov 2023 04:33:36 -0800 (PST) It is claimed that srcu_read_lock_nmisafe() NMI-safe. However it triggers a lockdep if used from NMI because lockdep expects a deadlock since nothing disables NMIs while the lock is acquired. Use a try-lock annotation for srcu_read_lock_nmisafe() to avoid lockdep complains if used from NMI. Fixes: f0f44752f5f61 ("rcu: Annotate SRCU's update-side lockdep dependencies") Link: https://lore.kernel.org/r/20230927160231.XRCDDSK4@linutronix.de Signed-off-by: Sebastian Andrzej Siewior --- This is a repost of https://lore.kernel.org/r/20230927160231.XRCDDSK4@linutronix.de Based on the discussion there I *think* this is preferred over the NMI check in lock_acquire(). But then PeterZ also pointed out that he has a problem with f0f44752f5f61 ("rcu: Annotate SRCU's update-side lockdep dependencies") because trace_.*_rcuidle machinery. This looks okay because the _rcuidle part is using SRCU and the rcu_dereference_raw() tracepoint_func is using RCU + SRCU in its free part. include/linux/rcupdate.h | 6 ++++++ include/linux/srcu.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -301,6 +301,11 @@ static inline void rcu_lock_acquire(stru lock_acquire(map, 0, 0, 2, 0, NULL, _THIS_IP_); } +static inline void rcu_try_lock_acquire(struct lockdep_map *map) +{ + lock_acquire(map, 0, 1, 2, 0, NULL, _THIS_IP_); +} + static inline void rcu_lock_release(struct lockdep_map *map) { lock_release(map, _THIS_IP_); @@ -315,6 +320,7 @@ int rcu_read_lock_any_held(void); #else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */ # define rcu_lock_acquire(a) do { } while (0) +# define rcu_try_lock_acquire(a) do { } while (0) # define rcu_lock_release(a) do { } while (0) static inline int rcu_read_lock_held(void) --- a/include/linux/srcu.h +++ b/include/linux/srcu.h @@ -229,7 +229,7 @@ static inline int srcu_read_lock_nmisafe srcu_check_nmi_safety(ssp, true); retval = __srcu_read_lock_nmisafe(ssp); - rcu_lock_acquire(&ssp->dep_map); + rcu_try_lock_acquire(&ssp->dep_map); return retval; }