From patchwork Fri Aug 16 06:13:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj Upadhyay X-Patchwork-Id: 13765473 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8FB57E76F; Fri, 16 Aug 2024 06:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723788836; cv=none; b=hFfkIAKrlbJ/QrhgxEwVvnziq2tt8d7+5ffXloQp1w4ZRee2ie1sMec7YEuM9QhQysou5Qg9AXiP+hcSuFuItSGVnkx1TXK5JR78jGTbdJD4G9QiUGm5rvpefup3ofFP4vjYaOCKyr9TN925JktroGYUnaIU6rNsYr7aWgmxchs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723788836; c=relaxed/simple; bh=YPkQUjcHmgKFCc+e9xA6C2pGFVqWtssaMx5lnsv5h8w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n3hrgBIqJCJ3GNrdDpgcaXvHz1bWu9+T/qAaAXhfFcUbY7VpAVvXkL/ohtAjYxqNmdDXmo6vLztQAT2hWdhwYfVafmM2KZk5qr6bxX2mF+aCaKroSwJQdI0+j2MrGCDvDIZgkYkZaoVcpYwzy05AYPKcQrgU3YlJCHtiaKXXJR8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JRzDP8Cr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JRzDP8Cr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D16F2C32782; Fri, 16 Aug 2024 06:13:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723788836; bh=YPkQUjcHmgKFCc+e9xA6C2pGFVqWtssaMx5lnsv5h8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JRzDP8CrWR1g9FqqiiSCcvVgKw/N0wRGnKCsqDVEB1bs2TeFs910Zjyr2c7owqpxM P23U7/aog9aCHpfzeAK3lkRj4+Jp/I6NUNLPcFWl0g1JSqcoWfN42+fbmGeoesims2 FSq4RdvokeWpk8OTeNeOf9iOkmqzXEIP4F0lh/UL8GqHeXEY3ealFcfCOhrH0DNAUN uICFdAMOIf7vkJ4rQvksk6zRr926BVi4xj86hUptkAERALqBB6xRpn8PfHEMdHr8c/ F3zVqSMVIxnadi+IYjY80uw9PVjfihzFwJebjFpxli9tn641DQ8O6OJitz+576Qfer MYXUWJOPwqZ8g== From: neeraj.upadhyay@kernel.org To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, paulmck@kernel.org, neeraj.upadhyay@kernel.org, neeraj.upadhyay@amd.com, boqun.feng@gmail.com, joel@joelfernandes.org, urezki@gmail.com, frederic@kernel.org Subject: [PATCH rcu 1/4] rcu: Summarize RCU CPU stall warnings during CSD-lock stalls Date: Fri, 16 Aug 2024 11:43:01 +0530 Message-Id: <20240816061304.48843-1-neeraj.upadhyay@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240816061050.GA46994@neeraj.linux> References: <20240816061050.GA46994@neeraj.linux> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" During CSD-lock stalls, the additional information output by RCU CPU stall warnings is usually redundant, flooding the console for not good reason. However, this has been the way things work for a few years. This commit therefore adds an rcutree.csd_lock_suppress_rcu_stall kernel boot parameter that causes RCU CPU stall warnings to be abbreviated to a single line when there is at least one CPU that has been stuck waiting for CSD lock for more than five seconds. To make this abbreviated message happen with decent probability: tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 8 \ --configs "2*TREE01" --kconfig "CONFIG_CSD_LOCK_WAIT_DEBUG=y" \ --bootargs "csdlock_debug=1 rcutorture.stall_cpu=200 \ rcutorture.stall_cpu_holdoff=120 rcutorture.stall_cpu_irqsoff=1 \ rcutree.csd_lock_suppress_rcu_stall=1 \ rcupdate.rcu_exp_cpu_stall_timeout=5000" --trust-make [ paulmck: Apply kernel test robot feedback. ] Signed-off-by: Paul E. McKenney Signed-off-by: Neeraj Upadhyay --- Documentation/admin-guide/kernel-parameters.txt | 4 ++++ kernel/rcu/tree_stall.h | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index f1384c7b59c9..d56356c13184 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4937,6 +4937,10 @@ Set maximum number of finished RCU callbacks to process in one batch. + rcutree.csd_lock_suppress_rcu_stall= [KNL] + Do only a one-line RCU CPU stall warning when + there is an ongoing too-long CSD-lock wait. + rcutree.do_rcu_barrier= [KNL] Request a call to rcu_barrier(). This is throttled so that userspace tests can safely diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index 4b0e9d7c4c68..b497d4c6dabd 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -9,6 +9,7 @@ #include #include +#include ////////////////////////////////////////////////////////////////////////////// // @@ -719,6 +720,9 @@ static void print_cpu_stall(unsigned long gps) set_preempt_need_resched(); } +static bool csd_lock_suppress_rcu_stall; +module_param(csd_lock_suppress_rcu_stall, bool, 0644); + static void check_cpu_stall(struct rcu_data *rdp) { bool self_detected; @@ -791,7 +795,9 @@ static void check_cpu_stall(struct rcu_data *rdp) return; rcu_stall_notifier_call_chain(RCU_STALL_NOTIFY_NORM, (void *)j - gps); - if (self_detected) { + if (READ_ONCE(csd_lock_suppress_rcu_stall) && csd_lock_is_stuck()) { + pr_err("INFO: %s detected stall, but suppressed full report due to a stuck CSD-lock.\n", rcu_state.name); + } else if (self_detected) { /* We haven't checked in, so go dump stack. */ print_cpu_stall(gps); } else { From patchwork Fri Aug 16 06:13:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj Upadhyay X-Patchwork-Id: 13765474 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DDFC2E859; Fri, 16 Aug 2024 06:14:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723788853; cv=none; b=iQ/PXCG2D+wMKEgZW7/ImAOegI2bgdVeGn4XiEiI/Vl6IhElBlk49FQQn2oKiBQUGAcUvft9G6PcAnGr+XVmFEDmhwbZSzYa11Nb9xkl79Dv/Kimn6JfH0huZVvHKTi6X51maVQwGl253gTxgQjkzAt/TcboMBlZSw+Ev5HHfr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723788853; c=relaxed/simple; bh=kbqoRxS0REFF16B8tCthIXXPEkLqu32lnFeaTK/bu5M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GBqW+uM+LepifK+WZ2f9UBfMNF1YpaElK7ZzqFU2+pme9H1bFFWYxJl8rNi0Zb/ugYY2MCQIFLye+22sfxYmX7Rv81iF2iL63FWwuDA+Dmq7dmYJGOTy8KC2lynu5Jggl0ZFGy4luamk8VQ2UAn9abnpyc9myCpLsNOapnQ6y/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p6/wi1hC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p6/wi1hC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBAE1C32782; Fri, 16 Aug 2024 06:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723788853; bh=kbqoRxS0REFF16B8tCthIXXPEkLqu32lnFeaTK/bu5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p6/wi1hCqsg2OOd1yHiqDL5iP/DW5ROEPi6QRAfuqNPiVXwq7k1JXRoo6Vv5Vc9sH CyzoJBNYMta8s3WlrN3hVGdmy0ofqqNdjo0XDVdigYAw76zaEkm/fSafMo0KIWe23H 1alPuaY75z+ZgzcZYfWZRokx6pP5Isjs1cslGmnBgi5h/hjNPBw8H9+Wn7lA3iAnZw 35j3r9MMwXZdimmW8ZhW3cypa+3/D0z/oR++6FtzFR0rTc/yEzyDx1wRYfjgcyu9V1 WgB6gqeUvNmPPkST+f+WD4ylPeAsZgVxLgPvDopR6QGMKjFpGbKcwdrXmFOIgh0bOu D5GF8voOGxzvg== From: neeraj.upadhyay@kernel.org To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, paulmck@kernel.org, neeraj.upadhyay@kernel.org, neeraj.upadhyay@amd.com, boqun.feng@gmail.com, joel@joelfernandes.org, urezki@gmail.com, frederic@kernel.org Subject: [PATCH rcu 2/4] rcu: Extract synchronize_rcu_expedited_stall() from synchronize_rcu_expedited_wait() Date: Fri, 16 Aug 2024 11:43:02 +0530 Message-Id: <20240816061304.48843-2-neeraj.upadhyay@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240816061050.GA46994@neeraj.linux> References: <20240816061050.GA46994@neeraj.linux> 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 extracts the RCU CPU stall-warning report code from synchronize_rcu_expedited_wait() and places it in a new function named synchronize_rcu_expedited_stall(). This is strictly a code-movement commit. A later commit will use this reorganization to avoid printing expedited RCU CPU stall warnings while there are ongoing CSD-lock stall reports. Signed-off-by: Paul E. McKenney Signed-off-by: Neeraj Upadhyay --- kernel/rcu/tree_exp.h | 111 +++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 51 deletions(-) diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h index 4acd29d16fdb..17dd5169012d 100644 --- a/kernel/rcu/tree_exp.h +++ b/kernel/rcu/tree_exp.h @@ -542,6 +542,65 @@ static bool synchronize_rcu_expedited_wait_once(long tlimit) return false; } +/* + * Print out an expedited RCU CPU stall warning message. + */ +static void synchronize_rcu_expedited_stall(unsigned long jiffies_start, unsigned long j) +{ + int cpu; + unsigned long mask; + int ndetected; + struct rcu_node *rnp; + struct rcu_node *rnp_root = rcu_get_root(); + + pr_err("INFO: %s detected expedited stalls on CPUs/tasks: {", rcu_state.name); + ndetected = 0; + rcu_for_each_leaf_node(rnp) { + ndetected += rcu_print_task_exp_stall(rnp); + for_each_leaf_node_possible_cpu(rnp, cpu) { + struct rcu_data *rdp; + + mask = leaf_node_cpu_bit(rnp, cpu); + if (!(READ_ONCE(rnp->expmask) & mask)) + continue; + ndetected++; + rdp = per_cpu_ptr(&rcu_data, cpu); + pr_cont(" %d-%c%c%c%c", cpu, + "O."[!!cpu_online(cpu)], + "o."[!!(rdp->grpmask & rnp->expmaskinit)], + "N."[!!(rdp->grpmask & rnp->expmaskinitnext)], + "D."[!!data_race(rdp->cpu_no_qs.b.exp)]); + } + } + pr_cont(" } %lu jiffies s: %lu root: %#lx/%c\n", + j - jiffies_start, rcu_state.expedited_sequence, data_race(rnp_root->expmask), + ".T"[!!data_race(rnp_root->exp_tasks)]); + if (ndetected) { + pr_err("blocking rcu_node structures (internal RCU debug):"); + rcu_for_each_node_breadth_first(rnp) { + if (rnp == rnp_root) + continue; /* printed unconditionally */ + if (sync_rcu_exp_done_unlocked(rnp)) + continue; + pr_cont(" l=%u:%d-%d:%#lx/%c", + rnp->level, rnp->grplo, rnp->grphi, data_race(rnp->expmask), + ".T"[!!data_race(rnp->exp_tasks)]); + } + pr_cont("\n"); + } + rcu_for_each_leaf_node(rnp) { + for_each_leaf_node_possible_cpu(rnp, cpu) { + mask = leaf_node_cpu_bit(rnp, cpu); + if (!(READ_ONCE(rnp->expmask) & mask)) + continue; + preempt_disable(); // For smp_processor_id() in dump_cpu_task(). + dump_cpu_task(cpu); + preempt_enable(); + } + rcu_exp_print_detail_task_stall_rnp(rnp); + } +} + /* * Wait for the expedited grace period to elapse, issuing any needed * RCU CPU stall warnings along the way. @@ -553,10 +612,8 @@ static void synchronize_rcu_expedited_wait(void) unsigned long jiffies_stall; unsigned long jiffies_start; unsigned long mask; - int ndetected; struct rcu_data *rdp; struct rcu_node *rnp; - struct rcu_node *rnp_root = rcu_get_root(); unsigned long flags; trace_rcu_exp_grace_period(rcu_state.name, rcu_exp_gp_seq_endval(), TPS("startwait")); @@ -593,55 +650,7 @@ static void synchronize_rcu_expedited_wait(void) j = jiffies; rcu_stall_notifier_call_chain(RCU_STALL_NOTIFY_EXP, (void *)(j - jiffies_start)); trace_rcu_stall_warning(rcu_state.name, TPS("ExpeditedStall")); - pr_err("INFO: %s detected expedited stalls on CPUs/tasks: {", - rcu_state.name); - ndetected = 0; - rcu_for_each_leaf_node(rnp) { - ndetected += rcu_print_task_exp_stall(rnp); - for_each_leaf_node_possible_cpu(rnp, cpu) { - struct rcu_data *rdp; - - mask = leaf_node_cpu_bit(rnp, cpu); - if (!(READ_ONCE(rnp->expmask) & mask)) - continue; - ndetected++; - rdp = per_cpu_ptr(&rcu_data, cpu); - pr_cont(" %d-%c%c%c%c", cpu, - "O."[!!cpu_online(cpu)], - "o."[!!(rdp->grpmask & rnp->expmaskinit)], - "N."[!!(rdp->grpmask & rnp->expmaskinitnext)], - "D."[!!data_race(rdp->cpu_no_qs.b.exp)]); - } - } - pr_cont(" } %lu jiffies s: %lu root: %#lx/%c\n", - j - jiffies_start, rcu_state.expedited_sequence, - data_race(rnp_root->expmask), - ".T"[!!data_race(rnp_root->exp_tasks)]); - if (ndetected) { - pr_err("blocking rcu_node structures (internal RCU debug):"); - rcu_for_each_node_breadth_first(rnp) { - if (rnp == rnp_root) - continue; /* printed unconditionally */ - if (sync_rcu_exp_done_unlocked(rnp)) - continue; - pr_cont(" l=%u:%d-%d:%#lx/%c", - rnp->level, rnp->grplo, rnp->grphi, - data_race(rnp->expmask), - ".T"[!!data_race(rnp->exp_tasks)]); - } - pr_cont("\n"); - } - rcu_for_each_leaf_node(rnp) { - for_each_leaf_node_possible_cpu(rnp, cpu) { - mask = leaf_node_cpu_bit(rnp, cpu); - if (!(READ_ONCE(rnp->expmask) & mask)) - continue; - preempt_disable(); // For smp_processor_id() in dump_cpu_task(). - dump_cpu_task(cpu); - preempt_enable(); - } - rcu_exp_print_detail_task_stall_rnp(rnp); - } + synchronize_rcu_expedited_stall(jiffies_start, j); jiffies_stall = 3 * rcu_exp_jiffies_till_stall_check() + 3; panic_on_rcu_stall(); } From patchwork Fri Aug 16 06:13:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj Upadhyay X-Patchwork-Id: 13765475 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B1EB83CD2; Fri, 16 Aug 2024 06:14:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723788872; cv=none; b=Q9IKDwB7z2iylS7bOXDTRpQWat954BQBQb+jUUNVUdbTOF1ja+yObBiGUajDHmn0yOYhYcgze2yDCkAY7ljKwC3Al9rjvWmE/e9inf1PQNG4VuxsjBaFXkBMlAih8Ftnj/aVHNAd4EQh+YYrCm44Je/kPVPLTbIryrvlFVt4URA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723788872; c=relaxed/simple; bh=GzcF/AxsZadA5DCdyDyvjw9DG5Drn9I841sZqkPWd50=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WDE5Cx9eMjpaEsT2KCSYaFNnEcqFNJapnvD6CiAD5gCykv7CQD57ecOf73+Ubs3IBYCnbY5IYTqOzkSFlyCuFfj9MiGF5SBPWGOuvqgHyN0b4f57xhvSe4hO771O9pC1crMbZrl4g4UN1Ap6bkdNVJaSBqBw/sz+uNIHRVgnHAg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nVM0vMlr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nVM0vMlr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1843C32782; Fri, 16 Aug 2024 06:14:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723788870; bh=GzcF/AxsZadA5DCdyDyvjw9DG5Drn9I841sZqkPWd50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nVM0vMlrBxaGmFXnQw58wniNmFb36Q/QZ5FW0v6E1b5dlHRWcre/dBrabKgVgf8jq 7YFT4pZgm+GhUo6J8ayZhRrMDLMO8yPjcWnRaji2ckA39NdcNJ1QA/h6vycpA9W5+F idv19HXlBcvkhouSoFW6rA9xieWYFlr97dvIlM0iQNFzS74Ny8P3O3+0wCZjgtn7Jj e1qsKM4EjhsAIgzt13g1jS44q/sdKDRK5p0gTCmUUxLG/k5B5/k/pYFf3StkfOme8E KbPgs8OJaj7mE3KwTzwalxrEAvqqfRVmt4ywz/1xWjWBlVsQM49vX4TFCaWhEqcoFn 1QgOU29EO/wtw== From: neeraj.upadhyay@kernel.org To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, paulmck@kernel.org, neeraj.upadhyay@kernel.org, neeraj.upadhyay@amd.com, boqun.feng@gmail.com, joel@joelfernandes.org, urezki@gmail.com, frederic@kernel.org Subject: [PATCH rcu 3/4] rcu: Summarize expedited RCU CPU stall warnings during CSD-lock stalls Date: Fri, 16 Aug 2024 11:43:03 +0530 Message-Id: <20240816061304.48843-3-neeraj.upadhyay@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240816061050.GA46994@neeraj.linux> References: <20240816061050.GA46994@neeraj.linux> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" During CSD-lock stalls, the additional information output by expedited RCU CPU stall warnings is usually redundant, flooding the console for not good reason. However, this has been the way things work for a few years. This commit therefore uses rcutree.csd_lock_suppress_rcu_stall kernel boot parameter that causes expedited RCU CPU stall warnings to be abbreviated to a single line when there is at least one CPU that has been stuck waiting for CSD lock for more than five seconds. Signed-off-by: Paul E. McKenney Signed-off-by: Neeraj Upadhyay --- kernel/rcu/tree_exp.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h index 17dd5169012d..d4be644afb50 100644 --- a/kernel/rcu/tree_exp.h +++ b/kernel/rcu/tree_exp.h @@ -553,6 +553,10 @@ static void synchronize_rcu_expedited_stall(unsigned long jiffies_start, unsigne struct rcu_node *rnp; struct rcu_node *rnp_root = rcu_get_root(); + if (READ_ONCE(csd_lock_suppress_rcu_stall) && csd_lock_is_stuck()) { + pr_err("INFO: %s detected expedited stalls, but suppressed full report due to a stuck CSD-lock.\n", rcu_state.name); + return; + } pr_err("INFO: %s detected expedited stalls on CPUs/tasks: {", rcu_state.name); ndetected = 0; rcu_for_each_leaf_node(rnp) { From patchwork Fri Aug 16 06:13:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj Upadhyay X-Patchwork-Id: 13765476 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E66F80C0C; Fri, 16 Aug 2024 06:14:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723788888; cv=none; b=qPq1YdBKKVTi36ir2e40934I+QHNvzZuT4KfsoPbTKMkw/nGoFo6JTS0iehZzaQrZoa2vWg1SQwhQbvTIFZ82IoNMOSi3ghSdX1IJDRWfgWGb7tE3aYdm6iSpWeGDFSxAmnoVZWkVdqBimxZdIjLSQnrU2O/qptoIMKWIpHB1JE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723788888; c=relaxed/simple; bh=IX21ZbjyaTwTK68KfByMdmzZ2IeYlI7XNFXs1WUQi44=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uTWO5UHNmrY5vzt8/OSYZEMIYq+oGrfcEr7eiz+iLjiKL5OS86Ek3405qQnt2A1b/a/nTaQ5RBjGNr5uDeWx72Ts0AEnRzBsb7pFp2Wgf62K59Zas5JS0FeQJBFPKDs3sNkAlrtElvloytluj5hGcTQLn91QbVAk1btFWClJ3qQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fYvAYCti; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fYvAYCti" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99AF2C32782; Fri, 16 Aug 2024 06:14:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723788887; bh=IX21ZbjyaTwTK68KfByMdmzZ2IeYlI7XNFXs1WUQi44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fYvAYCti06hgDC9rKiUB5bmRSxRMhbHsbjvsyP9rk6qW12cVp8pqB6m9KZCz7W4vK QrzOunJED+geNVtykKKW8uTlDV6WFQts9qKEYpunZQYdI73DiYuKqEMLmjkRd1UGgX ywdD9qyxqM6xPc8j/5L9ccl2ng9N90+ihaEY+g7Bk34apuETf20ZYxoZikj/V7gyhZ iK6BN1RiY1iGqQhJNl1L/WmwasnCLDVPmVlstfidN0Ek54gjhdfJaOdvFF12ybquyH HW13GBVt2kC0BQlh3pT6s4VhtGfrOyQfqY/p8/9W9x1Sma4vTAwnVAi3n0LLkQOQIx JNQ5CXTcgM5Ug== From: neeraj.upadhyay@kernel.org To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, paulmck@kernel.org, neeraj.upadhyay@kernel.org, neeraj.upadhyay@amd.com, boqun.feng@gmail.com, joel@joelfernandes.org, urezki@gmail.com, frederic@kernel.org, Ryo Takakura Subject: [PATCH rcu 4/4] rcu: Let dump_cpu_task() be used without preemption disabled Date: Fri, 16 Aug 2024 11:43:04 +0530 Message-Id: <20240816061304.48843-4-neeraj.upadhyay@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240816061050.GA46994@neeraj.linux> References: <20240816061050.GA46994@neeraj.linux> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Ryo Takakura The commit 2d7f00b2f0130 ("rcu: Suppress smp_processor_id() complaint in synchronize_rcu_expedited_wait()") disabled preemption around dump_cpu_task() to suppress warning on its usage within preemtible context. Calling dump_cpu_task() doesn't required to be in non-preemptible context except for suppressing the smp_processor_id() warning. As the smp_processor_id() is evaluated along with in_hardirq() to check if it's in interrupt context, this patch removes the need for its preemtion disablement by reordering the condition so that smp_processor_id() only gets evaluated when it's in interrupt context. Signed-off-by: Ryo Takakura Signed-off-by: Paul E. McKenney Signed-off-by: Neeraj Upadhyay --- kernel/rcu/tree_exp.h | 2 -- kernel/sched/core.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h index d4be644afb50..c5d9a7eb0803 100644 --- a/kernel/rcu/tree_exp.h +++ b/kernel/rcu/tree_exp.h @@ -597,9 +597,7 @@ static void synchronize_rcu_expedited_stall(unsigned long jiffies_start, unsigne mask = leaf_node_cpu_bit(rnp, cpu); if (!(READ_ONCE(rnp->expmask) & mask)) continue; - preempt_disable(); // For smp_processor_id() in dump_cpu_task(). dump_cpu_task(cpu); - preempt_enable(); } rcu_exp_print_detail_task_stall_rnp(rnp); } diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a9f655025607..78ae888a1fa2 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -9726,7 +9726,7 @@ struct cgroup_subsys cpu_cgrp_subsys = { void dump_cpu_task(int cpu) { - if (cpu == smp_processor_id() && in_hardirq()) { + if (in_hardirq() && cpu == smp_processor_id()) { struct pt_regs *regs; regs = get_irq_regs();