From patchwork Wed Aug 31 18:10:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 12961233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9121EC0502A for ; Wed, 31 Aug 2022 18:13:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232313AbiHaSNz (ORCPT ); Wed, 31 Aug 2022 14:13:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232586AbiHaSNH (ORCPT ); Wed, 31 Aug 2022 14:13:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43197E7243; Wed, 31 Aug 2022 11:11:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9A803B82273; Wed, 31 Aug 2022 18:10:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CD19C433B5; Wed, 31 Aug 2022 18:10:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661969446; bh=RUFHG/k2inBKsfsfPIko0AaoBZnwqbkHwx1FvhaHJSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZAbB+KfK+QjMTUCkFi6skSO/D3TFLksYWWsmQOAmZmYENp5U5nBxyqOKLwFZkTVxv WeXXBbJY9lbxu84Kvxbve9rHCMCWROyRH4uCa9ANhri4kycBE3hGVhsJWkJLrjYEZu KHP9aQEV0Ep6opmXfVhH+lEKPFecMWNzl2rk+wfaTDgOdmDglCa2S52XhnyF0K579l gRh8TomuqrfGIOOzJxq/6CYg09Ftivq5hVmDUqrGAAvYE9drIA52SjcP8rfroQYXbm hOZhLFJORAMQJv4zXiCando23xvZUarD0mjKInevcCWI+KeFKKOeQdpA+LIV0HgoOU RA110V6ahvERw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 081635C015D; Wed, 31 Aug 2022 11:10:46 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Zqiang , "Paul E . McKenney" Subject: [PATCH rcu 1/3] rcu/nocb: Choose the right rcuog/rcuop kthreads to output Date: Wed, 31 Aug 2022 11:10:42 -0700 Message-Id: <20220831181044.2694488-1-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831181040.GA2694278@paulmck-ThinkPad-P17-Gen-1> References: <20220831181040.GA2694278@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org From: Zqiang The show_rcu_nocb_gp_state() function is supposed to dump out the rcuog kthread and the show_rcu_nocb_state() function is supposed to dump out the rcuo[ps] kthread. Currently, both do a mixture, which is not optimal for debugging, even though it does not affect functionality. This commit therefore adjusts these two functions to focus on their respective kthreads. Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney --- kernel/rcu/tree_nocb.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index a8f574d8850d2..f20aec4f4394b 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1452,8 +1452,8 @@ static void show_rcu_nocb_gp_state(struct rcu_data *rdp) (long)rdp->nocb_gp_seq, rnp->grplo, rnp->grphi, READ_ONCE(rdp->nocb_gp_loops), rdp->nocb_gp_kthread ? task_state_to_char(rdp->nocb_gp_kthread) : '.', - rdp->nocb_cb_kthread ? (int)task_cpu(rdp->nocb_gp_kthread) : -1, - show_rcu_should_be_on_cpu(rdp->nocb_cb_kthread)); + rdp->nocb_gp_kthread ? (int)task_cpu(rdp->nocb_gp_kthread) : -1, + show_rcu_should_be_on_cpu(rdp->nocb_gp_kthread)); } /* Dump out nocb kthread state for the specified rcu_data structure. */ @@ -1497,7 +1497,7 @@ static void show_rcu_nocb_state(struct rcu_data *rdp) ".B"[!!rcu_cblist_n_cbs(&rdp->nocb_bypass)], rcu_segcblist_n_cbs(&rdp->cblist), rdp->nocb_cb_kthread ? task_state_to_char(rdp->nocb_cb_kthread) : '.', - rdp->nocb_cb_kthread ? (int)task_cpu(rdp->nocb_gp_kthread) : -1, + rdp->nocb_cb_kthread ? (int)task_cpu(rdp->nocb_cb_kthread) : -1, show_rcu_should_be_on_cpu(rdp->nocb_cb_kthread)); /* It is OK for GP kthreads to have GP state. */ From patchwork Wed Aug 31 18:10:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 12961229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51DA0ECAAD1 for ; Wed, 31 Aug 2022 18:13:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232432AbiHaSM7 (ORCPT ); Wed, 31 Aug 2022 14:12:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232409AbiHaSMl (ORCPT ); Wed, 31 Aug 2022 14:12:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92071E3961; Wed, 31 Aug 2022 11:11:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DEEDC61BF0; Wed, 31 Aug 2022 18:10:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CC2FC433D6; Wed, 31 Aug 2022 18:10:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661969446; bh=RzA/0h68ZhBe7KOWBZY3n3Aj4fMOY0YIfHq1RWU0ov4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AhLOP54ZWRohzBkh5yFGWcRdlrY5IQ7hBScdDCNCfQFaKOWaV/OVPWBdHYwQ6H1Fx fuyyZcMC+Nfpkn377Bu3xN/SzZMyvq4VhqLR6y0c6x0dj5RM3R7moXPfFlfYYInYsT s+uFqkEu2cTP9aPp2wmJ5sLwD7jIpMiBuWRprTXEQaJ0E0jSyk1HpA3OYmr/i2uqDv ndgZNpZiZyUNLWyY5OslicLNgrGj8tAu3xJxgN/HHeNrCWSRwo9kXBHzTwMzfp1L58 NpIKnMIYrDTGcfhjY+Pz38Qlnnkzj5dNcb9A8XkWZMB1nRKpLNisB+q1ya8yEl0ECT cTvRMz0NX5LsA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 0AA015C019C; Wed, 31 Aug 2022 11:10:46 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, "Paul E. McKenney" , Frederic Weisbecker Subject: [PATCH rcu 2/3] rcu/nocb: Add CPU number to CPU-{,de}offload failure messages Date: Wed, 31 Aug 2022 11:10:43 -0700 Message-Id: <20220831181044.2694488-2-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831181040.GA2694278@paulmck-ThinkPad-P17-Gen-1> References: <20220831181040.GA2694278@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org Offline CPUs cannot be offloaded or deoffloaded. Any attempt to offload or deoffload an offline CPU causes a message to be printed on the console, which is good, but this message does not contain the CPU number, which is bad. Such a CPU number can be helpful when debugging, as it gives a clear indication that the CPU in question is in fact offline. This commit therefore adds the CPU number to the CPU-{,de}offload failure messages. Cc: Frederic Weisbecker Signed-off-by: Paul E. McKenney --- kernel/rcu/tree_nocb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index f20aec4f4394b..0a5f0ef414845 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1111,7 +1111,7 @@ int rcu_nocb_cpu_deoffload(int cpu) if (!ret) cpumask_clear_cpu(cpu, rcu_nocb_mask); } else { - pr_info("NOCB: Can't CB-deoffload an offline CPU\n"); + pr_info("NOCB: Cannot CB-deoffload offline CPU %d\n", rdp->cpu); ret = -EINVAL; } } @@ -1196,7 +1196,7 @@ int rcu_nocb_cpu_offload(int cpu) if (!ret) cpumask_set_cpu(cpu, rcu_nocb_mask); } else { - pr_info("NOCB: Can't CB-offload an offline CPU\n"); + pr_info("NOCB: Cannot CB-offload offline CPU %d\n", rdp->cpu); ret = -EINVAL; } } From patchwork Wed Aug 31 18:10:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 12961231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 881D0ECAAD1 for ; Wed, 31 Aug 2022 18:13:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232377AbiHaSN3 (ORCPT ); Wed, 31 Aug 2022 14:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232403AbiHaSM6 (ORCPT ); Wed, 31 Aug 2022 14:12:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9242EF001; Wed, 31 Aug 2022 11:11:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E67B661C41; Wed, 31 Aug 2022 18:10:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CC76C433D7; Wed, 31 Aug 2022 18:10:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661969446; bh=kCjYd6SW2FfEw+BYAxl3L5fePtwdhSgZpFPL5cC1jvY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RJVo505mOTBXh7FtbY5V/L6k+gz0akbWJR+WLo5kvnsWpliol/BkiYuu4TFtzTkCZ jKX8i6NJ/AgXajtP7xMCkwJ28iT45Iwa+UgRWDvvV6B4Evca7Df99ZO8H6XPqjAefv prqjIoZusDRZfJ+NxYtkuKZg6swrsiCOsgzTgf+PPiwbgUajU7bTZoGcz1XKZPMZbS d8RGxjxmhmPygucTlXxgdfCz8DJUE1Aras5HpXzpVCQQe+Alzr3UrqmlInBLpVs7wx STycCXcJmbtadNbelPj21X9A8eFTwh0Rql76Es8tnKffEZN5x80ZAppdwDQxGX1mn0 HQEX06uVrC8iA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 0C8255C02A9; Wed, 31 Aug 2022 11:10:46 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Zhen Lei , "Paul E . McKenney" , Joel Fernandes Subject: [PATCH rcu 3/3] rcu: Simplify rcu_init_nohz() cpumask handling Date: Wed, 31 Aug 2022 11:10:44 -0700 Message-Id: <20220831181044.2694488-3-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831181040.GA2694278@paulmck-ThinkPad-P17-Gen-1> References: <20220831181040.GA2694278@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org From: Zhen Lei In kernels built with either CONFIG_RCU_NOCB_CPU_DEFAULT_ALL=y or CONFIG_NO_HZ_FULL=y, additional CPUs must be added to rcu_nocb_mask. Except that kernels booted without the rcu_nocbs= will not have allocated rcu_nocb_mask. And the current rcu_init_nohz() function uses its need_rcu_nocb_mask and offload_all local variables to track the rcu_nocb and nohz_full state. But there is a much simpler approach, namely creating a cpumask pointer to track the default and then using cpumask_available() to check the rcu_nocb_mask state. This commit takes this approach, thereby simplifying and shortening the rcu_init_nohz() function. Signed-off-by: Zhen Lei Signed-off-by: Paul E. McKenney Reviewed-by: Joel Fernandes (Google) --- kernel/rcu/tree_nocb.h | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index 0a5f0ef414845..c8167be2288fa 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1210,45 +1210,31 @@ EXPORT_SYMBOL_GPL(rcu_nocb_cpu_offload); void __init rcu_init_nohz(void) { int cpu; - bool need_rcu_nocb_mask = false; - bool offload_all = false; struct rcu_data *rdp; + const struct cpumask *cpumask = NULL; #if defined(CONFIG_RCU_NOCB_CPU_DEFAULT_ALL) - if (!rcu_state.nocb_is_setup) { - need_rcu_nocb_mask = true; - offload_all = true; - } -#endif /* #if defined(CONFIG_RCU_NOCB_CPU_DEFAULT_ALL) */ - -#if defined(CONFIG_NO_HZ_FULL) - if (tick_nohz_full_running && !cpumask_empty(tick_nohz_full_mask)) { - need_rcu_nocb_mask = true; - offload_all = false; /* NO_HZ_FULL has its own mask. */ - } -#endif /* #if defined(CONFIG_NO_HZ_FULL) */ + cpumask = cpu_possible_mask; +#elif defined(CONFIG_NO_HZ_FULL) + if (tick_nohz_full_running && !cpumask_empty(tick_nohz_full_mask)) + cpumask = tick_nohz_full_mask; +#endif - if (need_rcu_nocb_mask) { + if (cpumask) { if (!cpumask_available(rcu_nocb_mask)) { if (!zalloc_cpumask_var(&rcu_nocb_mask, GFP_KERNEL)) { pr_info("rcu_nocb_mask allocation failed, callback offloading disabled.\n"); return; } } + + cpumask_or(rcu_nocb_mask, rcu_nocb_mask, cpumask); rcu_state.nocb_is_setup = true; } if (!rcu_state.nocb_is_setup) return; -#if defined(CONFIG_NO_HZ_FULL) - if (tick_nohz_full_running) - cpumask_or(rcu_nocb_mask, rcu_nocb_mask, tick_nohz_full_mask); -#endif /* #if defined(CONFIG_NO_HZ_FULL) */ - - if (offload_all) - cpumask_setall(rcu_nocb_mask); - if (!cpumask_subset(rcu_nocb_mask, cpu_possible_mask)) { pr_info("\tNote: kernel parameter 'rcu_nocbs=', 'nohz_full', or 'isolcpus=' contains nonexistent CPUs.\n"); cpumask_and(rcu_nocb_mask, cpu_possible_mask,