Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp403521lqh; Tue, 7 May 2024 02:47:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXOIRtlUzOjgTpLl4abfeWBhFAPfyLF60bpkWb1b5WXcf84k1wIiuEj7k7qOqNNJgdo/804sO9IpPLgXMDs+unZwdzO9GFo/XVAVYsYQg== X-Google-Smtp-Source: AGHT+IH0T/ThZmuRhuZZDmzGWSFR4kT9YTqP3mBRtsowN7q3jUq62bO58Hvefvad/de9xXVGZAQB X-Received: by 2002:a05:6a21:8cc6:b0:1a9:a820:c604 with SMTP id ta6-20020a056a218cc600b001a9a820c604mr16985770pzb.48.1715075235687; Tue, 07 May 2024 02:47:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715075235; cv=pass; d=google.com; s=arc-20160816; b=QKwRiPQOH4x0t22RkPgkmdhiIx93siGf02X2uaRW2E+RHMjxMF233IPHPI/1GeSTzO KRSjPbn0ae8UDUy1y6e2NFebRXjqaW4105MeTt47en253JkUss4okoyyudkAe3eoNHYm kzCZzU1mLkqpRWlQG0p2UefE5u0tS1jpvifvt/ZrIVYb4EBN2qnRv31R53wyl7c0p4qp dA/wiD/OO+j3x/owR0pskB0NEgk1FnvDG1mycpXbe4bgxr32r35s0e2Da9w3a6ZrcSe6 CpLJo42MnLMNEr+1WHl04jVNiNxEffTbMlI8PQ2W+MqFXbVAOwPIRXWtK2OurMhi2vF7 /gsg== 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=WDinHeFOFRoHZYFqFBiK+RU+jTH857k5hI4wyyJy1g4=; fh=tgZivJUOUu2a2TYYLJlH+P/0P2c6LpnT9zDDj0QCM/k=; b=a/pyojUr8GVWtxvmbCAsx1P+ftb5kSA8e8ibuBgrxjs0Dl/BLnp38AT3YnoRfjtVO9 c3VSKMNB/rW8Dk+LoGczDC9X7PHt+G6tC4JqsLT9dAU/MWkOtprt+csj33KJ2IFnXCoX 16QoiavNq7c2YrNtexQ5gTHDvG6JGS1fmN5Jf2d6EbTCDWa6iiD8i9obHbxPtIXG8+IN 48t6+N8jnZVX6KwnLCkbL4miAbMFvInwbtmq4tIXp5LMBO/K1aqRrrIOknNyMx2Ngjft GkzVF3/VPhPjR5bPAyuKx0V9tmDSaA383ss5Cgs6J/zARaAG7uOZ32GVGnzxNh4FTdsG 42zg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="C/9ws5iR"; 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-170982-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170982-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b62-20020a62cf41000000b006f446816adesi9010346pfg.167.2024.05.07.02.47.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:47:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170982-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="C/9ws5iR"; 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-170982-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170982-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 61C92B24A37 for ; Tue, 7 May 2024 09:41:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B94BF15EFB9; Tue, 7 May 2024 09:36:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C/9ws5iR" Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 EE5BB15E818; Tue, 7 May 2024 09:35:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074559; cv=none; b=V+fIsk8QHADVyT4fMGYbwsYb8d4n0puTtfeXoCHAem8OjmOQLHU9N2FK7Ef8b0WegvGewN0J5YeNGh3MP72LuLzPP7wC2L72xvXtIJCcrWVVgyTIHjWgLzQmBIX/haLmFHN7wYtvUrTPlv/OLkHTCRuWcBBYPrxHMPN+Jpj1B9w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074559; c=relaxed/simple; bh=UN+MaHfAdkJ1rWWOKXorY2bu4/QkrbWb/32kAy3Tizk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tM6FzsWezZysHZMpgEbPsUwCrUaSPRZq7n8GJkfESNGZYXSQttvHFyvt3ewav1ONBBdn/sT+5Dha21LujDJ/uYBx31uej977Db9Tz3/Fz/WRAvRCH9f/Vh3RbMfnCdwGSa2ZQOar+EdbDJ7anONL8641M2Mt922RqD+oLUT53q8= 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=C/9ws5iR; arc=none smtp.client-ip=209.85.208.170 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-f170.google.com with SMTP id 38308e7fff4ca-2e0933d3b5fso37210831fa.2; Tue, 07 May 2024 02:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074555; x=1715679355; 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=WDinHeFOFRoHZYFqFBiK+RU+jTH857k5hI4wyyJy1g4=; b=C/9ws5iR8Fd7KKkeQ4Kn59FJN5sknAPLxGAfMJU2gJ+0U9rlCvyWfgE6CVG5/d3KI3 HX1b/Eq5/7pJpR//flWqXWVNvxZ3HlCmnmw8BadZ3G/Nsame69eM5URWCI/2SDl6/sHc Zoq2Q8ubZt7wZ3VmBwPfE+ba/IIbprm+8djhwENN4XnQJKL7WaOLUQPZhYsccs4GXNTS XeO941Ov2rhSfWjakwRuAgdonXdw38AV4N1JVx25HjAwdwfbstQhqhX0NOleyBK+LTtg P7x3j5AaYpvS+tKNTWr3Y+xCB/GICTDJ1Y2UKe38N5gSG0LEAVYS+mCFqfjl0/+wtqNv t9gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074555; x=1715679355; 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=WDinHeFOFRoHZYFqFBiK+RU+jTH857k5hI4wyyJy1g4=; b=sQqXiyKYuDIrzDIoeHBLatF7DUfMZTXNvn/loJ38aj0Ch7eIFzNIIwcVtKUhE3s47K 6anJkYw18C5SQXTDBrvZpaVlSwBypEz9/m6092I2Zha+6gZCDhB/Q7E4bu9fiScgb+ua W7wt7xo09MpPYXpoSYbWH0LdyeWpZWNRHJAIW6Rbn7ymsiwaK9D/VN9Eq7ECmGIAhdYH mhgSqnOY1nj7hq73kKfvJln3Ailwws1A/3lXJCSPNihndWfop6PYYrvdyvBxAmPSSlKN qHoyNUnOSEoBxxmJ37dFfNS49X5y4hK64NfW3+6JRnrnm69vN3Ngbo1obYpoQSnhYInw ym1w== X-Forwarded-Encrypted: i=1; AJvYcCU9XtaAStYvvUQCW9FchbTIra3Xj98+Cc7YmiH4tu44tKCD85156DuCrhzUcdgRy5GXxtawV64QI6LoahAw3Crrego7FYvWMXXCj56T X-Gm-Message-State: AOJu0YwrNzw7SXiUQbBBEW4SElOucbFYwKySlPDOAClfHBJ6vDUCQ7oI sOGkmtKX0GGXB+YMsijP6O4I8svaV1apT0sZ5wYl5I9PioJYc4tr X-Received: by 2002:a2e:981a:0:b0:2dd:409:3b25 with SMTP id a26-20020a2e981a000000b002dd04093b25mr8529160ljj.4.1715074554889; Tue, 07 May 2024 02:35:54 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:54 -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 , Linus Torvalds , Julia Lawall Subject: [PATCH 23/48] rcu: Remove redundant READ_ONCE() of rcu_state.gp_flags in tree.c Date: Tue, 7 May 2024 11:35:05 +0200 Message-Id: <20240507093530.3043-24-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 From: "Paul E. McKenney" Although it is functionally OK to do READ_ONCE() of a variable that cannot change, it is confusing and at best an accident waiting to happen. This commit therefore removes a number of READ_ONCE(rcu_state.gp_flags) instances from kernel/rcu/tree.c that are not needed due to updates to this field being excluded by virtue of holding the root rcu_node structure's ->lock. Reported-by: Linus Torvalds Closes: https://lore.kernel.org/lkml/4857c5ef-bd8f-4670-87ac-0600a1699d05@paulmck-laptop/T/#mccb23c2a4902da4d3c750165329f8de056903c58 Reported-by: Julia Lawall Closes: https://lore.kernel.org/lkml/4857c5ef-bd8f-4670-87ac-0600a1699d05@paulmck-laptop/T/#md1b5c026584f9c3c7b0fbc9240dd7de584597b73 Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tree.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 2795a1457acf..559f2d0d271f 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -1463,7 +1463,7 @@ static noinline_for_stack bool rcu_gp_init(void) WRITE_ONCE(rcu_state.gp_activity, jiffies); raw_spin_lock_irq_rcu_node(rnp); - if (!READ_ONCE(rcu_state.gp_flags)) { + if (!rcu_state.gp_flags) { /* Spurious wakeup, tell caller to go back to sleep. */ raw_spin_unlock_irq_rcu_node(rnp); return false; @@ -1648,8 +1648,7 @@ static void rcu_gp_fqs(bool first_time) /* Clear flag to prevent immediate re-entry. */ if (READ_ONCE(rcu_state.gp_flags) & RCU_GP_FLAG_FQS) { raw_spin_lock_irq_rcu_node(rnp); - WRITE_ONCE(rcu_state.gp_flags, - READ_ONCE(rcu_state.gp_flags) & ~RCU_GP_FLAG_FQS); + WRITE_ONCE(rcu_state.gp_flags, rcu_state.gp_flags & ~RCU_GP_FLAG_FQS); raw_spin_unlock_irq_rcu_node(rnp); } } @@ -1910,8 +1909,7 @@ static void rcu_report_qs_rsp(unsigned long flags) { raw_lockdep_assert_held_rcu_node(rcu_get_root()); WARN_ON_ONCE(!rcu_gp_in_progress()); - WRITE_ONCE(rcu_state.gp_flags, - READ_ONCE(rcu_state.gp_flags) | RCU_GP_FLAG_FQS); + WRITE_ONCE(rcu_state.gp_flags, rcu_state.gp_flags | RCU_GP_FLAG_FQS); raw_spin_unlock_irqrestore_rcu_node(rcu_get_root(), flags); rcu_gp_kthread_wake(); } @@ -2426,8 +2424,7 @@ void rcu_force_quiescent_state(void) raw_spin_unlock_irqrestore_rcu_node(rnp_old, flags); return; /* Someone beat us to it. */ } - WRITE_ONCE(rcu_state.gp_flags, - READ_ONCE(rcu_state.gp_flags) | RCU_GP_FLAG_FQS); + WRITE_ONCE(rcu_state.gp_flags, rcu_state.gp_flags | RCU_GP_FLAG_FQS); raw_spin_unlock_irqrestore_rcu_node(rnp_old, flags); rcu_gp_kthread_wake(); } -- 2.39.2