Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp830119rdd; Wed, 10 Jan 2024 00:11:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDwNncdrM34DJ8SvjxcSoDVU+wSKSLcy3h1WYBy2QwKdJDvbIxHyWmAFGvfC3R0me8lNlG X-Received: by 2002:a05:6e02:1747:b0:35f:ec66:154e with SMTP id y7-20020a056e02174700b0035fec66154emr1006268ill.64.1704874308036; Wed, 10 Jan 2024 00:11:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704874308; cv=none; d=google.com; s=arc-20160816; b=UO+XvyZpOZxT5C58p564jgU5qO8KywFaYvefAFrA947ox1xCh1/ZxT95rEBUcCiwXf iOSu6UtStyVsP69XwDI97SAWg4eqIw+HIqkVZ0xsiENfYhANakVv6l1tX+R44WrO6yKC Sg9sGV77UHVBjv8SXfhJc6ntKOF9Hg8wzsO7Rka5xGv9mgcEu+rCnGV0psqIGFF5sDZG dbIKDoVPIaaPxPUtdBj/amN1iOFmF4o1F8XMQBUIUg+jZYvh5Ni94R9EAm9aj+lScMb6 Jqt9m5Pl3zY66rjZH2iA4uoMGf8CdY7pU4qoSlVdeN5gehbX05dl55nTuU0Q3hX1E681 j1Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=iZaywHoOiMT3rUWnS91gy1WDghYyx7Hou7F1vPtGwj0=; fh=gBHKmotWusbmxz5JEuHA/RTvfoLB0D9BR2NQ7/FrpLw=; b=U+SMGNXthqoPQJL46L57BYZGTyeWXjz4EM03HlRYr3sS0iHM4XZ6E19iBJ2oAeeRG0 mcuLtiMsZ2XKcsBLAVQL3d3QKobRMaAqKNyMFJuQIc2M0eDobI+r77/pswEiwMKxRSVH H7A6foz2bAATidfeyYwOVGmPT8vSjsTSq/ciHlj0agtkefiVoQNFxl6Uba70ROCFYniV cOA2xzYqsbeBAOFSglntnXOwTupXcmVWA9K+/gOyzya5Hy7wS10ZiPIWcXzAXr0HpG0D Hwzp7RObDAL45zpyHgX3XyWtMOo84kdBf6fP3g3oGAfNcA8VlDNC/r5v6SSz52SHUm4W 8CFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fHL9b00d; spf=pass (google.com: domain of linux-kernel+bounces-21823-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21823-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i129-20020a639d87000000b005ceb4a70213si3235403pgd.385.2024.01.10.00.11.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 00:11:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21823-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fHL9b00d; spf=pass (google.com: domain of linux-kernel+bounces-21823-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21823-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AC28A28875B for ; Wed, 10 Jan 2024 08:11:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B9333E47F; Wed, 10 Jan 2024 08:11:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fHL9b00d" Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54A403E460; Wed, 10 Jan 2024 08:11:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-5c229dabbb6so1334661a12.0; Wed, 10 Jan 2024 00:11:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704874297; x=1705479097; darn=vger.kernel.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iZaywHoOiMT3rUWnS91gy1WDghYyx7Hou7F1vPtGwj0=; b=fHL9b00dhJm9cxpIP8g6cUVDs5X2laatMkSIElMmxkCopp6XJIwJtpuRxGKvHEM2Y3 sWun0yYkr6E5Tax3TRCrYGphM263Ui3+ctF+CBGOocl0nwvr7rOcgVq9rTWp/nnGfwJ+ AieqPoD2d6dCdr93xHqE7aYYOgBEINdE7QmedWJuXZMFJxzaM+cWDUS9kphzzFEWghkr /QrYMU5Sff4wzcJFNXAE7yrRZ9xnVij/f9ivzQbH9htw7wQeVYT1D/avyWpH6Tc0kEw/ 6DDanRSpqR2571tBTJU6Eu6kJ7KcydGWwSPrnz6lSkKAg6w8cJJyp4G+RystA0t3ROp7 VNzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704874297; x=1705479097; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iZaywHoOiMT3rUWnS91gy1WDghYyx7Hou7F1vPtGwj0=; b=b1bFlwuKPc1FB4wMkNZ7Zc/spv9u7KcWdbmyJcQ8cLwbZJfxoSoMNhrJwZKL1APHvh pNAbsXOPx4BNxZCYoz2cLfRsG5rwKuUUdVMx5QfL8KiidmFjV+0JdgWMuKdbP8PLJuTz 5LxRu+y6/tWogB9J40Dv6Vd4gGbWJZUiYC0MtCHONgoun0g2RgjyoAWL0iiuy/+V01AK opvSt4Ij6wqtMngJV0Bk1JKkCUZiyQt/E1jbh5dbmPiPk9NLvj4qzGCJJ/ykFgHpBIM6 fCbu4aw7BWLh28UASqUT6U5yEVgroVTUQq3N1nLR+/RctZUlyGONUvZVmvzOe+5iQ+Hc igzg== X-Gm-Message-State: AOJu0Yz4OvcMsJit7kUJWQL7nOqtMM3APCB+foAReGTrS822FMBB1yLT AMCzD+PQOXRlnyvbQJFRXL78/95r460= X-Received: by 2002:a17:90a:69e4:b0:28c:f391:242d with SMTP id s91-20020a17090a69e400b0028cf391242dmr338137pjj.98.1704874297564; Wed, 10 Jan 2024 00:11:37 -0800 (PST) Received: from MSCND1355B05.fareast.nevint.com ([117.128.58.94]) by smtp.gmail.com with ESMTPSA id d18-20020a17090b005200b0028d70a8d854sm857733pjt.54.2024.01.10.00.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 00:11:37 -0800 (PST) From: Zqiang To: paulmck@kernel.org, frederic@kernel.org, quic_neeraju@quicinc.com, joel@joelfernandes.org, qiang.zhang1211@gmail.com Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rcu/nocb: Fix WARN_ON_ONCE() in the rcu_nocb_bypass_lock() Date: Wed, 10 Jan 2024 16:11:28 +0800 Message-Id: <20240110081128.18683-1-qiang.zhang1211@gmail.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: For the kernels built with CONFIG_RCU_NOCB_CPU_DEFAULT_ALL=y and CONFIG_RCU_LAZY=y, here are the following scenarios that will trigger WARN_ON_ONCE() in the rcu_nocb_bypass_lock() and rcu_nocb_wait_contended(). CPU2 CPU11 kthread rcu_nocb_cb_kthread ksys_write rcu_do_batch vfs_write rcu_torture_timer_cb proc_sys_write __kmem_cache_free proc_sys_call_handler kmemleak_free drop_caches_sysctl_handler delete_object_full drop_slab __delete_object shrink_slab put_object lazy_rcu_shrink_scan call_rcu rcu_nocb_flush_bypass __call_rcu_commn rcu_nocb_bypass_lock raw_spin_trylock(&rdp->nocb_bypass_lock) fail atomic_inc(&rdp->nocb_lock_contended); rcu_nocb_wait_contended WARN_ON_ONCE(smp_processor_id() != rdp->cpu); WARN_ON_ONCE(atomic_read(&rdp->nocb_lock_contended)) | |_ _ _ _ _ _ _ _ _ _same rdp and rdp->cpu != 11_ _ _ _ _ _ _ _ _ __| This commit therefore use the rcu_nocb_try_flush_bypass() instead of rcu_nocb_flush_bypass() in lazy_rcu_shrink_scan(), if the nocb_bypass queue is being flushed, the rcu_nocb_try_flush_bypass will return directly. Signed-off-by: Zqiang --- kernel/rcu/tree_nocb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index d82f96a66600..9b618842c324 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1381,7 +1381,7 @@ lazy_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) rcu_nocb_unlock_irqrestore(rdp, flags); continue; } - WARN_ON_ONCE(!rcu_nocb_flush_bypass(rdp, NULL, jiffies, false)); + rcu_nocb_try_flush_bypass(rdp, jiffies); rcu_nocb_unlock_irqrestore(rdp, flags); wake_nocb_gp(rdp, false); sc->nr_to_scan -= _count; -- 2.17.1