From patchwork Tue May 7 09:34:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656488 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 8A67014E2E7; Tue, 7 May 2024 09:35:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074538; cv=none; b=aK6JfATTN4pFa0jAPMhrAwqWmBUnHOe4TCja3IfMOudaO+iI0Ey0EYmxRBj2wG1Extg0JHnQqKNcXzDi1gONgbGGC/3loTessFr2u5Ih0ufcmcR+Tyb4ZctDHD/MEhpBQjqFsan7FQ1sr0hZto7pBJq6TxR+4mqq5xkckkQwATw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074538; c=relaxed/simple; bh=gnS9CcaEQlXpIi1QO4y2SeHwVRYTfdUPzWNA0ABAbJI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dlCCYjPgg9cOymn1+Jsfw9/2AI25wo1QaNzqU+BhUm9DWxtVWP6nfgIPfZh9/bkDSByMAvbeo6+J4x4AYelZt7AXe3Cqpeor2HERhftQScfypE59bbq/N+/tDvoutw10dOb0/O+1dBvXgCCqg7UseKcixghMNqPDlQpUndcHMFU= 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=MQv1Y/LI; arc=none smtp.client-ip=209.85.208.181 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MQv1Y/LI" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2e2c70f0c97so36444451fa.0; Tue, 07 May 2024 02:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074535; x=1715679335; 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=eKSxKw3J4u17pMf8rY4oBSyEujXxW/P4ah2ldg1dFIM=; b=MQv1Y/LI9peGIksVlJHcV/PjTapie5DQkGg4WuOSbewgUt7pb8ZAQ9Cyd9ih/HG1o2 crRzx+5L0B2wuCzJnE6Co9QDY25eqfQHIMzK3Q66/rGFBQ8mXhagYnsxz1UcE/+UGOIR y7cW7vESNZq94zkfFlUo3/Er7UebHSg3lp5/z87ZVHsBqw1cGB5Mqq7VAVFgKfvW0Hsr Ymwx+bjEJgzhDd8a07tXyUpYo/QcpfTedaXDKCTX2RTAt8oWHDHGz8GoYftOwTcpZS0r OCv/IKiHc2+ZBr/595tS7V8MjPrNzlotpbkzSF8taQXDaQUE26QIh+5e3OzdQGacWDpk 4WqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074535; x=1715679335; 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=eKSxKw3J4u17pMf8rY4oBSyEujXxW/P4ah2ldg1dFIM=; b=DF1jGAAqh2KWmZey9mZ4rAf/wCG5zIViz7V8QQrDKRJh88Bz+6CYZcfjC3R5Q6AJkn Lqvbw0b1j/bdcDZ7dUoZPHtBiFQp7JqWuGvub4j/UTIWmyLxOpk147b7oce+GD9WwnQE dq9Pp9CbON5Qh/cC3kmWnugBRnYqPu+JExfHtfBlaxAg/lmEEJZyAmK822JjCj3xphQr XnomeLsCSWHErjfjHfxaLwK9335cC1kJhF2xD9BA7iIr8iQGXggRNE7EGXIfdsqdHvJA HhZlyZQhkaliR3X+hmjYcXiLpz10ShT5aBrctWa3RJaXKDsqxdRoXXTNJkRpQRgoKvnI LPng== X-Forwarded-Encrypted: i=1; AJvYcCVW1VNSHYVgkclxOl+JZdfS0yCgym/bX7bMAPgAYVQ+1yDRzXrnX7zvAJTr6v+qMc+6TM8ygaRP4YbitWdOWtrG45Os/blLQAOs6ptL X-Gm-Message-State: AOJu0Yxsb62SGe1T59swG9h9U1gmH8zkUldu3+BCgvHpKtUcH3KZ9Vem +6+m9QjVTSh41B2eorTjOhSRbjW4cfgioKcDCTHZgp1ZaTn6hLyx X-Google-Smtp-Source: AGHT+IGw1vTX1PP1f28XdFs43ofUOjMPjmA6T0iqArywpnhpbVZBrbGOZls0Ql5fr4s0md0S/FAbeA== X-Received: by 2002:a05:651c:1035:b0:2e1:ebec:1ded with SMTP id w21-20020a05651c103500b002e1ebec1dedmr7848663ljm.25.1715074534369; Tue, 07 May 2024 02:35:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:34 -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 Subject: [PATCH 01/48] scftorture: Increase memory provided to guest OS Date: Tue, 7 May 2024 11:34:43 +0200 Message-Id: <20240507093530.3043-2-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" The tradition, extending back almost a full year, has been 2GB plus an additional number of GBs equal to the number of CPUs divided by sixteen. This tradition has served scftorture well, even the CONFIG_PREEMPT=y version running KASAN within guest OSes having 40 CPUs. However, this test recently started OOMing on larger systems, and this commit therefore gives this test an additional GB of memory. It is quite possible that further testing on larger systems will show a need to decrease the divisor from 16 to (say) 8, but that is a change to make once it has been demonstrated to be required. Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- tools/testing/selftests/rcutorture/bin/torture.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/testing/selftests/rcutorture/bin/torture.sh index bbac5f4b03d0..42f0aee09e51 100755 --- a/tools/testing/selftests/rcutorture/bin/torture.sh +++ b/tools/testing/selftests/rcutorture/bin/torture.sh @@ -425,7 +425,7 @@ fi if test "$do_scftorture" = "yes" then # Scale memory based on the number of CPUs. - scfmem=$((2+HALF_ALLOTED_CPUS/16)) + scfmem=$((3+HALF_ALLOTED_CPUS/16)) torture_bootargs="scftorture.nthreads=$HALF_ALLOTED_CPUS torture.disable_onoff_at_boot csdlock_debug=1" torture_set "scftorture" tools/testing/selftests/rcutorture/bin/kvm.sh --torture scf --allcpus --duration "$duration_scftorture" --configs "$configs_scftorture" --kconfig "CONFIG_NR_CPUS=$HALF_ALLOTED_CPUS" --memory ${scfmem}G --trust-make fi From patchwork Tue May 7 09:34:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656489 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 51EC114E2EA; Tue, 7 May 2024 09:35:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074539; cv=none; b=l6E/Sy3b5JHdI8A/uF7K05MoJVDYL+bfHmjRYTvdb2xzSSYTlR+3BagfZrCDWaFbwoR3HPNZX/hCHh3lLFHlNtZCDYG7HeIqZSeydVkBrMYBdZjuuVeGk36t9dOpPBgiW1xDeWXCp6elEGQL+M8Hlv5mSau9ASNpbUxkyKmGcH8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074539; c=relaxed/simple; bh=iNxM3spYrH6jeXcFwXys+CzMIvg4TpaHf/M60KZ2Phg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=leeZ/0vW3Afklv2V7Cl5ET+oebUEl2LEK0nGcoYifN9JGpjHFW+vDgcQTt0BobPTFiW4/c6EUUnivsbEVk/KND1XcWPcxQ/I/X+8Az+aoi4dL/1lU1Y3RZypKKI81O9bLkgTiSw+yrID4sXUbvcXg/lPXtSeBuJ0hPccp02eGHc= 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=dWX85Njf; arc=none smtp.client-ip=209.85.208.175 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dWX85Njf" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2e242b1df60so34978091fa.1; Tue, 07 May 2024 02:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074535; x=1715679335; 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=+/dZXNHdnJdCiQVj1yFaboz7N4dw9CdxnQ0QkyKzyjM=; b=dWX85NjfDU1dLHmn/LnX0juXUVZ5dbtLev98m1MoocgMfX6NKRaBzA9srQ31mCpH3D nmtLXmIH6+0C+5MOSDUlNSH5H5SWlFflJbo6OhZXcGxyn7o1G50KD8IcdiPaYGRurIzp 5VF65KpvN1PtoahnOUXzKYZFZFg0S6Zm/ATZVArHXJSflL5ydsPri9aIwdkT0Vyb/xpm 17Ej7Lfz5DkYjLIEZuVlD2EeMXF0eqQLO6okRXyKEYOXrbZ+SX/pmuRLBM+s9w2Ys35r dgIpfjMica+E9aBoiKX+p2/gqMPvVGqVPfbzdB1v6a3w0OPlkNYeDk93XVHUeXk+CItH HbbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074535; x=1715679335; 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=+/dZXNHdnJdCiQVj1yFaboz7N4dw9CdxnQ0QkyKzyjM=; b=GBuyh7mBK9UDucaa3ih2hgZJ8gLPARFA8JqoUlHUsHueyKw6JnugHsKkj6MHwgC0KL 6QU7cK5ECwyVBNKHgLFHcgxNyFg8hbmMiZzIv78vodq/4W6sms83i+DulDpqCJLkQ41H XcXdxiJTHz/rQLcPhvzsPob0VavgwAdtLJNLU6ToYAiHzJMbs8d9ilqyy1esjv/MZgQ0 9HfuAXphKx0j1hcWm47S5i2TkCKPGvRAKR42GSud1zaLluYm8c20AoOT88Z2dwDZNtoz 0HZTxcLdXB+OuMtd1CfOo4RfD6sO3zGlMgHNLazIHzEjbNFYXQ8qExkbBwfBLmSqbYL4 bvkA== X-Forwarded-Encrypted: i=1; AJvYcCX4cIBYFCZmRbQ0HkGD3J+N1427e1n+DkBuDiYjg8txDpFxyIZ5ZrUVs5bwE9p6bWyo4mEt5rKtv2V8D1HKFHssiZmFJX7xaB+7IG93 X-Gm-Message-State: AOJu0YyBYf6KRu5Gy2YIslssswvgLIV7EvzIbvCYRZrTC5M2jCUwFvn5 brOtfe8IJtlPlB3w19KeG1jND5hpZWqwV1RbZfObcKbYF7J4CCeF X-Google-Smtp-Source: AGHT+IHGTGPMhUFWAjkriGKAKoiR1qDCoYN8/LSNdR+hMlhqCKcWYj/0UPIAVbRMNGNQEoL6wqkafw== X-Received: by 2002:a2e:800b:0:b0:2dd:ccb6:e836 with SMTP id j11-20020a2e800b000000b002ddccb6e836mr10197448ljg.25.1715074535187; Tue, 07 May 2024 02:35:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:34 -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 Subject: [PATCH 02/48] rcutorture: Disable tracing to permit Tasks Rude RCU testing Date: Tue, 7 May 2024 11:34:44 +0200 Message-Id: <20240507093530.3043-3-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Now that the KPROBES, TRACING, BLK_DEV_IO_TRACE, and UPROBE_EVENTS Kconfig options select the TASKS_TRACE_RCU option, the torture.sh tests of enabling exactly one of the RCU Tasks flavors fail. This commit therefore disables these options to allow this testing to succeed. Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- tools/testing/selftests/rcutorture/bin/torture.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/testing/selftests/rcutorture/bin/torture.sh index 42f0aee09e51..13875ee7b050 100755 --- a/tools/testing/selftests/rcutorture/bin/torture.sh +++ b/tools/testing/selftests/rcutorture/bin/torture.sh @@ -391,7 +391,7 @@ __EOF__ forceflavor="`echo $flavor | sed -e 's/^CONFIG/CONFIG_FORCE/'`" deselectedflavors="`grep -v $flavor $T/rcutasksflavors | tr '\012' ' ' | tr -s ' ' | sed -e 's/ *$//'`" echo " --- Running RCU Tasks Trace flavor $flavor `date`" >> $rtfdir/log - tools/testing/selftests/rcutorture/bin/kvm.sh --datestamp "$ds/results-rcutasksflavors/$flavor" --buildonly --configs "TINY01 TREE04" --kconfig "CONFIG_RCU_EXPERT=y CONFIG_RCU_SCALE_TEST=y $forceflavor=y $deselectedflavors" --trust-make > $T/$flavor.out 2>&1 + tools/testing/selftests/rcutorture/bin/kvm.sh --datestamp "$ds/results-rcutasksflavors/$flavor" --buildonly --configs "TINY01 TREE04" --kconfig "CONFIG_RCU_EXPERT=y CONFIG_RCU_SCALE_TEST=y CONFIG_KPROBES=n CONFIG_RCU_TRACE=n CONFIG_TRACING=n CONFIG_BLK_DEV_IO_TRACE=n CONFIG_UPROBE_EVENTS=n $forceflavor=y $deselectedflavors" --trust-make > $T/$flavor.out 2>&1 retcode=$? if test "$retcode" -ne 0 then From patchwork Tue May 7 09:34:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656490 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 40DE114E2F1; Tue, 7 May 2024 09:35:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074539; cv=none; b=iAUEYkj4r9Wdg/6whBMmefgoSDVttfoA5gfB/K/qH9mbxC76dVOWggg0cySJKR/GhBXDEiws/zYef37nujA/szWRSMilG3M/kaGRtj1ZiaXBboUnonT9Oq5a2jAgepIJdFdH+X27Hzi2Df1QCOZZG7uHK2/lyg8NxFPYdgixykU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074539; c=relaxed/simple; bh=+/Wzimi9IDd0AOad7JCOBMX+aJPeFaceFPRoaZUd6JQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZCWochjwwZwz9NztqWraIvMIuGg4l6idzMjg55a2fduCr/Z8Z1pg++R8NiPu+kSDJP5FZDpSJrB9qmijuq2h8K2u707NSmfl5RhXPjjFqoXgaz5XGzkaHAkgenyI97Jr3z8KKyk/vRrxCVFEA2qPRwpf5XnuCayIEZb7TqZ04Zs= 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=Qn9V5A0j; arc=none smtp.client-ip=209.85.208.172 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Qn9V5A0j" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2db101c11beso36565341fa.0; Tue, 07 May 2024 02:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074536; x=1715679336; 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=tHQ3wThlCa+tmPm7RaR+qFcrkGfD7gzEvoOA5PrmsZ8=; b=Qn9V5A0jesQZGCTXuVJHyqNGw/91oEXDjIgBz/SvXiZ9YgEOFnZ3GLIgWUxQi7Mkgi IdLpfkgpBsad/tqUYMYMscuLuqDTdvb7fdrjzWPazXJRw8/8nPYNrvq4GJKoHRzihu3p 6GT23cNQY1Qloec5lS22UXhNQmVsQK9OIAeaz63upP/VZZg4tDalQ7glnDbRvqTCRE19 LgNTPKaFuKycCmarguyQmGTyPMveC/07wz3cnsSV9wQ6qoxqgmO+I95gpdG+pnS3H/Ta 1UvVfnvx7a7iGATudsuL3BwehWn+Z5ZSKMm+3ERzR1rZkLWoYTeWfRr2mUGwCRRXTBv9 e4rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074536; x=1715679336; 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=tHQ3wThlCa+tmPm7RaR+qFcrkGfD7gzEvoOA5PrmsZ8=; b=CXjPGBIQoCbgcXn7xVJu/XpAvOaif58H4PK87Gi+TlMk+289DJ2m2H2T8PfzgQX/jf MWoVyZVAozg4fQz4xO+HUf25/DnXY0nKqbu2SMCs3ehSnax+BU4kkiVeQZ9qe+lPo+8j ZON+W9eNMSIf4lo2ZzU1fEMfc4j5sS0KT9pEnQOy9mGkFV3KzBvDi+7G4Cyjd8m/FV2M QD7dE5nwM4AGlDdlX2KwSmkgtWFYM0HjqbqN+2jjGvFTI3hppykGFKjUZDNIcKpwyvii +heNTR9DFhrOCb8KsZ+mnxAo8GemcAJc+LN0vbWlajIZKC1jKaOLxM2X9MPmWSZ2Tetd njvg== X-Forwarded-Encrypted: i=1; AJvYcCX1J+RbDqD9+y0rw6COw06z8VEGi5ub7/EWn1T2VMLrTIvxOZNv7rUOmg4wRnynzazsr0KYF1gpcp6nrOKVq0xCtSNO6pHdnhH/QlECOwA57LgK/crFnk7OpFUgi49tTmGg+Dzp X-Gm-Message-State: AOJu0Yzth5zG1sWevcu579UGoEjy0q0draT/MwMZmMTrZRUU3gB6xS3W GJIEflqCsXSViVMphY3hFMPV769ryHnG5LsqkegdcXH/mXFd3OFz X-Google-Smtp-Source: AGHT+IH3kyXVRJ4PLiuJO5l/3kxoCLnD2cm+0pheedS9Aj4zvXVnedQGHMETTqwaLGYpsfRGaYHCpA== X-Received: by 2002:a2e:9585:0:b0:2df:b800:5bff with SMTP id w5-20020a2e9585000000b002dfb8005bffmr8142337ljh.7.1715074536291; Tue, 07 May 2024 02:35:36 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:35 -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 , Eric Dumazet , Jakub Kicinski , "David S. Miller" , Yan Zhai , netdev@vger.kernel.org Subject: [PATCH 03/48] rcu: Add lockdep checks and kernel-doc header to rcu_softirq_qs() Date: Tue, 7 May 2024 11:34:45 +0200 Message-Id: <20240507093530.3043-4-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" There is some indications that rcu_softirq_qs() might be more generally used than anticipated. This commit therefore adds some lockdep assertions and some cautionary tales in a new kernel-doc header. Link: https://lore.kernel.org/all/Zd4DXTyCf17lcTfq@debian.debian/ Signed-off-by: Paul E. McKenney Cc: Eric Dumazet Cc: Jakub Kicinski Cc: "David S. Miller" Cc: Yan Zhai Cc: Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tree.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index d9642dd06c25..2795a1457acf 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -240,8 +240,36 @@ static long rcu_get_n_cbs_cpu(int cpu) return 0; } +/** + * rcu_softirq_qs - Provide a set of RCU quiescent states in softirq processing + * + * Mark a quiescent state for RCU, Tasks RCU, and Tasks Trace RCU. + * This is a special-purpose function to be used in the softirq + * infrastructure and perhaps the occasional long-running softirq + * handler. + * + * Note that from RCU's viewpoint, a call to rcu_softirq_qs() is + * equivalent to momentarily completely enabling preemption. For + * example, given this code:: + * + * local_bh_disable(); + * do_something(); + * rcu_softirq_qs(); // A + * do_something_else(); + * local_bh_enable(); // B + * + * A call to synchronize_rcu() that began concurrently with the + * call to do_something() would be guaranteed to wait only until + * execution reached statement A. Without that rcu_softirq_qs(), + * that same synchronize_rcu() would instead be guaranteed to wait + * until execution reached statement B. + */ void rcu_softirq_qs(void) { + RCU_LOCKDEP_WARN(lock_is_held(&rcu_bh_lock_map) || + lock_is_held(&rcu_lock_map) || + lock_is_held(&rcu_sched_lock_map), + "Illegal rcu_softirq_qs() in RCU read-side critical section"); rcu_qs(); rcu_preempt_deferred_qs(current); rcu_tasks_qs(current, false); From patchwork Tue May 7 09:34:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656491 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 F234C14EC6E; Tue, 7 May 2024 09:35:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074540; cv=none; b=uhmF+zVVAPtVNyanRBoVukVQ0PvImpDjCtscGnJpT+Ld4aU0hNOsksgWsRU/BzrFG/HP/hJ6c+tBjQvCuoPy+GkwTp0KecAgmh9anUr4wlYBl92ktNj5HTkBjjuC4t6KTmpTbw3CmDsIDMTgzhuT46k+nfBdXcKBVC82E88V1TQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074540; c=relaxed/simple; bh=SwXMBkAHbGHY45sy8CaLSa2Ff0hHYoq/irtkVE3Cotg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ja9lkR2nwVyzrrK9rfvFLKHV7tb1s+upofSCwLlP+gv4BM1sCi5knqKNejx8lx+cb8p7C5HrZoU+FMkQLmDsXsT40KSFyt62CLj9oWBtLtM3u+yvMOO64CnujsYu9eDPIhqArBdqDCZvN4xtehz1nFjiTsVuxhfVqCV+0KOiIh0= 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=lN87LEEB; arc=none smtp.client-ip=209.85.208.182 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lN87LEEB" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2e1d6166521so42219321fa.1; Tue, 07 May 2024 02:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074537; x=1715679337; 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=YbfiHnjmo3bJ9ltYrcPbr8miklUfUo24oHJfMl/NaTk=; b=lN87LEEB7Vlbi+VvSli5eJfGpDCzeL2JK9xXxWJNnFYjrHaXYLd/8QnUxDTxeam1oH GbH0ocqg8NJTZ7EptrDbr5C/nc4UED0cbiWU8zz+Pwi3mqVkOAEG/C6efkVxv6iGt+Q5 odJhzMHBEElAPSA9IyALmKGyxHRBVdS7VBF03gs1rkKEtjEFkVQGMiR1DtuSTA4R/GsD 2ofgNNa/xQowRVsehTEiOZHWj9Txjcp/mcnn6ejn8BV1WVr5j4VBm7y91fPfyYSfNvNn jsEx3qe89tVBrNlDZgYbFa/ld5VP8I3XxNW5dNbmo/OsxCSlT1oi0QOUyub7ZJBFP0e8 uz8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074537; x=1715679337; 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=YbfiHnjmo3bJ9ltYrcPbr8miklUfUo24oHJfMl/NaTk=; b=l1+9GwISxZ1fjPs0zOH2egNAxOGBeUls5qLaz/QYL4Fqd48cS4u3P319B4AZDVKCYC 33moi0+NoW/oUWjnSo2MzH9YiW2todH89I3YVV9pph9MapGDYIySxs+LKgpDlbawW1Td Wd0sltTw+Z4bRTUltZY/sZ4Yq025a6wuvRA84VCQs04cCONRYzuy/p/hSeSClEoEenGU SzcUYrG/exceDsyVO9CZ7aLY04ReDcHRzD+3JPdeINgP2vgelcrLKa8BZ9ogu1zEiYoa gnJ/pDuH9VSGY3Q/Jw9ZEjjeMO3CYiUJ8LhN7boYAoELOy35cwx1glZHCwq3bG2CknyN JJ0A== X-Forwarded-Encrypted: i=1; AJvYcCXukV0f92+zwYstPMybmx4H59vrK9epAi5eFE45J1r7qO6pq8Otxj5usFk6I74AvSGy0cxMu6yUzmKRtC2lDYZu4On2Z/KXmHUNjmVo X-Gm-Message-State: AOJu0YycWgK4vHLYGAaJz6R7omjY7a3moeYU5ragvidCionF7/hUYLc0 LlE2B9RXFSK/RtTwSIW2IwJwjTjcORe9jlHFOnD9azVATy5/X97k X-Google-Smtp-Source: AGHT+IG7hg4338f5EsIReZHWEu3tVUIcMMQTnQrYJokfQt195I6wm3Pv1x1RHLTY7b2gWAbPu/Xo8w== X-Received: by 2002:a2e:4e19:0:b0:2e1:d95b:3735 with SMTP id c25-20020a2e4e19000000b002e1d95b3735mr628024ljb.11.1715074537103; Tue, 07 May 2024 02:35:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:36 -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 Subject: [PATCH 04/48] rcutorture: Enable RCU priority boosting for TREE09 Date: Tue, 7 May 2024 11:34:46 +0200 Message-Id: <20240507093530.3043-5-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" The TREE09 rcutorture scenario exhausts memory from time to time, and this is due to a reader being preempted and blocking grace periods, thus preventing recycling of the memory used in callback-flooding tests. This commit therefore enables RCU priority boosting and sets the boosting delay to 100 milliseconds after grace-period start. Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- tools/testing/selftests/rcutorture/configs/rcu/TREE09 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/rcutorture/configs/rcu/TREE09 b/tools/testing/selftests/rcutorture/configs/rcu/TREE09 index fc45645bb5f4..9ecd1b4e653d 100644 --- a/tools/testing/selftests/rcutorture/configs/rcu/TREE09 +++ b/tools/testing/selftests/rcutorture/configs/rcu/TREE09 @@ -10,8 +10,9 @@ CONFIG_NO_HZ_FULL=n CONFIG_RCU_TRACE=n CONFIG_RCU_NOCB_CPU=n CONFIG_DEBUG_LOCK_ALLOC=n -CONFIG_RCU_BOOST=n +CONFIG_RCU_BOOST=y +CONFIG_RCU_BOOST_DELAY=100 CONFIG_DEBUG_OBJECTS_RCU_HEAD=n -#CHECK#CONFIG_RCU_EXPERT=n +CONFIG_RCU_EXPERT=y CONFIG_KPROBES=n CONFIG_FTRACE=n From patchwork Tue May 7 09:34:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656492 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 1CA6914F9DE; Tue, 7 May 2024 09:35:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074541; cv=none; b=Ys4S5Fb19P5h7D7/Dv1kKo6CRbAdcjl8ePkB0DPAQy1Wof/31CAG2vo2C71XRLQFE5iqFeMh7evzdShfo0g4k5mAXDDcSoKGYAMl7q6+RrgTyUYtR65sB1/B2WA0DN85UoqL00Htm6e4Ld7KG/E5ekWbFSJKhpGtxhGNW4wuj/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074541; c=relaxed/simple; bh=woWciDuB/Xya4YTrH1Yno35AomIgowF5eaSff2qzqBc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gECjGg+MTUc/xRuZZYdBoX+lpNeBJG0Tl1hXRqNmdt7T9HwzU1ZOs7UDygqRv76xx+vNUqzp+EGCY/m+vg0OufPTFv/VkhjTxlFmJ8I3I389fWvOqE2Qm6iINPzAsifEj7Y6PXT6t30Vw2h0tegEBeXiAIqacDLTaRXFnSnkWqA= 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=GThhpff7; arc=none smtp.client-ip=209.85.208.175 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GThhpff7" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2dac77cdf43so37615171fa.2; Tue, 07 May 2024 02:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074538; x=1715679338; 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=eclAVoj14Efpyk+hWPVGoQ5bvRfQw2I1KgUC6c1EF4Q=; b=GThhpff7B8Jfh0Ak17LSSKb55NG4Re8RVvwN13VWb9OER8xD6g5yJiPXolu2cjzhTa Vm7IG0kJqudqegw+Hb0zSsSvtrstuTO7mudWid+FvdHAB9Qh4nyFxlogVtEgnfjOHBbC 0A6SJ6EvaFVtwa9uTI+LUKKrLD58k9qgY1O3vWnJBrtoy+/PMsgkAsJYPPXlx0KwgzzV evKwzrj8QlBO2t6eJuz5F3tBuArI49GYolexkFwFsvyJVRVLPrDFOaQbSTLnr0NTcPfs GzmjjZutpfRHRJQmkHDjOX2QSaSSdJ4EYMdAY00Coc5i11+14mpAfHE2QoaNmI59NKVg BJCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074538; x=1715679338; 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=eclAVoj14Efpyk+hWPVGoQ5bvRfQw2I1KgUC6c1EF4Q=; b=oN9HDdkzppTF6a/g46as1ws/gVTlO0px8Y+tfVBT2clMpWSthfvhm5OFtSXb+ARNRO clyMpZBSzB1VASg+PLaXVlD3e7Cn5803RpyjNTxyN82Qc+C+vITrhoKmvc3sGjVpqFZ8 oz2owTLyYf3K6pIqfwHHXV8iJ3X1Ts19OD8pGrttKTwYM2Bd5gVa8b06quEIQKMXU7eK wNC9y7WA7Dfwe23sPCPvtLUdHHDnQP7uPjrEl8CgCL12atxFIsQ/v05IHMX0x2rAJx6g lletAe4V1gg+wqnQ4g/DoWVzdm7Uss/4WcOrIgR8Jgt290LFP+bBnmETm6wqV3rQQgqm 1Crw== X-Forwarded-Encrypted: i=1; AJvYcCXhBB3mvll0KMg4mXtl2DIJIvGbCzBN7dqh/jsF+huTWXvd27x1W5Z+pi24aJJYu3p7O+Z19TLoKj8RcMNKs6Higa/mplt7J+WzSTw+ X-Gm-Message-State: AOJu0YxBo+nDnJLsftlXQ2A31Sj3HxBp0U/b/0NOLYqSMC2Scehqlgbl qVccRn28BfwlNzrDyVCReZPk50DcT4L35ySP2Ot97XLws4Hhf6VrttvAMA== X-Google-Smtp-Source: AGHT+IGbYyKSNB5D70RlkZLzMwWIHSfHqLyIlG+C0IZsnXgPjVQk3IEXoTTrtyWHDjbtXjQYK5zuqw== X-Received: by 2002:a2e:80d3:0:b0:2e0:c689:f8cd with SMTP id r19-20020a2e80d3000000b002e0c689f8cdmr8709643ljg.29.1715074537908; Tue, 07 May 2024 02:35:37 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:37 -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 Subject: [PATCH 05/48] rcutorture: Dump # online CPUs on insufficient cb-flood laundering Date: Tue, 7 May 2024 11:34:47 +0200 Message-Id: <20240507093530.3043-6-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" This commit adds the number of online CPUs to the state dump following an unsuccesful callback-flood test. Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/rcutorture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 45d6b4c3d199..6611ef3e71c3 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2833,12 +2833,12 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp) if (!torture_must_stop() && !READ_ONCE(rcu_fwd_emergency_stop) && !shutdown_time_arrived()) { WARN_ON(n_max_gps < MIN_FWD_CBS_LAUNDERED); - pr_alert("%s Duration %lu barrier: %lu pending %ld n_launders: %ld n_launders_sa: %ld n_max_gps: %ld n_max_cbs: %ld cver %ld gps %ld\n", + pr_alert("%s Duration %lu barrier: %lu pending %ld n_launders: %ld n_launders_sa: %ld n_max_gps: %ld n_max_cbs: %ld cver %ld gps %ld #online %u\n", __func__, stoppedat - rfp->rcu_fwd_startat, jiffies - stoppedat, n_launders + n_max_cbs - n_launders_cb_snap, n_launders, n_launders_sa, - n_max_gps, n_max_cbs, cver, gps); + n_max_gps, n_max_cbs, cver, gps, num_online_cpus()); atomic_long_add(n_max_cbs, &rcu_fwd_max_cbs); mutex_lock(&rcu_fwd_mutex); // Serialize histograms. rcu_torture_fwd_cb_hist(rfp); From patchwork Tue May 7 09:34:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656493 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 B3E6315099C; Tue, 7 May 2024 09:35:40 +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=1715074542; cv=none; b=RITgbmejqn39EEeXFRKP7fQkORwI5DJcGuVomJSz0OcI3Z6Vfa5jTt7kK1StyB8sHMhxSwxUr1M8QWEUJIyiUta0ZrNa4jyxmkVjaCbDN74Y1QesnEeSf43FshjH8PP1xtT7Hdq5Sk2TmvlBckA18bOV7jH0DsD6bTTJfGLzQVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074542; c=relaxed/simple; bh=EPTqQr2FdmneGl4AimQETF40urKH1/71YF21d/iWyVA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IysrOLjQEWs5w9QTpBFuvzhj7RP5w19sLliQ7OZz3Qust52KvKmcEcQV0AeRhs3ucgFwBqZb5EvBVjROiVwPbQzedmwWL1asKRYGPH8Aa1lHcNdOQMfM9qNhVaMLnDn9zqZm9HMDcj0YVdm50Uts9SaU8mbOR7WjmJIM12Tj2no= 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=CHIizMS1; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CHIizMS1" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2e34e85ebf4so16678401fa.2; Tue, 07 May 2024 02:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074539; x=1715679339; 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=YeytRa7j93+R3e0SRP+HJTXGjEr2JuSSGpTGmEKlzUY=; b=CHIizMS1fK3R0JnFJ9FYfXfKmGxtdFZUhbrWYLrDdMFEMjxj1Z9dkwsCGcrEeERjNz 2QCYQPMtS0UTouHLNAJqxtyOaX7N4dgkz7eA254DkBvWlcltTNFRRU3XOt5pgTJjqAn+ eBF29sVxXgvl63OySGLJMu0hfY0tVRQF7mNp3dxyvrvU9gNZ8/rTyNkmkm+LEe+VDw6l Ehh0v2CfbmX+DZgHke2xwAWvCG0VTODEKjBwA61g4LTDhPYljWzs7NqBHFFgBOBkBXU9 3pRxe0MT9l/s03qFVUu5wI7cAcvTGYlfbPTzc50uZvomYfhyHgqeEpZrBDCWS6UB2VZ1 77Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074539; x=1715679339; 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=YeytRa7j93+R3e0SRP+HJTXGjEr2JuSSGpTGmEKlzUY=; b=lz5FJtQJOXRqjuFens8Gf12dT1Sns92E+CbrL3v8jgrfLQ0Q89P/WhtL7Afas4Yq/Z utIgHA0tk64Cd9Evm2oIjwTvAzxtZC7J9lfq6b8Y6A+HUetVJsFbj0V4WJsdv/6CCvIl JMsbBnUXBsKr/u8A2Z6TXUG9DsBkcp2Bj7aIojxU0g+hj5IUEjunFpvx6OoYuruqGOeP gCxiZJF4LLKI8lPjAFW/Dm8sdnft4VXJIkS3sLRT4rPx1JhEFX0USFJUcRMN9kboN77y iPoEqTxuhvgn2k+eASG7dbIpj16TmTp0TfCqQItYcDBoqjz7giVGOUpQbO6gpvoTDfhM qVYg== X-Forwarded-Encrypted: i=1; AJvYcCXLFXxsn96RcMy8sq+DpGbf4vyZnDkXtDp6RnOzf9C66MRopmycO+Uu2bT46ItKSwXVH4g5U6UR4XHeo+f//KP9BDKqMt4Ry+rcHdLg X-Gm-Message-State: AOJu0YxeOjz+RfeMdxgi/G+ObKUZJfYsa82X8rHQrHXPHD+K0G19HKpr k1+xnLRDBGt99q9GOqWfQExB86uzLeNAeIxMqKys3NBJ+PoN+F8n X-Google-Smtp-Source: AGHT+IEWdV6/qAUYuncG7ZVsClM1CU+/ZyzcnOioJaa2iCWDjpsSvmMFljWZHYV748y60anlcnt3YQ== X-Received: by 2002:a05:651c:20b:b0:2df:8bef:d900 with SMTP id y11-20020a05651c020b00b002df8befd900mr7026832ljn.16.1715074538723; Tue, 07 May 2024 02:35:38 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:38 -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 Subject: [PATCH 06/48] rcutorture: Dump GP kthread state on insufficient cb-flood laundering Date: Tue, 7 May 2024 11:34:48 +0200 Message-Id: <20240507093530.3043-7-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" If a callback flood prevents grace period from completing, rcutorture does a WARN_ON(). Avoiding this WARN_ON() currently requires that at least three grace periods elapse during an eight-second callback-flood interval. Unfortunately, the current debug information does not include anything about the grace-period state. This commit therefore adds a call to cur_ops->gp_kthread_dbg(), if this function pointer is non-NULL. Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/rcutorture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 6611ef3e71c3..eff51a26216f 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2832,7 +2832,8 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp) if (!torture_must_stop() && !READ_ONCE(rcu_fwd_emergency_stop) && !shutdown_time_arrived()) { - WARN_ON(n_max_gps < MIN_FWD_CBS_LAUNDERED); + if (WARN_ON(n_max_gps < MIN_FWD_CBS_LAUNDERED) && cur_ops->gp_kthread_dbg) + cur_ops->gp_kthread_dbg(); pr_alert("%s Duration %lu barrier: %lu pending %ld n_launders: %ld n_launders_sa: %ld n_max_gps: %ld n_max_cbs: %ld cver %ld gps %ld #online %u\n", __func__, stoppedat - rfp->rcu_fwd_startat, jiffies - stoppedat, From patchwork Tue May 7 09:34:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656494 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 BCA7E1509AF; Tue, 7 May 2024 09:35:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074543; cv=none; b=I70WtToGa+dOwnQJbSBDAZuBHj1IV1NTeSTfoeN3apEPGqY0TPAfjrPk6eCidcIBun2WRDih5APdU0z17347h+Sb96LFmWBAU3jLoE4uPAKqpGN9iTWgp32AImnCDBubWBi/Cso+dQUfOd7q+MkICqPI0eGR1PiAguLjyAHlAn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074543; c=relaxed/simple; bh=DV6vIFK2FLypyV6BWlos84+4RzQSRmAQjUtGFDgwpX4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UqawW25OtcAXZFvWG0QUqZlBiCpsQq4duRrVhbChfCpAtlG+EXhGMZJahjTrG2coseXAiAvwQ62inlhYzyCg+GagPE3Amiz7qyBaMeqKacp5/SbpUADoFYJPIu6XuA+YCZcxqWoWR6KbV6OSG6NRgTPLQrvJ08m6wiaooQ90ixg= 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=ecJPLTry; arc=none smtp.client-ip=209.85.208.176 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ecJPLTry" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2e367c2457bso20445671fa.1; Tue, 07 May 2024 02:35:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074540; x=1715679340; 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=k4dwCi2d+dr1+Mr0Ui3A39VvgagQ4Bs0gp3srLfjB8s=; b=ecJPLTryxx6Z6pYydxAWPK+GJ8+aIUFyzfptqKvn8J/XjA9cUMaJb+pAlPh7gVVwEs 0Mcd3IzV5Y1S8tqAg7BnzvCQxqwEULe+HinU1PZCgIov+xS0FJxV7KlJB8K/B44SbMWw I1HhJYrhxaq0H2wKvtJYgvovXPnk9Df0HGCx5aCUA8Ebe6fyde3JbO8Md5yXJGZqUTby S18qa4cT2HfpCQrJ8hh9yaSf0mquyL726RKjx29xLKf0f1h3un5x3lVuNa+HUxBz6lCm 3FSSFxzrOEkw6SdnNjzH34soZtzbkOCV72NYM/lFf+atXBvDPCfeUIebEuMPNyiYBnhR /I/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074540; x=1715679340; 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=k4dwCi2d+dr1+Mr0Ui3A39VvgagQ4Bs0gp3srLfjB8s=; b=rcxws+ENHjz0ckvObCqXMgGj61XfxRanWIVvVQ4e+Z9XhlfYDvl0FErDCodgaz7o0V 0d9LN295fh/0w46ke3eh0PRFmxwl/qvE9WeuI/M4vfYYsBQ1v3inp7kN10YWPS2u0sAy uVZRDWVTZ2epP7O/inM0vSFMtoCDglrQG0tQwlK5xYhVifcEbjok1Zm9FZLWvAyTHjp1 xGRzepXoMZSH1Lukdeyg0J7Y53s+wtViaXNxjlIb+WJyofJJJ1yiFncOPOTuJ7g7dih0 XOxudgagHlHLjnPcjaTayNXhaQHohOIhQUwbM3bQuTip9fZKnqLMQTxVqNT7LKdkImjA wn2g== X-Forwarded-Encrypted: i=1; AJvYcCX4NYPqdYJtWaxTv6tDzSVcaeUD6Y9UPv97EVcDD3VkSRNo7xFCkh5uc1kHAXXF6p6Z7PINb5s93xNhQMf173qFrN461VtFgrXj/axJ X-Gm-Message-State: AOJu0YyP8mAhKVsDYPPIcWXoa47VN5+53dNBALuZDSVBLhTHnSQ/eRg4 S1JWLV1WC77IdhXfLmeNZqR3FdDuUChtosT7qHtvpTEQjzBnl5D0 X-Google-Smtp-Source: AGHT+IFImqgKNBlFQdFXMbNhwPY/Z+4UJzIWcOtBdwmOrjE48c1ZjErp2rw2AfPF6aTfdENuCsEUXQ== X-Received: by 2002:a2e:a589:0:b0:2df:a177:58e3 with SMTP id m9-20020a2ea589000000b002dfa17758e3mr10215793ljp.13.1715074539565; Tue, 07 May 2024 02:35:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:39 -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 Subject: [PATCH 07/48] rcutorture: ASSERT_EXCLUSIVE_WRITER() for ->rtort_pipe_count updates Date: Tue, 7 May 2024 11:34:49 +0200 Message-Id: <20240507093530.3043-8-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" It turns out that only one CPU at a time will ever invoke rcu_torture_pipe_update_one() on a given rcu_torture structure. This commit therefore adds three ASSERT_EXCLUSIVE_WRITER() calls to enlist KCSAN's aid in checking this. Signed-off-by: Paul E. McKenney Cc: Linus Torvalds Reviewed-by: Joel Fernandes (Google) Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/rcutorture.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index eff51a26216f..d8c12eba35b7 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -466,6 +466,7 @@ rcu_torture_pipe_update_one(struct rcu_torture *rp) i = RCU_TORTURE_PIPE_LEN; atomic_inc(&rcu_torture_wcount[i]); WRITE_ONCE(rp->rtort_pipe_count, i + 1); + ASSERT_EXCLUSIVE_WRITER(rp->rtort_pipe_count); if (rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) { rp->rtort_mbtest = 0; return true; @@ -1399,6 +1400,7 @@ rcu_torture_writer(void *arg) if (rp == NULL) continue; rp->rtort_pipe_count = 0; + ASSERT_EXCLUSIVE_WRITER(rp->rtort_pipe_count); rcu_torture_writer_state = RTWS_DELAY; udelay(torture_random(&rand) & 0x3ff); rcu_torture_writer_state = RTWS_REPLACE; @@ -1414,6 +1416,7 @@ rcu_torture_writer(void *arg) atomic_inc(&rcu_torture_wcount[i]); WRITE_ONCE(old_rp->rtort_pipe_count, old_rp->rtort_pipe_count + 1); + ASSERT_EXCLUSIVE_WRITER(old_rp->rtort_pipe_count); // Make sure readers block polled grace periods. if (cur_ops->get_gp_state && cur_ops->poll_gp_state) { From patchwork Tue May 7 09:34:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656495 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 88C2D152181; Tue, 7 May 2024 09:35:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074544; cv=none; b=GRu9heq8WmjPn5wahgfQ9mVeKUORyu3LzCy8jxdjo0rSk7xfHJCr35L+D9YpFmOWk2YWIt6m3a0939IrNI4gLDSRC3QipeHuKwX1GWkqAnDHU9Z2hqsatP1THuCNki3ua/KcWeYU7nFQRSP2tt7RyVik/DCSNVWyjeWqWKbk+2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074544; c=relaxed/simple; bh=1pd6CZTByaXHSagaB3Jstn7bSvLFY2rnruSLMRHxzDw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d0c5CRjK+xGIoDDMURAKe6Rxyxs9PnC6KKHF5Y1s5+avXoJXf4kUYJrTCFz1hnfUV7+NK/Ty9xFb6di/6ssXAniSoxcTz1clB8ltUUShCp1f1FYIsgpAzhSJgYzcLPgmhB5dzS9YRFyJqKNvKnirOd0g09Cqecb451Bwp2vHvVg= 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=nabvQoMS; arc=none smtp.client-ip=209.85.208.172 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nabvQoMS" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2e2a4c20870so37450141fa.3; Tue, 07 May 2024 02:35:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074541; x=1715679341; 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=XzO2bnnbUb7qNypPC+CxtK/Lg/bpaDGc7T8gLSepklU=; b=nabvQoMSgORpLmkJZ6mXmq1bsrCOtm9j4yZs/XF+Xn8K+0S25T/GP0N2TYIXzm4kO5 UPAOtYAAjz/jpoCYh3AbS2xNLGtGHN0k4v9AxLmTgkd1MFtm+PC8fIr7SnzM3gPD6YaH t4sHW00LMaU/ccdJd47sTgmNYTVcdNmbv5/CKPznHh8A1TN7cGa42ACGpvPuXqb9CALG cLUGqWy80m73FuJ8RYzfDC4TE9fCXhPoFvO3UMtFQBosKlmdh5EyoDsM+7XyEb0z4ENX s3oUSrzT1lesJaRWwhF+Z7Z7BP4R6U3O6dL8nkYJ7WermqE8cWx0GnVEHhJPpA3J4Run xCsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074541; x=1715679341; 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=XzO2bnnbUb7qNypPC+CxtK/Lg/bpaDGc7T8gLSepklU=; b=pb/gpbei4UTdoWSYSvwwW5kYBiKaYS7iGB2nnl9DeaylX9HKcUmJ4EHB+FxLDuuRw2 WxHugryT5lnW51iN22PVlowM3X6AhD4D1sb0kdHXa0FCv7A7OqMe3h3bJnQwostaPgED gsoGcqdHAY+eHPNmK0tv1VckCGAhTrBu/OAiaypP9HvYp7+97R7UNkl7UVLNrkCH/toI 7ZemMiBOcH1OI7HwDYvNaGfGOrQp4ld1Lzr7r5EfUzsimWsVzOrTL0ajclWmGqONruGn 3zLPg1veQVtYiOVCzzI/dxMxoRJAWnRiDZOoMPijD8TPFo1t1NYlQ4TwRtPoVXj2UNWb bkLw== X-Forwarded-Encrypted: i=1; AJvYcCWAXhCGYsb1GCHX8UhKJ3iX2qR3fVGAP+2TDPOtzSiA+iv7hLINpBSPRblca1HS0pUY8ngexXnrTIRN7Z3rlQ20UTuoOqAUMDlbd+tf X-Gm-Message-State: AOJu0YxyOFcYYJWWFDRKaJxqXPaqPYonY30xySXfy3dHhGk6J5wNdu9m 5EzXz55mvq87YRl+GxE72j3/EwgTjxTMCxRX+G22XCaBNHkTg5qE X-Google-Smtp-Source: AGHT+IGk4IpW7lK7tqjt58cDW+WdfWWjXdflP1wpka7DMwPhr9TOj4rpi+dt3MiwYN198X6DRzkCDQ== X-Received: by 2002:a2e:3510:0:b0:2dd:bd92:63a with SMTP id z16-20020a2e3510000000b002ddbd92063amr8237859ljz.34.1715074540489; Tue, 07 May 2024 02:35:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:40 -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 , Breno Leitao Subject: [PATCH 08/48] rcu-tasks: Make Tasks RCU wait idly for grace-period delays Date: Tue, 7 May 2024 11:34:50 +0200 Message-Id: <20240507093530.3043-9-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Currently, all waits for grace periods sleep at TASK_UNINTERRUPTIBLE, regardless of RCU flavor. This has worked well, but there have been cases where a longer-than-average Tasks RCU grace period has triggered softlockup splats, many of them, before the Tasks RCU CPU stall warning appears. These softlockup splats unnecessarily consume console bandwidth and complicate diagnosis of the underlying problem. Plus a long but not pathologically long Tasks RCU grace period might trigger a few softlockup splats before completing normally, which generates noise for no good reason. This commit therefore causes Tasks RCU grace periods to sleep at TASK_IDLE priority. If there really is a persistent problem, the eventual Tasks RCU CPU stall warning will flag it, and without the extra noise. Reported-by: Breno Leitao Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- include/linux/rcupdate_wait.h | 18 +++++++++--------- kernel/rcu/tasks.h | 6 +++++- kernel/rcu/update.c | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/linux/rcupdate_wait.h b/include/linux/rcupdate_wait.h index d07f0848802e..303ab9bee155 100644 --- a/include/linux/rcupdate_wait.h +++ b/include/linux/rcupdate_wait.h @@ -19,18 +19,18 @@ struct rcu_synchronize { }; void wakeme_after_rcu(struct rcu_head *head); -void __wait_rcu_gp(bool checktiny, int n, call_rcu_func_t *crcu_array, +void __wait_rcu_gp(bool checktiny, unsigned int state, int n, call_rcu_func_t *crcu_array, struct rcu_synchronize *rs_array); -#define _wait_rcu_gp(checktiny, ...) \ -do { \ - call_rcu_func_t __crcu_array[] = { __VA_ARGS__ }; \ - struct rcu_synchronize __rs_array[ARRAY_SIZE(__crcu_array)]; \ - __wait_rcu_gp(checktiny, ARRAY_SIZE(__crcu_array), \ - __crcu_array, __rs_array); \ +#define _wait_rcu_gp(checktiny, state, ...) \ +do { \ + call_rcu_func_t __crcu_array[] = { __VA_ARGS__ }; \ + struct rcu_synchronize __rs_array[ARRAY_SIZE(__crcu_array)]; \ + __wait_rcu_gp(checktiny, state, ARRAY_SIZE(__crcu_array), __crcu_array, __rs_array); \ } while (0) -#define wait_rcu_gp(...) _wait_rcu_gp(false, __VA_ARGS__) +#define wait_rcu_gp(...) _wait_rcu_gp(false, TASK_UNINTERRUPTIBLE, __VA_ARGS__) +#define wait_rcu_gp_state(state, ...) _wait_rcu_gp(false, state, __VA_ARGS__) /** * synchronize_rcu_mult - Wait concurrently for multiple grace periods @@ -54,7 +54,7 @@ do { \ * grace period. */ #define synchronize_rcu_mult(...) \ - _wait_rcu_gp(IS_ENABLED(CONFIG_TINY_RCU), __VA_ARGS__) + _wait_rcu_gp(IS_ENABLED(CONFIG_TINY_RCU), TASK_UNINTERRUPTIBLE, __VA_ARGS__) static inline void cond_resched_rcu(void) { diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index 147b5945d67a..82e458ea0728 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -74,6 +74,7 @@ struct rcu_tasks_percpu { * @holdouts_func: This flavor's holdout-list scan function (optional). * @postgp_func: This flavor's post-grace-period function (optional). * @call_func: This flavor's call_rcu()-equivalent function. + * @wait_state: Task state for synchronous grace-period waits (default TASK_UNINTERRUPTIBLE). * @rtpcpu: This flavor's rcu_tasks_percpu structure. * @percpu_enqueue_shift: Shift down CPU ID this much when enqueuing callbacks. * @percpu_enqueue_lim: Number of per-CPU callback queues in use for enqueuing. @@ -107,6 +108,7 @@ struct rcu_tasks { holdouts_func_t holdouts_func; postgp_func_t postgp_func; call_rcu_func_t call_func; + unsigned int wait_state; struct rcu_tasks_percpu __percpu *rtpcpu; int percpu_enqueue_shift; int percpu_enqueue_lim; @@ -134,6 +136,7 @@ static struct rcu_tasks rt_name = \ .tasks_gp_mutex = __MUTEX_INITIALIZER(rt_name.tasks_gp_mutex), \ .gp_func = gp, \ .call_func = call, \ + .wait_state = TASK_UNINTERRUPTIBLE, \ .rtpcpu = &rt_name ## __percpu, \ .lazy_jiffies = DIV_ROUND_UP(HZ, 4), \ .name = n, \ @@ -638,7 +641,7 @@ static void synchronize_rcu_tasks_generic(struct rcu_tasks *rtp) // If the grace-period kthread is running, use it. if (READ_ONCE(rtp->kthread_ptr)) { - wait_rcu_gp(rtp->call_func); + wait_rcu_gp_state(rtp->wait_state, rtp->call_func); return; } rcu_tasks_one_gp(rtp, true); @@ -1160,6 +1163,7 @@ static int __init rcu_spawn_tasks_kthread(void) rcu_tasks.postscan_func = rcu_tasks_postscan; rcu_tasks.holdouts_func = check_all_holdout_tasks; rcu_tasks.postgp_func = rcu_tasks_postgp; + rcu_tasks.wait_state = TASK_IDLE; rcu_spawn_tasks_kthread_generic(&rcu_tasks); return 0; } diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c index 46aaaa9fe339..f8436969e0c8 100644 --- a/kernel/rcu/update.c +++ b/kernel/rcu/update.c @@ -408,7 +408,7 @@ void wakeme_after_rcu(struct rcu_head *head) } EXPORT_SYMBOL_GPL(wakeme_after_rcu); -void __wait_rcu_gp(bool checktiny, int n, call_rcu_func_t *crcu_array, +void __wait_rcu_gp(bool checktiny, unsigned int state, int n, call_rcu_func_t *crcu_array, struct rcu_synchronize *rs_array) { int i; @@ -440,7 +440,7 @@ void __wait_rcu_gp(bool checktiny, int n, call_rcu_func_t *crcu_array, if (crcu_array[j] == crcu_array[i]) break; if (j == i) { - wait_for_completion(&rs_array[i].completion); + wait_for_completion_state(&rs_array[i].completion, state); destroy_rcu_head_on_stack(&rs_array[i].head); } } From patchwork Tue May 7 09:34:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656496 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 2B07515250D; Tue, 7 May 2024 09:35:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074544; cv=none; b=XXicRjmZizo+aaniwKCnyXqFarkSwXEXuod4E0BYwRnRSR3TyWsYlT/iO0iWKI3SPi1mjmf/d2mcrXCEHbQEFVE4A8x+scLeZi+gCa0LRL0y+ANkXLsa9UxtdK6XqlaP/fTjmefYhC09wESKFIz6ERMm68L2Wuyg/ose13feNOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074544; c=relaxed/simple; bh=Ul60Dz2Wb7t1suuj5txMkvljL21mKCYQ9LzjJSAVCpk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XzvjvHKPpLa3esyowit5Uq8ILzJ6axFAXoIOps173qSqKxV4ptjTH2IVDxfYFKmEMGdgyLeTu2ULl5siKc2GqsG38TuzQpcHBvzfJnRpTuu+BjXGGnZ47J6Ko5iXhk7QWkHri1x2udKbTySfwOrgJtgLXbFeCut5BbU7vcGsiWM= 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=iK2Hot4e; arc=none smtp.client-ip=209.85.208.178 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iK2Hot4e" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2e34e85ebf4so16678791fa.2; Tue, 07 May 2024 02:35:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074541; x=1715679341; 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=0ODfneSlJwi5tq6mU5vRRHw3ltc4HQQLLdkqm9V0KGc=; b=iK2Hot4e0cONi1/SDuL1u5yYoJa9G3HunmWZldrdXZ6qmAMOO25TkFMN6EXZjUkkBZ wMSOm1yza8kSGEAfV0AGg+E6Wg+OtsRclXoDWAryUizo8pc0AGEcICFCRscjNKsj2zjo xYX9UJhU/nrNX1Obcy1k9Mr31ePp7u8RsmtcRv003dXdEePO/kGd57rdTiNqOzec8TDF w6BS884E0jz1u3o8WIkZbCuAobZJscI0LjfkMDngEMAg1PeRaMlcMOrWbzBqUBSUJWfh +K1TNWhpLnJwbZHq3IavtUtodYozgdoD0ylc5vl2yuSgV8JF4yvJ/ItuBOeCaKNDPJAC wV8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074541; x=1715679341; 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=0ODfneSlJwi5tq6mU5vRRHw3ltc4HQQLLdkqm9V0KGc=; b=k0T6zUqTC94mZyTblolMWnnoKyVC17nyKh8HuNlBF/woiMq2Yt3uxNq08RufRPOlUz aAH28ExgiPwBfLU3S02biAXsrdKHXpEV/vduJkZIpjLQuLzHjJJZmjKQQ4rK3OZBpO9a wILRMyslbhya8/gLxfpYXU0W0a4dKOOA4v25OrPguLdDqZuU2BnOv3hg7qwVf2S3b4SG NnsPn6++fRM3n1ooRBjH3uaduMJJ9m710Evc9i3vgmjvr5n6b3o9o0CeOhsNnYIAN2Lg nz47EgPa9EqFoPY0XEuY/prOq1+jadrc4UsNry9oV6Wf+W8PDi+bfEbEsoQ+F1TvQxpy AY/Q== X-Forwarded-Encrypted: i=1; AJvYcCUFpP4tDWoHZ7mvpdGqp4is+8L2rpZZXfPxSAaKv5KxZc5AMyutUFWIaAJyVRPUV2evqaIJHGrfvM2N3H3RxlPjmwzKb4t8gwFiLry0 X-Gm-Message-State: AOJu0YyMgXyruHaLbPtqiFRsb2edTj/fSVbo5WdgxtTI1NrJEPaVAFdd mDIt6GuqCzfGPqfr7d8plKbALR8V8nnb4ApP5OfUyIydeDA5pkmp X-Google-Smtp-Source: AGHT+IEhy9I6zK1bKc7Zlag8/vshhJpg+y7oa7zLYZLeeXFG9gFd1GEJa1QUDul2IKsFXRXWBZB0Jg== X-Received: by 2002:a2e:94d6:0:b0:2e0:37be:b70f with SMTP id r22-20020a2e94d6000000b002e037beb70fmr7454523ljh.26.1715074541347; Tue, 07 May 2024 02:35:41 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:41 -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 , Zenghui Yu Subject: [PATCH 09/48] doc: Remove references to arrayRCU.rst Date: Tue, 7 May 2024 11:34:51 +0200 Message-Id: <20240507093530.3043-10-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Zenghui Yu arrayRCU.rst has been removed since commit ef2555cf68c3 ("doc: Remove arrayRCU.rst") but is still referenced by whatisRCU.rst. Update it to reflect the current state of the documentation. Signed-off-by: Zenghui Yu Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- Documentation/RCU/whatisRCU.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/RCU/whatisRCU.rst b/Documentation/RCU/whatisRCU.rst index 872ac665223f..94838c65c7d9 100644 --- a/Documentation/RCU/whatisRCU.rst +++ b/Documentation/RCU/whatisRCU.rst @@ -427,7 +427,7 @@ their assorted primitives. This section shows a simple use of the core RCU API to protect a global pointer to a dynamically allocated structure. More-typical -uses of RCU may be found in listRCU.rst, arrayRCU.rst, and NMI-RCU.rst. +uses of RCU may be found in listRCU.rst and NMI-RCU.rst. :: struct foo { @@ -510,8 +510,8 @@ So, to sum up: data item. See checklist.rst for additional rules to follow when using RCU. -And again, more-typical uses of RCU may be found in listRCU.rst, -arrayRCU.rst, and NMI-RCU.rst. +And again, more-typical uses of RCU may be found in listRCU.rst +and NMI-RCU.rst. .. _4_whatisRCU: From patchwork Tue May 7 09:34:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656497 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 0FB77152DE0; Tue, 7 May 2024 09:35:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074546; cv=none; b=cNtWipDS2QbLXf7l9vMzZPTrCl/DeHzCNlKfocY0/fpqETcFEc5g4FUe1cgGkYSq1RkL6jZmc8SXYZP0X/QbI3c9j5FcRBvM55hXA8JfVMHSaY3+7++5VWkFinQKesh350OrUFeFR0vBRqxb6vMGgCl7QEGInm5Xbi8/Kox2Yg0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074546; c=relaxed/simple; bh=CEEiylPlq3j71LNCmuDby9KtGNd1YDAPS3GOOTnrKaA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=offROE2NN4JJU1Wt2DeckecRoqwGSZWovb4PLE09SHDGL/JiCH0gTPeyXGajjy2FuxTcHANf1P+BHIzV75nuWiC2V9JXle5x8DvwRj23ff53ySUdicYL4rcVBV/BkAX7YI4VjC3aKQfqzslDDpwG+6d4+OEUAG//necqxzlDALg= 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=EJ6BYvlH; arc=none smtp.client-ip=209.85.208.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EJ6BYvlH" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2e1fa1f1d9bso55702661fa.0; Tue, 07 May 2024 02:35:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074542; x=1715679342; 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=k5OtpNZnclUijB37KVBOy2jnede7b3aa5kSGilAYif0=; b=EJ6BYvlHjDC+UDFuWuAMNZoZ4B1hDP9GpfiYixJ7rs2gU4QQ6ucLJHNBRlbeGfR175 qGxmSOogECS0bfi81SrO6D9Ys5CJ9g8WvqX8dkavNkKHD5Naw4HDITo8iJYb8NGBO+ad DXgfuSAjrJWBcFZjp40TSPgb+hszukNEx4hacv2K6/lAlJydDZYhFUv9yD062XBFLi8a gsuFMVSX4jDba708+4U2dPwfBU19l/ls7wlh7r+AVuvbqjRGLb1FUH3xJxzRwabZRPpE 4PUCDkK4ZfAJxya4eqnUxRGPxIZCpCxvJOQb8TGB6iIXNwfe9cAm3lT+PC0mPHl/myFq EC2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074542; x=1715679342; 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=k5OtpNZnclUijB37KVBOy2jnede7b3aa5kSGilAYif0=; b=GtZFN72zVxKRT6aYRPj3LjnqLPZUijU5BTkT3hJKKGVfdIKTnOUuwbInNQHpKt3fSb r+IZdK6GRPKB2yoojWutjeCX45Vr/OOAIyQFrDhuqz3TgAHfSQ79hNlIengjcwO+IyGr S+zgvEBcl6w9wE88IFkrPN0xly7HJBBK8uhzoj5oLkN9beM9PwWvGxpmg24593fNrCSM YypG6cqJxNnBlsuzM3sdWsbmkm17/3L8qvP94WVhC08PkDzogAANG3M7VLxsXOxFwb2H RuGod8UivYIlF8BIY8PBMjTSA8WuvlY8e2cTrpLvGkhM5ZHjey8c+BQ0M3XZ75OVZD6z wNGQ== X-Forwarded-Encrypted: i=1; AJvYcCW1OuG17tc+6JrxyHhmLnzDg13CAyHysKkY/ssSKEO7jE1dGIp45+orrV6aF27/mdrrRN7Bdhg2tzqxZZ8Lxz409+eHuFsFTaq/9+xy X-Gm-Message-State: AOJu0YzbtptiNxAiyB2VCNtIUTQhEVMQuVLs39cKt82ajBrlXdp+fBrw 5Z6XQdCOxdtK3kxWJkSP6MnBGvJ6dm3t5TJrKXAGJXmNwdqoWTLq X-Google-Smtp-Source: AGHT+IGNPUx/C384/inFDXioDn+uBYnBPZRb4XAF3oX/NOg6AfZ61TvDJvKeDlg2PdGyJStq53z3kA== X-Received: by 2002:a2e:919a:0:b0:2e1:a2d5:62c2 with SMTP id f26-20020a2e919a000000b002e1a2d562c2mr10695933ljg.33.1715074542210; Tue, 07 May 2024 02:35:42 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:41 -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 , Neeraj Upadhyay Subject: [PATCH 10/48] MAINTAINERS: Update Neeraj's email address Date: Tue, 7 May 2024 11:34:52 +0200 Message-Id: <20240507093530.3043-11-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Neeraj Upadhyay Update my email-address in MAINTAINERS and .mailmap entries to my kernel.org account. Signed-off-by: Neeraj Upadhyay Reviewed-by: Joel Fernandes Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- .mailmap | 3 ++- MAINTAINERS | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap index 59c9a841bf71..32e12c26bdda 100644 --- a/.mailmap +++ b/.mailmap @@ -445,7 +445,8 @@ Nadav Amit Nadia Yvette Chambers William Lee Irwin III Naoya Horiguchi Nathan Chancellor -Neeraj Upadhyay +Neeraj Upadhyay +Neeraj Upadhyay Neil Armstrong Nguyen Anh Quynh Nicholas Piggin diff --git a/MAINTAINERS b/MAINTAINERS index 7c121493f43d..0370e571f312 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18591,7 +18591,7 @@ F: tools/testing/selftests/resctrl/ READ-COPY UPDATE (RCU) M: "Paul E. McKenney" M: Frederic Weisbecker (kernel/rcu/tree_nocb.h) -M: Neeraj Upadhyay (kernel/rcu/tasks.h) +M: Neeraj Upadhyay (kernel/rcu/tasks.h) M: Joel Fernandes M: Josh Triplett M: Boqun Feng From patchwork Tue May 7 09:34:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656498 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 4DE62155390; Tue, 7 May 2024 09:35:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074547; cv=none; b=drLS33OU0KDImWTemDXS/SlvjmF0Lrdry/x+jf+ZrHB3OUqPBvCn/x/VDjoURtLc6F3e15UAq98K52Sq16586KW9JT2n7XLtTF38eJDACNhvJHIUBUZifp+FDTJ8K+eYUBChT8yubgIUxJXDA6zClGWmXBNK1GYSG99H/3wnQ+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074547; c=relaxed/simple; bh=chdfDJkJUd2381b+AYErmHdsM+6kHBcN2R8PWQKTK+w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZldjTnukViJ49IyYLPPl/dXwoR5dmr+/JxUg8RbC4ickHWHshmB4IgGFui4jXpkReLLDh8QJ4dNoKLt6pBiGcv1gHFZy30x4Jf0fOrXw1RucqsgWQ+48t/ta322MpZvDLyJjmsEP+/BLQMbsK7PFl6MTZ4gmntlLOlTppamO3yc= 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=MtT+8ywr; arc=none smtp.client-ip=209.85.208.176 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MtT+8ywr" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2e3f6166e4aso7187251fa.1; Tue, 07 May 2024 02:35:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074543; x=1715679343; 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=qp9Gj7lq4ACmCS98GBHRZFh0tqGLeKwKmlOcd+I5en8=; b=MtT+8ywrCi5/iQhwutoypnQspkEBkOeIZ3ujcsFJewmsDbGXx6uzHcz+7KsakzSz3N /oJISuR6Vjaa58IlRdQ2xi9qE8mYaBnEJ/jt0VhNTFFrJ3cwVyDfSKAnQSE1qUy7Fhbm VHXpfrZxLKiDko0O20xheOore+68yCR3WR0HEDe8zHS3Tuakok80b4857eHUAhNwoU0a 7OUIQ9DLSurTW5/fYqjaBYC310V+nHDOqZtTumQIcMh1e37jAvXNA/Qd7EGdHr/tFzkd ULb8QYz+Q4E1giAzOY0oYNyOSk7yZCxc7gCasQjaQMxN2pFwhxj09T75TfnRDztbIizr C3JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074543; x=1715679343; 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=qp9Gj7lq4ACmCS98GBHRZFh0tqGLeKwKmlOcd+I5en8=; b=Zhh/UtlKheF3Gx4Io58FsgUh1TCw3j7ztG3CQ2Z54EbUS0g3l7tSjNc5CgohqyTvpg nNZmNSearJUgYMOh60//2rXYlk31wlIiPN5lm06oGKvs/ZWkbRZi4xOdNMMTocVnmrSb vxpOaYzt+6no7CXYz+vNY7d3cJsel8L0IgEqEcxeo41O/BwcRhozTRemI5LQI7FqWC8f 0WBY2gmsZK7Jzogzxdz4OMEQ0D9tS1fHWuVk6H1aa6bIwkuVYwLLUkAZRJP1aNMAuN0K X1laj1683FL75GjpsBZDO+1C6n9Ppb9LCBq8jIu84FPq5pAIvcAkgQNxhSPWGuS99RbJ n/xQ== X-Forwarded-Encrypted: i=1; AJvYcCXreQtJiIo4EFqvgpFGG1cy7AEd6XhlTFhR1ERiOzXc0C1kmT4GgjEC/H289ilpC91edI8q919uuCLQmgdraCcTTgKeV0tNFtDG1L4fsaWFbLxO9PIpdSBBTpDtXekNS4uS X-Gm-Message-State: AOJu0YygEgI3vICDO9iJqHiQfTITFSVJbvVLSBYNMBWCimOtzJAlzCKS 6zBB9/lyjz1SacSIcyBtwrsRRSSRMLukuckQCgWPMmBAhmUDSYypQWsRQ59E X-Google-Smtp-Source: AGHT+IE1e9KG4xXibyeIv5ywJLp8h+Y7KAHo9JjU55aHVH5tx8ojg9MGUZmij8FPRmFRUqtHpxZifw== X-Received: by 2002:a2e:b8d4:0:b0:2e2:72a7:8440 with SMTP id s20-20020a2eb8d4000000b002e272a78440mr10513801ljp.41.1715074543428; Tue, 07 May 2024 02:35:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:43 -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 , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf@vger.kernel.org, Ankur Arora , Thomas Gleixner , Steven Rostedt , Mark Rutland Subject: [PATCH 11/48] bpf: Select new NEED_TASKS_RCU Kconfig option Date: Tue, 7 May 2024 11:34:53 +0200 Message-Id: <20240507093530.3043-12-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Currently, if a Kconfig option depends on TASKS_RCU, it conditionally does "select TASKS_RCU if PREEMPTION". This works, but requires any change in this enablement logic to be replicated across all such "select" clauses. A new NEED_TASKS_RCU Kconfig option has been created to allow this enablement logic to be in one place in kernel/rcu/Kconfig. Therefore, make BPF select the new NEED_TASKS_RCU Kconfig option. Signed-off-by: Paul E. McKenney Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Andrii Nakryiko Cc: Martin KaFai Lau Cc: Song Liu Cc: Yonghong Song Cc: John Fastabend Cc: KP Singh Cc: Stanislav Fomichev Cc: Hao Luo Cc: Jiri Olsa Cc: Cc: Ankur Arora Cc: Thomas Gleixner Cc: Steven Rostedt Acked-by: Mark Rutland Signed-off-by: Uladzislau Rezki (Sony) --- kernel/bpf/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/Kconfig b/kernel/bpf/Kconfig index bc25f5098a25..4100df44c665 100644 --- a/kernel/bpf/Kconfig +++ b/kernel/bpf/Kconfig @@ -28,7 +28,7 @@ config BPF_SYSCALL bool "Enable bpf() system call" select BPF select IRQ_WORK - select TASKS_RCU if PREEMPTION + select NEED_TASKS_RCU select TASKS_TRACE_RCU select BINARY_PRINTF select NET_SOCK_MSG if NET From patchwork Tue May 7 09:34:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656499 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 7B25D14E2C5; Tue, 7 May 2024 09:35:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074548; cv=none; b=E+/mqNBxCtprWONjs0vdIpHjW0pjsaktBmxVq4HzGTO22Ytazf0BNU1+ngQ1loTWZgk2jy2NQPu+rO/+XXQPnOxPOV7zWjlhgNsnaCQjt1EOnyefZPnig3CJxsHlVrS8q80Hf0jgubOVQ4OCEaeHk0rD4ayFIr2eExP8Ny0L8Qg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074548; c=relaxed/simple; bh=c3pcsZaBxcT4XT+/DSNV8MoonKro3JB3EF7WT41QDgo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gTnfph66XkSo4PxbrRMzxL3/WUT9kpQKsZovy5sMmCJjJIld4Qw8IZv7ZzyIzNL6SuYDzqRJsIUqK7iir9OHNguDdgwOWzensLnm8ArNkZXbZTC7zvLbBMJSdfsLZGmr2mHcZrGM/zON2UL31q6WUo7JJ8Z0EXxsmPGhIQosa7I= 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=a4xsB7hq; arc=none smtp.client-ip=209.85.208.182 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a4xsB7hq" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2e3e18c24c1so8120471fa.1; Tue, 07 May 2024 02:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074544; x=1715679344; 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=FsT5Z8z8aN6DXWEnnpzj6QsDHO6m4UY1ubPVXNAMDxk=; b=a4xsB7hqMWfEN3NzSH3webJm8hFIIfwR8d3fZ8or1WjskJf80awDuYRRcBXVDWR6nv 2Epk9/DCjwOkTZfxD43VlTEDsU92JR6g0Boodu3WBcn0OPPtMXo3S3j8NGEmy4KVs652 p3rQ+Qmd+sjvEb8b4rys4BerseJNFn5T8Q/sPthcMfdI+0Oqd8GczFeadPidZKExNb5u TBnL4bllV1woELD/wcEdO5C02r5Oar+x94G6aN7/4YAwDQUoF1IrEdI3G/5T77SGs/4Y WIrIumzWpZ3K1OnxAEtbqM7ACIZTAeF9FE3JhACH3sIB7YWE+g63SwhjiJ3/6scTmYtv VeKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074544; x=1715679344; 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=FsT5Z8z8aN6DXWEnnpzj6QsDHO6m4UY1ubPVXNAMDxk=; b=ggmcTdQ40Hhy0kRtYyI95XdqdJcGoLT7jJhqldfqQTAJDRRs1DNS0QmBosDTrDccxD JF5lXznSsAXO86gYv4xF1iw1XxIYELwxdrIM2wGKyJYr7r7z64/Gy049ToRoO1+XFlQR zU8+cgp6hwX1MPrHxKT38eSF0A0yVqNwn5DciwNarZ3NHLdux59+SImHaZ8XfbD//w/D MPE+wdP2eR/kG6c+tX9eTxiRJGXvhWWWFV72KDSz17WIsf+HtKXT+hHV4gjJfd41QgyK qpiiJK1wNXgg85i7zRlzp0zTSWF/VLmgjaJ2o/IgJyye6+wTDSBtSSirUU8Jp1t7e9C4 mo2A== X-Forwarded-Encrypted: i=1; AJvYcCUC6s8OdAfkQ6FhztqBLK4i8F3gMIOTZMcuIWKQRN7Q+DwpmSTc+LHjIa1jysCdFb0fdILVthkJEZrfpMPQDAID8lyR0UD4s6vD1vxK X-Gm-Message-State: AOJu0Yx84UZq4xTkVT72+UCE3LOTWZEu6M4rcd0ciThxGoJVB6j6ICi6 8JofTPl7JeDmOkQjceEXCJ6F0lkLQnd6pO4w51crm80TsdwFKGqZ X-Google-Smtp-Source: AGHT+IGK8gvnE0HOnK8b+PD2X5+MiPLLyDqmSDCByUZIin09SOHuRMpEFOiPchdlCxr/6LB0pCOnGQ== X-Received: by 2002:a2e:602:0:b0:2e3:cba4:234 with SMTP id 2-20020a2e0602000000b002e3cba40234mr1710352ljg.10.1715074544568; Tue, 07 May 2024 02:35:44 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:44 -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 , Andrew Morton , Thomas Gleixner , Heiko Carstens , Arnd Bergmann , Douglas Anderson , Ankur Arora , Mark Rutland , Steven Rostedt Subject: [PATCH 12/48] arch: Select new NEED_TASKS_RCU Kconfig option Date: Tue, 7 May 2024 11:34:54 +0200 Message-Id: <20240507093530.3043-13-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Currently, if a Kconfig option depends on TASKS_RCU, it conditionally does "select TASKS_RCU if PREEMPTION". This works, but requires any change in this enablement logic to be replicated across all such "select" clauses. A new NEED_TASKS_RCU Kconfig option has been created to allow this enablement logic to be in one place in kernel/rcu/Kconfig. Therefore, select the new NEED_TASKS_RCU Kconfig option instead of the old TASKS_RCU option. Signed-off-by: Paul E. McKenney Cc: Andrew Morton Cc: Thomas Gleixner Cc: Heiko Carstens Cc: Arnd Bergmann Cc: Douglas Anderson Cc: Ankur Arora Acked-by: Mark Rutland Reviewed-by: Steven Rostedt (Google) Signed-off-by: Uladzislau Rezki (Sony) --- arch/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 9f066785bb71..ae4a4f37bbf0 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -55,7 +55,7 @@ config KPROBES depends on MODULES depends on HAVE_KPROBES select KALLSYMS - select TASKS_RCU if PREEMPTION + select NEED_TASKS_RCU help Kprobes allows you to trap at almost any kernel address and execute a callback function. register_kprobe() establishes @@ -104,7 +104,7 @@ config STATIC_CALL_SELFTEST config OPTPROBES def_bool y depends on KPROBES && HAVE_OPTPROBES - select TASKS_RCU if PREEMPTION + select NEED_TASKS_RCU config KPROBES_ON_FTRACE def_bool y From patchwork Tue May 7 09:34:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656500 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 2614C156F36; Tue, 7 May 2024 09:35:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074548; cv=none; b=oxUnVqEU7lVrPQ3a6LZUB/8FMblrj+9EZdgcFMkLRKIyDfX8w6g2cli0ZkC5Wfhp9K9emq3/+CHtKpoW0dAuXvYxKtV+0ohN5mZxqcioK5rJfwEun+uPUNoqEU7HImYGmCDyQZgmKH8YerbCxLYPVcd66u0B61l6c2sKdkRTv8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074548; c=relaxed/simple; bh=uI1wZYUdEsHG1vr/UD/ng0oR9crfeMvCEO8dnQg07kM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RbWAF6zOqdTbBWwde892XP+1ysZN4nlPAXhfGPOJFvX00+LH0iWSH6XeCbGugdjsvuRww8G6GFF4pm1CYyQYNftY93qgpOU2f26xRo/O17BdSpIYqACBsmnSL+betDSOYnHU0OF79LCL9+eb1K2/GibhBYo6XrN4JlL6MgTaemY= 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=CLQDeegI; arc=none smtp.client-ip=209.85.208.173 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CLQDeegI" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2e0a0cc5e83so29085011fa.1; Tue, 07 May 2024 02:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074545; x=1715679345; 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=9khWE7rlDVNG5sjle6yOolXySu0ObdFH96voTvp2Qf4=; b=CLQDeegInkUSqAvqe+S8qHHa3bUS5VAhJUngZl6s5hA8v+wvH9BCKk8/Bk0lEtO5ku svOZKolrB14Ivox+oWC2QVLfDudX3vLM3wdYPHP3jeLHs1ZbkugavmyGNGG8j3ckpwTv yI7g6i5Q1FOi5/WKBpC0JTOqfKG+MK8/9U40t/X2lhIQF1g8KErpIlSKChTauDKQV7rr WtHMDYo6vuLeHm9oDC8lz/oDi/NlTcqFZC7j93661wV3yXhK5MUOiQffFpfwHS0ucsmV h0p/73k8cIWqJH/O2PSLRErtJjEyQEYTz7UJ4TyD9YTWUQiXGFZsqjYvzrwcJAYOTpa9 /m5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074545; x=1715679345; 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=9khWE7rlDVNG5sjle6yOolXySu0ObdFH96voTvp2Qf4=; b=a9H1L+D24Qo/kRtoYL6h7e5M6bL0HkyvjCKyHXjmAYRRslZWC0EnPiWwn2IKTeW80M 0fiwAvexrQa8LgDphnSaP3Idw/QRfcZa3j8Gb2MX58rtxz/oker4VDEevCN4a2OUHcjo hJ4q1kittb7jPxNq2QzXa0SOhlSZU9nIpAgqxFGh9GIFAlV9Gs7aQ0v8zPbOrXnChO2L ToAPFoU4YsZdp27bx2wNjTYWfVe3GmXeOlV8EfrSawbAEXwty9uvOypjEZjCgMqkzi5r Bir1R7HSLGaHip3KeH6+0Y9zBtGfB9V31snCQ0/DKcWPWqv0wDgNfDmyubGt9Xq8SA8e oFJw== X-Forwarded-Encrypted: i=1; AJvYcCUi4mOFs6yPkNfPIpHe4YfQFFGMoP5X8RyAeODZMV/BMTY39KLeOcHsicLXQ8mgRBoOe88NHJHS8PhOn9Yj5arOjqZ/QDMtCKN/8XlD X-Gm-Message-State: AOJu0Yx+YXyLwQ9/Pcs53DXUGG6/KWXsQerT1U7ihfqczUekcwMArhOj k7KPBIfbVQDCKeUb24EYXG7U2ikeD2qFAEtLzDi3HsyT36ksTblT X-Google-Smtp-Source: AGHT+IGz8XnvZ8KkknLMrsQ7bPyorVmuS3zglfZMTVnQ3etWj7zmuGV3RWijd25RAAzMNeZbT7uXpQ== X-Received: by 2002:a05:651c:604:b0:2e0:4cbb:858a with SMTP id k4-20020a05651c060400b002e04cbb858amr6192750lje.27.1715074545378; Tue, 07 May 2024 02:35:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:45 -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 Subject: [PATCH 13/48] rcu: Add data structures for synchronize_rcu() Date: Tue, 7 May 2024 11:34:55 +0200 Message-Id: <20240507093530.3043-14-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The synchronize_rcu() call is going to be reworked, thus this patch adds dedicated fields into the rcu_state structure. Reviewed-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tree.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index df48160b3136..b942b9437438 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -315,6 +315,13 @@ do { \ __set_current_state(TASK_RUNNING); \ } while (0) +#define SR_NORMAL_GP_WAIT_HEAD_MAX 5 + +struct sr_wait_node { + atomic_t inuse; + struct llist_node node; +}; + /* * RCU global state, including node hierarchy. This hierarchy is * represented in "heap" form in a dense array. The root (first level) @@ -400,6 +407,13 @@ struct rcu_state { /* Synchronize offline with */ /* GP pre-initialization. */ int nocb_is_setup; /* nocb is setup from boot */ + + /* synchronize_rcu() part. */ + struct llist_head srs_next; /* request a GP users. */ + struct llist_node *srs_wait_tail; /* wait for GP users. */ + struct llist_node *srs_done_tail; /* ready for GP users. */ + struct sr_wait_node srs_wait_nodes[SR_NORMAL_GP_WAIT_HEAD_MAX]; + struct work_struct srs_cleanup_work; }; /* Values for rcu_state structure's gp_flags field. */ From patchwork Tue May 7 09:34:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656501 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 3ECFF158A37; Tue, 7 May 2024 09:35:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074550; cv=none; b=Ki4PX7XjMl/CMLb+M2F1PpN1qqqMRhLbI8bqKml2KF4oCNbTxEbmqgGGhrvGZdp/WgHdPaHwL5RdIss5KeSJ1Vey0jFDQzk0HhFB47oYioLdA0eaCKz6lSMoDTQxU2LISEQTDyPLO8H5RdYaMudBjkVRGWk1SNZ/41TCfxNu+uI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074550; c=relaxed/simple; bh=bHpVyST44tF4T9zshldUiiEXw2+O/L/8cC2lpkSqiIU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hnuTpwclRP+OzmSjPhkNiqeCALZIQ61M1U9Ogk6zWF6HcDyRjPXYmjJiR8ILT5nfrryaNDvYpGhAE1FIMl769uOMiXxUjfkjRVQ/ZT+kewm1ys0ev5+dLKvrbUTGiXM+lrUDrsxJ/Fpfc0lOoXVLg+EGnuYM6fsloakseT+SUSo= 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=gmPCNE3M; arc=none smtp.client-ip=209.85.208.181 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gmPCNE3M" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2e3f6166e4aso7188491fa.1; Tue, 07 May 2024 02:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074546; x=1715679346; 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=Yj9chs7bm2QTr68OIU1XSJLLlP4/vHDWkmUWKji8NeI=; b=gmPCNE3McolKMXC5ZYfscVhmcO1TvunGl3BJ1EymyBC4MWokKfNeRJACHZGBBVcGmh XlyvZS7gY50kuHAxFNg2iCHi8+YFAar2vD8bheDU43pnSgnonLuDUHUUYhEU/JwQtZJo OvQaBUYjhEHsxViMyo2vyhzICI1aq+gsw6Ju6eqiXdRSssdSEWfU3XwgwfaDSXprkMbM Jo/RNNKeyYYMLWSLsNFdWl/m5zDFrvexbJwmLuDmSx6MmaTJSyVcTXXWh4kj1uxvISoo bK9TAA4YmAZo6ugGzP1e/jL6qLHVWJqUpIiKCpsOE5IAoY4b7zKHIZSNVwhzCpOqyVOp p7RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074546; x=1715679346; 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=Yj9chs7bm2QTr68OIU1XSJLLlP4/vHDWkmUWKji8NeI=; b=d8efuk23QaekLsj49Nm0XUrq6ifLP5V3GQEwUked1ODyUCo0ZHYqFrhVXV+EPkou3i 0DhVCmTv9eMcYp5Q5rLilxeXWUuHaFH5NxkDPZZCKEB0ioLR4w2KnoIUJ2zl5pVBfSIO pi+whBhPoCK6zSCZq9iLJDLTbXf77RQQA2rKBWAhaHKT7XEMrveBVUf2E7ebx5jwxbJu zByI7kRgDeLYrS79dVjt9tlNphZ55iBg1VtLdhYyoXCRdtC2jxDbnEbSkx4Ouo+xdfN5 zpxlyTcT+h05bQsiBnbMAEgN39LH8RSlWMTdUVh59cZT5nXg+wAxaWa9RkF67YTrfNO+ WiRQ== X-Forwarded-Encrypted: i=1; AJvYcCXcIPcBTrq6rCSF+Uf59yDeY6geB9gctmgeB1FkViLChBv6uq6WX0lYjwVxo6WAymX24dpspzNSzEqBL8WVOce2PmtpLQkJOF5hoP07HcQBRfx/TrCcAGxOBWsyzxl18V4FjPxRlab6ijL9stK5Jylv X-Gm-Message-State: AOJu0YyYJ7IslmLk+YIaZGYphiE2pYl28q9lcTcBPAxt15Xz535PDdqI hBPDreo7vFBIT6S/60FV5pWW8BpCyhgdUzZ6JaVujsp3j8AQeRpT X-Google-Smtp-Source: AGHT+IEOauf9hq+Z225wSpCSM8stmekpSw5GxESD2O7JL7gGXrziPe3FLkwTMOzEhMXKzlo+hwk88w== X-Received: by 2002:a2e:7a14:0:b0:2e1:c636:168a with SMTP id v20-20020a2e7a14000000b002e1c636168amr9523289ljc.24.1715074546347; Tue, 07 May 2024 02:35:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:45 -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 , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , linux-trace-kernel@vger.kernel.org, Ankur Arora , Thomas Gleixner , Mark Rutland Subject: [PATCH 14/48] tracing: Select new NEED_TASKS_RCU Kconfig option Date: Tue, 7 May 2024 11:34:56 +0200 Message-Id: <20240507093530.3043-15-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Currently, if a Kconfig option depends on TASKS_RCU, it conditionally does "select TASKS_RCU if PREEMPTION". This works, but requires any change in this enablement logic to be replicated across all such "select" clauses. A new NEED_TASKS_RCU Kconfig option has been created to allow this enablement logic to be in one place in kernel/rcu/Kconfig. Therefore, select the new NEED_TASKS_RCU Kconfig option instead of the old TASKS_RCU option. Signed-off-by: Paul E. McKenney Cc: Steven Rostedt Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Cc: Cc: Ankur Arora Cc: Thomas Gleixner Acked-by: Mark Rutland Signed-off-by: Uladzislau Rezki (Sony) --- kernel/trace/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index 61c541c36596..6cdc5ff919b0 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -163,7 +163,7 @@ config TRACING select BINARY_PRINTF select EVENT_TRACING select TRACE_CLOCK - select TASKS_RCU if PREEMPTION + select NEED_TASKS_RCU config GENERIC_TRACER bool @@ -204,7 +204,7 @@ config FUNCTION_TRACER select GENERIC_TRACER select CONTEXT_SWITCH_TRACER select GLOB - select TASKS_RCU if PREEMPTION + select NEED_TASKS_RCU select TASKS_RUDE_RCU help Enable the kernel to trace every kernel function. This is done From patchwork Tue May 7 09:34:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656502 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 87D4715B11A; Tue, 7 May 2024 09:35:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074551; cv=none; b=C31O6r5Lgnkr5mPrqyOXriq9ZaJIv+rIuCDWxzy9GqwgMpaNeweT1JK3hciQzF9kkB/jr9A/dJnLtkLbRvAyI1zC/L9SUdVAfbcAR/9CrPVCqUBQNaY49IVDhDwwOJKJPfCtdcRMnY8gGa1WQdlpVaWxGLFoq0Wy+vrbgBdmNHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074551; c=relaxed/simple; bh=G5UgDUwYgbkYtBYd0068KteomsXMFoI4xHNbykAdpq8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dNWPNCHik5pgbLcaiWzM+X/fMB+XQNS7wnjO8I0ROuj/UBJiw5LW+ABa+AkTd1z4kBEUgCNWI4ROkROm2aaZWhZJES3s3uFT6BW9IVEguRxxdnAtF2HzwG0RM0DrI1ZOeoYSBKATC1hbGLox8zVj3+5uri1zm19hvb2Qx8xyHMg= 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=HtzLRibQ; arc=none smtp.client-ip=209.85.208.173 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HtzLRibQ" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2e3e1ad0b19so8250161fa.0; Tue, 07 May 2024 02:35:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074548; x=1715679348; 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=/haxlK53UizV+SleK0qa7ThwxwFJdnlLNlR+JkvSJOE=; b=HtzLRibQ2FMBXjR7xQsprPaIwuSkHaplJiuUfg0EN0femlK2o2JM0DQBrPq33jxfJ2 Ptmnr0+ZDGhB3aIy3hYF6PrOXd7dmpXHw+Ogwacy4JAyjepvl1ClvPsCd4EYAoK6/+w+ n7+sjODPiODOJ9nbuCsddAIqfRgwkhww10T53VeiqFDB1V32LChC7Bs1huqIMK0RPPUP Q65dZuhQ8ue2DmYxa/Vw2vEfELn30t3ltSwS3y3CfIAwZPkXaq9Vp9SpqDSIW+vgrKUq 17Ikx/EB4tVaYO3HNsCGlj63SNpjY/LqSDfWfBjbkROWPbarVv0C0g+4tWVU2h+KE4lR J2ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074548; x=1715679348; 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=/haxlK53UizV+SleK0qa7ThwxwFJdnlLNlR+JkvSJOE=; b=kVJudqZuZwabvnVhdgqhvBQi357fSyFGLLD6GF7g/J/0nqRUsrC499Jfwzw8lzODOH DGsSWB/9AERAVHE5cwsVvKc6MRfNDyx6tpnSxWpT5XJ7bzXeovUxmz4o25zAqWu9TBGi lM3WP6P6dnIsEXo6Gk1O66z24dcLjW4+7jSb1A7hNg8NNlw4zg3DO56f2wEbPvIIhX3r g9rVwB0wTHn/vVkYeGgk+vkqr6D5MAlhi2rxgbE+wE/fUPLsghGXtgcKoD5mGUhb5rra qLVu/VjEqgkK44/5h2wYQegP70plyQ559JjpF3ZmuDlFVRQkAn4GOcDlikhsLL6w0x4E UmFQ== X-Forwarded-Encrypted: i=1; AJvYcCV2VyfD+7Vca4LHQkRrvyXBnN6T8mp/0/kTZbJGAIheVdXe6mQ0ITNzl5xHIF9A0LWh3GSCBPRp0qxowX39shGu0NkClE8ZSVsvzwYFf+ei8A2I2dun6OYNl5ab2+MUpYyu X-Gm-Message-State: AOJu0Yzc2HTcPzAUTLuXrIci0Yf3iA2vIXz0wNjy+W6CA9ALF4+aHu2F 2b1akwOAyJtPanjmjgI4kchhTQC4B2XCewDklL/OG9P/vxJEWm3+3ZFSmKID X-Google-Smtp-Source: AGHT+IEoIfKd7XfhA0BRXVZFDJt+SXdbx+BppfUXbCeRu12K7jxUfWy7v/cBvFIssPL6qXdVfiZCLw== X-Received: by 2002:a2e:2e0b:0:b0:2e2:3dac:447b with SMTP id u11-20020a2e2e0b000000b002e23dac447bmr9471075lju.18.1715074547523; Tue, 07 May 2024 02:35:47 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:47 -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 , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Ankur Arora , Thomas Gleixner , bpf@vger.kernel.org Subject: [PATCH 15/48] bpf: Choose RCU Tasks based on TASKS_RCU rather than PREEMPTION Date: Tue, 7 May 2024 11:34:57 +0200 Message-Id: <20240507093530.3043-16-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" The advent of CONFIG_PREEMPT_AUTO, AKA lazy preemption, will mean that even kernels built with CONFIG_PREEMPT_NONE or CONFIG_PREEMPT_VOLUNTARY might see the occasional preemption, and that this preemption just might happen within a trampoline. Therefore, update bpf_tramp_image_put() to choose call_rcu_tasks() based on CONFIG_TASKS_RCU instead of CONFIG_PREEMPTION. This change might enable further simplifications, but the goal of this effort is to make the code safe, not necessarily optimal. Signed-off-by: Paul E. McKenney Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: John Fastabend Cc: Andrii Nakryiko Cc: Martin KaFai Lau Cc: Song Liu Cc: Yonghong Song Cc: KP Singh Cc: Stanislav Fomichev Cc: Hao Luo Cc: Jiri Olsa Cc: Ankur Arora Cc: Thomas Gleixner Cc: Signed-off-by: Uladzislau Rezki (Sony) --- kernel/bpf/trampoline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c index db7599c59c78..88673a4267eb 100644 --- a/kernel/bpf/trampoline.c +++ b/kernel/bpf/trampoline.c @@ -333,7 +333,7 @@ static void bpf_tramp_image_put(struct bpf_tramp_image *im) int err = bpf_arch_text_poke(im->ip_after_call, BPF_MOD_JUMP, NULL, im->ip_epilogue); WARN_ON(err); - if (IS_ENABLED(CONFIG_PREEMPTION)) + if (IS_ENABLED(CONFIG_TASKS_RCU)) call_rcu_tasks(&im->rcu, __bpf_tramp_image_put_rcu_tasks); else percpu_ref_kill(&im->pcref); From patchwork Tue May 7 09:34:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656503 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 756BE15B995; Tue, 7 May 2024 09:35:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074552; cv=none; b=Gedy9bovmu8bbFDgkGVDNDaoXlIfKtficblqSzqc+m6B+GrPELq88cemQJ6NJeE2HjmHZOmW726ki4fbYpyzVetktidUN+oiWGOyNx6dEMEERN55VGYtdrlwz4l/mUhgaHPa13JhrwKbM+Z1GKJJRg8nAcig5PJy9C/NjGc6gDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074552; c=relaxed/simple; bh=Xup+ur6V7gGCPjLWD2d3gVVVucYcMlzVWTS+lp/sUdg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b17VeTI+aYrJ5inuUaq3Lz2CZEVRBe8aY2VH6A9TV7MR0kkcfPIMJ+mXh9XNrHIpy++e4SbCT53InaP7LDB1/54HQnGantClA4abbFOFhYc2vxQtWUClnFL0o+Vghv2iP2vZHMgPHaG+pXiaKlsaTluU5lcZCvR5DtW+S+WAfYs= 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=M8gmE8Mb; arc=none smtp.client-ip=209.85.208.173 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M8gmE8Mb" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2e3f6166e4aso7189291fa.1; Tue, 07 May 2024 02:35:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074548; x=1715679348; 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=CGeMtJo22ZpGiOOGfiBpDVqkkH4o+185ycvE55zdP/o=; b=M8gmE8MbMnYyAKJYr96bfv+XLsSbDdAhX4rNHDjsq/wfokUCfq2CAY2O9CQNK+9T4x KqMAsvdD/k1epQZNCcjR1GIdAJDEJ6UY0gZO7XgE5hhGSUMR7jlExF0dpsBb42jBEJkv vEGeo6rJXXJxb9hkVpcOKm6qAewaHmjwQixLvULRNfI2cP3fI+YOiCS4eghQ+HAhTlrs nYgAbpCTX3rdw97oVJkqW7s30Syqb0vwghnrjahPaIGATacVaCi0oWst9rAvdc2aHrZn oiJZSmytnJjPnPOWuEHV9cTkQ6k4QOPk1R/dN7+azbytTTXexJX/nhD4XxpvsDRXTAvK YlTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074548; x=1715679348; 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=CGeMtJo22ZpGiOOGfiBpDVqkkH4o+185ycvE55zdP/o=; b=muIfTO7vbe8a8/v2IFCk5feI5tsoW4eO7RvzzKWy3MGMiT8LL6YN5FdO7METUDHokq ZwCEpV4rqcJNFpS+1sVMJNOZOOqW9XIXO4QsAfzBSi6VHTQ/Be9AzZpVbWL6IogObrpW rQx6V+AKYocIPrF8604uo3JaFdiqIufIAXIAC9+Rf66kYXZvl+nwp3NopCIyacquNakY NV8AH/37vM9yjNWGmXYeNdK/hIbg+Sc712ZRbOK7EYelzip/FQiIquPj+Jw/uNXYsbh1 hlyzBqPOESEVgn/kjpDrEZYMOSEqRVeZsNjj7wZ6HhoSSX0wfj63NBFJHjeKcWyJwiwS ltDA== X-Forwarded-Encrypted: i=1; AJvYcCXVqtMNPnJU1VsD2Jzeqso6NF557n9ualH4vskklfiJRQPZf5/IUzVkJZ9IWsFoXGaEu8NYleIE539kSyWDhKIodyZ1zoriIj/c8mMBIxv9gfSqzjwYiN8p5HN4QusKV8/B2UekK79URhvNWeiXULNj X-Gm-Message-State: AOJu0Yz/sPzPA2fouQqUnL/41R7p9O9WXUhwC4FDg1z9OIzFC16mpxGm Mwuq+B7ktomR202b0PhXM2W50UziYSowA383Zvb6Q9R01HM6tGL4 X-Google-Smtp-Source: AGHT+IHLJp/5yXY68S2MEoHJWtlxnGiX1bJVli0zsoyajbNNQvNKrwVfZXDfz7x/bta8cstMv3LicA== X-Received: by 2002:a2e:914d:0:b0:2de:75de:5b0b with SMTP id q13-20020a2e914d000000b002de75de5b0bmr11651610ljg.18.1715074548565; Tue, 07 May 2024 02:35:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:48 -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 , Steven Rostedt , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Ankur Arora , Thomas Gleixner , linux-trace-kernel@vger.kernel.org Subject: [PATCH 16/48] ftrace: Choose RCU Tasks based on TASKS_RCU rather than PREEMPTION Date: Tue, 7 May 2024 11:34:58 +0200 Message-Id: <20240507093530.3043-17-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" The advent of CONFIG_PREEMPT_AUTO, AKA lazy preemption, will mean that even kernels built with CONFIG_PREEMPT_NONE or CONFIG_PREEMPT_VOLUNTARY might see the occasional preemption, and that this preemption just might happen within a trampoline. Therefore, update ftrace_shutdown() to invoke synchronize_rcu_tasks() based on CONFIG_TASKS_RCU instead of CONFIG_PREEMPTION. [ paulmck: Apply Steven Rostedt feedback. ] Signed-off-by: Paul E. McKenney Cc: Steven Rostedt Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Ankur Arora Cc: Thomas Gleixner Cc: Signed-off-by: Uladzislau Rezki (Sony) --- kernel/trace/ftrace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index da1710499698..6c96b30f3d63 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -3157,8 +3157,7 @@ int ftrace_shutdown(struct ftrace_ops *ops, int command) * synchronize_rcu_tasks() will wait for those tasks to * execute and either schedule voluntarily or enter user space. */ - if (IS_ENABLED(CONFIG_PREEMPTION)) - synchronize_rcu_tasks(); + synchronize_rcu_tasks(); ftrace_trampoline_free(ops); } From patchwork Tue May 7 09:34:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656504 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QaFmP+d6" 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-Google-Smtp-Source: AGHT+IESvo928QYIKVoiGJbS3Gqs7DuqvngqFe4PS3eX9ShGzVXSihMCTUfUgehug3MiuXvwwkmFdA== 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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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. */ } /** From patchwork Tue May 7 09:35:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656505 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 2B4E315DBCC; Tue, 7 May 2024 09:35:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074553; cv=none; b=BEBhY4SdqgLZlcgDwKCgnDGb4crfuCV6IjBHW3pnsEhtG+pkvcJ7IGo/eno2qBngEZOKDeNjdICMvCezi9zMM9pSG7dMTyZY2hST32thHQFU77+fTqSO69//9VckwU7xWEfVFTHrySltGHycIKGug1dlOe2k0Lut8uNcAcPVEtc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074553; c=relaxed/simple; bh=CQi6omiuMOIdje2fZYB1jOQAZbYXL+rdG54y+ely1xA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=R2bHyvibTl9XZB+Ct6bjjkKfQuoYrwrzBaUJQOs9FzQkmuzP+ny3PZJz2pfMHz/XXzVHS56toX8hMHqijzESqim2x2aXnP5tdeFJe5LfuIgdSylAMzJIZKyKI/FKwum9UrjL9s0AopsfQx5BTsh7lVheqn8H6ucBWqYg+aiEcL8= 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=M3+BwMt4; arc=none smtp.client-ip=209.85.208.179 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M3+BwMt4" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2e3e18c240fso8454661fa.0; 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=1715074550; x=1715679350; 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=yNkYNx/ZpQTIkDY1eBLed5ZhKwlCgOHBgpZcacIwxtE=; b=M3+BwMt4pyRqxhOgICZ8yIM+IWmXsOm6eki6C1CEBJfF6mhgpkq5gHv+lxj5y5aFPx ajIQG/eWNzEv/k2M+lrY1PMsXe+TNEga77yK4rgFQbd4+dkT0V50IWLRjlGVU017Iuvu 4xQLEkZym7xGpq3vsk84h0aFkXNHtFi+z/Nrxk5l68BYC4Uk2FUy+u7CwwfovzXwe6Y1 XEGEWP01Qgr+meDHon1+37OvpClJWTgbxJqyPXSU+L/Ud9Bqx1B6mZIipcEv3k5gPYUW 2ZLkElpc2Srq9ekOBFighDD6zohEMKH4vu4/oENv8reR25zft048QGvaJTsJ3FiweR0X YKUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074550; x=1715679350; 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=yNkYNx/ZpQTIkDY1eBLed5ZhKwlCgOHBgpZcacIwxtE=; b=ee/iwwbdK2xklxJ7+E0kVGMXt+sMGOqcy+farzfagS7KdIBp5PMqqVoWkLjsxzlOIB 4ZhXbXR+1X11o3Ns6pMzuEPC2DJLJfpALF/iATYQjmjxJ4On9QSizGHZApQjH3FG+dq9 N+t+Oc7obnOgE1qGHYQukccJWgAF5TnrwpnmjMmqBJhfBW0Uq+HCdqP7s9FYoeOFkb9v xmDMyql9etG91vmQWP9GxZHA9YBtt0Pczzt/hgyShLN0kQdYtNj4Wf9RK6UEDIzAD42F tjGVaQfem2d0pXbgI8Xmz37jS3owSjv6dGdXx8Bck3fzGTwzEOvhSe8RbyKnH+kf9YXi yMKg== X-Forwarded-Encrypted: i=1; AJvYcCUo/7Qh+qDXDb0gbvqmdWoyz+ZN/oyQBBF21CnaE/jKGYcoIvKPYA5vMoLLSxLbVFBtNraic8NQ2cIB8I2Ng+uGKzz3X/TSqEuiovc2 X-Gm-Message-State: AOJu0Yx2MIejIPPVkoiUyLBh302rmcqNA5UuIMjrjOt4EGWU7EN1iKi6 Y3Tsn+VuC08wum82HEVrSWMMsfc9eN9/8spbCOwySOVjbAN2TRfB X-Google-Smtp-Source: AGHT+IGO43ycIxjLnUJmQ9JIjfUAooDLvQqcbcp/oHvUpwF20pPOHY6XSusd2tislsuzjFBkmC4/EQ== X-Received: by 2002:a2e:8e74:0:b0:2da:36be:1b4a with SMTP id t20-20020a2e8e74000000b002da36be1b4amr9300341ljk.19.1715074550355; Tue, 07 May 2024 02:35:50 -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.49 (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 18/48] rcu: Make TINY_RCU depend on !PREEMPT_RCU rather than !PREEMPTION Date: Tue, 7 May 2024 11:35:00 +0200 Message-Id: <20240507093530.3043-19-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Right now, TINY_RCU depends on (!PREEMPTION && !SMP), which has served the kernel well for many years due to the fact that PREEMPT_RCU is normally a synonym for PREEMPTION. But with the advent of lazy preemption, it will be possible to have non-preemptible RCU in a preemptible kernel, so that kernels could be built with PREEMPT_RCU=n and PREEMPTION=y. This commit therefore makes TINY_RCU depend on (!PREEMPT_RCU && !SMP), thus allowing for a non-preemptible RCU in preemptible kernels. Signed-off-by: Paul E. McKenney Cc: Ankur Arora Cc: Thomas Gleixner Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig index e7d2dd267593..7dca0138260c 100644 --- a/kernel/rcu/Kconfig +++ b/kernel/rcu/Kconfig @@ -31,7 +31,7 @@ config PREEMPT_RCU config TINY_RCU bool - default y if !PREEMPTION && !SMP + default y if !PREEMPT_RCU && !SMP help This option selects the RCU implementation that is designed for UP systems from which real-time response From patchwork Tue May 7 09:35:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656506 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 1068215E202; Tue, 7 May 2024 09:35:52 +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=1715074555; cv=none; b=QJdT6fGoBKP59BupbrQDiiZeNqpkr2+wo72E0wcsAfbIFKsSBb++Iaunh4r5FPXsOvsunEe4kgk25pXXi0vNWo5Luzx7JKhIRaOktP+kQ7ZTcLZgHNHZzdSEl2Z4Id0Xo0s3UalUyPIKKQiQbdjCS8qtrScU5R7uY1wwlB5bfOw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074555; c=relaxed/simple; bh=l+TmEbx4CZVxGim40UrwGluV+jj9QY0FS6+FbuN8SPE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jc6aZ4I5SAj6u75YVGP/87UU4HwumTK41V2wzNLK/oF8QUwvFfOch70av6C2w0KjkK9XS8zyj6Rla487YmTAJo/PQkruozWvEMXgrWGoe3wAUewgBnwAciHLs45Ut37hUhV8RSdXIdsYytPvbeh0gOzuQCl0uwtNTpa9ASudRdA= 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=FT58enar; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FT58enar" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2e2b468ea12so27098181fa.1; Tue, 07 May 2024 02:35:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074551; x=1715679351; 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=QwgYfRQeH2LZBoFYMj3QaS/pu39IjMn5T1SZZO1FiIg=; b=FT58enars63RpPsOhVX2AsQVYIk3C8hc/WgNMvHrECFb6jYL0/RH8GmX+FPBXyZSYJ QSKPLzFhHIx3E1FWAf24Jb0QtgegemVrfO8BYTHSS5oKWEW8RMiCD+qIfR3mn5gGL7Lg YNcH7c4H1xECdc4gQOFDZd/8g4AccKi0XhiDruRI17mC7PNNLpCaymchSkzU2IVuT1ne aEcb8mONQiYykPQrsk3prI5EB9Wx9XEJzP7CzMQ0d7ykpiPLS/stXIQgEw901+UV2C25 MiCPbEWbdAJp+zwGcik7yTrgP+Q/8dVV0CV/iVc5WY7opDkfUxZTvvtX+Bbn5IsHPIp8 Q7Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074551; x=1715679351; 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=QwgYfRQeH2LZBoFYMj3QaS/pu39IjMn5T1SZZO1FiIg=; b=ZPPSvQCouoFvPGmENaLoHl+8iqPYBJUuDDbflBK6oWJL0t33aXfxGP3jlkRVn0Rb6P m4tVDWPrIvJbOoJDFJswE5f1jE7OnHoN5OkUwAooVHyGf2bIImn0IpAy9YDsoUgF/XBa dqBW6DeaN1n28X/hz7mfa9lWkAgt6m9rmrqrsethK9OQSERMED7epUR57zEJ0joNeQz3 SvdJvxOpP1KTK1g/NYksMngua5HPypm8CtkQeJPvgWXg2ncuDl2Pu0YPWrrHgyFqUX6b E5m3HQlWKbzwghDWeXL6iv/rG2WUjkFlYllyF4F4LK7gMAOYvidnTmqxvLEE2ycM34JL zb/g== X-Forwarded-Encrypted: i=1; AJvYcCUA0YpAtm9AcpIscFYjTwEFxr1cbrrDQVXu3od+XP7JUJBGPD0m910HhGAKlD6sOc+5QQRcnV9ccpl1ohiNtvsnfYGrRYrHx6Ff7kSw X-Gm-Message-State: AOJu0Yx+WOxZ60chiT8Bc04s2zrok5LESh+OuUUK9RxVz7QIdCE3dIfC RttH8TfoxlTPdUKn3cvFF94x04JO/WnecbLK52TD5RYYxfzePJhc X-Google-Smtp-Source: AGHT+IEpk0YG201j9uTFaKgX/2/QvGXXxyPYmpbGMIa2dQWtXy3VFHixmRjgHAflSWZemlMv04YvIQ== X-Received: by 2002:a2e:a0d7:0:b0:2e2:1b1c:7462 with SMTP id 38308e7fff4ca-2e3d945ad29mr6199361fa.10.1715074551231; Tue, 07 May 2024 02:35:51 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:50 -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 19/48] srcu: Make Tiny SRCU explicitly disable preemption Date: Tue, 7 May 2024 11:35:01 +0200 Message-Id: <20240507093530.3043-20-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Because Tiny SRCU is used only in kernels built with either CONFIG_PREEMPT_NONE=y or CONFIG_PREEMPT_VOLUNTARY=y, there has not been any need for TINY SRCU to explicitly disable preemption. However, the prospect of lazy preemption changes that, and the lazy-preemption patches do result in rcutorture runs finding both too-short grace periods and grace-period hangs for Tiny SRCU. This commit therefore adds the needed preempt_disable() and preempt_enable() calls to Tiny SRCU. Signed-off-by: Paul E. McKenney Cc: Ankur Arora Cc: Thomas Gleixner Signed-off-by: Uladzislau Rezki (Sony) --- include/linux/srcutiny.h | 2 ++ kernel/rcu/srcutiny.c | 31 ++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/include/linux/srcutiny.h b/include/linux/srcutiny.h index 447133171d95..4d96bbdb45f0 100644 --- a/include/linux/srcutiny.h +++ b/include/linux/srcutiny.h @@ -64,8 +64,10 @@ static inline int __srcu_read_lock(struct srcu_struct *ssp) { int idx; + preempt_disable(); // Needed for PREEMPT_AUTO idx = ((READ_ONCE(ssp->srcu_idx) + 1) & 0x2) >> 1; WRITE_ONCE(ssp->srcu_lock_nesting[idx], READ_ONCE(ssp->srcu_lock_nesting[idx]) + 1); + preempt_enable(); return idx; } diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c index c38e5933a5d6..5afd5cf494db 100644 --- a/kernel/rcu/srcutiny.c +++ b/kernel/rcu/srcutiny.c @@ -96,9 +96,12 @@ EXPORT_SYMBOL_GPL(cleanup_srcu_struct); */ void __srcu_read_unlock(struct srcu_struct *ssp, int idx) { - int newval = READ_ONCE(ssp->srcu_lock_nesting[idx]) - 1; + int newval; + preempt_disable(); // Needed for PREEMPT_AUTO + newval = READ_ONCE(ssp->srcu_lock_nesting[idx]) - 1; WRITE_ONCE(ssp->srcu_lock_nesting[idx], newval); + preempt_enable(); if (!newval && READ_ONCE(ssp->srcu_gp_waiting) && in_task()) swake_up_one(&ssp->srcu_wq); } @@ -117,8 +120,11 @@ void srcu_drive_gp(struct work_struct *wp) struct srcu_struct *ssp; ssp = container_of(wp, struct srcu_struct, srcu_work); - if (ssp->srcu_gp_running || ULONG_CMP_GE(ssp->srcu_idx, READ_ONCE(ssp->srcu_idx_max))) + preempt_disable(); // Needed for PREEMPT_AUTO + if (ssp->srcu_gp_running || ULONG_CMP_GE(ssp->srcu_idx, READ_ONCE(ssp->srcu_idx_max))) { return; /* Already running or nothing to do. */ + preempt_enable(); + } /* Remove recently arrived callbacks and wait for readers. */ WRITE_ONCE(ssp->srcu_gp_running, true); @@ -130,9 +136,12 @@ void srcu_drive_gp(struct work_struct *wp) idx = (ssp->srcu_idx & 0x2) / 2; WRITE_ONCE(ssp->srcu_idx, ssp->srcu_idx + 1); WRITE_ONCE(ssp->srcu_gp_waiting, true); /* srcu_read_unlock() wakes! */ + preempt_enable(); swait_event_exclusive(ssp->srcu_wq, !READ_ONCE(ssp->srcu_lock_nesting[idx])); + preempt_disable(); // Needed for PREEMPT_AUTO WRITE_ONCE(ssp->srcu_gp_waiting, false); /* srcu_read_unlock() cheap. */ WRITE_ONCE(ssp->srcu_idx, ssp->srcu_idx + 1); + preempt_enable(); /* Invoke the callbacks we removed above. */ while (lh) { @@ -150,8 +159,11 @@ void srcu_drive_gp(struct work_struct *wp) * at interrupt level, but the ->srcu_gp_running checks will * straighten that out. */ + preempt_disable(); // Needed for PREEMPT_AUTO WRITE_ONCE(ssp->srcu_gp_running, false); - if (ULONG_CMP_LT(ssp->srcu_idx, READ_ONCE(ssp->srcu_idx_max))) + idx = ULONG_CMP_LT(ssp->srcu_idx, READ_ONCE(ssp->srcu_idx_max)); + preempt_enable(); + if (idx) schedule_work(&ssp->srcu_work); } EXPORT_SYMBOL_GPL(srcu_drive_gp); @@ -160,9 +172,12 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp) { unsigned long cookie; + preempt_disable(); // Needed for PREEMPT_AUTO cookie = get_state_synchronize_srcu(ssp); - if (ULONG_CMP_GE(READ_ONCE(ssp->srcu_idx_max), cookie)) + if (ULONG_CMP_GE(READ_ONCE(ssp->srcu_idx_max), cookie)) { + preempt_enable(); return; + } WRITE_ONCE(ssp->srcu_idx_max, cookie); if (!READ_ONCE(ssp->srcu_gp_running)) { if (likely(srcu_init_done)) @@ -170,6 +185,7 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp) else if (list_empty(&ssp->srcu_work.entry)) list_add(&ssp->srcu_work.entry, &srcu_boot_list); } + preempt_enable(); } /* @@ -183,11 +199,13 @@ void call_srcu(struct srcu_struct *ssp, struct rcu_head *rhp, rhp->func = func; rhp->next = NULL; + preempt_disable(); // Needed for PREEMPT_AUTO local_irq_save(flags); *ssp->srcu_cb_tail = rhp; ssp->srcu_cb_tail = &rhp->next; local_irq_restore(flags); srcu_gp_start_if_needed(ssp); + preempt_enable(); } EXPORT_SYMBOL_GPL(call_srcu); @@ -241,9 +259,12 @@ EXPORT_SYMBOL_GPL(get_state_synchronize_srcu); */ unsigned long start_poll_synchronize_srcu(struct srcu_struct *ssp) { - unsigned long ret = get_state_synchronize_srcu(ssp); + unsigned long ret; + preempt_disable(); // Needed for PREEMPT_AUTO + ret = get_state_synchronize_srcu(ssp); srcu_gp_start_if_needed(ssp); + preempt_enable(); return ret; } EXPORT_SYMBOL_GPL(start_poll_synchronize_srcu); From patchwork Tue May 7 09:35:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656507 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 EBEA715E5AE; Tue, 7 May 2024 09:35:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074556; cv=none; b=hXlHrj9B9cYyUlihqAxjBYri4uNT5kof1i2bUHMyXX9WUTCAfKjAnbK2KhNy00ezgdzwsG/BERwmHABzov+rnCayWDxTnX5u8jyW9cDgWdFnQfn4IpoL3MgHQ/+4s8cU8m455yQ1+3Nyv1p3L8x+ShR/WjJHfL5/i5lT/X1xquo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074556; c=relaxed/simple; bh=1h5PTnEjN3XTAEqeqf7c//E2/U6L7mwbdJGy/pN+PlU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F8Tbde0AFir726XfPtjEUnwTlQ/Fhw0qf8zj7zUM5PdPTv77z+dJ0NlZXesZgxtgIt0vR8t4viTOjEtSbkpytBZGKXNf4OWE/v9QmA4Gf7sLUVFUuWXLvHYyxC0orSj7e66F2T2nVUoL4SoPjcmRroGpwYbg+/BuxCuyJM94sJU= 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=EOE9b1mN; arc=none smtp.client-ip=209.85.208.178 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EOE9b1mN" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2df9af57b5eso38860561fa.2; Tue, 07 May 2024 02:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074552; x=1715679352; 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=Pp3uSRTGzyTrrsXKNuVnjxaJ4vNThArGqCT0EkGmYcg=; b=EOE9b1mN729TAe548gtngGm6HviMcXY8bpaGi8vjIrTO9ETLmsDDAK0INMuNC7RtJA GGfcJaiH5VKQjYl4m0c2W1RNsBDsA3kMh1u01XTGPfm2OxfM54Zm45GCaFzYtODF3tyX bhETmzRc+hmNN37e6xB9g++MGHnidTQdB2GNdMReVZwI/AwBabI6v5CSsalu3nKb/KjL suZG9gkbw8Yl1br5/LPIm7wD888/7dmb0iq8etXv+VopnEF4HHCSuqPPyODjvqRErTUH N4/gfE7EBT5UE7BgLa1Ax7MHBu8NWEGC+2U3quHZGOYzdSrm0hwb2i/CUE3uxaohQBbY Fi0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074552; x=1715679352; 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=Pp3uSRTGzyTrrsXKNuVnjxaJ4vNThArGqCT0EkGmYcg=; b=AWzs0qVSaYei5Ca5Jj39uEG+d6L1Ze86A6fAw2Tw+lGJcHBE8zfUN5MPhzNj/rt3qj 0EPeebyTfWNRgnsnJCJBR6C+YZN8O8Uj6t/MW/wjiQ41Qpvz7XtZbP3pur3X8vV+aRVR zcGkX12NTnhWMUq+ZRsz9hIpaQD32WXieRYTbLpnElQPuYh9/aga2kYTud6jVIodqlUL kOo1gDa69aj925f9rEwFSIIu9CxgseFr1o4PoLAb0w+6BhV66S7eMbojsRsVSckUjlvg uFdTFa5L1vAP5whmUHHMnZIrnU9bGcY/6LYTzUovhPt+tfu3yRlfbEBgNEzYrf9YIbCJ sMtA== X-Forwarded-Encrypted: i=1; AJvYcCVN194zQzSqj9eLv62CPiJ2ICQ1vYHOaT+WfHW/IKpeNl5qE4sMmmjDU6CP9VNvtwYLbeKteEy8KP0UtfHCpIPy6o2NYkoPBJvFDY3i X-Gm-Message-State: AOJu0YyBW1vNPyUTAH0fRvQMuznwXRt5/Ry8V8jRvj5lATHCijZnKlve Ep/ZPmIg1SJ17s+/yxtQ4ec0+rJ787+FIWyrsJUhEUB2bMsTWM0Z X-Google-Smtp-Source: AGHT+IE97GB1z3q/6z5Vg5BApF0/HQT/0T3sW/RXQGwdM0BmQEs65+Yo/TSCby+tMP48EVe8SiCQ0A== X-Received: by 2002:a2e:be8e:0:b0:2dd:cb34:ddbc with SMTP id a14-20020a2ebe8e000000b002ddcb34ddbcmr12375237ljr.48.1715074552165; Tue, 07 May 2024 02:35:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:51 -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 , Steven Rostedt , Mark Rutland Subject: [PATCH 20/48] rcu: Create NEED_TASKS_RCU to factor out enablement logic Date: Tue, 7 May 2024 11:35:02 +0200 Message-Id: <20240507093530.3043-21-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Currently, if a Kconfig option depends on TASKS_RCU, it conditionally does "select TASKS_RCU if PREEMPTION". This works, but requires any change in this enablement logic to be replicated across all such "select" clauses. This commit therefore creates a new NEED_TASKS_RCU Kconfig option so that the default value of TASKS_RCU can depend on a combination of this new option and any needed enablement logic, so that this logic is in one place. While in the area, also anticipate a likely future change by adding PREEMPT_AUTO to that logic. Signed-off-by: Paul E. McKenney Cc: Ankur Arora Cc: Thomas Gleixner Cc: Steven Rostedt Acked-by: Mark Rutland Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/Kconfig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig index 7dca0138260c..3e079de0f5b4 100644 --- a/kernel/rcu/Kconfig +++ b/kernel/rcu/Kconfig @@ -85,9 +85,13 @@ config FORCE_TASKS_RCU idle, and user-mode execution as quiescent states. Not for manual selection in most cases. -config TASKS_RCU +config NEED_TASKS_RCU bool default n + +config TASKS_RCU + bool + default NEED_TASKS_RCU && (PREEMPTION || PREEMPT_AUTO) select IRQ_WORK config FORCE_TASKS_RUDE_RCU From patchwork Tue May 7 09:35:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656508 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 D956215E1E5; Tue, 7 May 2024 09:35:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074556; cv=none; b=nVn11yL4sMRfK6uC/COz1SLknkI3rXb2ffkF1wdJxiAu1hPUjWJZ6efdtv7WhsJK69wdDtI2no4HrLpI6gudn1aAHuYXByIPjVR9VDtxsZ7Ru/Sb4oP51zXcVk9FUsdrDyNTrsHc/tUL1qewe8o5siaHiVOnLmjwETjFjezSkZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074556; c=relaxed/simple; bh=zfE0jzpc3gN4d7Fx9F2XDO5M9JRfm30TahjMHP8f+8Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=utBuqLiaXi3dFEACZfs5us/sMjeGcLN8jf7FZqx3FM/dppwaeKB3dtZszYtr2UXFeFkRX7czymW2T2g5bFMcq/qXMPcRnq03+0u+Lh34YpChv4JYTRz3f6mFE5TLq+NY373U9WN2jkUCf6xRnVwJSqiJ1VnNzaC4jWD0SFR29bs= 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=bQla54pN; arc=none smtp.client-ip=209.85.208.175 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bQla54pN" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2e1d6166521so42221031fa.1; Tue, 07 May 2024 02:35:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074553; x=1715679353; 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=VAJsYakYPuzaiyx0tsxsRzlSG1LGaCLezN9z7sN3Trk=; b=bQla54pNU/AWLRtf8gB4cUHCrmGsOZ9S1O/TUwWSSEv4NDyGqsVEK6tvZxViqQQKz+ 2Un2jv4lB3zThS4ccNtPXIY6d8XmYz7ot9D+4/3q/KA1WsjoPHQMaRcb8ZFYaH/3Swy4 CSKnNP85PT03OTLt/X33KpMCpLmTjZzA7twWSydtXWjSy/tjN09/cqdx9i3OAHf4P6Sa WggZlClAQPDMnMI/vDbpjk4IXOa8GbcIMYd/ZlxrVTjo+7tiTsZPuIosRz93i6dktMpI ubsyHb9PzDGbiRVrECjOP8kqvv5nwSEV+wdbAgXQbC5OK0ok/MtpTVBcrNH1905rZMDx Cbxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074553; x=1715679353; 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=VAJsYakYPuzaiyx0tsxsRzlSG1LGaCLezN9z7sN3Trk=; b=b7C1fHTPnmNrLQ5KieZ1ewjsIgVQsLpvfRFmx7mRbE9cAEW7gR9B8W+VuggWQXkHKb DbOMgCaM5zgjdRfmmYYgQefecUDLkeB67/NnxLGbzFgOOJjKA0+NvTdlTPDrGmSzkscT f9mYgQXM/yIwfJfsVLl+KuN3Eh5oVNRcmQQevCQw1a58T7XL8Cl/SW/Hyp82a9l3+kxR YZTrNx1bRaAbjOQ9EXseXp+I9g1zh/LDeILds06it32xjy9MBdB0GNquFCAvznzGoYcx pTFjpcMipTr3t1ZDKYHdN66p6Lk+8zXQCtgD7BWwFBUxYn4ApCNVa7LkD243Evew7nRk hH5w== X-Forwarded-Encrypted: i=1; AJvYcCXlEA4BKO3RvM+j4VRnoBv07iaP/axORqco0KIMopcJpixhtrlOUn/2KLvlmHL/oIvd74tXflM0m5scHuju6jD/PFq+ARD7rrfvSHhL X-Gm-Message-State: AOJu0YxZ3+SO5yfMhXEPIc3w19LZweCQWismQPIiFUuxxJHo8q/+5iVg ta+WepJXxD1U84iTKeGG+znKmL7DybIzM6hQagluOnjdiv50mSWkBL8bLbmn X-Google-Smtp-Source: AGHT+IFHkxQwlfbiNpBbu7tJ+xnduiAQ17o62nmnxK29X7BBRylBpjE6EC6cV1+IWSFFcZIOYcYNkQ== X-Received: by 2002:a2e:99d7:0:b0:2df:4bad:cb68 with SMTP id l23-20020a2e99d7000000b002df4badcb68mr709364ljj.16.1715074553013; Tue, 07 May 2024 02:35:53 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:52 -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 Subject: [PATCH 21/48] rcu: Remove redundant BH disabling in TINY_RCU Date: Tue, 7 May 2024 11:35:03 +0200 Message-Id: <20240507093530.3043-22-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" The TINY_RCU rcu_process_callbacks() function is only ever invoked from a softirq handler, which means that BH is already disabled. This commit therefore removes the redundant local_bh_disable() and local_bh_ennable() from this function. Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tiny.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c index 705c0d16850a..4470af926a34 100644 --- a/kernel/rcu/tiny.c +++ b/kernel/rcu/tiny.c @@ -130,9 +130,7 @@ static __latent_entropy void rcu_process_callbacks(struct softirq_action *unused next = list->next; prefetch(next); debug_rcu_head_unqueue(list); - local_bh_disable(); rcu_reclaim_tiny(list); - local_bh_enable(); list = next; } } From patchwork Tue May 7 09:35:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656509 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 CFE5215E7F1; Tue, 7 May 2024 09:35:55 +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=1715074557; cv=none; b=sJt1t994C94SXxgmGS/VITWnNtEwshaCiyLS9WmaSskc9OJ+Eb2IN5sV9wldY5CK/aesmcmBp8SnA6rK+mdWv/v5tuvazeICd/jE3gJUAxjNqklCNCvpua4t6weoqL3b/OvCWCwDeem3WDZvF0OojfT0KrD/6Mh2bJB2ud7ODV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074557; c=relaxed/simple; bh=EOftjnAZd5uf9q9CC9tawmar6GdKcCD7no4cBP4OAig=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GEj/wOB1rFcDZ1oqMd6Y3lKvCa3P5YG34fH0UUoS44ih9+THIiJ9J7CUGYdLGy5QxzEMnzaRIPKdswuR7SAHRadwxL6d8NUveLRAxqhWWXK3OGjKADUz4oRuV1HvRVHLB5AOp50FzsJWUlJwnetx/A9ebTKwr81OBKd4GjbsOhA= 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=ivoADhJA; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ivoADhJA" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2e1fa2ff499so43173921fa.0; Tue, 07 May 2024 02:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074554; x=1715679354; 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=vrZOUbT7E5D7zH88y+EQ1yyWhied5edZTEw8B++TWpw=; b=ivoADhJAQYkMTBI44dD18gwueUHJBmXbpooAG2ZwLPM0U76IRebeWWosrtoqKOybVF 131JoLZMvZWPRzMUWdgEBr9dh2JYCuaySidwMWK8V1SpFFAo8WCAzIRmOFcHG1VrlkiO M8DgG14dJaFX2hi2v7hzsH61GUV8UQqsZgw2eJRNNfbsGp1xjAh0tIqGT1LUXjZoQMOD 4GsD+n38b8yggflGUxFhxYlmB+7wYDEKzdN1ol6UrG/tlhI8vCckXrJ8u1t7oo3e/8fM Cj1lPo2xMdtv7ae86nzNncxjBaNDrYSxxMPOa/BC9V/zJNYnmAJ0j15TAXXKvDDZ3d6d qd0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074554; x=1715679354; 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=vrZOUbT7E5D7zH88y+EQ1yyWhied5edZTEw8B++TWpw=; b=n33f+dDFC/X2HSk06HW5uGbDVsgdyfSNiD/0lJ0ZwZSu4yvkYDsgV8Hk4xZLptMWRd ob4jsf2/971Kd01hO+WMGHWCVInjgWR+6y6zR8HDGEl8pEGBUJEeCeoPmNftsd0gNM5p rlQ3YjDC1qB/1EsU+sTVXF5nGlCyZYRZ2bt/sfWvsfOCQF6HYHYuFS7Z7fHtVljr1Otu fk2Px+N8qw6b5FH41gAWApexyDodKAqtD9PmQTjChWUfJvmcvowpj2xdBvf7WLQ/cusf k6LqAIOhEu7exyf22N8iiWhv5VHg4qBIzYR5IZ0HY10qc6UTQ8+q6MwfI4bVB+7ZL9Bq 6iKQ== X-Forwarded-Encrypted: i=1; AJvYcCVWzsGzwwHNnvq2kKrrQSluyHPOXNehgYTIGy57ooY0mgZnGJ0HbjJqilM8ajZDjacTojjG0xaIONV6KEAn97/uUxS1lXVko6J2Rcen X-Gm-Message-State: AOJu0YwKq8ZusZ/J0uM9ujB55isA+760gZlJfwaaVgiLpgffCbjoh/pz G3ZE4rqFhkJfpdQCpFkUwJgoY0DDWB0KuzP6tnP/zRUnXj7NeBdK X-Google-Smtp-Source: AGHT+IHFbrIdKIIUDzFISLiWsY7z6rdJ3rfIId7xJWmLEY2K9EoZ3Iq9bHUjbOEGDS6bgMUUAeXUFg== X-Received: by 2002:a2e:874b:0:b0:2e2:6f90:8b84 with SMTP id 38308e7fff4ca-2e3d9b8bb94mr7233901fa.17.1715074553998; Tue, 07 May 2024 02:35:53 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:53 -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 22/48] rcu: Make Tiny RCU explicitly disable preemption Date: Tue, 7 May 2024 11:35:04 +0200 Message-Id: <20240507093530.3043-23-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Because Tiny RCU is used only in kernels built with either CONFIG_PREEMPT_NONE=y or CONFIG_PREEMPT_VOLUNTARY=y, there has not been any need for TINY RCU to explicitly disable preemption. However, the prospect of lazy preemption changes that, and preemption means that the non-atomic increment in synchronize_rcu() can be preempted, with the possibility that one of the increments is lost. This could cause failures for users of the APIs that poll RCU grace periods. This commit therefore adds the needed preempt_disable() and preempt_enable() call to Tiny RCU. Signed-off-by: Paul E. McKenney Cc: Ankur Arora Cc: Thomas Gleixner Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tiny.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c index 4470af926a34..4402d6f5f857 100644 --- a/kernel/rcu/tiny.c +++ b/kernel/rcu/tiny.c @@ -153,7 +153,9 @@ void synchronize_rcu(void) lock_is_held(&rcu_lock_map) || lock_is_held(&rcu_sched_lock_map), "Illegal synchronize_rcu() in RCU read-side critical section"); + preempt_disable(); WRITE_ONCE(rcu_ctrlblk.gp_seq, rcu_ctrlblk.gp_seq + 2); + preempt_enable(); } EXPORT_SYMBOL_GPL(synchronize_rcu); From patchwork Tue May 7 09:35:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656510 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C/9ws5iR" 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-Google-Smtp-Source: AGHT+IGFwWHJtNfle5tH6dVJd1sPaxZAFj/yLFYo/LOxrHHE0mYRMwj1W/uNqv+wKea2tN1WaCwzXA== 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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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(); } From patchwork Tue May 7 09:35:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656515 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 9C58D15ECCC; Tue, 7 May 2024 09:35:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074564; cv=none; b=At1I2yLQk8QLXMhnn97+EqCeu5l+uVN0WNoAOIz9V2ljXVxJherWJ559JTek5j4ATy8+Ow/l/TO+psY81rLIrRurV3mSJF54xI4OXfFTP9+mt+x+yApmqKpQAb2tnOPr6ta4st3poeDAXzuShVo2mcqe2/fffu9Hat5VYl1hgoU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074564; c=relaxed/simple; bh=EWsVRIZxGPSXoY2Njx9/Sp9Wsqp8UVQL2ck7eZ/1txM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P1YxwSukEcxJ0vS8P/tcudPtj79rKw3KbVa3E0xw8caUqMsqpT8RSw6Y7jRso94gh3HQZxkSzMqt9JqHZvJcuCVJjl7NK8h2DyvJ9oIY2vyLauN6Re2Qpwj2DO6/RLJexKKMeYVM/tTm3uCUvIYkn7ZPg1u2flQEf3IIBmsukX0= 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=mDdmL3aq; arc=none smtp.client-ip=209.85.208.173 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mDdmL3aq" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2e367c2457bso20449381fa.1; Tue, 07 May 2024 02:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074556; x=1715679356; 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=PfH9K/eXzjwreUAemmntcMfIwoR9Zl46+OauXvPYO0k=; b=mDdmL3aqYgEx5+BpKsDxmxnJ7WUsS/5vaVGb4vCzgdlQmtMSbcmZMH6kgXhgNVSYx1 0T1T3O0WQQ/EvdDNxeDwMXXLY+Uywl6j1/myp71r6UFEFaZKGQiN9wRCFoFntSAebNNt wTptxJrvTH/oobxk3QhXRmYb3LXSR7YMNT+v0GY8EAd6rXpYMpFOx+FYjHh+LHSiXS+N UoeCWS/+AebRcMPudgu3olf68Q+w0kjznrdLznVFoyTb6Elfdo0gOdKDTlQ+9/K8R8M1 noQXysCa9Od7udgSQs61RrJ0u2AnR+4Y3Vw0+Ui3HTg6lLZFZPUnXLB//4vQpqnK2CK0 K6xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074556; x=1715679356; 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=PfH9K/eXzjwreUAemmntcMfIwoR9Zl46+OauXvPYO0k=; b=R4f5gfiOKHdhOBCyljkJ8Whv6CVImfUaNknddI4FMEzL0Oz+KLDZQv+NTMpqaduHuZ pSHkl5UElBvosyqv+gXAaMqj1p24KgyCJCs8q2Bv6iQ4s3ruWSKfkZaCNOKT50TA4WEr vipV+lLdVpaBJJUbfJRalAhvm7ruOPAYRnh8GMaQg8dUY/+q7A8NIuh64e44aZtkt495 rSA3XVWUPY0Izsh6hIpapWgIXW/J0USorZX+9+UBHAjCF7r2d7IS5ZIeupJ+6JIdlOR1 X3c/pPmDCUhWrgJaI0KV81h3m2XQIICKafPyk/O5k67KLygYf0+Ln/lVWmuOFLa+gdvQ IOJg== X-Forwarded-Encrypted: i=1; AJvYcCWAMoruT66F1Bv4QNbBWJ1BUnMjhlxwc1GaX8BN9MWl2CW4SElZSYmH5G7GJXGGhgEvBqLBy2/PAW6S4N+6RXWIvg0pZYkjRtVj3J4K X-Gm-Message-State: AOJu0YzTKhEMca7m7c/m4xUxtW5Y3Vu22yqrZpBIh+lgCwiAxXIj+3Ka XhqVRDMi8VBaMxnkjj8raoD+xRdbiMuyxoZTRYDFRr87Tn7jViKjHTJPU4MS X-Google-Smtp-Source: AGHT+IHOIZDj0khBN1W8nHdPykH/y4sTAyNBeP5xmuK7akM5SJ1vs4umBw3oDZhkNvNfs4Mj+xr4NQ== X-Received: by 2002:a2e:6109:0:b0:2e2:ab69:d10a with SMTP id v9-20020a2e6109000000b002e2ab69d10amr6164194ljb.39.1715074555694; Tue, 07 May 2024 02:35:55 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:55 -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 Subject: [PATCH 24/48] rcu: Bring diagnostic read of rcu_state.gp_flags into alignment Date: Tue, 7 May 2024 11:35:06 +0200 Message-Id: <20240507093530.3043-25-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" This commit adds READ_ONCE() to a lockless diagnostic read from rcu_state.gp_flags to avoid giving the compiler any chance whatsoever of confusing the diagnostic state printed. Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tree_stall.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index 5d666428546b..62b2c4858028 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -579,7 +579,7 @@ static void rcu_check_gp_kthread_expired_fqs_timer(void) pr_err("%s kthread timer wakeup didn't happen for %ld jiffies! g%ld f%#x %s(%d) ->state=%#x\n", rcu_state.name, (jiffies - jiffies_fqs), (long)rcu_seq_current(&rcu_state.gp_seq), - data_race(rcu_state.gp_flags), + data_race(READ_ONCE(rcu_state.gp_flags)), // Diagnostic read gp_state_getname(RCU_GP_WAIT_FQS), RCU_GP_WAIT_FQS, data_race(READ_ONCE(gpk->__state))); pr_err("\tPossible timer handling issue on cpu=%d timer-softirq=%u\n", From patchwork Tue May 7 09:35:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656512 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 B275515ECE1; Tue, 7 May 2024 09:35:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074562; cv=none; b=b28z+RRz/b1G+vjkWpZoiiHCRYkQ9RX2ZQDsRfzJHAMs8HpUvMpan9nm9MiETjd5S49TA+H9Aju4i0yeym0Lkxn6qwhCZXOchU44QhD+6rX59dMIh/os97X0bL/qdKC1FfzGU7LWk59Jm1FCakY/WQ9f8kVHnzJDd/9CFzjKFB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074562; c=relaxed/simple; bh=frqB9JdZ2wKj2UZVAquGEnh6KcOwmldyv4Qg+7qDgQ0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qD5KXEpjXSYHU7bJ6keUKHL+9z7snzbYdGxPjUz1li1OoQO0iyzVufeY9ZOwBw/mnOvIjn1+CIbuyNGO3xTlw4jp4PR0bBlpCTkZs/vyxyAaTxPuOnCtAdSv6WKZlvZcPdhKGATjL9SsJAmQa3TTRujv84ses5bd0/ZbNtXVXRQ= 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=hUd2qyDf; arc=none smtp.client-ip=209.85.208.176 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hUd2qyDf" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2e3e1ad0b19so8252491fa.0; Tue, 07 May 2024 02:35:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074557; x=1715679357; 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=3wXXp0y3/5Dvry2xeNwt9T3OFvkk1THegZM211jibMU=; b=hUd2qyDf6Yd1OstOLXOUSm+9GB/qqI0Al6aDbMSm1KhuTERcul3i963bSnedE5uLgL /1iRMMxpewRnn4ixryBfU2g8OmaW0hPdX0qE7fnDZlV7wuTYuI7YHqsKvF5BZxcML3Uf S7IMa0b3voxbtVdB7znU16IFn28j0dYKxpY8IS5wGlcMmQgLWRYlrB8YQ5/xTUdnkXvt sJjX4IKN5VcsAuWjknC8UORWyslbQxRPdY0s2Izx99CdoIhlEeKkrAI5Hzi9Y8RYFmSm 8nTkb8BK+ykrw7FWFUTpip8y7Ty84xHpKfa/10VyZ4h8w4aSAotMso+jXD5HbZ8ga6Uo A/ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074557; x=1715679357; 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=3wXXp0y3/5Dvry2xeNwt9T3OFvkk1THegZM211jibMU=; b=odZRZSQkF4I+8yl/h/lFCqp3C36ZZdZnR6U9XhOYCtmfoJMFalz8+GOivFCH94ADZ0 RS3joLdLry2b5ykT2Zg51ALtDiOa9GfHxBZb89A+oijzzmWHBKw6ZfgfsLDPpcqRb3NL IJ0+I+tYbrLjNFjak9XN0lIwVZFiYbVKVfwEwILBYv7UwrIyHHFT6gvo4QqqX11AaMvT 28fphWnvyNV66OpFUoalkcN8b7cRyWW2t3w2WlokzVC8JXeVJ59GU8QkyVjVNSeX3RUA /0xhSAya5Faf9wG9uZ5bVNHk7LKUeMeWMS+1N+PtvHmqqRZgow5ouZuK5+zzSpPML1e2 mp5g== X-Forwarded-Encrypted: i=1; AJvYcCWeWiEvCDO1WT8AP2LNV8ClcyXUPJ0n4bRKn+J2gew67nGI/yeFqPrGrfIi00shRFyDMLa7Dd52i6Kg5s/bpHcs/cq4qVLIjMJJhnv6 X-Gm-Message-State: AOJu0YxX6DBsgGopjv8vpDhM6iP5hTDg3Th0Lb5KBCAKGddPBb2G6B3A rnuRNacelCOshWJg95pZBN5zHTwBUtzz7SPFd5cDBDKFM0ciDcw2 X-Google-Smtp-Source: AGHT+IGrg8/gY8t0r/95q18a1/2aEvenTXHbcwBbeF3Em7DTV1B7pZ46ANDu9JWC/D6UZVRXaIA73g== X-Received: by 2002:a2e:2e0b:0:b0:2e2:3dac:447b with SMTP id u11-20020a2e2e0b000000b002e23dac447bmr9471424lju.18.1715074556582; Tue, 07 May 2024 02:35:56 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:56 -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 , Oleg Nesterov , Peter Zijlstra Subject: [PATCH 25/48] rcu: Mark writes to rcu_sync ->gp_count field Date: Tue, 7 May 2024 11:35:07 +0200 Message-Id: <20240507093530.3043-26-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" The rcu_sync structure's ->gp_count field is updated under the protection of ->rss_lock, but read locklessly, and KCSAN noted the data race. This commit therefore uses WRITE_ONCE() to do this update to clearly document its racy nature. Signed-off-by: Paul E. McKenney Cc: Oleg Nesterov Cc: Peter Zijlstra Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/sync.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/sync.c b/kernel/rcu/sync.c index 86df878a2fee..6c2bd9001adc 100644 --- a/kernel/rcu/sync.c +++ b/kernel/rcu/sync.c @@ -122,7 +122,7 @@ void rcu_sync_enter(struct rcu_sync *rsp) * we are called at early boot time but this shouldn't happen. */ } - rsp->gp_count++; + WRITE_ONCE(rsp->gp_count, rsp->gp_count + 1); spin_unlock_irq(&rsp->rss_lock); if (gp_state == GP_IDLE) { @@ -151,11 +151,15 @@ void rcu_sync_enter(struct rcu_sync *rsp) */ void rcu_sync_exit(struct rcu_sync *rsp) { + int gpc; + WARN_ON_ONCE(READ_ONCE(rsp->gp_state) == GP_IDLE); WARN_ON_ONCE(READ_ONCE(rsp->gp_count) == 0); spin_lock_irq(&rsp->rss_lock); - if (!--rsp->gp_count) { + gpc = rsp->gp_count - 1; + WRITE_ONCE(rsp->gp_count, gpc); + if (!gpc) { if (rsp->gp_state == GP_PASSED) { WRITE_ONCE(rsp->gp_state, GP_EXIT); rcu_sync_call(rsp); From patchwork Tue May 7 09:35:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656511 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 8B8B915ECEE; Tue, 7 May 2024 09:35:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074562; cv=none; b=Ull7cVf82cS9NcSwb+FSWxIflxJ4Sm7liXz7y5dmjI2kgflNUjDtEyXqHoSrJAYa4PJ7E0EodEYFgQDrLsJTg4ejtoPOOXiSQnGUXoQuLCDuWGvhHFCg0RPd6CICycwVZ7dOSnWCSI3VHNG/cUYp8UmaH6bRCJATXUIm3f7btmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074562; c=relaxed/simple; bh=po1Bc4OlQN2l2sQd7lU08kIpHqYxLZA1VMA8exIsmUo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UwGgjMryFtwQkF6npD0+BJiDCcjyna3s2v0LOj49w9rgsIYkC5rcBtZRaGdLBF3c7A6kLYL0A/l7wVOR/B3C3bMIUnuF+XL+h/pDg4VHLu7FcTROcZAhXjQQcxKkwFFpFkSgnP0AEb6djBxcoob9/zCY2sOeiJxel6Zo3iIcamA= 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=UHZ24tCE; arc=none smtp.client-ip=209.85.208.182 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UHZ24tCE" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2db17e8767cso36154381fa.3; Tue, 07 May 2024 02:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074557; x=1715679357; 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=WDR1Qmw00xm3OT7ACyqw6PuZVtuXarB9fOJED0vsuzo=; b=UHZ24tCEUDvRXib+9H4EbocJrIM6EhhBlQ7hu1VHOdbwxs/FCbQZKW1om9ctEkpBzS MvxpvLTRjKrT96iubo+O/B3I6XjAOYV1OknJnJasaJ11L0wOdS0T98tyE52Q4SpZ3zkx 2epBO7I5GApf/cI3OzCvV/3naLDtyrSCFbuyPFPc5wE0tTXNSzzvRBFX0a8RINXFtDNP apgvnLlnJc4dlefkIhbPsjm7EkVyy8ia/c//E3q+1cCohBx0F+r36l53xRAf0QplcMgq JuSZcXnNJoF+i012N/DFFd4VENvjTGUzRsMqba3st+EQqNmIu6XqlNAyGq3XRcDDzTPw nczw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074557; x=1715679357; 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=WDR1Qmw00xm3OT7ACyqw6PuZVtuXarB9fOJED0vsuzo=; b=bhCrDP8gZwRVqzacWdWkv5L3Ht/Un9zpMmC2jEYi2yyGT6ru46YHh2fdmFMx7vBNh7 Xud1yO4/xg8drtW+BSRWITPecGM6842IYIEmC1+ikJMEFvVOkgItBsmqmQ7pMswKIOsy cQhVRJf48yda4itmK1R9mo8K+SRU2a0R43Bcqox2zOzpNTZLXsqSp1deG3pfRtnXIQ9+ +ub9By9uNQENAp1bRe+UCDZnGbYi2fP93GaJDXwoAWDHUP0tvWlG9jaY0FAmiCBQ9Uqh mPqaQ3Ltos9VMqj5VeqhAGgdikAOViwarrvyAv+LASpqniDlLParwjjmgJc9Hd/N0f6X MmTQ== X-Forwarded-Encrypted: i=1; AJvYcCUyp5b/gCFlfNh6NG04U24PWpbu6n0kfu1nTMk5PNTf84yNPJur/yRKyRURwpuVS/qBrym+O5WpJYDrPXhqd/wVRUrXHCqhuE+IsB1q X-Gm-Message-State: AOJu0YzOQyYSBTYKQOtMQpTpI+Zcm6jQHP5BdZWHDbBUkHLp/E0wetyZ huL3dWYcYQdokXEMs4PcoV8v9WrYV5KDrwwtdZ51+5wK6tWjBCod X-Google-Smtp-Source: AGHT+IGGQQ38KZ2VpG4c3sSrj1xA0S5pzEkwKFmmMks9ZmyND9PKewFv0bBW5uRGltNzXdTOUCk8Pw== X-Received: by 2002:a2e:9f45:0:b0:2e1:f591:a857 with SMTP id v5-20020a2e9f45000000b002e1f591a857mr8358944ljk.34.1715074557467; Tue, 07 May 2024 02:35:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:57 -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 Subject: [PATCH 26/48] rcu: Mark loads from rcu_state.n_online_cpus Date: Tue, 7 May 2024 11:35:08 +0200 Message-Id: <20240507093530.3043-27-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" The rcu_state.n_online_cpus value is only ever updated by CPU-hotplug operations, which are serialized. However, this value is read locklessly. This commit therefore marks those reads. While in the area, it also adds ASSERT_EXCLUSIVE_WRITER() calls just in case parallel CPU hotplug becomes a thing. Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tree.c | 4 +++- kernel/rcu/tree_stall.h | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 559f2d0d271f..7149b2d5cdd6 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4328,7 +4328,7 @@ EXPORT_SYMBOL_GPL(rcu_lockdep_current_cpu_online); // whether spinlocks may be acquired safely. static bool rcu_init_invoked(void) { - return !!rcu_state.n_online_cpus; + return !!READ_ONCE(rcu_state.n_online_cpus); } /* @@ -4538,6 +4538,7 @@ int rcutree_prepare_cpu(unsigned int cpu) raw_spin_unlock_irqrestore_rcu_node(rnp, flags); rcu_spawn_rnp_kthreads(rnp); rcu_spawn_cpu_nocb_kthread(cpu); + ASSERT_EXCLUSIVE_WRITER(rcu_state.n_online_cpus); WRITE_ONCE(rcu_state.n_online_cpus, rcu_state.n_online_cpus + 1); return 0; @@ -4806,6 +4807,7 @@ void rcutree_migrate_callbacks(int cpu) */ int rcutree_dead_cpu(unsigned int cpu) { + ASSERT_EXCLUSIVE_WRITER(rcu_state.n_online_cpus); WRITE_ONCE(rcu_state.n_online_cpus, rcu_state.n_online_cpus - 1); // Stop-machine done, so allow nohz_full to disable tick. tick_dep_clear(TICK_DEP_BIT_RCU); diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index 62b2c4858028..8a2edf6a1ef5 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -628,7 +628,8 @@ static void print_other_cpu_stall(unsigned long gp_seq, unsigned long gps) totqlen += rcu_get_n_cbs_cpu(cpu); pr_err("\t(detected by %d, t=%ld jiffies, g=%ld, q=%lu ncpus=%d)\n", smp_processor_id(), (long)(jiffies - gps), - (long)rcu_seq_current(&rcu_state.gp_seq), totqlen, rcu_state.n_online_cpus); + (long)rcu_seq_current(&rcu_state.gp_seq), totqlen, + data_race(rcu_state.n_online_cpus)); // Diagnostic read if (ndetected) { rcu_dump_cpu_stacks(); @@ -689,7 +690,8 @@ static void print_cpu_stall(unsigned long gps) totqlen += rcu_get_n_cbs_cpu(cpu); pr_err("\t(t=%lu jiffies g=%ld q=%lu ncpus=%d)\n", jiffies - gps, - (long)rcu_seq_current(&rcu_state.gp_seq), totqlen, rcu_state.n_online_cpus); + (long)rcu_seq_current(&rcu_state.gp_seq), totqlen, + data_race(rcu_state.n_online_cpus)); // Diagnostic read rcu_check_gp_kthread_expired_fqs_timer(); rcu_check_gp_kthread_starvation(); From patchwork Tue May 7 09:35:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656514 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 AAA3415EFA1; Tue, 7 May 2024 09:36:00 +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=1715074564; cv=none; b=nyXYf5yaydlkd9Ep4xR9UK4NNkKcwHpY9++tl9G5rJYgp51IdZlptdLEOhdWB/uIHN9S5NUPnmsVxEHfREK08ML7lp8cdES0mKeaTY7Y8NDJXLiFZbRUVYxvuchA+oR473UgwKGMeuRfht5rcWo3Mjq0MzU3ed4NNquajn5oRQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074564; c=relaxed/simple; bh=xLIkzUhYqkpoaAiaQxcqMO2Ytt7HUJ27tzDsmg6WfCM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KGvrZwkCnvz21DEXX0kMIy953m2/j3ehMq0QlHuJYIiF9J1ABgoagpo5KkK4kY6W/Ah7PssGWp8SMP/9myLWUJ2kikzjgs8dS/iQuMdWW1v2bY9bNkduZP4vozJg/ZBt2TUyNZVJwHQ51dA/u52xVcTFS+hMyz43CuDosqUzkf8= 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=URAp9JHq; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="URAp9JHq" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2e3e1ad0b19so8252951fa.0; Tue, 07 May 2024 02:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074559; x=1715679359; 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=WdJY0TZw/fjltnhvg0EPkwklXe5dzlu0wabU2jZ/52w=; b=URAp9JHq9K2vrhXWLr9yPZnKObzQo/IvLOJCvDYgJLqZP1m6Yq2dIQEGSvV+2snydK H0rHvmue5VnuKh1SWZn88El1ANktAsHPMRj8qfQ7k7tgID7ZDmpSFDiVWmnBvS1Co2FT 4K55opFA4KFxQW7Hz9mj+/7l8Sn0iwEbWPhmQJMHYsx8d+tlxmr4MIfaTHmo7fVJZeNE ZO64dQhiVMsrkN3eSFLda2iwm60hyH2WS4Eg5pS2rLI8qZG63hPdokF8Lr3Bue1u10Ub 95apv8G7Lea70EK/FXmbCPpPmh+EoEsms+pNnwdtOa2jf37H7+WILmiQD/sQm8NzoNyQ AvwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074559; x=1715679359; 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=WdJY0TZw/fjltnhvg0EPkwklXe5dzlu0wabU2jZ/52w=; b=t4ONy/ykzgRW0YvxTb3Cu5nBUj/3nrxNWcmFSU9sOEvGCrtNrAu5vxTshQesEcb/NK 57EaMdjrSMQs9b2dBUND4MmKvk/U/DRrem++MyMafaX9P1vz5oLmYZc8legrMRjNjA3r gUx6kR6Yu2EW6hoDBQBYMP0xJGyYjrmp4QTpbnd8gs0tYuJsD/z6E+CfOXwj/0/djHLi /At2MhaOeDTbFWhPFGfbCWCWhzRty80EPvbgNsQ+40KRVXtCEKsHhH753LyW6Y45Qm4b zqf8e4J2Llzo92rqoWD2/zpwQo3DZR5XqaQpu2wubQQe+j3f9IZBkc29PmnXH8QXzPAz WaGQ== X-Forwarded-Encrypted: i=1; AJvYcCXuLWELE/29xUT1pzgTuZoHKtp3VKjfHnLbQHJf3Cc45qodu7zad6iEkRJDyyBrkJimo87xCQgZlNJI9FGA2EqRKq/Zkau5WMGyWH16 X-Gm-Message-State: AOJu0YwMnMcRNeenSx99x4B2HE5Dpi/KC3OdVi8Bj+jd2bGWIoPT+UIr MzXt7sqFhU33gjsYmspUc6HeuuyAkotvuAl9XyCJFeuTsee8yHF6 X-Google-Smtp-Source: AGHT+IEA+c+gDL6J8ZrBuC+CGl6J+uw0YGSUA+D3NFyQuktUotuVGX88q5QGcMdQcwvZvDQ8PfEoXg== X-Received: by 2002:a2e:2406:0:b0:2e2:5fd:7030 with SMTP id k6-20020a2e2406000000b002e205fd7030mr7916249ljk.13.1715074558517; Tue, 07 May 2024 02:35:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:58 -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 Subject: [PATCH 27/48] rcu: Make hotplug operations track GP state, not flags Date: Tue, 7 May 2024 11:35:09 +0200 Message-Id: <20240507093530.3043-28-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Currently, there are rcu_data structure fields named ->rcu_onl_gp_seq and ->rcu_ofl_gp_seq that track the rcu_state.gp_flags field at the time of the corresponding CPU's last online or offline operation, respectively. However, this information is not particularly useful. It would be better to instead track the grace period state kept in rcu_state.gp_state. This would also be consistent with the initialization in rcu_boot_init_percpu_data(), which is to RCU_GP_CLEANED (an rcu_state.gp_state value), and also with the diagnostics in rcu_implicit_dynticks_qs(), whose format is consistent with an integer, not a bitmask. This commit therefore makes this change and changes the names to ->rcu_onl_gp_flags and ->rcu_ofl_gp_flags, respectively. Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tree.c | 12 ++++++------ kernel/rcu/tree.h | 4 ++-- kernel/rcu/tree_plugin.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 7149b2d5cdd6..306f55b81d10 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -841,8 +841,8 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp) __func__, rnp1->grplo, rnp1->grphi, rnp1->qsmask, rnp1->qsmaskinit, rnp1->qsmaskinitnext, rnp1->rcu_gp_init_mask); pr_info("%s %d: %c online: %ld(%d) offline: %ld(%d)\n", __func__, rdp->cpu, ".o"[rcu_rdp_cpu_online(rdp)], - (long)rdp->rcu_onl_gp_seq, rdp->rcu_onl_gp_flags, - (long)rdp->rcu_ofl_gp_seq, rdp->rcu_ofl_gp_flags); + (long)rdp->rcu_onl_gp_seq, rdp->rcu_onl_gp_state, + (long)rdp->rcu_ofl_gp_seq, rdp->rcu_ofl_gp_state); return 1; /* Break things loose after complaining. */ } @@ -4420,9 +4420,9 @@ rcu_boot_init_percpu_data(int cpu) WARN_ON_ONCE(rcu_dynticks_in_eqs(rcu_dynticks_snap(cpu))); rdp->barrier_seq_snap = rcu_state.barrier_sequence; rdp->rcu_ofl_gp_seq = rcu_state.gp_seq; - rdp->rcu_ofl_gp_flags = RCU_GP_CLEANED; + rdp->rcu_ofl_gp_state = RCU_GP_CLEANED; rdp->rcu_onl_gp_seq = rcu_state.gp_seq; - rdp->rcu_onl_gp_flags = RCU_GP_CLEANED; + rdp->rcu_onl_gp_state = RCU_GP_CLEANED; rdp->last_sched_clock = jiffies; rdp->cpu = cpu; rcu_boot_init_nocb_percpu_data(rdp); @@ -4682,7 +4682,7 @@ void rcutree_report_cpu_starting(unsigned int cpu) ASSERT_EXCLUSIVE_WRITER(rcu_state.ncpus); rcu_gpnum_ovf(rnp, rdp); /* Offline-induced counter wrap? */ rdp->rcu_onl_gp_seq = READ_ONCE(rcu_state.gp_seq); - rdp->rcu_onl_gp_flags = READ_ONCE(rcu_state.gp_flags); + rdp->rcu_onl_gp_state = READ_ONCE(rcu_state.gp_state); /* An incoming CPU should never be blocking a grace period. */ if (WARN_ON_ONCE(rnp->qsmask & mask)) { /* RCU waiting on incoming CPU? */ @@ -4733,7 +4733,7 @@ void rcutree_report_cpu_dead(void) arch_spin_lock(&rcu_state.ofl_lock); raw_spin_lock_irqsave_rcu_node(rnp, flags); /* Enforce GP memory-order guarantee. */ rdp->rcu_ofl_gp_seq = READ_ONCE(rcu_state.gp_seq); - rdp->rcu_ofl_gp_flags = READ_ONCE(rcu_state.gp_flags); + rdp->rcu_ofl_gp_state = READ_ONCE(rcu_state.gp_state); if (rnp->qsmask & mask) { /* RCU waiting on outgoing CPU? */ /* Report quiescent state -before- changing ->qsmaskinitnext! */ rcu_disable_urgency_upon_qs(rdp); diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index df48160b3136..ff4d8b60554b 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -273,9 +273,9 @@ struct rcu_data { bool rcu_iw_pending; /* Is ->rcu_iw pending? */ unsigned long rcu_iw_gp_seq; /* ->gp_seq associated with ->rcu_iw. */ unsigned long rcu_ofl_gp_seq; /* ->gp_seq at last offline. */ - short rcu_ofl_gp_flags; /* ->gp_flags at last offline. */ + short rcu_ofl_gp_state; /* ->gp_state at last offline. */ unsigned long rcu_onl_gp_seq; /* ->gp_seq at last online. */ - short rcu_onl_gp_flags; /* ->gp_flags at last online. */ + short rcu_onl_gp_state; /* ->gp_state at last online. */ unsigned long last_fqs_resched; /* Time of last rcu_resched(). */ unsigned long last_sched_clock; /* Jiffies of last rcu_sched_clock_irq(). */ struct rcu_snap_record snap_record; /* Snapshot of core stats at half of */ diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 36a8b5dbf5b5..340bbefe5f65 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -805,8 +805,8 @@ dump_blkd_tasks(struct rcu_node *rnp, int ncheck) rdp = per_cpu_ptr(&rcu_data, cpu); pr_info("\t%d: %c online: %ld(%d) offline: %ld(%d)\n", cpu, ".o"[rcu_rdp_cpu_online(rdp)], - (long)rdp->rcu_onl_gp_seq, rdp->rcu_onl_gp_flags, - (long)rdp->rcu_ofl_gp_seq, rdp->rcu_ofl_gp_flags); + (long)rdp->rcu_onl_gp_seq, rdp->rcu_onl_gp_state, + (long)rdp->rcu_ofl_gp_seq, rdp->rcu_ofl_gp_state); } } From patchwork Tue May 7 09:35:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656513 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 6F1DE15EFB2; Tue, 7 May 2024 09:36:01 +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=1715074563; cv=none; b=a1LPRkd2nAN4EOte66FM0kPnY0j/kXZP89GR+XXzaF2qqWvcQrdj2cm7cM/iyRYABUYVyv4+T0F8lZv2PDlukqM8Uf7DTcAajnAvO40BQ5hDr5Emtwh3hTZJ2c+7nRzIqrkc1ncWtuhPc00x2sIRPHOoSq9NdfJQnNd8TP4LPYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074563; c=relaxed/simple; bh=iDqzod0vjDc8e7O6tpb8LaBVtP1pQYzDsaE2j9NUzOo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bSjoZjjp4i+nt2UhTiPlVwdxWvlLBVWNJY5T4e5vZgMhlEvvoox7Nn3GL1iR7bs1DVxlU3aEx3mK+nUFdTKxWMkNIFKKJ5ElZYzG7+t/ASo/wr96yjWTqJ6FLdwUKbSd3kTMqePHHXOWGhEgIH0FBoOXSoiD0IVh84MEHUel74k= 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=DzOLN8DI; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DzOLN8DI" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2e0a0cc5e83so29089591fa.1; Tue, 07 May 2024 02:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074559; x=1715679359; 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=meUQG6It7c61OX5rw+9ctPkRI+dN99MXSc+fu3Gh8lA=; b=DzOLN8DImWwbVEVYYUUilnSRVyt+e2OQV/Kz5dhSdsvmO4NHJcMFb6YKJnMYPOuOl7 xXaSj/LIHeqBExtRN283haciyPzqy2JRYo9Fppv3V88bxhaxeTSFaxw0PnyO5azPX89w 8ZAGGqvU+xoy03whP2kHpDBgPaFN6M9xFgN3NLlOKr+oJYxcPs/BSAJ4DKX7qk2acJD7 O8kGHPChGRhUd/ykBYzaB/d/9dJYOAcjTizGkKOO6yxxBQBC1lOd/+uBav8NIYdJWZje mhzViClqF9o4kvkmwIxkhYCcAHBlNCLdbk6JdWeEwEm+1I7msPVNpEd4Z/0GLCTgFzTK woeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074559; x=1715679359; 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=meUQG6It7c61OX5rw+9ctPkRI+dN99MXSc+fu3Gh8lA=; b=iBYH7TlQ6Iaz8s/Vtn9MmF8gKV8CZIuzVjwH6zPSKbYJBX7hXVJF3w68DObXECofrf q1MRfmcv07nOtVqjiUcpII8PaPuDT5vAgxiAxN1p//EJIXU9k87FD9HAU7ok6tdGe6gd mJggTPskgec2dHv5AxC5YJ1mYzEAlYYmF/87vA3rumU42v49TjAcSJPCfyCu/fWorTc7 IJmsZdudBP3y8YtafaomEreISZSgo0LZ5VNi+xT0ogZvvDPhY1h0xAAIh9DSohLcIheq IL96CFdV3FPpTuUFZbtJZUgexpQZsbJ3x2DbwpUI/M4KW8yjobJ5o8WT4t4AGUVO0GIv oetQ== X-Forwarded-Encrypted: i=1; AJvYcCWksIknfyrmVDaDIqH9yu7dTqQEAlren2oYCPdPy8WN9Lc7adbRQdgFzneC5oUmg478u+s+l6QUXq6Aut0Cl+xXHJ/WSsBkcxYHPqF+ X-Gm-Message-State: AOJu0YzFiNua8BOzuk9vYHycobQm45KtviobIB1xqkd0HvJ5F5oGZoyA EjkarVdbIMqoMLpQkIYFikrwcRJQBb7PslTh5UlpLidEg5E/dSSr X-Google-Smtp-Source: AGHT+IGtWDWZT1q9jjh7d1r3JJDYU35pFBtvbBC29f67kkjeb18Ee/eBuT3cN+DDecPGl6zjxnSY3Q== X-Received: by 2002:a05:651c:141e:b0:2d8:729f:cf3a with SMTP id u30-20020a05651c141e00b002d8729fcf3amr6498619lje.32.1715074559518; Tue, 07 May 2024 02:35:59 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:59 -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 , Marco Elver Subject: [PATCH 28/48] rcu: Inform KCSAN of one-byte cmpxchg() in rcu_trc_cmpxchg_need_qs() Date: Tue, 7 May 2024 11:35:10 +0200 Message-Id: <20240507093530.3043-29-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Tasks Trace RCU needs a single-byte cmpxchg(), but no such thing exists. Therefore, rcu_trc_cmpxchg_need_qs() emulates one using field substitution and a four-byte cmpxchg(), such that the other three bytes are always atomically updated to their old values. This works, but results in false-positive KCSAN failures because as far as KCSAN knows, this cmpxchg() operation is updating all four bytes. This commit therefore encloses the cmpxchg() in a data_race() and adds a single-byte instrument_atomic_read_write(), thus telling KCSAN exactly what is going on so as to avoid the false positives. Signed-off-by: Paul E. McKenney Cc: Marco Elver Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tasks.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index 147b5945d67a..327fbfc999c8 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -1457,6 +1457,7 @@ static void rcu_st_need_qs(struct task_struct *t, u8 v) /* * Do a cmpxchg() on ->trc_reader_special.b.need_qs, allowing for * the four-byte operand-size restriction of some platforms. + * * Returns the old value, which is often ignored. */ u8 rcu_trc_cmpxchg_need_qs(struct task_struct *t, u8 old, u8 new) @@ -1468,7 +1469,14 @@ u8 rcu_trc_cmpxchg_need_qs(struct task_struct *t, u8 old, u8 new) if (trs_old.b.need_qs != old) return trs_old.b.need_qs; trs_new.b.need_qs = new; - ret.s = cmpxchg(&t->trc_reader_special.s, trs_old.s, trs_new.s); + + // Although cmpxchg() appears to KCSAN to update all four bytes, + // only the .b.need_qs byte actually changes. + instrument_atomic_read_write(&t->trc_reader_special.b.need_qs, + sizeof(t->trc_reader_special.b.need_qs)); + // Avoid false-positive KCSAN failures. + ret.s = data_race(cmpxchg(&t->trc_reader_special.s, trs_old.s, trs_new.s)); + return ret.b.need_qs; } EXPORT_SYMBOL_GPL(rcu_trc_cmpxchg_need_qs); From patchwork Tue May 7 09:35:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656516 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 8ADEC15ECD2; Tue, 7 May 2024 09:36:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074564; cv=none; b=dypMjQxxREDpugB6X9lK8PTB3eI/lFXFZZZCLobOFlKsxyHVkBI87dj9c0X4/fW/qMwv4gXrK3TEvLORjthUtXyNo9BZDQ8EdZQmLU7+lSjcD9MGec5p0vMORsSp9JtPRJUy0BHPcvi/8jdpieGA5tbwi66L32iFtvMhSyz+Tv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074564; c=relaxed/simple; bh=L9yyqsasGcBRwTVVl5BvyZK7asmI7UPEWvqiN+AHkfY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NbapZE0U4yjDjGyGt0h/NXLjLeEyxkceDitsec7fAjNmpYoSpaGFPtUbY3us6rPsWiC7LdKIoqtk+T2OtXlLY97kKZNMsmiAdtivX6i3kMPVNpDTDU1Z5zSUMshSaXdQg0xrFD95awZGSJ8pKOcaj0aR2B5BAsa6/c3V+S7FR+4= 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=OFBIqBY/; arc=none smtp.client-ip=209.85.208.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OFBIqBY/" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2df9af57b5eso38862831fa.2; Tue, 07 May 2024 02:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074560; x=1715679360; 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=w1tkz/C4aSczVsYDDvrLDAru1oEnBIKM9qUQq3rJqNA=; b=OFBIqBY/penvTFEvzDMkB83jyhUCTSiIYdGhLomlYiwBDYeNDQv3O9kDTT3p7ISOjC kxe1nE6LP9fg3IuC06wPb6aRT13ohfemTHR7/mPBZSHZgMh2NC8VYVOsMY04P2pcdMbV 5Qv+ekTH0G+ojyY7NdmbcSecAa2Rnk0NT7+PBBSOzrdco6Wir+PcR5StByq1SaFf1/+F V/nWL0leuSf89pQmsDP5WjfoEylyzIUG6QtNqyEJMB4Th/yYOYNg1FhDUZNljfsOKDaM QpC0F++ofZgLNTTYMXM9aYL/x/rC/rXOERxn/E00jCR04owKTCgevuzAcpD2EeCJhMup 7o0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074560; x=1715679360; 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=w1tkz/C4aSczVsYDDvrLDAru1oEnBIKM9qUQq3rJqNA=; b=X/ZmyBFVeXIPmeBIdZwo9TCkQp1uOdvlaQdVIC2e6arNtfBE9f0YNKlwZciKwzU+lW VnAOru9QyaNGX9xSf87uzo18xBReqiLwsD2sYUNeR0QB9CIcAjqLeLx3LC/y/RGsxp08 ygaD4u46qbwS6US1Ck6i7W+TqHSs4ZCxH9Iu+bCoO5iMVEzwlA0EiimIQJrKzSquSgNz 42eNXrCcSgctO5ZYUaiQl6i7Or4IJnvygK0HzvmTcrD+yeuiWGWJXE1mJL6MicPXb6tN HXc3cvDhdqCbm6C2NK9Sx7p4x+ELtAaylrKGt7qr9lphEN301TrKNe88czQ9FqsCHrl1 79Qg== X-Forwarded-Encrypted: i=1; AJvYcCVlWeOrC+tUXHbotycASOOz/WE/LYlvLvYg2tghGWBCHvRgHC6pv41UuHHjJuRyziOGjs2EwibAZXyDoTK2runv/6Ncsen8s+JWqCCE X-Gm-Message-State: AOJu0YyVNABP9XfEoOu0Zg1SCXWjalCoxVUet3hlyTUNCHTlPHzQKoaU swJoeBJwASyEBH1o6bWfF/ETTvbcCg/XsemtVoNnDxDq+1rnD58t X-Google-Smtp-Source: AGHT+IEe29Z4B5o9+JvHcbUN9sMcQQWlKTFt0TCj3L378xX+JENFQMwDnGLqTaJiYVlrjSE+Qd/rhg== X-Received: by 2002:a2e:8904:0:b0:2df:4bad:cb7a with SMTP id d4-20020a2e8904000000b002df4badcb7amr10088812lji.0.1715074560360; Tue, 07 May 2024 02:36:00 -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.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:35:59 -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 Subject: [PATCH 29/48] rcu: Remove redundant CONFIG_PROVE_RCU #if condition Date: Tue, 7 May 2024 11:35:11 +0200 Message-Id: <20240507093530.3043-30-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" The #if condition controlling the rcu_preempt_sleep_check() definition has a redundant check for CONFIG_PREEMPT_RCU, which is already checked for by an enclosing #ifndef. This commit therefore removes this redundant condition from the inner #if. Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- include/linux/rcupdate.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 2c54750e36a0..382780bb60f4 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -401,15 +401,15 @@ static inline int debug_lockdep_rcu_enabled(void) } \ } while (0) -#if defined(CONFIG_PROVE_RCU) && !defined(CONFIG_PREEMPT_RCU) +#ifndef CONFIG_PREEMPT_RCU static inline void rcu_preempt_sleep_check(void) { RCU_LOCKDEP_WARN(lock_is_held(&rcu_lock_map), "Illegal context switch in RCU read-side critical section"); } -#else /* #ifdef CONFIG_PROVE_RCU */ +#else // #ifndef CONFIG_PREEMPT_RCU static inline void rcu_preempt_sleep_check(void) { } -#endif /* #else #ifdef CONFIG_PROVE_RCU */ +#endif // #else // #ifndef CONFIG_PREEMPT_RCU #define rcu_sleep_check() \ do { \ From patchwork Tue May 7 09:35:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656517 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 3773615F30E; Tue, 7 May 2024 09:36:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074568; cv=none; b=NgZQu1AqPLt05yydGhAeXQWselBcvuDgWStLKi6DhVtiT5T6LflRUt9rA/PKsVe7SXBJl8LFgkilxxCeRyZQKFBABdhdKqb7mJ8OvJvHAFWb8HdMFWx2ih5Fx2klZSAKvu1b5WzjD6oQ8SZPjMGO/CkhAeP/AVCIsYL3Ql607Ts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074568; c=relaxed/simple; bh=epMddOCm5gZ2sI6W3hNDMzNbpLcxxjqRybXWGAgKqCI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VqoZQPzb+PiEpJuwRycMSuU0ee8udHlj6ykPORaoAsG5478SOp5jZXOeREWQRE7Hci00tnesRiMDCYeInznYtMTpdKMp7ve3T7/v0wo1mOtCrZ/kYNEyhgYBhjD7gOWaoPWUSALAe+B7Mwi/vGuNoIT7uvrpXDG2ied5ItvhHLU= 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=N5tTyf8D; arc=none smtp.client-ip=209.85.208.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N5tTyf8D" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2e367c2457bso20450891fa.1; Tue, 07 May 2024 02:36:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074562; x=1715679362; 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=cW00ztMzynhHfGhSqSCg5j9h7Fte9U/1sreRcK4DNwg=; b=N5tTyf8DToOG/UJkvgW5UHJnuNvCFjRg+qn3c3EYXAqIwbb8lmfaPmU9oCVXT1wom7 0cXDCWb+RuXMug6O4OBrH7gozxoz6WC0PDW5/azL91R96umis+T4og9n2CJRJa9LYxr/ ATaTF7cQ1epjdBKUqBLcUnPFMjBIYOz4mpcxwZsHqOKY3AjRFO/qFwpb85iDh1JXxWL6 nY6pzi+Be+Ysf3B3pWSHNoYA2apwPqgOmWEiOuechHJbl+wszK1YaA3TK1KohWRWLAmt fOuBhWKEzum57AUilmy+iSg4A7S7JBrKr2b2/n3sruiBoarM9RMr2QnuYdOkdBptaec9 q5iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074562; x=1715679362; 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=cW00ztMzynhHfGhSqSCg5j9h7Fte9U/1sreRcK4DNwg=; b=AoULq1Vkeqi+lzdO2/iyuf4/g6M3i7s1BtJP6WVtfIsXBTE9FbPVLtcW+2qpE5LOWf k08ewn9IkHsIZa4L2fM5qj/Jz9aJ7nMsljF+1rpXxX+uFyddD/yN78sdRX6ez7HZEz8M qo8CU7Ec1wQE1Ri9vRDXu4m0FQnZepcgT4uCN6QfADOaNy/UHVryMLVOErx9ha15JeEt 7RWCjWOpavUFRFCPzCXg+wEbKOC1UhogM+wAUe1Cvw4IOWeymJRSbwivFG3qjrLv9RUG c17IJRwogjyTboEABEwf+HxPaesjLMZp0UKRg5EQssBaIaQ+QA8Z8y6wdOKdukA0sBun 72zg== X-Forwarded-Encrypted: i=1; AJvYcCVA34JaSv+zdJkQJ1zGRAvA/jfvrZlSgVgJ3zFE+AvT47MtwKhc4v7Rh4DXe5JL2+vipCLIt30voyBKH8mtIheE0hreLKeqM35pXPMQ X-Gm-Message-State: AOJu0YzcXovYNAkYc84lMPg5i6xVkQvK/UFki8mbAVAYA0ldxspQhrGW rzsT+tKUf/okJo6lX06bJE97BWwckY0PfgL7+H0t3c/Qo6xGA5yM X-Google-Smtp-Source: AGHT+IFQOZS522CuskEGxnusjcVeqLYDbyLGjIH2q8Qx0LPkUhS1eK6bC5DUBFHNOOWXaxeNseTYWA== X-Received: by 2002:a2e:8904:0:b0:2df:44a1:2987 with SMTP id d4-20020a2e8904000000b002df44a12987mr7930872lji.5.1715074562339; Tue, 07 May 2024 02:36:02 -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.36.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:01 -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 Subject: [PATCH 30/48] rcu-tasks: Replace exit_tasks_rcu_start() initialization with WARN_ON_ONCE() Date: Tue, 7 May 2024 11:35:12 +0200 Message-Id: <20240507093530.3043-31-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Because the Tasks RCU ->rtp_exit_list is initialized at rcu_init() time while there is only one CPU running with interrupts disabled, it is not possible for an exiting task to encounter an uninitialized list. This commit therefore replaces the conditional initialization with a WARN_ON_ONCE(). Reported-by: Frederic Weisbecker Closes: https://lore.kernel.org/all/ZdiNXmO3wRvmzPsr@lothringen/ Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tasks.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index 82e458ea0728..78d74c81cc24 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -1203,8 +1203,7 @@ void exit_tasks_rcu_start(void) rtpcp = this_cpu_ptr(rcu_tasks.rtpcpu); t->rcu_tasks_exit_cpu = smp_processor_id(); raw_spin_lock_irqsave_rcu_node(rtpcp, flags); - if (!rtpcp->rtp_exit_list.next) - INIT_LIST_HEAD(&rtpcp->rtp_exit_list); + WARN_ON_ONCE(!rtpcp->rtp_exit_list.next); list_add(&t->rcu_tasks_exit_list, &rtpcp->rtp_exit_list); raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags); preempt_enable(); From patchwork Tue May 7 09:35:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656519 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 B164915F3FD; Tue, 7 May 2024 09:36:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074569; cv=none; b=At3QjI1248GyFl1xrAifFmaVNDTXMrgtspGgJ+0FcwqsDcyjCOgLg9h3pAdHB/UshFITtFQTFv89AfYl6XX7vDdR9ffjAasUXTHlxPUFIBItUXpBGT39Y9gjiW2leoOtLMP6EOKYiwjnOja5DD+BHQnOX0ZESam6lVzDtgGy1TA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074569; c=relaxed/simple; bh=rtlgupwLn0mEHf5kQVI1HauKwRCtBdwM7YKs0MzkqOQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jvPTE543jchiN9IyJtjL9mFckrhL3iqNd8tEEZ/2TDx0Aj8xTxKQZoC+vKbFed/ukOb578e00dezWdtIHmd6eRULYaw+wzyvxz7PA9HjkgQ4GYRoQOB8Q6+prNt1RP7G7RWukZ1sRu5akTQAiYmILUYDlK6kWVNL13ATdROLgK0= 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=OMOKybu/; arc=none smtp.client-ip=209.85.208.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OMOKybu/" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2e2c70f0c97so36450981fa.0; Tue, 07 May 2024 02:36:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074564; x=1715679364; 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=u129STYD4noSkSCV7bqtBz9/OCTztdlN/hG4nYi33QI=; b=OMOKybu/RRCKXDYNd9UavdQeBxrOeAqRcSxrBELL0nkkxRjU8zKyNtLiRrVuwI5o+U oE3cihaSLHBooFe/TGjFPZfq8vSnl/dwClvxlfc8WSltJZ6augf/LsMljUxyO/hUC9gR cHsn6vA8DxtAQe57369x7h0xTUUjM9Y5tZzFMiawrOPF61DUiNXa85j3WVyjNJNnEF46 owWdtHolqUNQ4524Ocd48+8zW5P3ln5H3sxqk9VOEy+LBsf7n5yJnBUbxpLoDvnevuuQ iFy2BsSTeBLsSvVnOZb9jNzCchQsc5+Tp7YNAnitWFl60j9CPg3/SUNF7PZVZZ6kZzsL 5t6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074564; x=1715679364; 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=u129STYD4noSkSCV7bqtBz9/OCTztdlN/hG4nYi33QI=; b=aEjJXLBjm6JgplRX2vvSo19IqwqwB/X5n2SgCo2dQdQWeGHLbAvjfMy1DGxXmazXek U6ui65FgUEEUwo9ZB3PePeM9SWKNEU3nFrZE4dpNSnG/No0MovUdZyXenn4DdaOJt7cM g7NNcmIHilKAxSDT3sJ/ZpGCs82L8CXeWOV8e7DtNV2U118DvnYPYd7O44IbDjAMwkEL qdFVcSKiAuHyR8oVEvia9CUFRZWlaiRFCrbUFTrasTWaMzB8RsW0bMR9rs9sIzba0T32 PNYCL8Bj7URhDby1WZsrgqFu4DsDff9hKUOT97ustvYDadWVTBy7JV1IUpiabske8jkN HWLA== X-Forwarded-Encrypted: i=1; AJvYcCVah6SxtlacwUXrM59kXSYpT25M86rr+v9q58TdSHLZXP2ZyMqRQpQ4RnVmQ1u4w1w+B2lhWvzuS6SuRroAefSt3Dw3mULWTjbX2WRV X-Gm-Message-State: AOJu0YwygtZtVKYkXmEv9uz0xyoVlWE7GsPwg5DrT0T9E+/VfSHTG4Go uR8/1G7shotw5dpVph+8xZMPj+lX1M/0gc9BYM7nK71NIIKi5WMU X-Google-Smtp-Source: AGHT+IEpA2noZYzq8aC+0HCkFA+QhYdvlE4pW2LiUMUeMOTxNI385y3P3dy0MafU/I9r8SZ8wVetJg== X-Received: by 2002:a2e:610a:0:b0:2e3:1991:ec1b with SMTP id v10-20020a2e610a000000b002e31991ec1bmr4030953ljb.4.1715074563454; Tue, 07 May 2024 02:36:03 -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.36.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:03 -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 , Zqiang Subject: [PATCH 31/48] rcu-tasks: Fix the comments for tasks_rcu_exit_srcu_stall_timer Date: Tue, 7 May 2024 11:35:13 +0200 Message-Id: <20240507093530.3043-32-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Zqiang The synchronize_srcu() has been removed by commit("rcu-tasks: Eliminate deadlocks involving do_exit() and RCU tasks") in rcu_tasks_postscan. This commit therefore fixes the tasks_rcu_exit_srcu_stall_timer comment. Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tasks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index 78d74c81cc24..d5319bbe8c98 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -150,7 +150,7 @@ static struct rcu_tasks rt_name = \ #ifdef CONFIG_TASKS_RCU -/* Report delay in synchronize_srcu() completion in rcu_tasks_postscan(). */ +/* Report delay of scan exiting tasklist in rcu_tasks_postscan(). */ static void tasks_rcu_exit_srcu_stall(struct timer_list *unused); static DEFINE_TIMER(tasks_rcu_exit_srcu_stall_timer, tasks_rcu_exit_srcu_stall); #endif From patchwork Tue May 7 09:35:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656521 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.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 794DE14E2F0; Tue, 7 May 2024 09:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074572; cv=none; b=jPDUisMyCUSVhpES+1KxtoAHdZeoFqabMN7ps2P6Lw22O3ddK0M43vkwefPgFVYANkR3qVey7V18NauJykXGn2Mo3tfVNdxY/BdyPmtqjRGdJJAgqyhTMV47k/5F8GbkvtUqfyDzd0W134LABJ9OpZmLsuKpRjrfFYyqxAsG6ZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074572; c=relaxed/simple; bh=ZonPLdD8zHKArk7jKUAil4WyUpljr0gYV6ie6TPJnnk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MfjvyayXMPlpHk0BrPHz2nxAwleBPQnFS0BBzykZQs8BgVBGxhcS1N/J82XNTm+ctyaokJsm79a0RfMuvwFYbNDKDGZydnar26yV84gSQmxyRhf9Ej2d1D+IfSSO5B5uzvCsWuJypDS2P1NRoz3UBLEcQOIw6SnWEhjRej7douE= 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=XsC5mSFE; arc=none smtp.client-ip=209.85.208.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XsC5mSFE" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2dac77cdf43so37620041fa.2; Tue, 07 May 2024 02:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074565; x=1715679365; 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=6Wzg2EFUCtxRH8etUmXaucx3Z1jVpwcvQQv3pqRMexI=; b=XsC5mSFEsLRULTfr8tc4RBdISh+sjnmB25vQ9unNY+9BK7vR3I/ojNqjY+AoI9Pqho PnWKZTf4iyAqWvQtwzzPS7363UFzuSFB+85TwhKD+TzfF+RhGx6+rmggNRycNxnvdjv4 fOdm9QjayDMgT3Wg2aSDjQbW34D+eOKgSUJgjGf2XsgIFr7rFY9MELljGqPZNHx1PYX9 r+O/VqhytIFxCLt3p+Z1qgfCHWHRdWo8HrgDi90zaec2sRSKSRolIA4cxQvAcefRNu+b rYv0JQiNMcpKKfLSf3kZkD70itLtiVuxpK/70rsiBnPA98e2Dj7RXgZgo0NvF/aC0Gm0 Dbig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074565; x=1715679365; 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=6Wzg2EFUCtxRH8etUmXaucx3Z1jVpwcvQQv3pqRMexI=; b=otFYN+LQ1+nYS+WIvvsvJK/sSeWAk3T0fQ0XZzYRQMGy5sD9dFjyW1qEsm+un0va6z toLdDopYwhKt94jqE2g/wUJgvj+1I8LihVvyT1B8pT8X3OvXDchYEP0VWFSlSfPz4V+R 1oXanZ1bA5qxJ7SsMaNeVfsoeqD77inDkwGHN3cK5AMhdDAk4FpISjVtEqkHN46merE7 mRZTBLlcYqj59TlVRAFiHtslcCwPrkQStIv3ww2wKmDl5Wi7fWUnCx0gEy5pKqIkzJY1 5IbE7S+tRWQv4b4QA9OgCpDDLC6UyaXgASOBAVsqo03BqBA8r/bF/yckGnnYxpOSeFPR qOXA== X-Forwarded-Encrypted: i=1; AJvYcCUFKWSsYmI15iNAvxr4XKile+jlW2MMHgZs+E4V9LXhPIKTvK/Dl7rVzIcYewStfM9HtZGvgMMKYWj90H1RoMQb5tV/UW6VdItw8z29 X-Gm-Message-State: AOJu0Yxhjra6H70GJoQK0zhbqOZKi+R7Ft5Zu7Wnx8gDTHKlYCtsMbBe VNabjkgGqyV6wu5nWSd1SI5JzPD0TWk/d9xfQ8xxQKONk9oWFvjr X-Google-Smtp-Source: AGHT+IFPcRIkObmSrDDYGtNVtOSeyoXB9l1lQvDPOWGnZFWV9+vj3HB5FDw55OWXNeurNzTdURHy8A== X-Received: by 2002:a2e:80d3:0:b0:2e0:c689:f8cd with SMTP id r19-20020a2e80d3000000b002e0c689f8cdmr8710468ljg.29.1715074564625; Tue, 07 May 2024 02:36:04 -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.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:04 -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 , Nikita Kiryushin , Steven Rostedt Subject: [PATCH 32/48] rcu-tasks: Fix show_rcu_tasks_trace_gp_kthread buffer overflow Date: Tue, 7 May 2024 11:35:14 +0200 Message-Id: <20240507093530.3043-33-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Nikita Kiryushin There is a possibility of buffer overflow in show_rcu_tasks_trace_gp_kthread() if counters, passed to sprintf() are huge. Counter numbers, needed for this are unrealistically high, but buffer overflow is still possible. Use snprintf() with buffer size instead of sprintf(). Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: edf3775f0ad6 ("rcu-tasks: Add count for idle tasks on offline CPUs") Signed-off-by: Nikita Kiryushin Reviewed-by: Steven Rostedt (Google) Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tasks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index d5319bbe8c98..08a92bffeb84 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -1997,7 +1997,7 @@ void show_rcu_tasks_trace_gp_kthread(void) { char buf[64]; - sprintf(buf, "N%lu h:%lu/%lu/%lu", + snprintf(buf, sizeof(buf), "N%lu h:%lu/%lu/%lu", data_race(n_trc_holdouts), data_race(n_heavy_reader_ofl_updates), data_race(n_heavy_reader_updates), From patchwork Tue May 7 09:35:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656518 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 6E45115F41E; Tue, 7 May 2024 09:36:07 +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=1715074569; cv=none; b=SCH8K2suu2ALdzv4zp2kyeWSjPm/xp5NEe/f0IDePSSI/xGYbnf/XBlGkHWQfhXL2AWBkfa2r9QtgReM/OF7hcaKeJcpj8doCoHjse3sYgSZ7dGG8teTez1bV4URX/C7VgZ53mXGvMrOBMDa5p0wNk6MdQWQQACXgaGrxroWq+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074569; c=relaxed/simple; bh=QxVXtzdhs6C8lEQAiNycFXjxv31dqO4CFqRpSFHL3Ps=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MyBpUM7FjPwyM9oo/B0y+hWhSPxTUZspVBYm2IrzLoV45V5aKaTnaypFB92EAzycAWtf/ppY6VFQLpEjy5jpQVgzi3YeRpSJV7/1X8OIBLfRtgsqeENypZx4pP1O4jTMHLxMUEuwjJccjiN623LB5VcVKcX1E2Dnvnnw36kP5Fk= 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=PLQfvSR5; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PLQfvSR5" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2e27277d2c1so38191181fa.2; Tue, 07 May 2024 02:36:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074566; x=1715679366; 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=VwtB62NUslMMWx9PmLeV+lqXAsyxxRJntMdHp4lNxBE=; b=PLQfvSR53rRLk/AMgRA6jJ5nz1r2UbozVhuUpGezHt6KlugbXItxyzF++IUr4Yaoxe LkVqggHotQkRIrI9knUoiJKT9pUMDFegfL7/pfrdLKwRm7RSVNlwfH6+9nE8mNJ1TACL Rqt0CmOgTTrjyc8BvToP4He0CnAXmlEKJvh77C7mXhoPi7yRAukpHdzAOExjHbxOiGGD 98dpec/hAFjDz1TAJyv32KRQ0k6fZQgV0HRi3G5slrR1WVmapATgzKa1r/JDdv9sUMwf 5wkiWprF0bP6UQ4OkfCBpxB+sWQ4u3AN8JQKLbUWibgMd7dcO1gnBSUBHHZOaBe6q5uV prJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074566; x=1715679366; 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=VwtB62NUslMMWx9PmLeV+lqXAsyxxRJntMdHp4lNxBE=; b=c46J7K4icpMFPOx27YTjM6eplLbkUw1BEGuHqB2ReEcaqGAP5y7B9LaPtae2bKoEIf J2VAQgK14ZcY3jmFuEt4G1PvAU7VKpPuNyrggjeWRv+hH2aAzv/sYfDKHnRffvtRvZbE KLlcPM8ZoxYJpTr3jEjHnpJqHvusbKLRVU+DYxnjz4hy7NO59/0/O28vQy1ugGFNcelD +oCYIgMYnzI4+P1ApStXLlbxHD8lQjQmKiQ+Gv+n93rbJeQcXQYE3vaPAkQlWAq2oouN Ge0GuWKNnvQa5zEP4iMeKUT+xxN2Fm977ip26rXwrlXWOq+oUpNPrpa7T4NPI/mzqXsf pn6Q== X-Forwarded-Encrypted: i=1; AJvYcCU1McmewynCObPI+xN4BmFn3eDvDOFYXjq8JRRPuFLaYp7Bp32Vn7l0pHrtMxC7dUMxoN59xhW+XRSN7HSjyBndXtXqaNEBublynb4F X-Gm-Message-State: AOJu0Yz4bU2yOq9xF2g+boHBW1g8S1fcqaSXRCfX76Ys0obdHF5Klxc6 +z8/3hKxQbSuU5ije22/HaW6VPNN5DcMIhYAH8fJ1mRWKs27Vc6A X-Google-Smtp-Source: AGHT+IGRn2UIUjS+sAlU42bGVlq8/pmc6JRVDE1tE+2uv2h/o/UvpfZbSB4cHbbOePDgvd3DdGjyEg== X-Received: by 2002:a2e:7007:0:b0:2de:883d:1aef with SMTP id l7-20020a2e7007000000b002de883d1aefmr7742109ljc.46.1715074565773; Tue, 07 May 2024 02:36:05 -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.36.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:05 -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 , Johannes Berg Subject: [PATCH 33/48] rcu: Mollify sparse with RCU guard Date: Tue, 7 May 2024 11:35:15 +0200 Message-Id: <20240507093530.3043-34-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Johannes Berg When using "guard(rcu)();" sparse will complain, because even though it now understands the cleanup attribute, it doesn't evaluate the calls from it at function exit, and thus doesn't count the context correctly. Given that there's a conditional in the resulting code: static inline void class_rcu_destructor(class_rcu_t *_T) { if (_T->lock) { rcu_read_unlock(); } } it seems that even trying to teach sparse to evalulate the cleanup attribute function it'd still be difficult to really make it understand the full context here. Suppress the sparse warning by just releasing the context in the acquisition part of the function, after all we know it's safe with the guard, that's the whole point of it. Signed-off-by: Johannes Berg Reviewed-by: Boqun Feng Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- include/linux/rcupdate.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 382780bb60f4..dfd2399f2cde 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -1090,6 +1090,18 @@ rcu_head_after_call_rcu(struct rcu_head *rhp, rcu_callback_t f) extern int rcu_expedited; extern int rcu_normal; -DEFINE_LOCK_GUARD_0(rcu, rcu_read_lock(), rcu_read_unlock()) +DEFINE_LOCK_GUARD_0(rcu, + do { + rcu_read_lock(); + /* + * sparse doesn't call the cleanup function, + * so just release immediately and don't track + * the context. We don't need to anyway, since + * the whole point of the guard is to not need + * the explicit unlock. + */ + __release(RCU); + } while (0), + rcu_read_unlock()) #endif /* __LINUX_RCUPDATE_H */ From patchwork Tue May 7 09:35:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656520 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 9FE8915F41B; Tue, 7 May 2024 09:36:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074571; cv=none; b=BfMlZgSDQhalCE5b14zP/hieJvKL2vv3cNSQVIiS7n8Aouo197e/qHDnsXQBkrvc/eCrNDd9KU2hVSvvtoIgWee/Ei95OO8sQ17eALPcTfz6MlBKk7+nyV+dPMd/ImizFCk0Bxkqa+fC5a/ccd+E22EYg8Q2+i3YDdeR4cH+M/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074571; c=relaxed/simple; bh=ToAdu7RjzQdPvjL5csdGxaziISsWmJ7d6C2sZF1asqI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RYeAKXBgeF28zyELu6+bU3ICfrh6YGoSQ61xqz6poRgxHmxlOHLiaR+CxwdO7Bq57zJ+4eoIj3xJVczOox1Ozylsl0lWV4Bv7DZMp9LfFQ01wWqXOfRXAI2Lj4fLyr2HuTsypnaerQ2OuBgSxz6xIgmnQLyKHV89h9fU1TbTaHU= 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=Ws5Ar5K9; arc=none smtp.client-ip=209.85.208.176 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ws5Ar5K9" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2e2a4c20870so37456891fa.3; Tue, 07 May 2024 02:36:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074567; x=1715679367; 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=lWO9GAa6Vpz9dtNuoHPKqA+NV6gG2l18egBHY+/A1h4=; b=Ws5Ar5K9D4NCl8rOsy3W+lQApINN4vsf679fJ00RULjajSgs2wjb4UHQDQnDMV1Y7y /otQGYNqHTpdZJfmo1E7O8mZi0yLxPAR/+V5G+XokMfr95AtldcnEAbAuZrE32e9EHX7 As7OBsmRcKDQ9vm+1CNLXkLeh1Ss5Zp+chaauPlpf/STf/a/JgTZ604/20ecldKd+I3I tIBybPzkyrmmBquYrX10l6sXxfjyrCc3dCzOLyBtZOQnNicIpX8b6gMP5eM5dKNPBKM4 hC4OAx9v83FbCKpVUldTfhuyiZ/kXqGQqbmIc6NAPvO/5uOI1+QZH4hOelrD7pcin8iD eVjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074567; x=1715679367; 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=lWO9GAa6Vpz9dtNuoHPKqA+NV6gG2l18egBHY+/A1h4=; b=LGzpQiBM7arBAR8TWItQD0oR+kr2PSxwnMOzcYGQr97jGgtYPbVcr7XbkfJd5Ol8jd Jh7n5d3n89RIDUyLWWcb+eAGSe3xtDkb7MyMnTJcil+4zfLoq/2q1u2pLGKYG5v9vSKa QBl70aEF/qDUA65DulAbE+OdCmxJHL+LtzImlJCdcHYv9Kg1fFzT6/aeygIGzZijNNTh ykli36GIaAaWemhRHtu/9ZoG3o7uwnDPf2exLNsWOp84IfSjx2jjn/GRyHS7Ncf2ewxf Hl9DWjG/firdgkHEX31XsNG3ibFnhJCZkDZAKf8tbXrL0r8PIS1OCL1vAVsW7I59MpaH F7Nw== X-Forwarded-Encrypted: i=1; AJvYcCUY7X8OFP8dfhaih2uTowfbsNz1cUKZmF2dM4iBNEN5jdrBrCGfnHXc468vOEflaiFe/Ovq6owSmD3yg87qvuAr2SINd+xx75Og6a6q X-Gm-Message-State: AOJu0Yy0qmv53YFdKcOm1844So6INCaXQHFC7KE7xWnG+uvYy5KoDI2G ad3K5ePzOCOs6vZrC5XYRLBtt1UiKplvNabgFR9k/7b98mG97FDs X-Google-Smtp-Source: AGHT+IHPnKvfOjFZr/dR+aaCu8enNiYVRchJi0ShOWXgYLMb0fJZQCr5XHybb87C5Hh7wnCLzYZn0g== X-Received: by 2002:a2e:87d9:0:b0:2e1:a8db:2bca with SMTP id v25-20020a2e87d9000000b002e1a8db2bcamr7681329ljj.48.1715074566779; Tue, 07 May 2024 02:36:06 -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.36.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:06 -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 , Nikita Kiryushin , Steven Rostedt Subject: [PATCH 34/48] rcu: Fix buffer overflow in print_cpu_stall_info() Date: Tue, 7 May 2024 11:35:16 +0200 Message-Id: <20240507093530.3043-35-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Nikita Kiryushin The rcuc-starvation output from print_cpu_stall_info() might overflow the buffer if there is a huge difference in jiffies difference. The situation might seem improbable, but computers sometimes get very confused about time, which can result in full-sized integers, and, in this case, buffer overflow. Also, the unsigned jiffies difference is printed using %ld, which is normally for signed integers. This is intentional for debugging purposes, but it is not obvious from the code. This commit therefore changes sprintf() to snprintf() and adds a clarifying comment about intention of %ld format. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 245a62982502 ("rcu: Dump rcuc kthread status for CPUs not reporting quiescent state") Signed-off-by: Nikita Kiryushin Reviewed-by: Steven Rostedt (Google) Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tree_stall.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index 8a2edf6a1ef5..460efecd077b 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -504,7 +504,8 @@ static void print_cpu_stall_info(int cpu) rcu_dynticks_in_eqs(rcu_dynticks_snap(cpu)); rcuc_starved = rcu_is_rcuc_kthread_starving(rdp, &j); if (rcuc_starved) - sprintf(buf, " rcuc=%ld jiffies(starved)", j); + // Print signed value, as negative values indicate a probable bug. + snprintf(buf, sizeof(buf), " rcuc=%ld jiffies(starved)", j); pr_err("\t%d-%c%c%c%c: (%lu %s) idle=%04x/%ld/%#lx softirq=%u/%u fqs=%ld%s%s\n", cpu, "O."[!!cpu_online(cpu)], From patchwork Tue May 7 09:35:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656525 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 E140815FD16; Tue, 7 May 2024 09:36:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074576; cv=none; b=uGLiu1Bo7LME1dLxzF2Q3VnmllJdeMkJvQmokm37pPUjq4/pLJkBDzJBoKt2gCXijBYjJLRujNCkd2k5gHbHDPBufgT0a/0I5jUZKLL3MWQ5QHQlD6Dv127zATcHWIxp+2DgKAJzP74btWkHDT4rs2Q7dHgxGywiKoJXe0AJrPU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074576; c=relaxed/simple; bh=LXW89NnIQnDZHH703FiW/0rcUXcyHsfDVEdm2i5fTas=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b36xXik9PzSjkucpSTQGwQTWPcul4W0T54jIbPy4gvw3/BmoRTj22En8QOJqlPWsfhDF/pNA69YjD/sZB7qSSG2WU8N6tVhtt2LvWD6l/j/WgVmpFDNHDs4+aEFbNmL31+S8GX9jGqythyPJ5K6R8xTNmwot83WZfzty6XAaw60= 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=atBTECpa; arc=none smtp.client-ip=209.85.208.179 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="atBTECpa" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2e3f6166e4aso7197571fa.1; Tue, 07 May 2024 02:36:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074568; x=1715679368; 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=gPpPcZ0MCHYID7b4/P/MypH0i9pa5u8HppdPaw9fSmY=; b=atBTECpamPZ7PHRU5+gTZ4V1QBorWBDiKg3crKJE/otjSTga7Z/b3WEC2MEozWD3HY TNfzK6uZAV3E6audWFxkeAAtja6rFlN5ZRN/7RZsTF44BRjIiom1kGf0k3oaThTit41y B6HJT+N0SvG2N+W3N3LxqDBZsE4WhnyzfZwsQyEiglvB4x1wZb2ODVALEjnIq6Mkoir1 Ahv9TIRUmDc3e8NPH1h32HWNONGmbFYssVRbezPs4dN4eiDlm7WfNC4qRYF6jqQ77lw4 l87KZvqKOThIAkv7y5y21qfLZF2GaX1jIpvwIj/yRB5vhVZwoSIylu4tWtpB7ba9O15B 2KTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074568; x=1715679368; 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=gPpPcZ0MCHYID7b4/P/MypH0i9pa5u8HppdPaw9fSmY=; b=RB+qYg9XP7GS9vyiFLYE6gFiyjATQKyfSs8WmmvhZrDWP97G7KC0V14xGAMf3vgcF2 9wgrb9lrlZ0Ekk8hZN+B8aIXhc9ytGNe6R2l7+L7BXPlXIBErN2ivHQwAU/CON0ot3Yt 40/bgZ21lInjcn+pLywWck7RX5kklrG+rA0mlnyQguGcwjX0N53UgM6IK50iG3lWu56M ZpE1w8uww/5a744AYCSV4NZaxeoGp1AeE2zaNVedKnsvRRQ3sQSN+6S8faU5lt3mRlLQ c4dwXyGT9G7WkuEXChg/1jF6ocW+9lVtBbFtl5d3Ud7oah57eKQq9sNuq9XjzTMV7KF4 k0xA== X-Forwarded-Encrypted: i=1; AJvYcCXVR5NY2pYtdwD27ZHWeDfrduH4M8mp7ly5hjHzS16abiZwTV3gITfEEaA6odej1ptGWjiN+saYJ/teq5Dwdm2a0nJJ2eLYeSNvWWi2 X-Gm-Message-State: AOJu0YxOl9NYDGnT/mNvtrgath0YRvIo6Mu1p8IkAV6fHQlvUuhCmQlp fJp0z3XrC6mhMnDhyBYd2xh83hPz9uN7IGL71M0g2MaLDcHAqwZGfOxX23wJ X-Google-Smtp-Source: AGHT+IHUqLYPDAwJwBUM2sNzfGm/w8CZ1CaQdJB4ocNTioZhB2HayopqZOkgHC/6vuGX6KmqjwjrIg== X-Received: by 2002:a2e:a71f:0:b0:2e1:f255:6673 with SMTP id s31-20020a2ea71f000000b002e1f2556673mr9660204lje.13.1715074567680; Tue, 07 May 2024 02:36:07 -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.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:07 -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 , Neeraj Upadhyay Subject: [PATCH 35/48] rcu: Reduce synchronize_rcu() latency Date: Tue, 7 May 2024 11:35:17 +0200 Message-Id: <20240507093530.3043-36-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 A call to a synchronize_rcu() can be optimized from a latency point of view. Workloads which depend on this can benefit of it. The delay of wakeme_after_rcu() callback, which unblocks a waiter, depends on several factors: - how fast a process of offloading is started. Combination of: - !CONFIG_RCU_NOCB_CPU/CONFIG_RCU_NOCB_CPU; - !CONFIG_RCU_LAZY/CONFIG_RCU_LAZY; - other. - when started, invoking path is interrupted due to: - time limit; - need_resched(); - if limit is reached. - where in a nocb list it is located; - how fast previous callbacks completed; Example: 1. On our embedded devices i can easily trigger the scenario when it is a last in the list out of ~3600 callbacks: <...>-29 [001] d..1. 21950.145313: rcu_batch_start: rcu_preempt CBs=3613 bl=28 ... <...>-29 [001] ..... 21950.152578: rcu_invoke_callback: rcu_preempt rhp=00000000b2d6dee8 func=__free_vm_area_struct.cfi_jt <...>-29 [001] ..... 21950.152579: rcu_invoke_callback: rcu_preempt rhp=00000000a446f607 func=__free_vm_area_struct.cfi_jt <...>-29 [001] ..... 21950.152580: rcu_invoke_callback: rcu_preempt rhp=00000000a5cab03b func=__free_vm_area_struct.cfi_jt <...>-29 [001] ..... 21950.152581: rcu_invoke_callback: rcu_preempt rhp=0000000013b7e5ee func=__free_vm_area_struct.cfi_jt <...>-29 [001] ..... 21950.152582: rcu_invoke_callback: rcu_preempt rhp=000000000a8ca6f9 func=__free_vm_area_struct.cfi_jt <...>-29 [001] ..... 21950.152583: rcu_invoke_callback: rcu_preempt rhp=000000008f162ca8 func=wakeme_after_rcu.cfi_jt <...>-29 [001] d..1. 21950.152625: rcu_batch_end: rcu_preempt CBs-invoked=3612 idle=.... 2. We use cpuset/cgroup to classify tasks and assign them into different cgroups. For example "backgrond" group which binds tasks only to little CPUs or "foreground" which makes use of all CPUs. Tasks can be migrated between groups by a request if an acceleration is needed. See below an example how "surfaceflinger" task gets migrated. Initially it is located in the "system-background" cgroup which allows to run only on little cores. In order to speed it up it can be temporary moved into "foreground" cgroup which allows to use big/all CPUs: cgroup_attach_task(): -> cgroup_migrate_execute() -> cpuset_can_attach() -> percpu_down_write() -> rcu_sync_enter() -> synchronize_rcu() -> now move tasks to the new cgroup. -> cgroup_migrate_finish() rcuop/1-29 [000] ..... 7030.528570: rcu_invoke_callback: rcu_preempt rhp=00000000461605e0 func=wakeme_after_rcu.cfi_jt PERFD-SERVER-1855 [000] d..1. 7030.530293: cgroup_attach_task: dst_root=3 dst_id=22 dst_level=1 dst_path=/foreground pid=1900 comm=surfaceflinger TimerDispatch-2768 [002] d..5. 7030.537542: sched_migrate_task: comm=surfaceflinger pid=1900 prio=98 orig_cpu=0 dest_cpu=4 "Boosting a task" depends on synchronize_rcu() latency: - first trace shows a completion of synchronize_rcu(); - second shows attaching a task to a new group; - last shows a final step when migration occurs. 3. To address this drawback, maintain a separate track that consists of synchronize_rcu() callers only. After completion of a grace period users are deferred to a dedicated worker to process requests. 4. This patch reduces the latency of synchronize_rcu() approximately by ~30-40% on synthetic tests. The real test case, camera launch time, shows(time is in milliseconds): 1-run 542 vs 489 improvement 9% 2-run 540 vs 466 improvement 13% 3-run 518 vs 468 improvement 9% 4-run 531 vs 457 improvement 13% 5-run 548 vs 475 improvement 13% 6-run 509 vs 484 improvement 4% Synthetic test(no "noise" from other callbacks): Hardware: x86_64 64 CPUs, 64GB of memory Linux-6.6 - 10K tasks(simultaneous); - each task does(1000 loops) synchronize_rcu(); kfree(p); default: CONFIG_RCU_NOCB_CPU: takes 54 seconds to complete all users; patch: CONFIG_RCU_NOCB_CPU: takes 35 seconds to complete all users. Running 60K gives approximately same results on my setup. Please note it is without any interaction with another type of callbacks, otherwise it will impact a lot a default case. 5. By default it is disabled. To enable this perform one of the below sequence: echo 1 > /sys/module/rcutree/parameters/rcu_normal_wake_from_gp or pass a boot parameter "rcutree.rcu_normal_wake_from_gp=1" Reviewed-by: Paul E. McKenney Reviewed-by: Frederic Weisbecker Co-developed-by: Neeraj Upadhyay (AMD) Signed-off-by: Neeraj Upadhyay (AMD) Signed-off-by: Uladzislau Rezki (Sony) --- .../admin-guide/kernel-parameters.txt | 14 + kernel/rcu/tree.c | 331 +++++++++++++++++- kernel/rcu/tree_exp.h | 2 +- 3 files changed, 345 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index bb884c14b2f6..0a3b0fd1910e 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5091,6 +5091,20 @@ delay, memory pressure or callback list growing too big. + rcutree.rcu_normal_wake_from_gp= [KNL] + Reduces a latency of synchronize_rcu() call. This approach + maintains its own track of synchronize_rcu() callers, so it + does not interact with regular callbacks because it does not + use a call_rcu[_hurry]() path. Please note, this is for a + normal grace period. + + How to enable it: + + echo 1 > /sys/module/rcutree/parameters/rcu_normal_wake_from_gp + or pass a boot parameter "rcutree.rcu_normal_wake_from_gp=1" + + Default is 0. + rcuscale.gp_async= [KNL] Measure performance of asynchronous grace-period primitives such as call_rcu(). diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index d9642dd06c25..f65255205e44 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -75,6 +75,7 @@ #define MODULE_PARAM_PREFIX "rcutree." /* Data structures. */ +static void rcu_sr_normal_gp_cleanup_work(struct work_struct *); static DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, rcu_data) = { .gpwrap = true, @@ -93,6 +94,8 @@ static struct rcu_state rcu_state = { .exp_mutex = __MUTEX_INITIALIZER(rcu_state.exp_mutex), .exp_wake_mutex = __MUTEX_INITIALIZER(rcu_state.exp_wake_mutex), .ofl_lock = __ARCH_SPIN_LOCK_UNLOCKED, + .srs_cleanup_work = __WORK_INITIALIZER(rcu_state.srs_cleanup_work, + rcu_sr_normal_gp_cleanup_work), }; /* Dump rcu_node combining tree at boot to verify correct setup. */ @@ -1422,6 +1425,282 @@ static void rcu_poll_gp_seq_end_unlocked(unsigned long *snap) raw_spin_unlock_irqrestore_rcu_node(rnp, flags); } +/* + * There is a single llist, which is used for handling + * synchronize_rcu() users' enqueued rcu_synchronize nodes. + * Within this llist, there are two tail pointers: + * + * wait tail: Tracks the set of nodes, which need to + * wait for the current GP to complete. + * done tail: Tracks the set of nodes, for which grace + * period has elapsed. These nodes processing + * will be done as part of the cleanup work + * execution by a kworker. + * + * At every grace period init, a new wait node is added + * to the llist. This wait node is used as wait tail + * for this new grace period. Given that there are a fixed + * number of wait nodes, if all wait nodes are in use + * (which can happen when kworker callback processing + * is delayed) and additional grace period is requested. + * This means, a system is slow in processing callbacks. + * + * TODO: If a slow processing is detected, a first node + * in the llist should be used as a wait-tail for this + * grace period, therefore users which should wait due + * to a slow process are handled by _this_ grace period + * and not next. + * + * Below is an illustration of how the done and wait + * tail pointers move from one set of rcu_synchronize nodes + * to the other, as grace periods start and finish and + * nodes are processed by kworker. + * + * + * a. Initial llist callbacks list: + * + * +----------+ +--------+ +-------+ + * | | | | | | + * | head |---------> | cb2 |--------->| cb1 | + * | | | | | | + * +----------+ +--------+ +-------+ + * + * + * + * b. New GP1 Start: + * + * WAIT TAIL + * | + * | + * v + * +----------+ +--------+ +--------+ +-------+ + * | | | | | | | | + * | head ------> wait |------> cb2 |------> | cb1 | + * | | | head1 | | | | | + * +----------+ +--------+ +--------+ +-------+ + * + * + * + * c. GP completion: + * + * WAIT_TAIL == DONE_TAIL + * + * DONE TAIL + * | + * | + * v + * +----------+ +--------+ +--------+ +-------+ + * | | | | | | | | + * | head ------> wait |------> cb2 |------> | cb1 | + * | | | head1 | | | | | + * +----------+ +--------+ +--------+ +-------+ + * + * + * + * d. New callbacks and GP2 start: + * + * WAIT TAIL DONE TAIL + * | | + * | | + * v v + * +----------+ +------+ +------+ +------+ +-----+ +-----+ +-----+ + * | | | | | | | | | | | | | | + * | head ------> wait |--->| cb4 |--->| cb3 |--->|wait |--->| cb2 |--->| cb1 | + * | | | head2| | | | | |head1| | | | | + * +----------+ +------+ +------+ +------+ +-----+ +-----+ +-----+ + * + * + * + * e. GP2 completion: + * + * WAIT_TAIL == DONE_TAIL + * DONE TAIL + * | + * | + * v + * +----------+ +------+ +------+ +------+ +-----+ +-----+ +-----+ + * | | | | | | | | | | | | | | + * | head ------> wait |--->| cb4 |--->| cb3 |--->|wait |--->| cb2 |--->| cb1 | + * | | | head2| | | | | |head1| | | | | + * +----------+ +------+ +------+ +------+ +-----+ +-----+ +-----+ + * + * + * While the llist state transitions from d to e, a kworker + * can start executing rcu_sr_normal_gp_cleanup_work() and + * can observe either the old done tail (@c) or the new + * done tail (@e). So, done tail updates and reads need + * to use the rel-acq semantics. If the concurrent kworker + * observes the old done tail, the newly queued work + * execution will process the updated done tail. If the + * concurrent kworker observes the new done tail, then + * the newly queued work will skip processing the done + * tail, as workqueue semantics guarantees that the new + * work is executed only after the previous one completes. + * + * f. kworker callbacks processing complete: + * + * + * DONE TAIL + * | + * | + * v + * +----------+ +--------+ + * | | | | + * | head ------> wait | + * | | | head2 | + * +----------+ +--------+ + * + */ +static bool rcu_sr_is_wait_head(struct llist_node *node) +{ + return &(rcu_state.srs_wait_nodes)[0].node <= node && + node <= &(rcu_state.srs_wait_nodes)[SR_NORMAL_GP_WAIT_HEAD_MAX - 1].node; +} + +static struct llist_node *rcu_sr_get_wait_head(void) +{ + struct sr_wait_node *sr_wn; + int i; + + for (i = 0; i < SR_NORMAL_GP_WAIT_HEAD_MAX; i++) { + sr_wn = &(rcu_state.srs_wait_nodes)[i]; + + if (!atomic_cmpxchg_acquire(&sr_wn->inuse, 0, 1)) + return &sr_wn->node; + } + + return NULL; +} + +static void rcu_sr_put_wait_head(struct llist_node *node) +{ + struct sr_wait_node *sr_wn = container_of(node, struct sr_wait_node, node); + + atomic_set_release(&sr_wn->inuse, 0); +} + +/* Disabled by default. */ +static int rcu_normal_wake_from_gp; +module_param(rcu_normal_wake_from_gp, int, 0644); + +static void rcu_sr_normal_complete(struct llist_node *node) +{ + struct rcu_synchronize *rs = container_of( + (struct rcu_head *) node, struct rcu_synchronize, head); + unsigned long oldstate = (unsigned long) rs->head.func; + + WARN_ONCE(IS_ENABLED(CONFIG_PROVE_RCU) && + !poll_state_synchronize_rcu(oldstate), + "A full grace period is not passed yet: %lu", + rcu_seq_diff(get_state_synchronize_rcu(), oldstate)); + + /* Finally. */ + complete(&rs->completion); +} + +static void rcu_sr_normal_gp_cleanup_work(struct work_struct *work) +{ + struct llist_node *done, *rcu, *next, *head; + + /* + * This work execution can potentially execute + * while a new done tail is being updated by + * grace period kthread in rcu_sr_normal_gp_cleanup(). + * So, read and updates of done tail need to + * follow acq-rel semantics. + * + * Given that wq semantics guarantees that a single work + * cannot execute concurrently by multiple kworkers, + * the done tail list manipulations are protected here. + */ + done = smp_load_acquire(&rcu_state.srs_done_tail); + if (!done) + return; + + WARN_ON_ONCE(!rcu_sr_is_wait_head(done)); + head = done->next; + done->next = NULL; + + /* + * The dummy node, which is pointed to by the + * done tail which is acq-read above is not removed + * here. This allows lockless additions of new + * rcu_synchronize nodes in rcu_sr_normal_add_req(), + * while the cleanup work executes. The dummy + * nodes is removed, in next round of cleanup + * work execution. + */ + llist_for_each_safe(rcu, next, head) { + if (!rcu_sr_is_wait_head(rcu)) { + rcu_sr_normal_complete(rcu); + continue; + } + + rcu_sr_put_wait_head(rcu); + } +} + +/* + * Helper function for rcu_gp_cleanup(). + */ +static void rcu_sr_normal_gp_cleanup(void) +{ + struct llist_node *wait_tail; + + wait_tail = rcu_state.srs_wait_tail; + if (wait_tail == NULL) + return; + + rcu_state.srs_wait_tail = NULL; + ASSERT_EXCLUSIVE_WRITER(rcu_state.srs_wait_tail); + + // concurrent sr_normal_gp_cleanup work might observe this update. + smp_store_release(&rcu_state.srs_done_tail, wait_tail); + ASSERT_EXCLUSIVE_WRITER(rcu_state.srs_done_tail); + + schedule_work(&rcu_state.srs_cleanup_work); +} + +/* + * Helper function for rcu_gp_init(). + */ +static bool rcu_sr_normal_gp_init(void) +{ + struct llist_node *first; + struct llist_node *wait_head; + bool start_new_poll = false; + + first = READ_ONCE(rcu_state.srs_next.first); + if (!first || rcu_sr_is_wait_head(first)) + return start_new_poll; + + wait_head = rcu_sr_get_wait_head(); + if (!wait_head) { + // Kick another GP to retry. + start_new_poll = true; + return start_new_poll; + } + + /* Inject a wait-dummy-node. */ + llist_add(wait_head, &rcu_state.srs_next); + + /* + * A waiting list of rcu_synchronize nodes should be empty on + * this step, since a GP-kthread, rcu_gp_init() -> gp_cleanup(), + * rolls it over. If not, it is a BUG, warn a user. + */ + WARN_ON_ONCE(rcu_state.srs_wait_tail != NULL); + rcu_state.srs_wait_tail = wait_head; + ASSERT_EXCLUSIVE_WRITER(rcu_state.srs_wait_tail); + + return start_new_poll; +} + +static void rcu_sr_normal_add_req(struct rcu_synchronize *rs) +{ + llist_add((struct llist_node *) &rs->head, &rcu_state.srs_next); +} + /* * Initialize a new grace period. Return false if no grace period required. */ @@ -1432,6 +1711,7 @@ static noinline_for_stack bool rcu_gp_init(void) unsigned long mask; struct rcu_data *rdp; struct rcu_node *rnp = rcu_get_root(); + bool start_new_poll; WRITE_ONCE(rcu_state.gp_activity, jiffies); raw_spin_lock_irq_rcu_node(rnp); @@ -1456,10 +1736,24 @@ static noinline_for_stack bool rcu_gp_init(void) /* Record GP times before starting GP, hence rcu_seq_start(). */ rcu_seq_start(&rcu_state.gp_seq); ASSERT_EXCLUSIVE_WRITER(rcu_state.gp_seq); + start_new_poll = rcu_sr_normal_gp_init(); trace_rcu_grace_period(rcu_state.name, rcu_state.gp_seq, TPS("start")); rcu_poll_gp_seq_start(&rcu_state.gp_seq_polled_snap); raw_spin_unlock_irq_rcu_node(rnp); + /* + * The "start_new_poll" is set to true, only when this GP is not able + * to handle anything and there are outstanding users. It happens when + * the rcu_sr_normal_gp_init() function was not able to insert a dummy + * separator to the llist, because there were no left any dummy-nodes. + * + * Number of dummy-nodes is fixed, it could be that we are run out of + * them, if so we start a new pool request to repeat a try. It is rare + * and it means that a system is doing a slow processing of callbacks. + */ + if (start_new_poll) + (void) start_poll_synchronize_rcu(); + /* * Apply per-leaf buffered online and offline operations to * the rcu_node tree. Note that this new grace period need not @@ -1825,6 +2119,9 @@ static noinline void rcu_gp_cleanup(void) } raw_spin_unlock_irq_rcu_node(rnp); + // Make synchronize_rcu() users aware of the end of old grace period. + rcu_sr_normal_gp_cleanup(); + // If strict, make all CPUs aware of the end of the old grace period. if (IS_ENABLED(CONFIG_RCU_STRICT_GRACE_PERIOD)) on_each_cpu(rcu_strict_gp_boundary, NULL, 0); @@ -3559,6 +3856,38 @@ static int rcu_blocking_is_gp(void) return true; } +/* + * Helper function for the synchronize_rcu() API. + */ +static void synchronize_rcu_normal(void) +{ + struct rcu_synchronize rs; + + if (!READ_ONCE(rcu_normal_wake_from_gp)) { + wait_rcu_gp(call_rcu_hurry); + return; + } + + init_rcu_head_on_stack(&rs.head); + init_completion(&rs.completion); + + /* + * This code might be preempted, therefore take a GP + * snapshot before adding a request. + */ + if (IS_ENABLED(CONFIG_PROVE_RCU)) + rs.head.func = (void *) get_state_synchronize_rcu(); + + rcu_sr_normal_add_req(&rs); + + /* Kick a GP and start waiting. */ + (void) start_poll_synchronize_rcu(); + + /* Now we can wait. */ + wait_for_completion(&rs.completion); + destroy_rcu_head_on_stack(&rs.head); +} + /** * synchronize_rcu - wait until a grace period has elapsed. * @@ -3610,7 +3939,7 @@ void synchronize_rcu(void) if (rcu_gp_is_expedited()) synchronize_rcu_expedited(); else - wait_rcu_gp(call_rcu_hurry); + synchronize_rcu_normal(); return; } diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h index 6b83537480b1..8a1d9c8bd9f7 100644 --- a/kernel/rcu/tree_exp.h +++ b/kernel/rcu/tree_exp.h @@ -930,7 +930,7 @@ void synchronize_rcu_expedited(void) /* If expedited grace periods are prohibited, fall back to normal. */ if (rcu_gp_is_normal()) { - wait_rcu_gp(call_rcu_hurry); + synchronize_rcu_normal(); return; } From patchwork Tue May 7 09:35:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656522 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 A770115FD0D; Tue, 7 May 2024 09:36:10 +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=1715074573; cv=none; b=RYRwwK0LaBT+1bPhFtaTbohdmZa5FwqHLpXv4oOzr3SfQYds0sgErhHJlcF4iyS8Gd61+8aEou/d1pVruE50DKtRC7AfuTGkQz1yOQdIWT6/mERJqq4VJOUPqvCOGTis8HUt9M7jPKnNrxP2dlbiYQREPkFSrcPWVtLevIW/f7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074573; c=relaxed/simple; bh=n9Lpi3xDswaRGuMexMLHv+Fr/pOl2uShyoPzAxM/LkI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nrndFEXZSSR+JGRLW25RsjZRiQSrqjQfnfw9AQkYrCLkjKa7ql5T8YqTMaIhdhrb58khLHEiLgxeHNDhsfmG9Ot9b1ptjvRfjlFCJ0WNrJhkibGNbo2AObWV9yEE+7RqySQgICyHClhHAtAvS1FolUerA1Kt+AtAFQ0R0I1obPM= 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=A86JSHW1; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A86JSHW1" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2e242b1df60so34987121fa.1; Tue, 07 May 2024 02:36:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074569; x=1715679369; 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=dz5BXU3UHX4CwUX1cfETvCcNBZ5e+2wWNg8Li1dCQhQ=; b=A86JSHW1fpMiKREDa7dcbuZtDYqKOdqw/m7nGl+T+JvvboNRIhnMPkHMx1KPON9Bgj HkS5QHjxTmHg1aIyQ+8KW/8EC6hS3soFF+ByDVFg//2XsTxrc8HWTAT5EQZy6grUvTHh dCYn32LRhGe8QzLV9pCNUZA+zYE5/BisL/zbwLpVZd+GqthWyLI+LWPm+y70HikjTFaS 0F7HimHjGVXOpitWRqwAXkbw7TnVc5ysbyQC7hINEfjfj2YFlyaVNUcTkuBxTg9yyNdk kscSkPs8E2JqTe2UWT0hET1upAY5ECYzCWZ6LfRTM8UgAbfmKllRzEUxNzgIMVk8kkF1 XhXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074569; x=1715679369; 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=dz5BXU3UHX4CwUX1cfETvCcNBZ5e+2wWNg8Li1dCQhQ=; b=GzU4NUqRBuv7+srNFoyU6LqDSZY+DewL5IY6Ed0qefKXQjnir5PRoMcpY2e1sU7rG2 dojK5vPqhMfrysHByt0Ve/jA/oeiZ4ZralBrj9JuVjNhaOLPgmUS282Y7HV7jul8E5wt QXDcIcdJvIKwvQ+dA6s/dPDUl41LETfTXoiN0J03RLkf6WAHx6s/g5xQkaUiCe0rckxK nlKIeNQP9n9N3EQtLfCtuee4IKVS+BQAnD7rLQYN70RRxMVudM6Lnz92IuBxg1dK+wHj ajPtxxU113tv4Rmy/BtXL3ApqspQILh4Onqk71fJQcLpf3mbTFSLmRAUSncLj/XYGgTv ybag== X-Forwarded-Encrypted: i=1; AJvYcCUU51VaTy3KEqaZ8oh/Z3tM+Vd5q1uq0HCZJfK6F5i6P5Nf/64fNyivV8FWeJSxtbUUcGc4DVw+oXk5XQYhAtmRg61rxQUmfmw52wUK X-Gm-Message-State: AOJu0YwYM+/7htlQPC5sMDQxsGpR4/D3DcrcNnBX921EfZuwrR0avnHZ dtayZ5E9Alr6QScpzbxDnVbK77cLtQhv4WpYayZg1iaIMhfGvGqS X-Google-Smtp-Source: AGHT+IF9egT9BOHQ1RvjlkxBBCieeXHyaTXF18N4dYlrO9IeXmUlDdQYAz8W6Ivqg9cdHHkFCgCRyA== X-Received: by 2002:a2e:9dd0:0:b0:2e2:6372:7747 with SMTP id x16-20020a2e9dd0000000b002e263727747mr10079058ljj.4.1715074568625; Tue, 07 May 2024 02:36:08 -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.36.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:08 -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 Subject: [PATCH 36/48] rcu: Add a trace event for synchronize_rcu_normal() Date: Tue, 7 May 2024 11:35:18 +0200 Message-Id: <20240507093530.3043-37-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add an rcu_sr_normal() trace event. It takes three arguments first one is the name of RCU flavour, second one is a user id which triggeres synchronize_rcu_normal() and last one is an event. There are two traces in the synchronize_rcu_normal(). On entry, when a new request is registered and on exit point when request is completed. Please note, CONFIG_RCU_TRACE=y is required to activate traces. Reviewed-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- include/trace/events/rcu.h | 27 +++++++++++++++++++++++++++ kernel/rcu/tree.c | 7 ++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h index 2ef9c719772a..31b3e0d3e65f 100644 --- a/include/trace/events/rcu.h +++ b/include/trace/events/rcu.h @@ -707,6 +707,33 @@ TRACE_EVENT_RCU(rcu_invoke_kfree_bulk_callback, __entry->rcuname, __entry->p, __entry->nr_records) ); +/* + * Tracepoint for a normal synchronize_rcu() states. The first argument + * is the RCU flavor, the second argument is a pointer to rcu_head the + * last one is an event. + */ +TRACE_EVENT_RCU(rcu_sr_normal, + + TP_PROTO(const char *rcuname, struct rcu_head *rhp, const char *srevent), + + TP_ARGS(rcuname, rhp, srevent), + + TP_STRUCT__entry( + __field(const char *, rcuname) + __field(void *, rhp) + __field(const char *, srevent) + ), + + TP_fast_assign( + __entry->rcuname = rcuname; + __entry->rhp = rhp; + __entry->srevent = srevent; + ), + + TP_printk("%s rhp=0x%p event=%s", + __entry->rcuname, __entry->rhp, __entry->srevent) +); + /* * Tracepoint for exiting rcu_do_batch after RCU callbacks have been * invoked. The first argument is the name of the RCU flavor, diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index f65255205e44..2e1c5be6d64b 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -3863,9 +3863,11 @@ static void synchronize_rcu_normal(void) { struct rcu_synchronize rs; + trace_rcu_sr_normal(rcu_state.name, &rs.head, TPS("request")); + if (!READ_ONCE(rcu_normal_wake_from_gp)) { wait_rcu_gp(call_rcu_hurry); - return; + goto trace_complete_out; } init_rcu_head_on_stack(&rs.head); @@ -3886,6 +3888,9 @@ static void synchronize_rcu_normal(void) /* Now we can wait. */ wait_for_completion(&rs.completion); destroy_rcu_head_on_stack(&rs.head); + +trace_complete_out: + trace_rcu_sr_normal(rcu_state.name, &rs.head, TPS("complete")); } /** From patchwork Tue May 7 09:35:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656523 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 9226B15ECCC; Tue, 7 May 2024 09:36:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074574; cv=none; b=ht7Js9Z18dtj7op/t4dpAIMFSzvGLaTrfLII9+rs2fpTscgqbtjFP4zJGZNbUor9TY3r2RhJy9kuFkrc8w1gvEOWYnxKXNacwwTvqy/CZoueIRk3rYLW6QnANHf8ukwUX1PGODWrDx41qFhGg3BBBnQPFJTG0QWd7x9MhALCft4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074574; c=relaxed/simple; bh=FSe7L4XahPulJ5NWwKASJPrFyN+6QSNIQKLFJWJyFOU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=r8M/7TPahBJZW53Br+cmnXoGptq1BXiWFwoeMMIthVnUVdnqCYnGduJDAXzoKqQCnZ6ajOl9VVBkGhCDiE2wzcCzX8MyuOZVEQaRs8fZBAdwdjJRb/kbpeYR7xz3YU6d13hAxFdZACVjbq2RQq+lh82SyR5zAZWJNKFAVk2WiRo= 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=mYZ0ep+x; arc=none smtp.client-ip=209.85.208.178 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mYZ0ep+x" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2e3e18c240fso8460181fa.0; Tue, 07 May 2024 02:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074569; x=1715679369; 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=2K4LgSBtjYfVsokX8qgwwcmFotZID2ml7T+yfPfGHDY=; b=mYZ0ep+x5jwNKoVZINdgBE3KuH9yfI/Rwi2PxKVpeKEWuS0CW24QSi43BPPcFfcbGg WJcUDbmLhyaeg3fdbkPqidgc723KRKFhfjC4hYf2xzZaNrEpvMDuYJSp0amp5FYj0Zcm h+w21M3gr/smMzqU3xa9Xulfpli8QW8ZiNJ/tD7vVTcG2JuufKLFTvXTGtqasWGjY6pC WFf3jQsZQa8i+ObFfkvAaZHfcvEGnWZW4ekzyyIg1bglqUSlqfcWxz/2YYN5nXbhlYDo 3EmZWz/nl4gIlMcruzHRZpusex/35AXB/daPbWMv9J6thojEbcKbaQAzBSBkXuh9bM6u Zthg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074569; x=1715679369; 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=2K4LgSBtjYfVsokX8qgwwcmFotZID2ml7T+yfPfGHDY=; b=QgMZdVf29veObcmVNTjY1ZSxmud+Bg1p5ez/kRr6rAwvK/3qzFaJDvig/+XenHaktj Y0/lV6ybCsvKX4ScvhkhQ3ITZPPu52FZvKFYJ3UEJNvWndtDybhGrgpLxnY3aFnDn+NZ 5J/no/mW0j5o/gQO8V8QnylL4zqKVcRQRZJzMTc3wSO/FGyn0AFtK/eO+qKyKeveBCye H+0Jdy/8p0FBsFFHMVbK1wrUqb1SQoejk8sA7vGzcBCRRbOKzAeeWuvQKU3vPhVdh8qT AWZbf8cDB0mJwSp9zuKaaf62KXe/zNiwq9GFii3jKjIl3c6D8sZI2VvyauA7scDRnYiW CNdQ== X-Forwarded-Encrypted: i=1; AJvYcCWhhNSr+CMYOVVGVxZEuhz7dRgT5bkpqx6gjYlyM62RmzQihmxYiOp4zjfoD8EZ+BKV1tcGnQHDYDc5fITupVCDVUfUiulxZniWdAGP X-Gm-Message-State: AOJu0YwPEr1WFb5BAx1M4E4J+yEa+EHHAwUMn7sPsvzCtMQHKq9NyZCm +bENiiE+344sSrqA+7AkCsZVDduRA9zx0iGI+aeXrzoQSFZRUbaI X-Google-Smtp-Source: AGHT+IHFO+7vnyh7sLgrAAy1bapshrWvgpxYIMic2T3SiCD6fIcqP0vLE6uWUTB4gSO9QyJ3221r+A== X-Received: by 2002:a2e:3309:0:b0:2e1:f05f:6424 with SMTP id d9-20020a2e3309000000b002e1f05f6424mr9920045ljc.15.1715074569596; Tue, 07 May 2024 02:36:09 -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.36.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:09 -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 Subject: [PATCH 37/48] rcu: Support direct wake-up of synchronize_rcu() users Date: Tue, 7 May 2024 11:35:19 +0200 Message-Id: <20240507093530.3043-38-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch introduces a small enhancement which allows to do a direct wake-up of synchronize_rcu() callers. It occurs after a completion of grace period, thus by the gp-kthread. Number of clients is limited by the hard-coded maximum allowed threshold. The remaining part, if still exists is deferred to a main worker. Link: https://lore.kernel.org/lkml/Zd0ZtNu+Rt0qXkfS@lothringen/ Reviewed-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tree.c | 24 +++++++++++++++++++++++- kernel/rcu/tree.h | 6 ++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 2e1c5be6d64b..2a270abade4d 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -1645,7 +1645,8 @@ static void rcu_sr_normal_gp_cleanup_work(struct work_struct *work) */ static void rcu_sr_normal_gp_cleanup(void) { - struct llist_node *wait_tail; + struct llist_node *wait_tail, *next, *rcu; + int done = 0; wait_tail = rcu_state.srs_wait_tail; if (wait_tail == NULL) @@ -1653,11 +1654,32 @@ static void rcu_sr_normal_gp_cleanup(void) rcu_state.srs_wait_tail = NULL; ASSERT_EXCLUSIVE_WRITER(rcu_state.srs_wait_tail); + WARN_ON_ONCE(!rcu_sr_is_wait_head(wait_tail)); + + /* + * Process (a) and (d) cases. See an illustration. + */ + llist_for_each_safe(rcu, next, wait_tail->next) { + if (rcu_sr_is_wait_head(rcu)) + break; + + rcu_sr_normal_complete(rcu); + // It can be last, update a next on this step. + wait_tail->next = next; + + if (++done == SR_MAX_USERS_WAKE_FROM_GP) + break; + } // concurrent sr_normal_gp_cleanup work might observe this update. smp_store_release(&rcu_state.srs_done_tail, wait_tail); ASSERT_EXCLUSIVE_WRITER(rcu_state.srs_done_tail); + /* + * We schedule a work in order to perform a final processing + * of outstanding users(if still left) and releasing wait-heads + * added by rcu_sr_normal_gp_init() call. + */ schedule_work(&rcu_state.srs_cleanup_work); } diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index b942b9437438..2832787cee1d 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -315,6 +315,12 @@ do { \ __set_current_state(TASK_RUNNING); \ } while (0) +/* + * A max threshold for synchronize_rcu() users which are + * awaken directly by the rcu_gp_kthread(). Left part is + * deferred to the main worker. + */ +#define SR_MAX_USERS_WAKE_FROM_GP 5 #define SR_NORMAL_GP_WAIT_HEAD_MAX 5 struct sr_wait_node { From patchwork Tue May 7 09:35:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656528 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 4ACD615FA82; Tue, 7 May 2024 09:36:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074577; cv=none; b=Rh/fZScds+IGSArgM9FZFgOH5IwUHYVy2E9glNo+eDTPmYudSs01TjCNVmlB/F+t84BKR2DILNZVIlzyaJqaYoJOfJYvdcEQ9Aoirgg89mjQRvZufWP6FCfNGLqRUz4qIRm2UJZJakJiMiQma94rv4GtL8JQCw7hyyuR8uwGwIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074577; c=relaxed/simple; bh=QKSqgdzxusUu2mHIh3mAgH0aWgzgQr+xVcxYkLJ9pLo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C40F2mBE5XDLohFCFoqrUPQC03vHl3fRGZbptnHTTG/tfRENj029aBxXSB74807+3FGSrDrICBdTRBs5UNpCg6CvXs3cHq9Ob5H16B/d9iHylihuo8oMoE7he3OpbJaK5465uK6UtfEFGw/CqmyGfpDttIQZDSPBBXrNN2dsspo= 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=QEH12vyn; arc=none smtp.client-ip=209.85.208.175 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QEH12vyn" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2df848f9325so34230421fa.1; Tue, 07 May 2024 02:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074570; x=1715679370; 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=vMiIpeM1d8lFeOaPEE+VPZ7k+2yYPj98QEqarfz20oU=; b=QEH12vynqZPLxg6EMqXvkYhrKvN5tud8VrEukfJBisF8RfKVrrk/QNOTrq5kMp0tY0 wNWvApK9INPloEPdLkTIuSFa8ldVAE9onHoQwDfuWqgYV+YmqB4tw7cylBjk18CrV7e1 u0M0vB5IMfBUecT77hediettyrmYy/EyCmOwEEBF+AovM2YXThJQnYp1S/1LduE3wnOD koblzXyJT2lGS89iSt9cu+nLteUvvkzrvp3n3RZ3JRTgvs8bHHNBLYSQfH/LZhyd3deT CsLjTZn6/BEGHfzm4p+tWVC+rwJMmAjg/Ak0tWQ2Q+EA8Xs1pRs1ex3rBKyHOrXeUwBs Lv1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074570; x=1715679370; 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=vMiIpeM1d8lFeOaPEE+VPZ7k+2yYPj98QEqarfz20oU=; b=gks9z8R8BhsVxVUdi/sdIr9Pcjka/naISdMOSOME0T0bBlIjvUQ90gqVC99ZUnWpHP BQWGJ6fq7/4pmvwCvHh2QKK+r4zENlql83VxXSF0hj1V77XnQeb1EZ/m2OVR1GTEC92B Y22JnVGIyruakadxIZgOQBCMNZFS8tPX+3OS/5ywMxOmbn2HxygD4tOvsk4o1FsQN44P c7T3IPeXvWwx30rfHV7W8WS6qKxjtqAnzGrsFy3N1aqs5TY4GFEhLX/cv9QY7qZSmoDQ M3ZF/E4gDDcCir6LBMYFJ8UPJSZiSeA4GJBdUXl+ObCgcghBUnNoHEr4A6olBMEIRcO8 6gOA== X-Forwarded-Encrypted: i=1; AJvYcCWVi3rSoXbxpfRppSP0JcguXtuo4/9sMlmsvEqlA373WHvUrQpcF7T/bXTX8BDx/0jeaWBbc2st5alaropt/jszb23WL+c5LVRmS46Y X-Gm-Message-State: AOJu0Yzr2yxE5nmw3vyAVch6MfPxmNTsgByCoB13u/NdUixkSWR5Qi0I LHai7p6KYM9RIuD/jCH+9hQImmJmqpr/MtZoDTgpcZ/9oELPh0w1 X-Google-Smtp-Source: AGHT+IFTSPnMqNJuabynMCKLpS20u3n4+Lw184hqoe3LFtLJl+j8mMtkSJH2spEebBcJhJkTG6mi8Q== X-Received: by 2002:a2e:b173:0:b0:2da:49cc:ef3f with SMTP id a19-20020a2eb173000000b002da49ccef3fmr7916188ljm.42.1715074570392; Tue, 07 May 2024 02:36:10 -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.36.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:10 -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 Subject: [PATCH 38/48] rcu: Allocate WQ with WQ_MEM_RECLAIM bit set Date: Tue, 7 May 2024 11:35:20 +0200 Message-Id: <20240507093530.3043-39-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 synchronize_rcu() users have to be processed regardless of memory pressure so our private WQ needs to have at least one execution context what WQ_MEM_RECLAIM flag guarantees. Reviewed-by: Paul E. McKenney Reviewed-by: Joel Fernandes (Google) Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tree.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 2a270abade4d..1d5c000e5c7a 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -1582,6 +1582,7 @@ static void rcu_sr_put_wait_head(struct llist_node *node) /* Disabled by default. */ static int rcu_normal_wake_from_gp; module_param(rcu_normal_wake_from_gp, int, 0644); +static struct workqueue_struct *sync_wq; static void rcu_sr_normal_complete(struct llist_node *node) { @@ -1680,7 +1681,7 @@ static void rcu_sr_normal_gp_cleanup(void) * of outstanding users(if still left) and releasing wait-heads * added by rcu_sr_normal_gp_init() call. */ - schedule_work(&rcu_state.srs_cleanup_work); + queue_work(sync_wq, &rcu_state.srs_cleanup_work); } /* @@ -5585,6 +5586,9 @@ void __init rcu_init(void) rcu_gp_wq = alloc_workqueue("rcu_gp", WQ_MEM_RECLAIM, 0); WARN_ON(!rcu_gp_wq); + sync_wq = alloc_workqueue("sync_wq", WQ_MEM_RECLAIM, 0); + WARN_ON(!sync_wq); + /* Fill in default value for rcutree.qovld boot parameter. */ /* -After- the rcu_node ->lock fields are initialized! */ if (qovld < 0) From patchwork Tue May 7 09:35:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656526 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 4B42E1607AD; Tue, 7 May 2024 09:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074576; cv=none; b=HQyr6P75Oh/Bii6zt6nS+1J29hEPRVpWvOZ/xG8sW+9CZ+YJ6h9nB/MNH16ghIckVlDcGpc0OI7Uh2vL018m3WlFNfe59dNhlIxQGPMrH9yFOgknle78ibNQpJexDwPQwrCBk2CCEYxVla7WK/Wctj6/X+/UUyZGgYpzMSy381E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074576; c=relaxed/simple; bh=xpb7OlvSSo1eFdDyHPiIjhWcGu0wWewuK+3bzuPFsbU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oDx7E6bIIuJZAPkkG3+qL1D4xxwT8nI3YZ6tLTT8tp37DLR/T/O+wUnBQ+Jexg7Cc1cseGzrMIFcjk4tcZZHsz4kTNwaj36yk+5/5trXXJgtMZVn/vSepL9PNW9Lrh23TWuAwdr3iGjcnDO5EPIe4uhKxJ8rLrtCan6HpKWFFEs= 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=KzKq8LMB; arc=none smtp.client-ip=209.85.208.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KzKq8LMB" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2db17e8767cso36158051fa.3; Tue, 07 May 2024 02:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074571; x=1715679371; 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=CKbmQWc+9T9jJILreLJTePG04vL0LrIDb9GwepNxo3I=; b=KzKq8LMBOt+2tgNLhCa41kfA9tIxfLFoR2sL0JVEa6uN6iTYBMsCK6FweM2rBql4+B 5UiZKHKfjBRH2yslcqM/RgqrfLiL3ZIuWh+8VnH0RuVLrCZGPT0eDFqRX4+uz3groWgb rfW5EeBVHFDYHrJE7U0+vYvl5giAzeCgM0fZT45pQhEfY9N4T+5+XxiPFyAbcsVtMlDy gaD4ZjEGWGkFQKY9FOxf5u1wT5EAT/JtmWKFbFZVJHrzwV7dPRPutvfoQVyHEBYV3B8s jyI/hPUAL8N1edfBSf4wygl9iyClVkDc0Is2CdkrMWJcANQQOPr8cRIkcekcxloIyaHM ZDNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074571; x=1715679371; 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=CKbmQWc+9T9jJILreLJTePG04vL0LrIDb9GwepNxo3I=; b=WZevy3W2ZuRDRev0X3ou525e5aT+jyUMZG0YxDwqzZ1ZLWxXdyo8fz8ZSxA3EXhEhZ l6IStfPQz08+uJJBMTRAGi0uYDgZKEVF4AHw6+Kx4lclntt8MSOmQr22TegL7/QUr2My rMJWVgkBqdbgLCMbnsuNkPZbajpsw625orH1qYbaPnYpEpg9M+Hpj9Czd72fZk48F0F/ j49jaKoZlnP7T/z/7Sms6bWZfSfclrsv/69KuQ4r8/d8bZy4UlYsapyiO4Sdi3soMArU aQekBuPkpKdrCybZJL04+5Cq+LC5c3hpQklF6ptzC/NTQDbuQwTLK2wlDn1+WzcIxDh9 Wz8A== X-Forwarded-Encrypted: i=1; AJvYcCVeYJz7bnynwWwl1mK662tU4C35a3al1+yODJCkP2ic8mhUAuCzIL8tXjtmhG2UCctitt78Pyel0ynY4BQwMY1eyi6i7KivEcLmNBFh X-Gm-Message-State: AOJu0Yz79mz/KPzjKFvDd+e31kefFhVkeJZ0GILW2DKb0Kh/+cXBQGjQ BTjWUZzyKUpvWCVtcM6cb7ZXqj8hzV8yu28OaM6GuMAjSqcpRrPK X-Google-Smtp-Source: AGHT+IEE9OwN9hgrxrUXXrlzUlyEFsgLBZf8UOvqt+QLmmzylv0mw7r1Pcmk4kRtcP4ng8Sd1BwtMw== X-Received: by 2002:a05:651c:201c:b0:2dd:c9fc:c472 with SMTP id s28-20020a05651c201c00b002ddc9fcc472mr7408812ljo.26.1715074571380; Tue, 07 May 2024 02:36:11 -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.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:11 -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 Subject: [PATCH 39/48] rcutorture: Remove extraneous rcu_torture_pipe_update_one() READ_ONCE() Date: Tue, 7 May 2024 11:35:21 +0200 Message-Id: <20240507093530.3043-40-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" The rcu_torture_pipe_update_one() cannot run concurrently with any updates of ->rtort_pipe_count, so this commit removes the extraneous READ_ONCE() from the read from this field. Reported-by: Linus Torvalds Closes: https://lore.kernel.org/lkml/CAHk-=wiX_zF5Mpt8kUm_LFQpYY-mshrXJPOe+wKNwiVhEUcU9g@mail.gmail.com/ Signed-off-by: Paul E. McKenney Reviewed-by: Joel Fernandes (Google) Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index d8c12eba35b7..6b821a7037b0 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -461,7 +461,7 @@ rcu_torture_pipe_update_one(struct rcu_torture *rp) WRITE_ONCE(rp->rtort_chkp, NULL); smp_store_release(&rtrcp->rtc_ready, 1); // Pair with smp_load_acquire(). } - i = READ_ONCE(rp->rtort_pipe_count); + i = rp->rtort_pipe_count; if (i > RCU_TORTURE_PIPE_LEN) i = RCU_TORTURE_PIPE_LEN; atomic_inc(&rcu_torture_wcount[i]); From patchwork Tue May 7 09:35:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656524 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 492EE16132A; Tue, 7 May 2024 09:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074576; cv=none; b=eLScoywT3IiCVcGdudtka9etOgJMH1S5JzXyOAEodHFJuVJSXfstqF2JNQML0iGRJwZueItSym5tdLRxEhBtTyEWuUOmxw3QYfOLd3SjnHXejOM6ceROulHcFTO8eMl49dgbe9v1Nb+eYRWBQkx8NONzZ+8a9WgliO8RBFrf8TA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074576; c=relaxed/simple; bh=zwo8GaVLL+3hw0Cv/JQfcpn/MdzBC8bJdprk9Rpnixk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WTKRa95nPxIXeZdFoyY0zq+kjGIoJvDiykWIH1ZnXeWcInKESF9OXjhvhCI2zK6u9gRIYvidpm6G8kum3ajcb2FpSCP6luljIb9zy1HDyAYu0VtX10GCk59vMnAHbKuHQPtf6eoV6tTlWaNY1t6wPzRhGngjXUEo9GpTERJ0v+I= 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=OmlFqxHR; arc=none smtp.client-ip=209.85.208.181 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OmlFqxHR" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2e1fa1f1d9bso55712111fa.0; Tue, 07 May 2024 02:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074572; x=1715679372; 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=ALGD50dfBLDLVyD3Lt2LManagWExKBPG3j+4x0bgOm4=; b=OmlFqxHRQB7f/Q5CnuQ5h25j29eEJY70I8EwbfW9QC4ZMqIfW0n97Q2GyH6yhLBiIJ btyWzjsgbe325QjS+d8Mj4NITSmANzukzRjHBsVCHShzOXHp+aeIRb9dLmDtA+DKTYjL ObEzVh0denAbbR87P9xpT9flHWUHfsQjlyfmZoyAh/pEo7+HlboMUQ2ixTsKt0OMQZld 7++H0WLtFDZF+QBNbq7fhlxF9eduP3eYQDn/hgcxzaAlC4vIAYZ2CxRUgraMCdidmoac vmlFvh1wkHcp/fhNFWPY58uad89emWN7BlsRStn6TDSsGL5PV0wQjlTN3xop1G/t8CbM +BCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074572; x=1715679372; 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=ALGD50dfBLDLVyD3Lt2LManagWExKBPG3j+4x0bgOm4=; b=vyM6BJ9KdmLo+dl3iUt4x55bQ51N1H4SKG17I+Dx/FSofBj3GN5rlf23YWLlGp8JrN 3LNuODvb5Hc6tEEp0rk1sXS3u0gdPj799+Yb5VSs8k9FWb3SmbOylUC71AhIMBOLAuAB FrjsvVQBIOJM/NaPRS0fli78pn8RgYuPuHyvll1FzIkyhUNqDdkRdR0pjuDLQGLrMlLS sQ/W3EPfvI0EyRsKJot0o0jwiDSe7tqokEgZIEouC278aOvcXyc3OxP69A9zBw/Md1BW 7TKu3VmBtL0KTpsotSKN1wqslKtahzifZMa7H1qNzOekrHG/NU9nnMLL6rFGHNAdaa7f 5W4g== X-Forwarded-Encrypted: i=1; AJvYcCXFY64HWFHn3N9goTtcBfF5fci3NXvDPUjALwpoXytY02zSotEpIndJpRmPhkUJmTgRSFgxRsjueZS5ZTDmuHVJ+CzZ0kdV78QVxQLx X-Gm-Message-State: AOJu0YxhRd0cKzDjE5qLQvz7F8uZeRqrjoZsAPA+C0By1UXX5SaGx+cS 5C8XJnOnxVoWgolTHWC62v9flp15ypa4130Hf7mCgfuhokDs2nzl X-Google-Smtp-Source: AGHT+IE1aRpC7BZU7Jhkp5OgFGXus4CGvWnQDyQ6L4ZqGSCbouY1bqByQmp89pOOsJCJ2NM9xABHcw== X-Received: by 2002:a2e:984c:0:b0:2e1:d94a:771d with SMTP id e12-20020a2e984c000000b002e1d94a771dmr11437082ljj.4.1715074572233; Tue, 07 May 2024 02:36:12 -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.36.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:11 -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 Subject: [PATCH 40/48] rcutorture: Fix rcu_torture_one_read() pipe_count overflow comment Date: Tue, 7 May 2024 11:35:22 +0200 Message-Id: <20240507093530.3043-41-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" The "pipe_count > RCU_TORTURE_PIPE_LEN" check has a comment saying "Should not happen, but...". This is only true when testing an RCU whose grace periods are always long enough. This commit therefore fixes this comment. Reported-by: Linus Torvalds Closes: https://lore.kernel.org/lkml/CAHk-=wi7rJ-eGq+xaxVfzFEgbL9tdf6Kc8Z89rCpfcQOKm74Tw@mail.gmail.com/ Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/rcutorture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 6b821a7037b0..0cb5452ecd94 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2000,7 +2000,8 @@ static bool rcu_torture_one_read(struct torture_random_state *trsp, long myid) preempt_disable(); pipe_count = READ_ONCE(p->rtort_pipe_count); if (pipe_count > RCU_TORTURE_PIPE_LEN) { - /* Should not happen, but... */ + // Should not happen in a correct RCU implementation, + // happens quite often for torture_type=busted. pipe_count = RCU_TORTURE_PIPE_LEN; } completed = cur_ops->get_gp_seq(); From patchwork Tue May 7 09:35:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656527 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.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 21FCD1635A3; Tue, 7 May 2024 09:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074577; cv=none; b=HCBRAfG0un1F12tA80ln8p51VkVermgmIn/IA75g7zNPiiCSOYmNPgAYbTx7LGMPoXYSrSHJTUlh8xm9Eaw1nAhHJkIFACHWPfxMx1eysMJZr67ALAMGTt9SFr4MF8tmj8OpT80RAtHeZDOK58kF6LYFlzXlTuk2SGWgnSlWMfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074577; c=relaxed/simple; bh=JN0w1xsQGF3iE6mpueRmof2UMzcBsc+EhVwKMcjJxBw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HswU6R1J6MAe6tD+H/bFwU0Lf8ev4BCYMMHfrr3EIemevoJW2G/kN0/V8nHBmezGCui2fDWND6AEIEt69ogYSDOdMGi+w/AA6OnID/ALwxvjj7HMPKdhlrvhvDJfsWb45bFCD46n1h2CCZ8wWBhBdKbvXLadHx+Tc4HK/Rfbx74= 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=ehhr9sjR; arc=none smtp.client-ip=209.85.208.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ehhr9sjR" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2e30c625178so25906011fa.1; Tue, 07 May 2024 02:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074573; x=1715679373; 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=0jO2a1vN4cs3B1CONKF++m02zLGls5jBFIdXQrkGHDs=; b=ehhr9sjRIk5M3KulSZb42g/O0DJgYMBU/BhFs8D4sGsmyF7anhtK7TU28OkK3Ab7vV cGxRIAkGa07p88mcNcJRm5f4BCDYkkYqUVZCAJ3RNzieeSXtNX5DSyPfXN0Uuc1BspJe C3jRBGam4QIDxpK4OU6KYzSGEtMM/QhSHKYHnsN7ZZ/zlBynZmUrX7asQ0KoZ1BgJFrZ Q/26QzH5LMaAj9vvb/nISdt4dm3Z+TtgATvol3ZXjkNWummqMUGysYYtecTQ3TwbP87M SjsDXbhqfZzJaOOmSSKpp16IUfmrM/3YRR7J/Dq+fOw9vbUJ+HuWB9xGR9JX+TjwQDh7 jgNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074573; x=1715679373; 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=0jO2a1vN4cs3B1CONKF++m02zLGls5jBFIdXQrkGHDs=; b=V8NAR6qa2Y5DwRCD3qFnUmluBwit8LXrmn8wI7roL3ZaT89ZbowP6yngIkw9NEwuPD VGwPcUbDeekLGtgjYyeD9/JjwrSXE3nbTKhFjd/NbM4E6UnVib9/z1B0WWlWQuCt17fe IUEHpp4qkd+SBxu5/IAiEeX4NDwCknJKsb1JpQgzfA05K7DjOC71jyD9Uxo/a5azKEQZ GZijhWNlDrZfv/7BaUCieSpCM3S+Q0ZeeyFxvx+VyDLBy6EwTMiM/rhq6CK30YeS6kxc CyFbAzO4DqRaeKOxwTgvDnNMmVxXwtNLrCDU2heaiOHhYM3qgxuxvX1nkqVnIIAUeLT5 7HEw== X-Forwarded-Encrypted: i=1; AJvYcCX2WYXTzNUXgg3cHZQLC/jlI2utK+PKl2nDCGvJtccbPt8BXBr9zJQFoscryPJNss4H2bNEwT34NAFWa8N4Xb+bu/gsdSao0mLSHYUX X-Gm-Message-State: AOJu0YwcL+5p/qrgGsiYgWKArj2MLKcw1ZnH/J4vpMWsYJKh48Lg0FTi oYFAV+TgUEhdHMWRrNFX72n5Nl5cqx1rRnU8b01RLHYw5e6UKKXO X-Google-Smtp-Source: AGHT+IFMHiHJqIdDweja6wmqeVlqkX7I7JoUo0BkwXd63EadpeKgm7Wtp2NuplKHiNmK6c/Pt20L0Q== X-Received: by 2002:a2e:800b:0:b0:2dc:d2c5:ed0 with SMTP id j11-20020a2e800b000000b002dcd2c50ed0mr7629467ljg.12.1715074573120; Tue, 07 May 2024 02:36:13 -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.36.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:12 -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 , linke li , Linus Torvalds Subject: [PATCH 41/48] rcutorture: Re-use value stored to ->rtort_pipe_count instead of re-reading Date: Tue, 7 May 2024 11:35:23 +0200 Message-Id: <20240507093530.3043-42-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: linke li Currently, the rcu_torture_pipe_update_one() writes the value (i + 1) to rp->rtort_pipe_count, then immediately re-reads it in order to compare it to RCU_TORTURE_PIPE_LEN. This re-read is pointless because no other update to rp->rtort_pipe_count can occur at this point. This commit therefore instead re-uses the (i + 1) value stored in the comparison instead of re-reading rp->rtort_pipe_count. Signed-off-by: linke li Reviewed-by: Joel Fernandes (Google) Signed-off-by: Paul E. McKenney Cc: Linus Torvalds Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 0cb5452ecd94..dd7d5ba45740 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -467,7 +467,7 @@ rcu_torture_pipe_update_one(struct rcu_torture *rp) atomic_inc(&rcu_torture_wcount[i]); WRITE_ONCE(rp->rtort_pipe_count, i + 1); ASSERT_EXCLUSIVE_WRITER(rp->rtort_pipe_count); - if (rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) { + if (i + 1 >= RCU_TORTURE_PIPE_LEN) { rp->rtort_mbtest = 0; return true; } From patchwork Tue May 7 09:35:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656529 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.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 CAFD815E5D3; Tue, 7 May 2024 09:36:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074577; cv=none; b=j1B6PgCWpkfKzjUD0dsWR5BU6vU709IdXKOG3Ccy5myPRXuTS8fswLy6XdTU58y87iO3fWEHq+XCQL2h4c6SBoVfEKxMl3HMu/LEw3UxeAmC7UYaTLywtFm+CWTjTAMEwVqpzeZKvOudfckQ4Hm6nuwA+9g+do9+6TVQWBLbHz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074577; c=relaxed/simple; bh=2Ovb4QazW6xz+ZnbPbv0Z7w0+7dCSRlGQn8IFZIJ2m4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=URdPXV/44zWDtMGa27YOlulG+P4lKBGdqOgdDPcKPkGHNpp5CdwNvIOHMa71/CTMj2O+mJFu6mn8iGo1o/BmooPZQiFuElwR8FAN3TJZId9wWlyheVCI7NaW+T0lF93FG9BnGrj6w9T6oL/hZXuwktJASaLwN+SHswfCtn3w1Cc= 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=bl8sOfUS; arc=none smtp.client-ip=209.85.208.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bl8sOfUS" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2e2c70f0c97so36453441fa.0; Tue, 07 May 2024 02:36:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074574; x=1715679374; 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=8Mu7OuPta/bPwR0Ew9sS9HB7xqXazraEBV86ZqklXS4=; b=bl8sOfUSRVaRWPQDPPXJGemF6bNrYoaxcDAnpcZpNjd3qubgf2JutEhJO5GkiBlU63 LVGMjc7kicDYXMmp3vpwq33kJrjiK02bMZmEPPkwF6SLzCF9x38eOpUse/TYhkdsVsj9 vOe2pJFtB5UrWTOiXL1hO93ycwqGp8OtKvWCNNBS9vOL8xaZmHOy8ljaFIWFoMQp4aMR Z1r/fEezdt/ZMiVnuqOBYH2q7pdCX2+EzZ1wZ+Hydvm3j4BNHQ4nuQrZz58uzgN8X5pE mG9Y7SuWFPT43GpzNq2zBNCyjQrAKfrf2j/8hqq/Dw3NRxabOGK4s8LAuoiSep6GQRgk pTIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074574; x=1715679374; 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=8Mu7OuPta/bPwR0Ew9sS9HB7xqXazraEBV86ZqklXS4=; b=d2PIYlMrDR4OxYcghb6ATRHuYp7YjyWFGR20NGMAJLTqi5o3WFlrbysmbtBIvOURR8 mtyQ66kB6wKP6UE7eVwj+xSVo+Ll4IkwGuXsvnAPwaLtXDqA/vRp9MzPGWO7hJTE+p4g 5JLs3i4dUs30RpRDkTd2F7UuAY6V57nd0Xbq6oiS9g9mDw6DtCehRmH6jyeQ/+ywLD8w 3NoyM0IliHOOSu5aFl0ruzwfaPxniDn3RegZkzXYQKuDqtuRHCb090OmjC6NkFx7LlIi m1Z/TvG8gQ7yLiPvfH4biNZptWgWfvUYDGaFutCJBOLhAJZqrCmIZb15LmFveMBs5ED5 ECNw== X-Forwarded-Encrypted: i=1; AJvYcCUDYL2X8R7vWyM5N6y+jqFBE00YW8gQtn++cuivUN7S5tvTx+p4/vsRVfSZcHf8+j7Z4BAcpzw88FImRykyhlZ6r1VSYrNayzOSTix9 X-Gm-Message-State: AOJu0YxQdVlDEazGMgOLCBzeE2QBhaXaweX/+hlvuNE2toDgGr9UN7AB oqxIVeCNl+LIwe1qmavZcbHrhYnigejyANy4eidHQCN83ND/Iwm1 X-Google-Smtp-Source: AGHT+IEP4HpLK+/xx6R5D2NqSB6q2z5OIZlj2Z3l4ywCZWpsP83riqqtHJpBHYV83ocXwDL+7Qifng== X-Received: by 2002:a2e:bc02:0:b0:2df:fa4a:ef15 with SMTP id b2-20020a2ebc02000000b002dffa4aef15mr10847723ljf.39.1715074573942; Tue, 07 May 2024 02:36:13 -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.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:13 -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 , Zqiang Subject: [PATCH 42/48] rcutorture: Use the gp_kthread_dbg operation specified by cur_ops Date: Tue, 7 May 2024 11:35:24 +0200 Message-Id: <20240507093530.3043-43-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Zqiang Despite there being a cur_ops->gp_kthread_dbg(), rcu_torture_writer() unconditionally invokes vanilla RCU's show_rcu_gp_kthreads(). This is not at all helpful when some other flavor of RCU is being tested. This commit therefore makes rcu_torture_writer() invoke cur_ops->gp_kthread_dbg() for RCU implementations providing this function. Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/rcutorture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index dd7d5ba45740..2f43d31fb7a5 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -1589,7 +1589,8 @@ rcu_torture_writer(void *arg) if (list_empty(&rcu_tortures[i].rtort_free) && rcu_access_pointer(rcu_torture_current) != &rcu_tortures[i]) { tracing_off(); - show_rcu_gp_kthreads(); + if (cur_ops->gp_kthread_dbg) + cur_ops->gp_kthread_dbg(); WARN(1, "%s: rtort_pipe_count: %d\n", __func__, rcu_tortures[i].rtort_pipe_count); rcu_ftrace_dump(DUMP_ALL); } From patchwork Tue May 7 09:35:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656530 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 B842D1649C2; Tue, 7 May 2024 09:36:16 +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=1715074579; cv=none; b=nZ+TJvh8eWYRvRR0BcwfDOSp10v5q9sfKdL8nfVZY824AFtFYlLUYSILG5go/GAPzgZUxUcYladF0yXcBHJ4arblMD+nmKLfF6eI7n8GCEzTHcsGuPoZo0uQRISUSm6UdpRFvhFBmEcrMVH4oz7FleTy/SvkuQosGqiHa0wweGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074579; c=relaxed/simple; bh=W6srazA8My9c3VJNvGbQUH5pt6lz0Yqm91b96E1iJC8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CXX+My/wJe4CwUTHvFasaQWdinaoooG92BGyGJUrbxny/9Gl9wTFT+v7MpjVJiv5vf41Zvv2uHgNrSV72A3wWzchhN1T3zH6BUGiGSeeDoqK/CbarQE80C3U4YXGNi14gayxInv2V1dsJKfzS9ONo6OMbMNTqWYTzJAmsQcDvjg= 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=NF1VS3y7; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NF1VS3y7" Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2e1d6166521so42223761fa.1; Tue, 07 May 2024 02:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074575; x=1715679375; 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=bDYWUjC6b4I7IdmUpsXl93lsJEyU12nmQdU8PFGVoCc=; b=NF1VS3y74I2yWSryeRbp9UTvN2fHopppZkainLRbjt1Ihm6q4zQgNM42tTaRM04w4n ma9vYK9js2xUL15EhIC5mPg4dPLK2vBv64iceD+h5a9jz4CmpJK7VibhB7/W9A0WGKZ9 LgBjyY8HPs4PE7HiaAQ+56buDTHmFi3QiIVXUDukjf1zRTXXTejJJEsuZ6It8lecxI0o x5SNkzs20MZNh1kd61geRkxNDfbnyEVJCOnSOt8e8k57FLV7y6LlBbrZrEWB11GGqDjF zqwyskSLGWsmneR16CZHl+tVmgojGNiuWW7vo/kBCqvLkL5PsW4PTPk3PfbulNTd5LPp 6mDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074575; x=1715679375; 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=bDYWUjC6b4I7IdmUpsXl93lsJEyU12nmQdU8PFGVoCc=; b=UlzN6rHJBkKcTWT+ExlWfc2iY4YAmZvsEC2GhFgwmBdBW0u/W9q8Hw8Uh/rgGWEHoh QPrlbNtI6Ps74oNffvFmS6HdH0ZPiGswfEAEXlx2rS0rrgeuSx5xlB0Y0aSu8dze8rJe jtBdyFo68aoSQMb+HKsLrnodwDeOSVY5jBcWTmlh0d1XUBnxxXJfkcP6N05Sn4P4USy3 Xor6PFiGwDlT1ng5O8pIa3QAeksQjy9TlycpJSb9aIsHsIlUYMEks58lFVDy8f+wWwdQ HHy2FCC3n9EFYGYpgDMwMd3ZI756m8+zS6wP7fRNHhHVIdOhz6EvnF3qsRfqLol+1zGG b7ww== X-Forwarded-Encrypted: i=1; AJvYcCWT/tvILQEDFkfAveyKIOzoWh62DgfQ+ZKZJyFLg1AcHe+/MaG3Ug2b3rQz3uIKjB/JzlDKNdguzVkuLHHLYPGLzHVAm+j1SybrD3LQ X-Gm-Message-State: AOJu0YxIaYKeW7+9M0PC0tceCc+FoeCXOAhhjJKYXv1u4KFrUMd9pzHe wwNacKPi0KsPk2tKboyBu4hZYtLm8Vkyr4ueccuCKJlvpKdy9Fcr X-Google-Smtp-Source: AGHT+IF5ANK6BXj2T316aF2QXq49wXZTyUybiVKnKcxza7ZVo3XWc+5D77IR8mAefAImTNYRFu4GKQ== X-Received: by 2002:a2e:9450:0:b0:2e2:88:1205 with SMTP id o16-20020a2e9450000000b002e200881205mr686973ljh.3.1715074574823; Tue, 07 May 2024 02:36:14 -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.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:14 -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 , Zqiang Subject: [PATCH 43/48] rcutorture: Make rcutorture support print rcu-tasks gp state Date: Tue, 7 May 2024 11:35:25 +0200 Message-Id: <20240507093530.3043-44-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Zqiang This commit make rcu-tasks related rcutorture test support rcu-tasks gp state printing when the writer stall occurs or the at the end of rcutorture test, and generate rcu_ops->get_gp_data() operation to simplify the acquisition of gp state for different types of rcutorture tests. Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/rcu.h | 20 ++++++++++---------- kernel/rcu/rcutorture.c | 26 ++++++++++++++++++-------- kernel/rcu/srcutree.c | 5 +---- kernel/rcu/tasks.h | 21 +++++++++++++++++++++ kernel/rcu/tree.c | 13 +++---------- 5 files changed, 53 insertions(+), 32 deletions(-) diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h index 86fce206560e..38238e595a61 100644 --- a/kernel/rcu/rcu.h +++ b/kernel/rcu/rcu.h @@ -522,12 +522,18 @@ static inline void show_rcu_tasks_gp_kthreads(void) {} #ifdef CONFIG_TASKS_RCU struct task_struct *get_rcu_tasks_gp_kthread(void); +void rcu_tasks_get_gp_data(int *flags, unsigned long *gp_seq); #endif // # ifdef CONFIG_TASKS_RCU #ifdef CONFIG_TASKS_RUDE_RCU struct task_struct *get_rcu_tasks_rude_gp_kthread(void); +void rcu_tasks_rude_get_gp_data(int *flags, unsigned long *gp_seq); #endif // # ifdef CONFIG_TASKS_RUDE_RCU +#ifdef CONFIG_TASKS_TRACE_RCU +void rcu_tasks_trace_get_gp_data(int *flags, unsigned long *gp_seq); +#endif + #ifdef CONFIG_TASKS_RCU_GENERIC void tasks_cblist_init_generic(void); #else /* #ifdef CONFIG_TASKS_RCU_GENERIC */ @@ -557,8 +563,7 @@ static inline void rcu_set_jiffies_lazy_flush(unsigned long j) { } #endif #if defined(CONFIG_TREE_RCU) -void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags, - unsigned long *gp_seq); +void rcutorture_get_gp_data(int *flags, unsigned long *gp_seq); void do_trace_rcu_torture_read(const char *rcutorturename, struct rcu_head *rhp, unsigned long secs, @@ -566,8 +571,7 @@ void do_trace_rcu_torture_read(const char *rcutorturename, unsigned long c); void rcu_gp_set_torture_wait(int duration); #else -static inline void rcutorture_get_gp_data(enum rcutorture_type test_type, - int *flags, unsigned long *gp_seq) +static inline void rcutorture_get_gp_data(int *flags, unsigned long *gp_seq) { *flags = 0; *gp_seq = 0; @@ -587,20 +591,16 @@ static inline void rcu_gp_set_torture_wait(int duration) { } #ifdef CONFIG_TINY_SRCU -static inline void srcutorture_get_gp_data(enum rcutorture_type test_type, - struct srcu_struct *sp, int *flags, +static inline void srcutorture_get_gp_data(struct srcu_struct *sp, int *flags, unsigned long *gp_seq) { - if (test_type != SRCU_FLAVOR) - return; *flags = 0; *gp_seq = sp->srcu_idx; } #elif defined(CONFIG_TREE_SRCU) -void srcutorture_get_gp_data(enum rcutorture_type test_type, - struct srcu_struct *sp, int *flags, +void srcutorture_get_gp_data(struct srcu_struct *sp, int *flags, unsigned long *gp_seq); #endif diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 2f43d31fb7a5..85ff8a32f75a 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -381,6 +381,7 @@ struct rcu_torture_ops { void (*gp_kthread_dbg)(void); bool (*check_boost_failed)(unsigned long gp_state, int *cpup); int (*stall_dur)(void); + void (*get_gp_data)(int *flags, unsigned long *gp_seq); long cbflood_max; int irq_capable; int can_boost; @@ -569,6 +570,7 @@ static struct rcu_torture_ops rcu_ops = { .gp_kthread_dbg = show_rcu_gp_kthreads, .check_boost_failed = rcu_check_boost_fail, .stall_dur = rcu_jiffies_till_stall_check, + .get_gp_data = rcutorture_get_gp_data, .irq_capable = 1, .can_boost = IS_ENABLED(CONFIG_RCU_BOOST), .extendables = RCUTORTURE_MAX_EXTEND, @@ -628,6 +630,11 @@ static struct srcu_struct srcu_ctld; static struct srcu_struct *srcu_ctlp = &srcu_ctl; static struct rcu_torture_ops srcud_ops; +static void srcu_get_gp_data(int *flags, unsigned long *gp_seq) +{ + srcutorture_get_gp_data(srcu_ctlp, flags, gp_seq); +} + static int srcu_torture_read_lock(void) { if (cur_ops == &srcud_ops) @@ -736,6 +743,7 @@ static struct rcu_torture_ops srcu_ops = { .call = srcu_torture_call, .cb_barrier = srcu_torture_barrier, .stats = srcu_torture_stats, + .get_gp_data = srcu_get_gp_data, .cbflood_max = 50000, .irq_capable = 1, .no_pi_lock = IS_ENABLED(CONFIG_TINY_SRCU), @@ -774,6 +782,7 @@ static struct rcu_torture_ops srcud_ops = { .call = srcu_torture_call, .cb_barrier = srcu_torture_barrier, .stats = srcu_torture_stats, + .get_gp_data = srcu_get_gp_data, .cbflood_max = 50000, .irq_capable = 1, .no_pi_lock = IS_ENABLED(CONFIG_TINY_SRCU), @@ -882,6 +891,7 @@ static struct rcu_torture_ops tasks_ops = { .call = call_rcu_tasks, .cb_barrier = rcu_barrier_tasks, .gp_kthread_dbg = show_rcu_tasks_classic_gp_kthread, + .get_gp_data = rcu_tasks_get_gp_data, .fqs = NULL, .stats = NULL, .irq_capable = 1, @@ -922,6 +932,7 @@ static struct rcu_torture_ops tasks_rude_ops = { .call = call_rcu_tasks_rude, .cb_barrier = rcu_barrier_tasks_rude, .gp_kthread_dbg = show_rcu_tasks_rude_gp_kthread, + .get_gp_data = rcu_tasks_rude_get_gp_data, .cbflood_max = 50000, .fqs = NULL, .stats = NULL, @@ -974,6 +985,7 @@ static struct rcu_torture_ops tasks_tracing_ops = { .call = call_rcu_tasks_trace, .cb_barrier = rcu_barrier_tasks_trace, .gp_kthread_dbg = show_rcu_tasks_trace_gp_kthread, + .get_gp_data = rcu_tasks_trace_get_gp_data, .cbflood_max = 50000, .fqs = NULL, .stats = NULL, @@ -2264,10 +2276,8 @@ rcu_torture_stats_print(void) int __maybe_unused flags = 0; unsigned long __maybe_unused gp_seq = 0; - rcutorture_get_gp_data(cur_ops->ttype, - &flags, &gp_seq); - srcutorture_get_gp_data(cur_ops->ttype, srcu_ctlp, - &flags, &gp_seq); + if (cur_ops->get_gp_data) + cur_ops->get_gp_data(&flags, &gp_seq); wtp = READ_ONCE(writer_task); pr_alert("??? Writer stall state %s(%d) g%lu f%#x ->state %#x cpu %d\n", rcu_torture_writer_state_getname(), @@ -3390,8 +3400,8 @@ rcu_torture_cleanup(void) fakewriter_tasks = NULL; } - rcutorture_get_gp_data(cur_ops->ttype, &flags, &gp_seq); - srcutorture_get_gp_data(cur_ops->ttype, srcu_ctlp, &flags, &gp_seq); + if (cur_ops->get_gp_data) + cur_ops->get_gp_data(&flags, &gp_seq); pr_alert("%s: End-test grace-period state: g%ld f%#x total-gps=%ld\n", cur_ops->name, (long)gp_seq, flags, rcutorture_seq_diff(gp_seq, start_gp_seq)); @@ -3762,8 +3772,8 @@ rcu_torture_init(void) nrealreaders = 1; } rcu_torture_print_module_parms(cur_ops, "Start of test"); - rcutorture_get_gp_data(cur_ops->ttype, &flags, &gp_seq); - srcutorture_get_gp_data(cur_ops->ttype, srcu_ctlp, &flags, &gp_seq); + if (cur_ops->get_gp_data) + cur_ops->get_gp_data(&flags, &gp_seq); start_gp_seq = gp_seq; pr_alert("%s: Start-test grace-period state: g%ld f%#x\n", cur_ops->name, (long)gp_seq, flags); diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index e4d673fc30f4..bc4b58b0204e 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -1826,12 +1826,9 @@ static void process_srcu(struct work_struct *work) srcu_reschedule(ssp, curdelay); } -void srcutorture_get_gp_data(enum rcutorture_type test_type, - struct srcu_struct *ssp, int *flags, +void srcutorture_get_gp_data(struct srcu_struct *ssp, int *flags, unsigned long *gp_seq) { - if (test_type != SRCU_FLAVOR) - return; *flags = 0; *gp_seq = rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq); } diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index 147b5945d67a..a1af7dadc0f7 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -1178,6 +1178,13 @@ struct task_struct *get_rcu_tasks_gp_kthread(void) } EXPORT_SYMBOL_GPL(get_rcu_tasks_gp_kthread); +void rcu_tasks_get_gp_data(int *flags, unsigned long *gp_seq) +{ + *flags = 0; + *gp_seq = rcu_seq_current(&rcu_tasks.tasks_gp_seq); +} +EXPORT_SYMBOL_GPL(rcu_tasks_get_gp_data); + /* * Protect against tasklist scan blind spot while the task is exiting and * may be removed from the tasklist. Do this by adding the task to yet @@ -1358,6 +1365,13 @@ struct task_struct *get_rcu_tasks_rude_gp_kthread(void) } EXPORT_SYMBOL_GPL(get_rcu_tasks_rude_gp_kthread); +void rcu_tasks_rude_get_gp_data(int *flags, unsigned long *gp_seq) +{ + *flags = 0; + *gp_seq = rcu_seq_current(&rcu_tasks_rude.tasks_gp_seq); +} +EXPORT_SYMBOL_GPL(rcu_tasks_rude_get_gp_data); + #endif /* #ifdef CONFIG_TASKS_RUDE_RCU */ //////////////////////////////////////////////////////////////////////// @@ -2010,6 +2024,13 @@ struct task_struct *get_rcu_tasks_trace_gp_kthread(void) } EXPORT_SYMBOL_GPL(get_rcu_tasks_trace_gp_kthread); +void rcu_tasks_trace_get_gp_data(int *flags, unsigned long *gp_seq) +{ + *flags = 0; + *gp_seq = rcu_seq_current(&rcu_tasks_trace.tasks_gp_seq); +} +EXPORT_SYMBOL_GPL(rcu_tasks_trace_get_gp_data); + #else /* #ifdef CONFIG_TASKS_TRACE_RCU */ static void exit_tasks_rcu_finish_trace(struct task_struct *t) { } #endif /* #else #ifdef CONFIG_TASKS_TRACE_RCU */ diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index d9642dd06c25..60e79ed73700 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -508,17 +508,10 @@ static struct rcu_node *rcu_get_root(void) /* * Send along grace-period-related data for rcutorture diagnostics. */ -void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags, - unsigned long *gp_seq) +void rcutorture_get_gp_data(int *flags, unsigned long *gp_seq) { - switch (test_type) { - case RCU_FLAVOR: - *flags = READ_ONCE(rcu_state.gp_flags); - *gp_seq = rcu_seq_current(&rcu_state.gp_seq); - break; - default: - break; - } + *flags = READ_ONCE(rcu_state.gp_flags); + *gp_seq = rcu_seq_current(&rcu_state.gp_seq); } EXPORT_SYMBOL_GPL(rcutorture_get_gp_data); From patchwork Tue May 7 09:35:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656539 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 873B3168AEB; Tue, 7 May 2024 09:36:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074579; cv=none; b=nFwteNHTlnuYxrcGCSGteIUtX1m6Iguftun5HHbGJKkL5JNzBf2y589rtVfCslFmPw0MCjoq4PnW+YBorOALa0t1YaAfsZ81m5uV8CzQgszWlESkOPEi1YxMNaJmHpiv7uQyw4BAcJDv690mpQUd3Foqou4wyaowOGGrI7CJeDU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074579; c=relaxed/simple; bh=oelWA1yUmfghM3lDepfzYUmSPKLaOwMcYDivNtABeLc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WAlcLwp0g27qypHqXoxyt5v3DTm6OaVTp3d92Ivys5cfnmQ9lvSSxtIV6wMx7gGNC1gs/lCUlCTf+1GJ5FfFFljbLzxU/kuAvcD0IwKGt8qLOS5lT4lKm58pcrVpZ2uSyJfSFX86fUqUacYTzGbnbsGmN8dmMBhNk44ttcrErhE= 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=Fhvw2Mu8; arc=none smtp.client-ip=209.85.208.175 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Fhvw2Mu8" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2e3e1ad0b19so8257971fa.0; Tue, 07 May 2024 02:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074576; x=1715679376; 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=Epu6iZvnUCozfcFQLTzyJDJ7BNw1imFQ/N79IeKES7w=; b=Fhvw2Mu8QTcCUwNyBXrGFve3VeJ2K3Q4mcRLMmkaw7UxaMu4qr4jNgro5iPBgcOaIV KQsq6NZF5X5BzEQp7xYHxYoHX+sHPuacmUr28gsRhQdutlZ/Dpc/TAC7ump0LTg/fyst dlNcILuOgWDVYBOBkbqAqJMCkcE6AvcbhHKEWw7WhNzAwLHa1BNiAgOWN4a4q4QLy/C9 NZDvipwptgZoc0om8IZw+k98qe5PI7ajQXn93iW/jfdgVkyCyclMdxDVi9HixgX3gden zwiKz6w9KTRM9Ki/ncZBa9EFadPAf4eXFK8SZOdXfoLJOjQNyhQ2oOezzZCPFQpv3Eeq BaNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074576; x=1715679376; 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=Epu6iZvnUCozfcFQLTzyJDJ7BNw1imFQ/N79IeKES7w=; b=IgwpeMZ1y9QTbNwMeiQeIRMkPA7RYV1wO9ORVV71qtsTJbiKa6+EFmSaTdRmeCVIV2 wKsz/vFU8L5MjzJR6vFO0tu/+c+5QHsH4/Sjrn8LcoulHDBciOZFBuAdtjHttwZPPfyN 7/ZTgaO6SwT4BYQEUFs1eQeMD86xCZI3/sbR4PTFz7rePCtTTsBEfP83tBEVHO7CuBPJ OUrDp77ajn7+Y5Sv8EwBYFlRoYAV9o6oBeuwVlT0fG71pnmnRHuNfBCclTqDTTexiDrC C+5waKX1e59LsWSPqCeAq+KjD//4Yw+sBMttN9hATvJPUT13+Y3ezvyxZOfKpp2fh71b FWmw== X-Forwarded-Encrypted: i=1; AJvYcCVBiWNP4yHFpWA2n9lFrMEqghP09cAwXJpjcE8aK3Fd/eI6RVDyPCm8Kq5vpdLu1Qm4Pdaguj/ylPXNKCWeMjn2MepgtoMINkhvXsI+ X-Gm-Message-State: AOJu0YzbFJsuq6QdTdi2mPEnIREkh94+mIkHr82jUm/O5O6a6QaT3T8e YDpRjlXt7syRtWQSdGFHVvlJaiQbggi8kwS/Q0xMi6a+3ERfSgAn X-Google-Smtp-Source: AGHT+IHDlh705pfvq4NGiRe19u8W45dtROF2rBhsHOfwyxGouaaLDWrAKOWVrr0T5sHNXGSNEqA3Hg== X-Received: by 2002:a2e:7204:0:b0:2df:7824:7d32 with SMTP id n4-20020a2e7204000000b002df78247d32mr8358817ljc.50.1715074575658; Tue, 07 May 2024 02:36:15 -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.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:15 -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 , Zqiang Subject: [PATCH 44/48] rcutorture: Removing redundant function pointer initialization Date: Tue, 7 May 2024 11:35:26 +0200 Message-Id: <20240507093530.3043-45-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Zqiang For these rcu_torture_ops structure's objects defined by using static, if the value of the function pointer in its member is not set, the default value will be NULL, this commit therefore remove the pre-existing initialization of function pointers to NULL. Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/rcutorture.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 85ff8a32f75a..3f9c3766f52b 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -566,7 +566,6 @@ static struct rcu_torture_ops rcu_ops = { .call = call_rcu_hurry, .cb_barrier = rcu_barrier, .fqs = rcu_force_quiescent_state, - .stats = NULL, .gp_kthread_dbg = show_rcu_gp_kthreads, .check_boost_failed = rcu_check_boost_fail, .stall_dur = rcu_jiffies_till_stall_check, @@ -614,9 +613,6 @@ static struct rcu_torture_ops rcu_busted_ops = { .sync = synchronize_rcu_busted, .exp_sync = synchronize_rcu_busted, .call = call_rcu_busted, - .cb_barrier = NULL, - .fqs = NULL, - .stats = NULL, .irq_capable = 1, .name = "busted" }; @@ -847,8 +843,6 @@ static struct rcu_torture_ops trivial_ops = { .get_gp_seq = rcu_no_completed, .sync = synchronize_rcu_trivial, .exp_sync = synchronize_rcu_trivial, - .fqs = NULL, - .stats = NULL, .irq_capable = 1, .name = "trivial" }; @@ -892,8 +886,6 @@ static struct rcu_torture_ops tasks_ops = { .cb_barrier = rcu_barrier_tasks, .gp_kthread_dbg = show_rcu_tasks_classic_gp_kthread, .get_gp_data = rcu_tasks_get_gp_data, - .fqs = NULL, - .stats = NULL, .irq_capable = 1, .slow_gps = 1, .name = "tasks" @@ -934,8 +926,6 @@ static struct rcu_torture_ops tasks_rude_ops = { .gp_kthread_dbg = show_rcu_tasks_rude_gp_kthread, .get_gp_data = rcu_tasks_rude_get_gp_data, .cbflood_max = 50000, - .fqs = NULL, - .stats = NULL, .irq_capable = 1, .name = "tasks-rude" }; @@ -987,8 +977,6 @@ static struct rcu_torture_ops tasks_tracing_ops = { .gp_kthread_dbg = show_rcu_tasks_trace_gp_kthread, .get_gp_data = rcu_tasks_trace_get_gp_data, .cbflood_max = 50000, - .fqs = NULL, - .stats = NULL, .irq_capable = 1, .slow_gps = 1, .name = "tasks-tracing" From patchwork Tue May 7 09:35:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656540 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 7B68216ABDE; Tue, 7 May 2024 09:36:18 +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=1715074580; cv=none; b=Vy8V1IY2L6j6aY6ZdIolxA8KMYzyo5/JNR0JTtfLMuwJ9AxlQDQZvLJ9uxbsgLhb4VpnvyOrIlWsRrW9THB8QSD76DzCtkRA61sJ2xWk5wR5GoVLeKjDJ0B3SATsPzT20SvQhQMfgW90Qa88aUz3rzJyUEyB8QVa5kDTCBK40rM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074580; c=relaxed/simple; bh=o8QNqUWMDKmYcupNV+ex08qslA455LJ6fBNThqJ+gjo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kUfmlVe4qMPqT/Vt/EaDNRqw4NND8KFw9s0XiImpCvFVBRNfOeSirk1o+1ZKnULMM79q9kGLKy4x15TbbJuKVTcZfDcjtggMxUbNeJLUWZ2X444V9ACYvu0gi2ykKrXL69mdlo6AuoN8IBPdhbxJdSgTMCEOa0IqLnI1dMTe3kU= 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=lcHzRh6c; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lcHzRh6c" Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2e34e85ebf4so16684711fa.2; Tue, 07 May 2024 02:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074576; x=1715679376; 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=4giIpQovPJ+xyAcNjMeRcsmVa+ZmTidW6qcBvozTz1s=; b=lcHzRh6cXbmo0+iVSqIlwKMJUWA+Q7mnLNR3/wZEsRvMcLk32sdlM0AJ7vQW8zuJpX xLr2Lxl0SGW6ClhDkSwFanVzXsMzN62hqFK6pIg44YiMVEKMPRmPpoQKamFN3b2m1kUa noy9rmSlMG7dmGPT+eitnP4YbSC3Su9u9vOUYe0JPeFXJ/ASJ38oNilJLmXIKarLYbb1 EWft7g5ZkAtchljdcJe+9CMopMn/A4zvcjE3Fq6kj3ngM3mk7Dh//Oy04D6qj4ajl5Pc yFsk4C2n71rC4RofZcvorxBO4Ho+DTDh+RgY3y2ns89oU6NT3N1FjBmM1ZAuwZxBpA/d hOXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074576; x=1715679376; 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=4giIpQovPJ+xyAcNjMeRcsmVa+ZmTidW6qcBvozTz1s=; b=IDPTZvV+uBcUyrC/43Br5CjfH7sD3Vbr25BJZxdR1cRW337WTUioO0Z9GSWYzffinQ tVs5rrWevz3PrU0+4OoK49cZq2Hh5L4qXANyD2cNb39CGrQio1pwSpR/fPbdQX/4Tmy+ GqRmnrj2L5kZZ8pE+VmtNzALiD6fshZ6HPLNjhR7802Xmk3SWSrV0FhanDnrtHhEY9wm PotzFJzzfD8DYBTE21m/NbE5odDDi34Trd1zHsxoEYQiGO3YLcn7lq2aQ1tcQrMOnuol PBKF4GDxRmO5H69MpHMAcBI6koJTMwi3WcD8y3FU6b4r/gxC46wP2PM/eiCVUwAVYHbP 9tXA== X-Forwarded-Encrypted: i=1; AJvYcCW2NEbSEWKUuruVJZyKTaTI6nm1nEdOWT7lZPGtmExcCb9efUro57CuxUwXSAYMfYGJoP2PVqFPmI5wRJBenxtMTVHVNcb5gVg6rz3y X-Gm-Message-State: AOJu0YznvVPJg4xp1O1jxaqWHtLBCI+aj684uGWP0F9aBo6Qt04JbdQS QzjBAMA8yCMRX044iJ03MuE5jjC0a9USxnJefxIo7a+CLi9JbX6W X-Google-Smtp-Source: AGHT+IEdlgPKASMcAXsb/+V3a2DOzgPncU0m0YsG/SFNTfc0/QFiE1TnVpkcvSZUdWq5OXpIRGNrsA== X-Received: by 2002:a2e:9ccd:0:b0:2e2:466b:1a68 with SMTP id g13-20020a2e9ccd000000b002e2466b1a68mr6610640ljj.41.1715074576562; Tue, 07 May 2024 02:36:16 -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.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:16 -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 , Zqiang Subject: [PATCH 45/48] rcutorture: Make stall-tasks directly exit when rcutorture tests end Date: Tue, 7 May 2024 11:35:27 +0200 Message-Id: <20240507093530.3043-46-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Zqiang When the rcutorture tests start to exit, the rcu_torture_cleanup() is invoked to stop kthreads and release resources, if the stall-task kthreads exist, cpu-stall has started and the rcutorture.stall_cpu is set to a larger value, the rcu_torture_cleanup() will be blocked for a long time and the hung-task may occur, this commit therefore add kthread_should_stop() to the loop of cpu-stall operation, when rcutorture tests ends, no need to wait for cpu-stall to end, exit directly. Use the following command to test: insmod rcutorture.ko torture_type=srcu fwd_progress=0 stat_interval=4 stall_cpu_block=1 stall_cpu=200 stall_cpu_holdoff=10 read_exit_burst=0 object_debug=1 rmmod rcutorture [15361.918610] INFO: task rmmod:878 blocked for more than 122 seconds. [15361.918613] Tainted: G W 6.8.0-rc2-yoctodev-standard+ #25 [15361.918615] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [15361.918616] task:rmmod state:D stack:0 pid:878 tgid:878 ppid:773 flags:0x00004002 [15361.918621] Call Trace: [15361.918623] [15361.918626] __schedule+0xc0d/0x28f0 [15361.918631] ? __pfx___schedule+0x10/0x10 [15361.918635] ? rcu_is_watching+0x19/0xb0 [15361.918638] ? schedule+0x1f6/0x290 [15361.918642] ? __pfx_lock_release+0x10/0x10 [15361.918645] ? schedule+0xc9/0x290 [15361.918648] ? schedule+0xc9/0x290 [15361.918653] ? trace_preempt_off+0x54/0x100 [15361.918657] ? schedule+0xc9/0x290 [15361.918661] schedule+0xd0/0x290 [15361.918665] schedule_timeout+0x56d/0x7d0 [15361.918669] ? debug_smp_processor_id+0x1b/0x30 [15361.918672] ? rcu_is_watching+0x19/0xb0 [15361.918676] ? __pfx_schedule_timeout+0x10/0x10 [15361.918679] ? debug_smp_processor_id+0x1b/0x30 [15361.918683] ? rcu_is_watching+0x19/0xb0 [15361.918686] ? wait_for_completion+0x179/0x4c0 [15361.918690] ? __pfx_lock_release+0x10/0x10 [15361.918693] ? __kasan_check_write+0x18/0x20 [15361.918696] ? wait_for_completion+0x9d/0x4c0 [15361.918700] ? _raw_spin_unlock_irq+0x36/0x50 [15361.918703] ? wait_for_completion+0x179/0x4c0 [15361.918707] ? _raw_spin_unlock_irq+0x36/0x50 [15361.918710] ? wait_for_completion+0x179/0x4c0 [15361.918714] ? trace_preempt_on+0x54/0x100 [15361.918718] ? wait_for_completion+0x179/0x4c0 [15361.918723] wait_for_completion+0x181/0x4c0 [15361.918728] ? __pfx_wait_for_completion+0x10/0x10 [15361.918738] kthread_stop+0x152/0x470 [15361.918742] _torture_stop_kthread+0x44/0xc0 [torture 7af7f9cbba28271a10503b653f9e05d518fbc8c3] [15361.918752] rcu_torture_cleanup+0x2ac/0xe90 [rcutorture f2cb1f556ee7956270927183c4c2c7749a336529] [15361.918766] ? __pfx_rcu_torture_cleanup+0x10/0x10 [rcutorture f2cb1f556ee7956270927183c4c2c7749a336529] [15361.918777] ? __kasan_check_write+0x18/0x20 [15361.918781] ? __mutex_unlock_slowpath+0x17c/0x670 [15361.918789] ? __might_fault+0xcd/0x180 [15361.918793] ? find_module_all+0x104/0x1d0 [15361.918799] __x64_sys_delete_module+0x2a4/0x3f0 [15361.918803] ? __pfx___x64_sys_delete_module+0x10/0x10 [15361.918807] ? syscall_exit_to_user_mode+0x149/0x280 Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/rcutorture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 3f9c3766f52b..456185d9e6c0 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2489,8 +2489,8 @@ static int rcu_torture_stall(void *args) preempt_disable(); pr_alert("%s start on CPU %d.\n", __func__, raw_smp_processor_id()); - while (ULONG_CMP_LT((unsigned long)ktime_get_seconds(), - stop_at)) + while (ULONG_CMP_LT((unsigned long)ktime_get_seconds(), stop_at) && + !kthread_should_stop()) if (stall_cpu_block) { #ifdef CONFIG_PREEMPTION preempt_schedule(); From patchwork Tue May 7 09:35:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656541 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 44FDE165FB2; Tue, 7 May 2024 09:36:19 +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=1715074581; cv=none; b=GDNByb9PptH07gWtCPKHEmBNulxUc+yFnxIU1jyMwsLik4JBL/SX4clzhT2l/k8gip4dsXWfnYQaeJ5Jovc/L98mmnGMOifRcaW4eb0gDjwEy5+RLklB69X0+Zeu7w6sn9SM8TeznAxLITguv0FSVpDQ9SQAnC2ck6iNcfg583k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074581; c=relaxed/simple; bh=3CB9bqogXmxT3xgnGjFG4YsM0X24b664O2CNVeLO1Vs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iz7GrUAxgOQP0Rb+Fy19dk4Y/ALBf9RgSrokjNJjDHFxwpZRgqYbgjDC9cxpOclQT42lYGgbrcC1ilxKu/Lh5k89HQ3rP06ZCX49rpWmtUVTxXsaZIZOhWTKUg3UoHlcL8gyqydR42IHzWbmbXiBVRVlFyqXfLs/GeK/ZkPd9oE= 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=Y/KHWKVq; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y/KHWKVq" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2e242b1df60so34989161fa.1; Tue, 07 May 2024 02:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074577; x=1715679377; 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=YSbSW28iEU5SGTrhgUEkX06lcEl9tav85cbSpYw4LcU=; b=Y/KHWKVqXDtgQ8eokJZYvKKs90aTM0koAOjS/6npABuGJcjaiLw1grBSnFfWSCR4vQ V2I6TMNaHZigzBzuGTMdHyiUttNAsIYx0cVFyXQmnBNHNzsVv6gXyYZExFxiUJKcT+g9 EvDn0GuHH4d5HzN4PyyGqr+6vdjo7JjoASrb3CBzBE01p3H2UtDDMEnEVyTJTlbK7KRr izSus8U+8Y2HUv+H1eTuWIDJZvyZUTRQGEsUqBAflGxR/6W/F5mZGrLfjIcNLjpBi+AL U488IYOf3lN9lZ95gzT6qc/+p9AU5zYbynA+eHqXg1U5+dfHcCQVSScBG0fCUQoEXadM xyUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074577; x=1715679377; 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=YSbSW28iEU5SGTrhgUEkX06lcEl9tav85cbSpYw4LcU=; b=t0eJvO4jey3HnI6X1poWnQqMP/w85gbaTsdKx8pygTjtRJRSzrSCIaT/9JOT1aWwo1 /WuJbHV36zQYQTtIV9BqzkwbTnxnWq3sKPYHRu2vi9vEerg8AYbnSi0sRWkHYuydBFgm R/4qhUNWOBGR+9sEcvJST/WNfJlu7sk7ekIN3x/bsjcxXpzbRXvyHXCSgi+bvDK1OIxW v4YVeqFKHdcglBBg12VKUA1akXVIRTFxNr0f4Fx8YbjXVi5RF+/mBjiCpYZkLxMavYGA QQBtz1KL5aahiid7fuhYeZCSH5OkI3DP0IO5wd5I4E7pJ07A5gk1+Ztn1CUrGtMNbvLy xgbQ== X-Forwarded-Encrypted: i=1; AJvYcCWBEcbCxP26L35/aC/KyyJbK5vt41bwFYji0I6kqpwjy1WuYcuesSxBbrmxXoDZppaMjzTd9WR6JZpKa/B2Eq2NfT99lYcsoB4Cz+iZ X-Gm-Message-State: AOJu0YyzVPqQ6vKAIpPF75JfuSRNHW7KsU6WcVtWxKRlFWiWScWO+9LM cfTsRP5IFRFbahTk/KSjxKR9njS7LjtT+Sqj47swcABq44EKUtUS X-Google-Smtp-Source: AGHT+IFxu5RfY4AEiX+Eze/I9NGzwR7AEcv/jV/cGqqNCDGTMRqjo2Fo5+9CvJ/Mh2mLwjNS58vTaQ== X-Received: by 2002:a2e:b0f4:0:b0:2d8:5b4e:bddb with SMTP id h20-20020a2eb0f4000000b002d85b4ebddbmr10957170ljl.52.1715074577428; Tue, 07 May 2024 02:36:17 -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.36.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:17 -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 , Zqiang Subject: [PATCH 46/48] rcutorture: Fix invalid context warning when enable srcu barrier testing Date: Tue, 7 May 2024 11:35:28 +0200 Message-Id: <20240507093530.3043-47-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Zqiang When the torture_type is set srcu or srcud and cb_barrier is non-zero, running the rcutorture test will trigger the following warning: [ 163.910989][ C1] BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48 [ 163.910994][ C1] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/1 [ 163.910999][ C1] preempt_count: 10001, expected: 0 [ 163.911002][ C1] RCU nest depth: 0, expected: 0 [ 163.911005][ C1] INFO: lockdep is turned off. [ 163.911007][ C1] irq event stamp: 30964 [ 163.911010][ C1] hardirqs last enabled at (30963): [] do_idle+0x362/0x500 [ 163.911018][ C1] hardirqs last disabled at (30964): [] sysvec_call_function_single+0xf/0xd0 [ 163.911025][ C1] softirqs last enabled at (0): [] copy_process+0x16ff/0x6580 [ 163.911033][ C1] softirqs last disabled at (0): [<0000000000000000>] 0x0 [ 163.911038][ C1] Preemption disabled at: [ 163.911039][ C1] [] stack_depot_save_flags+0x24b/0x6c0 [ 163.911063][ C1] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G W 6.8.0-rc4-rt4-yocto-preempt-rt+ #3 1e39aa9a737dd024a3275c4f835a872f673a7d3a [ 163.911071][ C1] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org 04/01/2014 [ 163.911075][ C1] Call Trace: [ 163.911078][ C1] [ 163.911080][ C1] dump_stack_lvl+0x88/0xd0 [ 163.911089][ C1] dump_stack+0x10/0x20 [ 163.911095][ C1] __might_resched+0x36f/0x530 [ 163.911105][ C1] rt_spin_lock+0x82/0x1c0 [ 163.911112][ C1] spin_lock_irqsave_ssp_contention+0xb8/0x100 [ 163.911121][ C1] srcu_gp_start_if_needed+0x782/0xf00 [ 163.911128][ C1] ? _raw_spin_unlock_irqrestore+0x46/0x70 [ 163.911136][ C1] ? debug_object_active_state+0x336/0x470 [ 163.911148][ C1] ? __pfx_srcu_gp_start_if_needed+0x10/0x10 [ 163.911156][ C1] ? __pfx_lock_release+0x10/0x10 [ 163.911165][ C1] ? __pfx_rcu_torture_barrier_cbf+0x10/0x10 [ 163.911188][ C1] __call_srcu+0x9f/0xe0 [ 163.911196][ C1] call_srcu+0x13/0x20 [ 163.911201][ C1] srcu_torture_call+0x1b/0x30 [ 163.911224][ C1] rcu_torture_barrier1cb+0x4a/0x60 [ 163.911247][ C1] __flush_smp_call_function_queue+0x267/0xca0 [ 163.911256][ C1] ? __pfx_rcu_torture_barrier1cb+0x10/0x10 [ 163.911281][ C1] generic_smp_call_function_single_interrupt+0x13/0x20 [ 163.911288][ C1] __sysvec_call_function_single+0x7d/0x280 [ 163.911295][ C1] sysvec_call_function_single+0x93/0xd0 [ 163.911302][ C1] [ 163.911304][ C1] [ 163.911308][ C1] asm_sysvec_call_function_single+0x1b/0x20 [ 163.911313][ C1] RIP: 0010:default_idle+0x17/0x20 [ 163.911326][ C1] RSP: 0018:ffff888001997dc8 EFLAGS: 00000246 [ 163.911333][ C1] RAX: 0000000000000000 RBX: dffffc0000000000 RCX: ffffffffae618b51 [ 163.911337][ C1] RDX: 0000000000000000 RSI: ffffffffaea80920 RDI: ffffffffaec2de80 [ 163.911342][ C1] RBP: ffff888001997dc8 R08: 0000000000000001 R09: ffffed100d740cad [ 163.911346][ C1] R10: ffffed100d740cac R11: ffff88806ba06563 R12: 0000000000000001 [ 163.911350][ C1] R13: ffffffffafe460c0 R14: ffffffffafe460c0 R15: 0000000000000000 [ 163.911358][ C1] ? ct_kernel_exit.constprop.3+0x121/0x160 [ 163.911369][ C1] ? lockdep_hardirqs_on+0xc4/0x150 [ 163.911376][ C1] arch_cpu_idle+0x9/0x10 [ 163.911383][ C1] default_idle_call+0x7a/0xb0 [ 163.911390][ C1] do_idle+0x362/0x500 [ 163.911398][ C1] ? __pfx_do_idle+0x10/0x10 [ 163.911404][ C1] ? complete_with_flags+0x8b/0xb0 [ 163.911416][ C1] cpu_startup_entry+0x58/0x70 [ 163.911423][ C1] start_secondary+0x221/0x280 [ 163.911430][ C1] ? __pfx_start_secondary+0x10/0x10 [ 163.911440][ C1] secondary_startup_64_no_verify+0x17f/0x18b [ 163.911455][ C1] This commit therefore use smp_call_on_cpu() instead of smp_call_function_single(), make rcu_torture_barrier1cb() invoked happens on task-context. Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/rcutorture.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 456185d9e6c0..8654e99bd4a3 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -3044,11 +3044,12 @@ static void rcu_torture_barrier_cbf(struct rcu_head *rcu) } /* IPI handler to get callback posted on desired CPU, if online. */ -static void rcu_torture_barrier1cb(void *rcu_void) +static int rcu_torture_barrier1cb(void *rcu_void) { struct rcu_head *rhp = rcu_void; cur_ops->call(rhp, rcu_torture_barrier_cbf); + return 0; } /* kthread function to register callbacks used to test RCU barriers. */ @@ -3074,11 +3075,9 @@ static int rcu_torture_barrier_cbs(void *arg) * The above smp_load_acquire() ensures barrier_phase load * is ordered before the following ->call(). */ - if (smp_call_function_single(myid, rcu_torture_barrier1cb, - &rcu, 1)) { - // IPI failed, so use direct call from current CPU. + if (smp_call_on_cpu(myid, rcu_torture_barrier1cb, &rcu, 1)) cur_ops->call(&rcu, rcu_torture_barrier_cbf); - } + if (atomic_dec_and_test(&barrier_cbs_count)) wake_up(&barrier_wq); } while (!torture_must_stop()); From patchwork Tue May 7 09:35:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656542 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 06CF716C696; Tue, 7 May 2024 09:36:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074581; cv=none; b=Z2AxuGS+IMj51RoU5MlDs7AJ24OiAtTB20VoggumcJhYBv1BQy9qsd0G0y9v2sirTiX8uFAcvMfi0ANZp3jnJKyVHHBDSwkS+nZNwcktNUoULaTMOCu6pZ84p+wMDb1nyVp7U8Y3ifnuq5JxZGCPDodrPR4QD8SWrI9RI4YMzoQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074581; c=relaxed/simple; bh=rm1RFxxDNWACtis5oePDLvdLL18Pj6+dDkJjOP/K3Pg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G94eqItcStxe9eN1LGGZLLC9byh0odh88r4rZuyfjYqES4m2Ju6805jJv3xuW/0AgzBSzxpQsYmKbyrb6bb6nbC++SJpO4gAvQXZLUtfEl9ldI6DX4Jk38tEBrZZfw0prTDnSAYbSoF0Nlba/e0RIIvaPTMLt0evBuxTV4zAjCA= 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=gXnyLpmG; arc=none smtp.client-ip=209.85.208.173 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gXnyLpmG" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2e242b1df60so34989361fa.1; Tue, 07 May 2024 02:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074578; x=1715679378; 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=PJIpU92r3nQAC/o5YT3DHRkgaet/v1o2kkX+oJHCr8c=; b=gXnyLpmGuGuLvwzYxnC9ZAgc4TaLCsKcwpLV5+aDbTmJ1W8q7h8tkCwmYKqdkfELDl n6B0hCP2HilFyKmjeB0TXc7SNzIRoIkh9bvzDPSxkBlVlBcxRvq2XmRuUQzlN/SlHxFD gYknTO+u7UNeTTAGtGIZ3sQCM4qzD294C8R8Lm5SQYHpqdgrMAGuQlGGAnBva2f7rLY+ A7o1EqZl3MYxYUyE4LYwW8k2V5RovFUZHA2EOjde68m0+MYzP/Rlv7OY39n57U/UXUmb W3YrYlVZj/W6ddLfeT+YcL2SK5pANXxIUIxkrfpMCJ32Ei0F4I5ajTic5NE/c4BtkjY5 dovw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074578; x=1715679378; 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=PJIpU92r3nQAC/o5YT3DHRkgaet/v1o2kkX+oJHCr8c=; b=HnUPUArBtIHMY/TiZD/ujB4s1KuVISp8DpJl5+21zM6dAYmA6af9LJKxUrotmFU80T NtrC0p/uqDWpc0KExOX7/7NtIRT87DEdCPfHvfKHKTVw5skJmE9XWbGiXjYYuyZQF79/ IJ3Um5+FyNRb0rExwCrk4xrrW0ChvoCullre2vNh5hYHNPnbsD7pHemPmbgiGpQ2gn2y ZChlTPTGEOQixLkqYbANov7OgXVD1sH6p+OLIZVhCTQSVLms/iWxpEtQcF1dDsoOrNpu pIaDNCjiOH5qNlhvZLX9jyOa0DrDgKcZLtiWYsAyhC4rPSrEVO6kqnMjc0xZh1O+k7Er qBSA== X-Forwarded-Encrypted: i=1; AJvYcCXcWM/9LhdrKrBt6rh6kbViNa1f+gekegFPdwVh9ZB5BTRx3hre0fibaMq8O+YyM5Atp+j+JFWCbLbi9QHT48jfm4xn3xhUOj+mB99m X-Gm-Message-State: AOJu0YzgaWhxbUzUksvrSljZQoZtCjqDU+CdF4FeZrivP7yfipzwTsxm WuY3UkmH5VpnJ8eM43Q7Y1rmmdtrpkCdFTnZixgQIPP+K823M01tAFkhuv15 X-Google-Smtp-Source: AGHT+IHEbQsnWb0EuVgdTwT+nhbFYd3OItlWoYXy8CGwEd+dwb48l/BzcwfCqOvHhFdpCH4sGMNoYQ== X-Received: by 2002:a2e:9214:0:b0:2e0:e7a5:7209 with SMTP id k20-20020a2e9214000000b002e0e7a57209mr9547478ljg.26.1715074578247; Tue, 07 May 2024 02:36:18 -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.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:17 -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 Subject: [PATCH 47/48] torture: Scale --do-kvfree test time Date: Tue, 7 May 2024 11:35:29 +0200 Message-Id: <20240507093530.3043-48-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Currently, the torture.sh --do-kvfree testing is hard-coded to ten minutes, ignoring the --duration argument. This commit therefore scales this test duration the same as for the rcutorture tests. Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- tools/testing/selftests/rcutorture/bin/torture.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/testing/selftests/rcutorture/bin/torture.sh index 13875ee7b050..990d24696fd3 100755 --- a/tools/testing/selftests/rcutorture/bin/torture.sh +++ b/tools/testing/selftests/rcutorture/bin/torture.sh @@ -559,7 +559,7 @@ do_kcsan="$do_kcsan_save" if test "$do_kvfree" = "yes" then torture_bootargs="rcuscale.kfree_rcu_test=1 rcuscale.kfree_nthreads=16 rcuscale.holdoff=20 rcuscale.kfree_loops=10000 torture.disable_onoff_at_boot" - torture_set "rcuscale-kvfree" tools/testing/selftests/rcutorture/bin/kvm.sh --torture rcuscale --allcpus --duration 10 --kconfig "CONFIG_NR_CPUS=$HALF_ALLOTED_CPUS" --memory 2G --trust-make + torture_set "rcuscale-kvfree" tools/testing/selftests/rcutorture/bin/kvm.sh --torture rcuscale --allcpus --duration $duration_rcutorture --kconfig "CONFIG_NR_CPUS=$HALF_ALLOTED_CPUS" --memory 2G --trust-make fi if test "$do_clocksourcewd" = "yes" From patchwork Tue May 7 09:35:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13656543 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 0F15D16C845; Tue, 7 May 2024 09:36:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074582; cv=none; b=H96gLqaPQA96g19Z9XOmeGs+TpNsPHnpOZpwxr9+wJiuYGwgRyPLyuEMBFxjRJFnwMyzolFgSSIOom25Jm8GNjzB1+XYfGs0fdbHf7A8FRkEp6+0I+o/wOMy8fx4YKrmJORJHF0dUA0giqmi6oJVMdYvPGiASkdbEirWOOgacuM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715074582; c=relaxed/simple; bh=9oDpi+Fem3Cos/zr4jTtNfAvBbEDM16i8DVTJbcW2hI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UcXDcFuZjb4LlaOu5t7BAdfi+Nil6+1h/qPPQ4F6S3T2Lh5TOKsv9adxmYjSuehRKyJ1QUD/4wOGoEs1+1TG2rMsdt2fugD9J5nNBtt9IJ3otLR6Q8tWNHjpowpqrV601GYGgHLUzIUa8wX9PcNLPn02ZI7WXgfiUhxpHKe9VLQ= 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=DfOVQ2sh; arc=none smtp.client-ip=209.85.208.169 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DfOVQ2sh" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2e30c625178so25907111fa.1; Tue, 07 May 2024 02:36:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715074579; x=1715679379; 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=jpnem8fG8lmGj5qC7Q/yc7iEgYHNFLn5w8ZfsCfYrbA=; b=DfOVQ2shsKkWi9DxW1gvp3QKE6lj01hDprItFuu78PLVjyrthL/Bb3CfTPtM/gaXnn aD5Yb2nSpNt9EocvMZ9UA8V50e/H1pnE8gOjDixsfC69M95KNXwLLir3b0VDiCWqd5xh /y/sQ+xfve9AaGrYNVz+JMAWJRo/GHvWYbRjvuCgkc0IPrc5Q3hDEkUSECB2x2x+nvHe 7uIcfK4S7GFKvAhmga1C/9J50MwoRK7cuOYYZCN4NBs4PZSXV5B0jDaIwTFgxsPmfypX DSEGob8Hbuy8as3urM7VaFZxdeKDA23XEnVI3F9xhrkzqzJPHU9U7kuVaCBagHoVOZaj EL3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715074579; x=1715679379; 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=jpnem8fG8lmGj5qC7Q/yc7iEgYHNFLn5w8ZfsCfYrbA=; b=dfxrxXv7QoZZ/cMmnRO3YszdLuUHft5415EsBdqmlnGgcEOFFSzfGrRRTSpwTfSt1Z /X/4eJuiR4hK7Ae+9iXS04D6znpKmtDZYoiGG/oRtq9esFgeX9RuhhdwQGi0kTvWz7ZH 1njNns4VZFUBVyuCwI+BpgBcRBY9bJRcrYlMsV/aVE7f+9jOdOXV2Sy6+Fki0cqIkMhS P+GHGeKtEpoR8whWhsOUFNWdahOFX77NY/uQPeGb/kcOaM+yWmhNvH56SBQ+7SCrq4XW o2V5HPmooSAycqx0uLh/5JNJv4LLXjjgz0u02VfR8mwh0IiOSLlJwbMUSELFQ/pqAAdg 2yLg== X-Forwarded-Encrypted: i=1; AJvYcCWXNKDpkw3XD1FRQVHIqvfcNFbZJC5N5FjUj6qvA2C6wAXtD+epXHNs4ighQbeUzTTzU8V1LF1/6xfGdnmQaivtUt4iKMNlt6IMtbUT X-Gm-Message-State: AOJu0Yy4D0adqntnR9G2iqWDVtYPASrn1F31enVostIT+y68ojLETt1P asKiE2G1WqCiVM6PRK+FxYdTI+gkPIyH6y3Wofq9qvz1YGIj/SMw X-Google-Smtp-Source: AGHT+IFxFDhj+lL2nzeOJOW9nLi0WbJqK1ZevxlqT1AqLU0U8bAmZbYThOh/2rGOyiHKLN9VnuOH4Q== X-Received: by 2002:a2e:9006:0:b0:2dc:b964:b15 with SMTP id h6-20020a2e9006000000b002dcb9640b15mr7563411ljg.25.1715074579178; Tue, 07 May 2024 02:36:19 -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.36.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:36:18 -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 , Zqiang Subject: [PATCH 48/48] rcutorture: Use rcu_gp_slow_register/unregister() only for rcutype test Date: Tue, 7 May 2024 11:35:30 +0200 Message-Id: <20240507093530.3043-49-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: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Zqiang The rcu_gp_slow_register/unregister() is only useful in tests where torture_type=rcu, so this commit therefore generates ->gp_slow_register() and ->gp_slow_unregister() function pointers in the rcu_torture_ops structure, and slows grace periods only when these function pointers exist. Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/rcutorture.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 8654e99bd4a3..807fbf6123a7 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -382,6 +382,8 @@ struct rcu_torture_ops { bool (*check_boost_failed)(unsigned long gp_state, int *cpup); int (*stall_dur)(void); void (*get_gp_data)(int *flags, unsigned long *gp_seq); + void (*gp_slow_register)(atomic_t *rgssp); + void (*gp_slow_unregister)(atomic_t *rgssp); long cbflood_max; int irq_capable; int can_boost; @@ -570,6 +572,8 @@ static struct rcu_torture_ops rcu_ops = { .check_boost_failed = rcu_check_boost_fail, .stall_dur = rcu_jiffies_till_stall_check, .get_gp_data = rcutorture_get_gp_data, + .gp_slow_register = rcu_gp_slow_register, + .gp_slow_unregister = rcu_gp_slow_unregister, .irq_capable = 1, .can_boost = IS_ENABLED(CONFIG_RCU_BOOST), .extendables = RCUTORTURE_MAX_EXTEND, @@ -3343,12 +3347,12 @@ rcu_torture_cleanup(void) pr_info("%s: Invoking %pS().\n", __func__, cur_ops->cb_barrier); cur_ops->cb_barrier(); } - rcu_gp_slow_unregister(NULL); + if (cur_ops->gp_slow_unregister) + cur_ops->gp_slow_unregister(NULL); return; } if (!cur_ops) { torture_cleanup_end(); - rcu_gp_slow_unregister(NULL); return; } @@ -3447,7 +3451,8 @@ rcu_torture_cleanup(void) else rcu_torture_print_module_parms(cur_ops, "End of test: SUCCESS"); torture_cleanup_end(); - rcu_gp_slow_unregister(&rcu_fwd_cb_nodelay); + if (cur_ops->gp_slow_unregister) + cur_ops->gp_slow_unregister(NULL); } #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD @@ -3929,7 +3934,8 @@ rcu_torture_init(void) if (object_debug) rcu_test_debug_objects(); torture_init_end(); - rcu_gp_slow_register(&rcu_fwd_cb_nodelay); + if (cur_ops->gp_slow_register && !WARN_ON_ONCE(!cur_ops->gp_slow_unregister)) + cur_ops->gp_slow_register(&rcu_fwd_cb_nodelay); return 0; unwind: