Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2380086rdd; Fri, 12 Jan 2024 07:47:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5++sycdZBlsqwUAzjfqqZRI7CYQSoDGH4ovRqzlRIHEx4QLF79zgsahlXjcyR9zrLxSFX X-Received: by 2002:a05:6359:6bca:b0:172:b539:3fcd with SMTP id tb10-20020a0563596bca00b00172b5393fcdmr1404377rwb.53.1705074447663; Fri, 12 Jan 2024 07:47:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705074447; cv=none; d=google.com; s=arc-20160816; b=WpnUOrx99ugaadJBjHqkLDb4KAkuoEjqSMa0woqR/BHuwAtiRqnZ6HzAv9kGt44A8j 8NA33vg+NrnCkmg4Zc2QGiIHeCHIEwAAtUlOUw0tA7ITdRc0JDpnOtuGdJjtfAVAzVbJ OB3alwxDA1dPo4IW7zHGgMZ4lR+reEeKdta8iFdVKywsa0bqY2BGVj7dZfenqmx+2Rc2 mlfi9iWC4YlMihU6QQAT8IkxqIZd4nlCgr7i7KNC/yTvBoj+ujzKzXW7A1PxQrfROPfv dfrSGIb9ViJcCzFWEP9MK7/RL9CP6krDPsZ95SwvyhnhI2fa/JSl8YvEKcaTmDrnjLR7 EtWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JjAEYWsVj7dDfUzGoz2dCWSij7el1+Z77XkwHHFzfvg=; fh=Vt4MF2mkEob8wHsiIEVO0FMp/tQ5kOJKjfDhEdncdXc=; b=LWH7ipHy8UR38QcQaySFX64Nvk5gNss4lTq/xB0JfWh38uqOyyQTUxC7wYK0tVgOaF OTIriG7d0H3EuW/yfddmp/dz+d02lmi6yXYdLsQNaeXx0i/PUZERv93Mx6yxGhreQsmp C6lkqeVHhIDiCUiYGJDHOb5tr4ZLHlHJc+uF7dUDr4WftKQ9lFD2adksgY9pYVYB7ixi fq2YxdOgujDovk9xHC4BwptOJC8d0inVyD6nMvfq6o+Y6TG8gBdmANe3X9NvipYsc0IR ldiEA7EDYI+tbFdqe6ALgwKuSQXKAu0EgsSMCHITs1LVcFi/9xOSp10lIsTNp7tQPc3h cSxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V8L388gC; spf=pass (google.com: domain of linux-kernel+bounces-24820-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24820-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id c32-20020a631c20000000b005cdffd0ec5esi3514542pgc.477.2024.01.12.07.47.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 07:47:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24820-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V8L388gC; spf=pass (google.com: domain of linux-kernel+bounces-24820-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24820-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7130EB23E31 for ; Fri, 12 Jan 2024 15:47:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38F547318A; Fri, 12 Jan 2024 15:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="V8L388gC" 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 6643B7317A; Fri, 12 Jan 2024 15:46:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38020C433A6; Fri, 12 Jan 2024 15:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705074396; bh=ZJYHTwI5oMs3AJIma8DdT7q/1S5boVpTb/VWCHsVrwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V8L388gCFiFAPfJpvHRXTW20amcvbGG24SdVNjndMJL8nHjTvMmUHcdqKrydxUyV/ rTsL0wBbmuha5OjYIdinbVSOjyUVNcC9B9B4ChWyXd4pVxU0h5mVmJiYIIDUb9q5IO amXR2FhNdMmRVoR+CrWAZhKQvRrr6i5KP/zmooVe41ao0JKf2w1o91JNlTbHbyK6K+ z8y/DGQ0tiIYxneqmbTx3XHUh2Me5XucgTiL59h3sl8aWy9RJx10eBTa/XnkhVV/LS J3h0gBt7F+iheOSkWPHxXx24RfcIJTiBk2YBbm5oH5j8/rhbd8FunUkvAPgyCy1eQF kyulePQrD/htg== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Boqun Feng , Joel Fernandes , Neeraj Upadhyay , "Paul E . McKenney" , Uladzislau Rezki , rcu , Kalesh Singh Subject: [PATCH 2/7] rcu/exp: Handle RCU expedited grace period kworker allocation failure Date: Fri, 12 Jan 2024 16:46:16 +0100 Message-Id: <20240112154621.261852-3-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240112154621.261852-1-frederic@kernel.org> References: <20240112154621.261852-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Just like is done for the kworker performing nodes initialization, gracefully handle the possible allocation failure of the RCU expedited grace period main kworker. While at it perform a rename of the related checking functions to better reflect the expedited specifics. Reviewed-by: Kalesh Singh Fixes: 9621fbee44df ("rcu: Move expedited grace period (GP) work to RT kthread_worker") Signed-off-by: Frederic Weisbecker --- kernel/rcu/tree.c | 2 ++ kernel/rcu/tree_exp.h | 25 +++++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index b000c1a83fc2..5cd90f1762e9 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4754,6 +4754,7 @@ static void __init rcu_start_exp_gp_kworkers(void) rcu_exp_gp_kworker = kthread_create_worker(0, gp_kworker_name); if (IS_ERR_OR_NULL(rcu_exp_gp_kworker)) { pr_err("Failed to create %s!\n", gp_kworker_name); + rcu_exp_gp_kworker = NULL; return; } @@ -4762,6 +4763,7 @@ static void __init rcu_start_exp_gp_kworkers(void) pr_err("Failed to create %s!\n", par_gp_kworker_name); rcu_exp_par_gp_kworker = NULL; kthread_destroy_worker(rcu_exp_gp_kworker); + rcu_exp_gp_kworker = NULL; return; } diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h index 014ddf672165..6123a60d9a4d 100644 --- a/kernel/rcu/tree_exp.h +++ b/kernel/rcu/tree_exp.h @@ -427,7 +427,12 @@ static void sync_rcu_exp_select_node_cpus(struct kthread_work *wp) __sync_rcu_exp_select_node_cpus(rewp); } -static inline bool rcu_gp_par_worker_started(void) +static inline bool rcu_exp_worker_started(void) +{ + return !!READ_ONCE(rcu_exp_gp_kworker); +} + +static inline bool rcu_exp_par_worker_started(void) { return !!READ_ONCE(rcu_exp_par_gp_kworker); } @@ -477,7 +482,12 @@ static void sync_rcu_exp_select_node_cpus(struct work_struct *wp) __sync_rcu_exp_select_node_cpus(rewp); } -static inline bool rcu_gp_par_worker_started(void) +static inline bool rcu_exp_worker_started(void) +{ + return !!READ_ONCE(rcu_gp_wq); +} + +static inline bool rcu_exp_par_worker_started(void) { return !!READ_ONCE(rcu_par_gp_wq); } @@ -540,7 +550,7 @@ static void sync_rcu_exp_select_cpus(void) rnp->exp_need_flush = false; if (!READ_ONCE(rnp->expmask)) continue; /* Avoid early boot non-existent wq. */ - if (!rcu_gp_par_worker_started() || + if (!rcu_exp_par_worker_started() || rcu_scheduler_active != RCU_SCHEDULER_RUNNING || rcu_is_last_leaf_node(rnp)) { /* No worker started yet or last leaf, do direct call. */ @@ -955,7 +965,7 @@ static void rcu_exp_print_detail_task_stall_rnp(struct rcu_node *rnp) */ void synchronize_rcu_expedited(void) { - bool boottime = (rcu_scheduler_active == RCU_SCHEDULER_INIT); + bool use_worker; unsigned long flags; struct rcu_exp_work rew; struct rcu_node *rnp; @@ -966,6 +976,9 @@ void synchronize_rcu_expedited(void) lock_is_held(&rcu_sched_lock_map), "Illegal synchronize_rcu_expedited() in RCU read-side critical section"); + use_worker = (rcu_scheduler_active != RCU_SCHEDULER_INIT) && + rcu_exp_worker_started(); + /* Is the state is such that the call is a grace period? */ if (rcu_blocking_is_gp()) { // Note well that this code runs with !PREEMPT && !SMP. @@ -995,7 +1008,7 @@ void synchronize_rcu_expedited(void) return; /* Someone else did our work for us. */ /* Ensure that load happens before action based on it. */ - if (unlikely(boottime)) { + if (unlikely(!use_worker)) { /* Direct call during scheduler init and early_initcalls(). */ rcu_exp_sel_wait_wake(s); } else { @@ -1013,7 +1026,7 @@ void synchronize_rcu_expedited(void) /* Let the next expedited grace period start. */ mutex_unlock(&rcu_state.exp_mutex); - if (likely(!boottime)) + if (likely(use_worker)) synchronize_rcu_expedited_destroy_work(&rew); } EXPORT_SYMBOL_GPL(synchronize_rcu_expedited); -- 2.34.1