Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp399777lqh; Tue, 7 May 2024 02:39:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXBDVIW0Fk00BWEhk9f3RdhZ9lj5bJvS1FHg86kYgJS3sDvesGhNIQZGIipHffFTNmjr5yXPhUN/Fn2yyfD3L5SRSnqULBaKRybenuTMg== X-Google-Smtp-Source: AGHT+IEAbm306oDYB/uirjtxtq49Ff6XBCendOzjriUdydIGLfiuVBBLnAe8dVV7phjHfJY/fe1r X-Received: by 2002:a17:907:7242:b0:a59:bd14:1f51 with SMTP id ds2-20020a170907724200b00a59bd141f51mr4993004ejc.41.1715074791862; Tue, 07 May 2024 02:39:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715074791; cv=pass; d=google.com; s=arc-20160816; b=a8xO0zfKaIgXKYsF47p9rLN7GmTZHikNCP4P3nY3Tn4jpt9/GTCUptHvcVW7zgGmT9 oURQVKZHhHOqw7o8N3+RG7hPexJ5V3rc2b5Py/bpex16f/ubneN+EGUx2U8UEagPccx3 TZ9UDgV7Acqton2jhhBM5drwUskX34eVgjdhgnyPQby0lhHgGq95ohqfAhmquElV4vjY 51eYdDUjvLSwWbvz2Ai317yCBNRQuR0ZPuASh+plClfQJIfAvr5FVHGA695MCOIDqQXm BZXeAx28Xy/L2DT72MxNnPe9zGaJmTg967yYFWP00eslVQ6gIlVl1z1urjvWQIAX/L3i Wh6w== 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=6u5ux+babHEh3iKjrb16crvTQ8dT+WrG3HJ02SvwUbk=; fh=koHB5+ZsF/v2a8lLpQ1lj5pO4jsH+puZqGFKiqoAOUM=; b=EcGCjNtiEWibDiHaapaNn4+lHWVDkAyBmQgOKpyTxMMVqrWqChuFu4eaM4gxB7dTjC U6SsWMeqvi1b201ZRWVsSSSYpbGByap/MTPdzitxVGs2Y0PkiCJLlzSy50urPckXOpGP rE2S+rssyx3NxQW+1R45ba3cX+BucJJ9PVRmka/LyK5lWRhZ5MJxs5g+uxfOnPELSC/x Kl8RIcUOhkSUHgPVrvrjLI2UkFB/mgb3SuYtGXK32LPH7JZ2oE3YcTfcjgadPf8fLHIh jBBMAP55pBPFTdU7Uf7IXxg7vehu+sry9tM/tWIZxzmeiaK1WJJi2Nc+j/zcU/spEBr6 qxgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QaFmP+d6; 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-170976-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170976-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 gv21-20020a170906f11500b00a59b13a4f61si3300567ejb.444.2024.05.07.02.39.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:39:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170976-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=QaFmP+d6; 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-170976-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170976-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 9673B1F23FFD for ; Tue, 7 May 2024 09:39:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF51815E5B0; Tue, 7 May 2024 09:35:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QaFmP+d6" Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 5A74E15D5C8; Tue, 7 May 2024 09:35:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074553; cv=none; b=nBI1laWcuaF7upX2BqiehXgNuZM1KBtbxBo2CrU8jqraDqu0cKQqdw8PcnemxdoEF/7dDbyrbmdZ5BvpBiSA+qXfL3hT7/+i8KVD75MHBiGmJGrC2gge8Hxl5X9ol1T0jUBuEep527GpEWBy5BpwXRykSldiLWhPRTW8Ptc0ggQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074553; c=relaxed/simple; bh=2LOVrQyF12vAmEu/o2Pc3Gqxkejx5J3xKLLX1Ni5V0I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VO2TbCPXLuMCPwNvGdZ3LnFvrU0rDRArMtMBAYRAm/DYp7BlY5V8HukP3S0V0KLaFEQVFz8TuyUcBxlVgt6+diq7M7SJ5wCX0NTkxZOs8+gu89V0LS9e5L+VFCOlXRc0+SE44v5UzDUBS0FWgUFY3OCOVRJWTOEza1WQmQqJ+rY= 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=QaFmP+d6; arc=none smtp.client-ip=209.85.208.174 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-lj1-f174.google.com with SMTP id 38308e7fff4ca-2df83058d48so35508451fa.1; Tue, 07 May 2024 02:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074549; x=1715679349; 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=6u5ux+babHEh3iKjrb16crvTQ8dT+WrG3HJ02SvwUbk=; b=QaFmP+d6bR+Mi7zYKq7ptwZYVAcCVPNucagNk5twOzJVXC/dXFce2Rrkz0xhztYceC G0YPC67mgRhoJ5zpBkg7qvOUbxNQbNedg5qGD4ThLUFvQWT3hqNi/8gHMZAoHtrGUyGm OB6EdZ3518Wu89kdMzInAxRW+97utrVkBR7zPsB7XDd7TjkmuMf6vMeKfgy3fm74YaB2 TCUVdI2KAZPRSAol60g8PHiN+PDqzEUK9w0onrvuOIa9gVwa24uAQi3nNB0XeJy1FRFF qZuY4rCwqtTFpO6tpoD4CVbqH3Be4W8PFFqkU/1N/qskmB9SPRPYMWBFmtrw6vXu0FTR j/+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074549; x=1715679349; 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=6u5ux+babHEh3iKjrb16crvTQ8dT+WrG3HJ02SvwUbk=; b=wMoU94t5cdomj1IL3nJ89QcFNVH6YTddKu5HWzHXhHRD0RnGL7Vc9jznkpUUo+Sw6I YbniQCuIl5oLuYP15Kd6tDZn/THoKTqFKxAiLgRHJDMaSuCOoanJxvv18tFtPn8CqZJ+ Y3BTKImKetIVQnq5gRQJmaHsdqlCoBaq72GIBlCnOHaxxld7+czon7SpDz25yUP+EuSQ 2dO6TXO+b9YbLoehUusR7gziH7MouERWzy/uqv8hijVjBYtrrNKQu1vKhtD3cR/byl+M yMFXe+CD9EJy98udo52aGFdSX/cY5ftPAeL6hjjRbPiRCoQ39okL5WPXQMYbsCvr10jv yEeA== X-Forwarded-Encrypted: i=1; AJvYcCX6xeAy4sPcfgv5W1QZwQwf9v73EwmeRQu1ZzsBexlKAW62F90P76OuoitiQVH9M48Iap8hQlEeF19OHx65VyacOY2R2kUjBOYeDrCx X-Gm-Message-State: AOJu0Yz9eIiOZufavDMa3s3Ul8JxbAyZtjwTU9TwgiJ634CPiVXD6thY tog7mnUbHntqupNbIqz4jURMygIQcWueDLpjx0d5YO8qSZS2twNCIh/G2u/1 X-Received: by 2002:a05:651c:a04:b0:2e1:e553:7b9b with SMTP id k4-20020a05651c0a0400b002e1e5537b9bmr8674655ljq.45.1715074549444; Tue, 07 May 2024 02:35:49 -0700 (PDT) Received: from pc638.lan (host-185-121-47-193.sydskane.nu. [185.121.47.193]) by smtp.gmail.com with ESMTPSA id t18-20020a2e9d12000000b002e29c50c4dcsm1335473lji.27.2024.05.07.02.35.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:49 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: "Paul E . McKenney" Cc: RCU , Neeraj upadhyay , Boqun Feng , Hillf Danton , Joel Fernandes , LKML , Uladzislau Rezki , Oleksiy Avramchenko , Frederic Weisbecker , Ankur Arora , Thomas Gleixner Subject: [PATCH 17/48] rcu: Update lockdep while in RCU read-side critical section Date: Tue, 7 May 2024 11:34:59 +0200 Message-Id: <20240507093530.3043-18-urezki@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240507093530.3043-1-urezki@gmail.com> References: <20240507093530.3043-1-urezki@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 With Ankur's lazy-/auto-preemption patches applied and with a lazy-preemptible kernel in combination with a non-preemptible RCU, lockdep sometimes complains about context switches within RCU read-side critical sections. This is a false positive due to rcu_read_unlock() updating lockdep state too late: __release(RCU); __rcu_read_unlock(); // Context switch here results in lockdep false positive!!! rcu_lock_release(&rcu_lock_map); /* Keep acq info for rls diags. */ Although this complaint could also happen with preemptible RCU in a preemptible kernel, the odds of that happening aer quite low. In constrast, with non-preemptible RCU, a long critical section has a high probability of performing a context switch from the preempt_enable() in __rcu_read_unlock(). The fix is straightforward, just move the rcu_lock_release() within rcu_read_unlock() to obtain the reverse order from that of rcu_read_lock(): rcu_lock_release(&rcu_lock_map); /* Keep acq info for rls diags. */ __release(RCU); __rcu_read_unlock(); This commit makes this change. Co-developed-by: Frederic Weisbecker Signed-off-by: Frederic Weisbecker Co-developed-by: Joel Fernandes (Google) Signed-off-by: Joel Fernandes (Google) Co-developed-by: Boqun Feng Signed-off-by: Boqun Feng Signed-off-by: Uladzislau Rezki (Sony) Reviewed-by: Paul E. McKenney Cc: Ankur Arora Cc: Thomas Gleixner --- include/linux/rcupdate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 17d7ed5f3ae6..2c54750e36a0 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -809,9 +809,9 @@ static inline void rcu_read_unlock(void) { RCU_LOCKDEP_WARN(!rcu_is_watching(), "rcu_read_unlock() used illegally while idle"); + rcu_lock_release(&rcu_lock_map); /* Keep acq info for rls diags. */ __release(RCU); __rcu_read_unlock(); - rcu_lock_release(&rcu_lock_map); /* Keep acq info for rls diags. */ } /** -- 2.39.2