Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4747595rdb; Tue, 12 Dec 2023 08:15:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGy4CRBl0isR/40rDae5wcUmZVhXkq51Z5BAVU3VG6XSmNU+46brS+IfWwTzq0mJTZSpaL3 X-Received: by 2002:a05:6a20:f390:b0:190:6920:e14b with SMTP id qr16-20020a056a20f39000b001906920e14bmr6153280pzb.122.1702397703246; Tue, 12 Dec 2023 08:15:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702397703; cv=none; d=google.com; s=arc-20160816; b=0G8jsLlaftwaq4PmZigZsgSR6mYb4xJTiahW2vDDyzMNfwWkOFBl4atKlV40TTUurd gWyvsqXyDcqr830oKYwf/DvPIJ6LE2lCXl+hjNGkyipOs2pDyU2ZfsMZnqfEBfwuV/ja 0NHs8JWte0HbhAysun0cf9G+pZj57sN1aJhsC6iH2jouerWxMyjt3Yxn7g07qOacjXhe +7o52vR84Lj961rGo8VFtPWqDNCB3ZEKN58g45eRyp04oh+GInIJwwOhsxu0mcaz9a/w AIQP/H0RaGB4q2sXysBIoN4gsnz01cvLSpp1WSU8MT3jJdpdEBlYS6piJnDuux1icH+L BU/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=4+KqdeA+ayPueTXRbDqPJvGB/NHejJMBX/m1tCj9sbw=; fh=j19A0/VN1W+hj4MGMIFhpUByA0GoqGuUADpQqubhNds=; b=Z4Z8bfLNSpRF1vWhE8vOgYfZNwj/6k1GqX2nq0O5klGFv4o1Y6j+aAe7BVIVGOj4W1 E2w6dfRpsruDG77vYz4Bu4jiF8NdZJl1lW8fkM6iq9vPsT6Snw5KqkR+qmvemk7dUhM9 iCvC4Agf3Lm7+7itC/l9/kNHNorzCHdafTbasW6ZsOFDqdJGiuqRV2x2luHLmLJ6N7Xh 3owFokvWQf67mBNhIs+YLkbjIBvUcw94Ebr6m2VzdBy0v6UkEBHoS3rIiPux2ytatTDo ctzqXaqSH09fZpR4m+1lE+6ihmSzwe1NTQRC+0tCw0+3dU3DNBm3eXp6qmPA9KNgh7Bk 2MIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CjhpNPQn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id z20-20020a656654000000b005b8f446408bsi7819307pgv.422.2023.12.12.08.15.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 08:15:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CjhpNPQn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2B46480A28FD; Tue, 12 Dec 2023 08:15:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232575AbjLLQOk (ORCPT + 99 others); Tue, 12 Dec 2023 11:14:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232529AbjLLQOj (ORCPT ); Tue, 12 Dec 2023 11:14:39 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ECB4C3 for ; Tue, 12 Dec 2023 08:14:45 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-551d5cd1c42so4194a12.0 for ; Tue, 12 Dec 2023 08:14:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702397683; x=1703002483; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=4+KqdeA+ayPueTXRbDqPJvGB/NHejJMBX/m1tCj9sbw=; b=CjhpNPQnMdSfwXoXcKA+pIfjlo2kfAzCePL1rAlHfnlZoGF9HReaipOXValH1ZeqHU Tq8ZAu9PAsluboSaMIRbGk8i4kA4KUVuzfyWLCf57S/vf1b2qAnUqiJ6b/8gGh+3pOy+ w2RQQmp7oqeVaCjIqOj/fITm21yhC86cD6LD6/Sd8EaUB3dJw7+STiKarpuC5c2WMIfo rg1VusBNmbNMfUoH5ZRWnRV0yOhSCdGL0Qs2yaTZhXJ7vL5uE2brXUtjgP6Xup+bBFHB zhqCPTLAqamOCgwOKky4dmcUYngdEMprU5hAmJqB2NsoZT6aU00H06YoEGKSv3yWYdkW WFug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702397683; x=1703002483; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4+KqdeA+ayPueTXRbDqPJvGB/NHejJMBX/m1tCj9sbw=; b=mcfcM9EO33dhF9/bi4QpMWz1nd0AF2P+mrVNzgpcBKbxwCyQKStvM5YpY94CPTN3zM YxzJcMi58U1jv/9Ma9+0h3vykxNzt3i3Ue6nmOdrrVjvDZ9z4V0eeWuBD/NLU+/i03uh VBVTXoqSA18zn2dc2bvGIpEPlnJSLs/TjIn6oRSNxMspXHcZddna1HB+vZ153KffbJIN CT3XQPjLdM3NdrAueIkQ1X71hSHHtghC6FZIwHwvP5qcMCUcPnvkscCNaIHQPKDLOWvJ x86ZoUbkWuhUXuzw5s7jGNvbtrRt80U4Dc09NilOahPPe9xMvBSoNlSCyUJCfwLdWE3c bh4A== X-Gm-Message-State: AOJu0Yyli3Ffys9algqAch/QrJoA9KhXrMxuRDkxY1Muz29c4nlKfOB2 4nSGkDEVVc2Rdqg8H83zp+7vO/DmdH4loZdpF7DE3A== X-Received: by 2002:a50:c092:0:b0:543:fb17:1a8 with SMTP id k18-20020a50c092000000b00543fb1701a8mr336717edf.3.1702397683342; Tue, 12 Dec 2023 08:14:43 -0800 (PST) MIME-Version: 1.0 References: <20231208220545.7452-1-frederic@kernel.org> <20231208220545.7452-5-frederic@kernel.org> In-Reply-To: <20231208220545.7452-5-frederic@kernel.org> From: Kalesh Singh Date: Tue, 12 Dec 2023 11:14:31 -0500 Message-ID: Subject: Re: [PATCH 4/8] rcu/exp: Handle RCU expedited grace period kworker allocation failure To: Frederic Weisbecker Cc: LKML , Boqun Feng , Joel Fernandes , Neeraj Upadhyay , "Paul E . McKenney" , Uladzislau Rezki , Zqiang , rcu , Anna-Maria Behnsen , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Tue, 12 Dec 2023 08:15:00 -0800 (PST) On Fri, Dec 8, 2023 at 5:06=E2=80=AFPM Frederic Weisbecker wrote: > > 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 kt= hread_worker") > Cc: Kalesh Singh > Signed-off-by: Frederic Weisbecker Reviewed-by: Kalesh Singh Thanks, Kalesh > --- > 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 =3D 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 =3D 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 =3D NULL; > kthread_destroy_worker(rcu_exp_gp_kworker); > + rcu_exp_gp_kworker =3D 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 kth= read_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 wor= k_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 =3D 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 !=3D 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(struc= t rcu_node *rnp) > */ > void synchronize_rcu_expedited(void) > { > - bool boottime =3D (rcu_scheduler_active =3D=3D 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 =3D (rcu_scheduler_active !=3D 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 >