[3/8] rcu/exp: Fix RCU expedited parallel grace period kworker allocation failure recovery
Message ID | 20231208220545.7452-4-frederic@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5746054vqy; Fri, 8 Dec 2023 14:06:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFTDWLxpHRBMZF+m2QRKJ3oZEXb7qLvZ8BJPVlLqNvyid0uBocHNp5FTpa++MWKch2qJoCr X-Received: by 2002:a05:6a20:7f83:b0:18b:594a:284c with SMTP id d3-20020a056a207f8300b0018b594a284cmr1935788pzj.15.1702073204408; Fri, 08 Dec 2023 14:06:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702073204; cv=none; d=google.com; s=arc-20160816; b=MrJS2djP+VVOLk+iIJlOndnbBEc/5eXFnujQ5+QJ4fzZlS8B/WGxQmU6fadvpCkkKd 92naq/Vh/KY97m8MZfjvz9pArpR5e0ZmusHqqnVM5x8qqm4REhxyhQsOopKCn+TLz79R nFUgD6mjxPLzfWqUD4BONHeBZaBTc9KsYrv5qvqYAu26vW1SHYgJTBD8TLGac1YF5a9Y CL+ncJWk0ANNps68cKYZhVx+KVioriCHkF9QvWizs1MssjluGXFYRA35cpB50fIu6/EW Jo5dfgNMan8eyZwmaR2brEgJkWwItrp2DgAo5uWjd/9gQCp4cJwUL2ESh7Cp5dgVSmY4 cZ/Q== 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=Uh5OANqX7FMWY3V9rBp+IcxRcWoBA18zMMXCxoygkls=; fh=z8Ne2JrnnXKUY28f9pwEdqls7nShSFwQTzvJMmkinP0=; b=DW/f9UDOfL2hAJZ3Luoxejq05zcwnqpWws1aZEUhdwtuyzyrHqlWb8me30ugjIbmI1 YLlhhQgmRhJMJFkxfthW9n4IEwzQuv8YEB4YBnPVDpIR/BfhsU3IdxUIEg0Lz/EOpXZn rFORuU/fGUeUK9efHcSCdskhWyljoLRq7K1PrBd4IKZVyehtKvWP+NGVM9Fo48eXaib6 xvVxbnoPvXqNHb5Q0A93861cplCRCSlTWirx98nCPN3/e62g39jg8uCzCVCFYmdJQOEh OxwvEllXRSa9KayAuG/Xa24OUJPxE5mdIZ1avKsvYyuSH0HC6EeHeesUQ1CCrcrYWx45 BeuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VXojr6rg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id m128-20020a632686000000b005c66e00ffccsi2133441pgm.260.2023.12.08.14.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 14:06:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VXojr6rg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 7D351802FD33; Fri, 8 Dec 2023 14:06:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574867AbjLHWGQ (ORCPT <rfc822;makky5685@gmail.com> + 99 others); Fri, 8 Dec 2023 17:06:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1574886AbjLHWFz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 8 Dec 2023 17:05:55 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A980E1712 for <linux-kernel@vger.kernel.org>; Fri, 8 Dec 2023 14:06:01 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8C95C433C7; Fri, 8 Dec 2023 22:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702073161; bh=6Rj2/Ew9i8og8UV1rs/YRIIkk8Z14PNfosvKFa7ip4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VXojr6rgF4CVtj1/yBPc4JDT25DImi7RK6bjPnZ/E9+OwRt5xlCa7VBBdmwAuZRQk aSMyIc9cocqzJ7LMudOAEPf9o4ryZal2Oa/HV7IOcfmPXz4JSTHA6hflKzWJ/j5U04 47RHygrGazdzJEjuHxp0zlfgxtpGTF+qVfmMzN8SY2ZLR55GpJobnvyxwHk7UYALl7 4STCMLMjN779SK0D/wWSsCw1K+XE/WQfSuIe67z0e0HnM3EUh57lV7WsdRJ2iUezAj fb1y3eftmg/tb2vDlQw7dP4H+Gb2wIPAd2efJnXF2+n9aW8kKJTT1tmwcbg5O9rDhc iINxxKaf0URqg== From: Frederic Weisbecker <frederic@kernel.org> To: LKML <linux-kernel@vger.kernel.org> Cc: Frederic Weisbecker <frederic@kernel.org>, Boqun Feng <boqun.feng@gmail.com>, Joel Fernandes <joel@joelfernandes.org>, Neeraj Upadhyay <neeraj.upadhyay@amd.com>, "Paul E . McKenney" <paulmck@kernel.org>, Uladzislau Rezki <urezki@gmail.com>, Zqiang <qiang.zhang1211@gmail.com>, rcu <rcu@vger.kernel.org>, Anna-Maria Behnsen <anna-maria.behnsen@linutronix.de>, Thomas Gleixner <tglx@linutronix.de>, Kalesh Singh <kaleshsingh@google.com> Subject: [PATCH 3/8] rcu/exp: Fix RCU expedited parallel grace period kworker allocation failure recovery Date: Fri, 8 Dec 2023 23:05:40 +0100 Message-ID: <20231208220545.7452-4-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=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 08 Dec 2023 14:06:26 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784753112570783747 X-GMAIL-MSGID: 1784753112570783747 |
Series |
rcu: Fix expedited GP deadlock (and cleanup some nocb stuff)
|
|
Commit Message
Frederic Weisbecker
Dec. 8, 2023, 10:05 p.m. UTC
Under CONFIG_RCU_EXP_KTHREAD=y, the nodes initialization for expedited
grace periods is queued to a kworker. However if the allocation of that
kworker failed, the nodes initialization is performed synchronously by
the caller instead.
Now the check for kworker initialization failure relies on the kworker
pointer to be NULL while its value might actually encapsulate an
allocation failure error.
Make sure to handle this case.
Fixes: 9621fbee44df ("rcu: Move expedited grace period (GP) work to RT kthread_worker")
Cc: Kalesh Singh <kaleshsingh@google.com>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
kernel/rcu/tree.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Fri, Dec 8, 2023 at 5:06 PM Frederic Weisbecker <frederic@kernel.org> wrote: > > Under CONFIG_RCU_EXP_KTHREAD=y, the nodes initialization for expedited > grace periods is queued to a kworker. However if the allocation of that > kworker failed, the nodes initialization is performed synchronously by > the caller instead. > > Now the check for kworker initialization failure relies on the kworker > pointer to be NULL while its value might actually encapsulate an > allocation failure error. > > Make sure to handle this case. > > Fixes: 9621fbee44df ("rcu: Move expedited grace period (GP) work to RT kthread_worker") > Cc: Kalesh Singh <kaleshsingh@google.com> > Signed-off-by: Frederic Weisbecker <frederic@kernel.org> > --- > kernel/rcu/tree.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 82f8130d3fe3..055f4817bc70 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -4723,6 +4723,7 @@ static void __init rcu_start_exp_gp_kworkers(void) > rcu_exp_par_gp_kworker = kthread_create_worker(0, par_gp_kworker_name); > if (IS_ERR_OR_NULL(rcu_exp_par_gp_kworker)) { > pr_err("Failed to create %s!\n", par_gp_kworker_name); > + rcu_exp_par_gp_kworker = NULL; > kthread_destroy_worker(rcu_exp_gp_kworker); Hi Frederic, Thanks for catching this. I think we need to remove the kthread_destroy_worker() in this case too. Otherwise, Reviewed-by: Kalesh Singh <kaleshsingh@google.com> --Kalesh > return; > } > -- > 2.42.1 >
On Tue, Dec 12, 2023 at 11:04 AM Kalesh Singh <kaleshsingh@google.com> wrote: > > On Fri, Dec 8, 2023 at 5:06 PM Frederic Weisbecker <frederic@kernel.org> wrote: > > > > Under CONFIG_RCU_EXP_KTHREAD=y, the nodes initialization for expedited > > grace periods is queued to a kworker. However if the allocation of that > > kworker failed, the nodes initialization is performed synchronously by > > the caller instead. > > > > Now the check for kworker initialization failure relies on the kworker > > pointer to be NULL while its value might actually encapsulate an > > allocation failure error. > > > > Make sure to handle this case. > > > > Fixes: 9621fbee44df ("rcu: Move expedited grace period (GP) work to RT kthread_worker") > > Cc: Kalesh Singh <kaleshsingh@google.com> > > Signed-off-by: Frederic Weisbecker <frederic@kernel.org> > > --- > > kernel/rcu/tree.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > index 82f8130d3fe3..055f4817bc70 100644 > > --- a/kernel/rcu/tree.c > > +++ b/kernel/rcu/tree.c > > @@ -4723,6 +4723,7 @@ static void __init rcu_start_exp_gp_kworkers(void) > > rcu_exp_par_gp_kworker = kthread_create_worker(0, par_gp_kworker_name); > > if (IS_ERR_OR_NULL(rcu_exp_par_gp_kworker)) { > > pr_err("Failed to create %s!\n", par_gp_kworker_name); > > + rcu_exp_par_gp_kworker = NULL; > > kthread_destroy_worker(rcu_exp_gp_kworker); > > Hi Frederic, > > Thanks for catching this. I think we need to remove the > kthread_destroy_worker() in this case too. Ahh sorry, that's the other kworker. LGTM. Thanks. > > Otherwise, > > Reviewed-by: Kalesh Singh <kaleshsingh@google.com> > > --Kalesh > > > return; > > } > > -- > > 2.42.1 > >
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 82f8130d3fe3..055f4817bc70 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4723,6 +4723,7 @@ static void __init rcu_start_exp_gp_kworkers(void) rcu_exp_par_gp_kworker = kthread_create_worker(0, par_gp_kworker_name); if (IS_ERR_OR_NULL(rcu_exp_par_gp_kworker)) { pr_err("Failed to create %s!\n", par_gp_kworker_name); + rcu_exp_par_gp_kworker = NULL; kthread_destroy_worker(rcu_exp_gp_kworker); return; }