Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2629849rdb; Fri, 8 Dec 2023 14:06:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIprnAuP+x/lm+8lB+qCX46XjAvo/yXNYBNIhteXBnv5nM8B17CWBbkdpxyNkhbBu59ois X-Received: by 2002:a17:90a:a114:b0:286:6cc0:cad2 with SMTP id s20-20020a17090aa11400b002866cc0cad2mr686441pjp.73.1702073200361; Fri, 08 Dec 2023 14:06:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702073200; cv=none; d=google.com; s=arc-20160816; b=Bt4XRkoz0txKrUc5Pm5rijtGXN3bGFFg8rt+RYEq3jRxO9QmD2A6fL387OnmYLoVhz EIMJtmY3OSSCfFre1QPG9uniKUbRZpN9GuCXdjMevUcioG9ey3qfYm32t0qQDC7vnQAg v3rUnitfkWD1uCj5Tg4HX5uTp9hjOjwObnpCCAhkBz8TG4PzVzn5c7jpEBGja9f/iEr7 OWYISePwBbeFI/pTywbr/iL6ZxHQo/NaXQyrtrH6HKVwVjV1WBT3iruW4ly+zJZsNsBH dxkZMC4PuP3iWkJR9HVOxxppypW6buXrzk6GxuvBKxkdUJO5pUWGIxJtOXb1r0cv4qHf sYcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EcyFKGCWlUpX9+xfMmQGnKBWo1Tws8oPuAWQpu+6bM4=; fh=z8Ne2JrnnXKUY28f9pwEdqls7nShSFwQTzvJMmkinP0=; b=emNxlzeaq0o2yJ20oGNH8SIZZvMqTy2Lq9902XDRRFfPDHLYapos0JZoLV4ZVgzP/T k9KxXPZDEWMySDtS3SmhsWoTCkwsIDMFHlmFBWLsti62gTF9I0Cy8s8tGLFG5Jic6mbP B9cbLAMU7jkBvOXviytb34RAcQje/ZOR+2zDQQF6T+JAJvBnoX2SVpRRbQSdX46umeBZ sRUtjGehHgewwBPjI7NBt0rXoiiJIMVxlzTc/UBrmGfyMu9ga+cJg5HzGTketp+MGD6D hBS2S99+XvMCVMr5z9ktkPpzTKNDnNSiTOj03kKdJFsdoHP+kt28w6SYyfs0FxFiZEdM qQZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sfV0bAA3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id d4-20020a170902b70400b001d0ced77a90si2131026pls.510.2023.12.08.14.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 14:06:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sfV0bAA3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 15405819E145; Fri, 8 Dec 2023 14:06:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574904AbjLHWGU (ORCPT + 99 others); Fri, 8 Dec 2023 17:06:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1574896AbjLHWF6 (ORCPT ); Fri, 8 Dec 2023 17:05:58 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE35610E0 for ; Fri, 8 Dec 2023 14:06:04 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2059C433CB; Fri, 8 Dec 2023 22:06:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702073164; bh=2VSL0I6CDQD3On48r7ZZl2KNfsOXx4qI+XGTjXvz4To=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sfV0bAA3jMUaWQ7vGD0VMm4RIRuqF0R57O6AyLWLuIz64dUmxfQpa8c1ga8kShpyW w/tmMOwatv3tjWq6lRY5NzU3lVvcHjTa6NLBBeUgAHOR9YdENAOSGYTgK3vs6pystc e+GqnbPLuT7sFWpY1mrdr55j099gb7C2lTMluQur4lQOFYzcWPm3r33wagwqn7AYZ+ e/T7zYVHXergvzndqp/awswOBzn26JxZhhw01hSmeGlJSJdxi6vwEHnWJaXdDV+f2f pSnEbC4NZlMyi2DCb3fYtdjlnztzoxJiLz6/recBTwHZpXndpdXAXKsgYKyHdhqKKM DQ/9wRlfXoBUQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Boqun Feng , Joel Fernandes , Neeraj Upadhyay , "Paul E . McKenney" , Uladzislau Rezki , Zqiang , rcu , Anna-Maria Behnsen , Thomas Gleixner , Kalesh Singh Subject: [PATCH 4/8] rcu/exp: Handle RCU expedited grace period kworker allocation failure Date: Fri, 8 Dec 2023 23:05:41 +0100 Message-ID: <20231208220545.7452-5-frederic@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231208220545.7452-1-frederic@kernel.org> References: <20231208220545.7452-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 08 Dec 2023 14:06:37 -0800 (PST) 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. Fixes: 9621fbee44df ("rcu: Move expedited grace period (GP) work to RT kthread_worker") Cc: Kalesh Singh 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 055f4817bc70..39679cf66c3a 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4717,6 +4717,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; } @@ -4725,6 +4726,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 6d7cea5d591f..cb31f4fb4b36 100644 --- a/kernel/rcu/tree_exp.h +++ b/kernel/rcu/tree_exp.h @@ -429,7 +429,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); } @@ -479,7 +484,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); } @@ -542,7 +552,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. */ @@ -957,7 +967,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 can_queue; unsigned long flags; struct rcu_exp_work rew; struct rcu_node *rnp; @@ -968,6 +978,9 @@ void synchronize_rcu_expedited(void) lock_is_held(&rcu_sched_lock_map), "Illegal synchronize_rcu_expedited() in RCU read-side critical section"); + can_queue = (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. @@ -997,7 +1010,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(!can_queue)) { /* Direct call during scheduler init and early_initcalls(). */ rcu_exp_sel_wait_wake(s); } else { @@ -1015,7 +1028,7 @@ void synchronize_rcu_expedited(void) /* Let the next expedited grace period start. */ mutex_unlock(&rcu_state.exp_mutex); - if (likely(!boottime)) + if (likely(can_queue)) synchronize_rcu_expedited_destroy_work(&rew); } EXPORT_SYMBOL_GPL(synchronize_rcu_expedited); -- 2.42.1