Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp750803lqe; Sun, 7 Apr 2024 02:03:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUIxq4H9zjqriKxX7KWOCLyrlx+YVLyKLDtTYIusgm0xQdpAh+8IFg3ydXSBvwpgglGxiCtj3L6RNmD+r60phMI7pk/ZRPJNNOM6VaQTQ== X-Google-Smtp-Source: AGHT+IHCWXYpekBUD+lg9FjHAxUS/UoRTcak0kGBzRMz0Zyc+bm8Rbc9w6lieHJX83G9ltEjurxZ X-Received: by 2002:a17:906:eb4c:b0:a51:970c:acd7 with SMTP id mc12-20020a170906eb4c00b00a51970cacd7mr3809190ejb.21.1712480639342; Sun, 07 Apr 2024 02:03:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712480639; cv=pass; d=google.com; s=arc-20160816; b=WZ3ulvpBDX5nsvMN4ogi6mhivHjt/jL3SytDb4bAA+oKMxiNa/w77CJGpuFOTmZJcK vm7rZXmAECse08SE6RyYlhlXGH6TYK3pBnmsPapduYVJn+iwuv5Q8zDZ3sTIcMRYI9a7 TbT+m+FpbH5C/NYHaZ9Y9KzLW9m/E5Oe97drCxOW3EbuX6in2WACb5zINObw2sL3FUka 5ugja9avi5A24ujmXViYU2HmiWYl09Cdn+55hX7qwPKkMgWZuZjYOHejTt86ispjrRzs Bfww50I1sMAcStJb7RmladMPhVLLiejY3fFhqMGOAPHX5MQWj3VrXZ3Y9/UThLcxgt8I fKGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=c1Nt907o8edMLRxAYjTwIu4B/dw5DVN79x2+si+sMmU=; fh=eGvgkgXol9sq/GOf8AN/GeRRpWRGPY3mfCO02L1VJ6E=; b=OwMt4pVSip8MZ5OaombRjW+iXuTU9UkKVSjozS5C365Zm0tzoXA/hjQOutwbNqq85N kZGvQS2XH41o9c1qryehfLySD0RghW9sxxZD87Oq6f4aeRpWV5GNgJFgGT0E7x22rx5n BT9/8ul5K2mfTs2QBdcR2i9Rqq6YYvlobzkpXV5DOhLZC2C32oyHAO4MSZd1HW8y6qMn xS4/EhRkLx2wdRMqkb6w7VaEOEb9t4kCJVni8UIMS8RA1G7oJEXLnlRlAvx0ylcaxL5M qnp/uqlLve2pRNYDwHKViLfeUKGCAYL8AtnJbYxBgizOuKsjJuLV5Uzxqe7PctC9PiNg kstg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UpGLFiR6; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-134275-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134275-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h7-20020a1709063b4700b00a4deec978d4si2505616ejf.608.2024.04.07.02.03.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 02:03:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134275-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UpGLFiR6; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-134275-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134275-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 am.mirrors.kernel.org (Postfix) with ESMTPS id BBFF31F22243 for ; Sun, 7 Apr 2024 09:03:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64400179AD; Sun, 7 Apr 2024 09:03:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UpGLFiR6" Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 306CE156E4; Sun, 7 Apr 2024 09:03:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712480614; cv=none; b=mGWONMP1qULugokf+ff1MaPJMHhZXYL0DJrpEinHkr0+vmtkJz0cTH9/BZwfrowYcDroHvCnmC7yhmeoKfrT/BjwmM9BLJX2fG4IHUA1coYJE+px+R3xRZ4JxksiGg7pWEeZ7N1Tf2NQ18SCue6CHHmO8jar3XUTWJMxi4IVUdc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712480614; c=relaxed/simple; bh=3Gos612aoLPrsPFZpY6vzxas7L2U1yTGHX46XVU7dYQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FpQVbCR69AgR9n1tLcDp1wac568T8ARkHdU42G9nsPFg1Lem6oBCVF3LUl7AMeCyzXhOSOYIxqR1E3hEDqq4e8sn3TrLOgcTuYRF/KYhLj/6Zw9bbvJMcMHfHRuk3ACjOxt0UxumLfWQ63bfJp/Jks3x84iJAiAg5HrGcjWxx/8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UpGLFiR6; arc=none smtp.client-ip=209.85.210.171 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-pf1-f171.google.com with SMTP id d2e1a72fcca58-6ed054f282aso1516534b3a.0; Sun, 07 Apr 2024 02:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712480612; x=1713085412; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c1Nt907o8edMLRxAYjTwIu4B/dw5DVN79x2+si+sMmU=; b=UpGLFiR6XiGSy72KoXCIfrXlV1ckg6ap9YDZIxWsydi86nwNYyH2/EmRcSLuUdx+ep 3XFOTNkH17QuISCjf9RamU1+/oxA5p090FErc6l1oFExNGaRqU2cMfF0xn9Yl+Bucjbt jIqtlhvwcISVYqUXo7lrb0bKO8LyAvz/CXVO8zMfCxMoQpu9eMtufJ2nuv24khrAt8rU xzM48W1eC7dZ4B1JpOUyMDZBUEFpwVp0pJ7HIJtOqFAr+nu2BYoG7P0gcpj1CQsyFNOO 6K1oBUZgJl6NwX5P8sARWzH7+fV7h6SkICRzLa4zDqwhdK3vc8oqEKYs07rMcf327lRE pJfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712480612; x=1713085412; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c1Nt907o8edMLRxAYjTwIu4B/dw5DVN79x2+si+sMmU=; b=CR3mWv1QX0o6/G/opSwrwCC/P97dVQrym9B/riTPQKDKYhEgez80vmTrm7aDPyDwFG YsowHswI0v7ssZCKlodrbmxiXj+VndrX6P9oPz/YjH/8d6Qp+pt+8m5kvnPrH5JFKjnN b4d5DbpFBLaLl7d6ZcSo064SpitVIkG8n0k9b5YGPZmG5Wu+SFqBgGs5hY44FO71+sUP 47bv5q09io+6TbfbeLMyfsFwLlZHW1ND6xX0YCZVgy7KNMYxLEE9E0kWr9M8Vx1Y/jtH xNo8lV2Ut1j/b5iYBNzhkz2+u7yQlFTIsgp0PvlkghNRtMIw1fsxIw0Oqqlyij5xVf5z sgxw== X-Gm-Message-State: AOJu0YylI3EhTgMg33+1udNEiI44A8EBoepK5FaSJnCT56WmVCzWLyt3 RkTavsUjTPTEsKTM2cN8eVJvK0EEnuozvYS4W4uTWz81ZWy8mmq5RcsdeTnn X-Received: by 2002:a17:90a:df85:b0:2a1:fb5e:6028 with SMTP id p5-20020a17090adf8500b002a1fb5e6028mr4428255pjv.20.1712480612016; Sun, 07 Apr 2024 02:03:32 -0700 (PDT) Received: from localhost ([47.89.225.180]) by smtp.gmail.com with ESMTPSA id i13-20020a63220d000000b005cd8044c6fesm4267344pgi.23.2024.04.07.02.03.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Apr 2024 02:03:31 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: rcu@vger.kernel.org, x86@kernel.org, Lai Jiangshan , "Paul E. McKenney" , Peter Zijlstra , Frederic Weisbecker , Andrew Morton , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Subject: [PATCH V2 01/11] lib: Use rcu_preempt_depth() to replace current->rcu_read_lock_nesting Date: Sun, 7 Apr 2024 17:05:48 +0800 Message-Id: <20240407090558.3395-2-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20240407090558.3395-1-jiangshanlai@gmail.com> References: <20240407090558.3395-1-jiangshanlai@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Lai Jiangshan Use the general wrapper rcu_preempt_depth() instead of the open code. Prepare for enabling per-cpu rcu_preempt_count, in which case current->rcu_read_lock_nesting might not be synced with real depth. Cc: "Paul E. McKenney" Cc: Peter Zijlstra Cc: Frederic Weisbecker Signed-off-by: Lai Jiangshan --- lib/locking-selftest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index 6f6a5fc85b42..9bb41fb18088 100644 --- a/lib/locking-selftest.c +++ b/lib/locking-selftest.c @@ -1434,7 +1434,7 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask) #ifdef CONFIG_SMP int saved_mgd_count = current->migration_disabled; #endif - int saved_rcu_count = current->rcu_read_lock_nesting; + int saved_rcu_count = rcu_preempt_depth(); #endif WARN_ON(irqs_disabled()); @@ -1476,9 +1476,9 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask) migrate_enable(); #endif - while (current->rcu_read_lock_nesting > saved_rcu_count) + while (rcu_preempt_depth() > saved_rcu_count) rcu_read_unlock(); - WARN_ON_ONCE(current->rcu_read_lock_nesting < saved_rcu_count); + WARN_ON_ONCE(rcu_preempt_depth() < saved_rcu_count); #endif #ifdef CONFIG_TRACE_IRQFLAGS -- 2.19.1.6.gb485710b