Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp816409rwi; Fri, 14 Oct 2022 08:58:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6SS0ms9gl12nY4vP2pQjGa3NANf9QVCHdDRKPB8+oXKNIAnkr6BwxB3YjM9uhwziKNygOE X-Received: by 2002:a17:907:971c:b0:78e:63f:c766 with SMTP id jg28-20020a170907971c00b0078e063fc766mr4122929ejc.330.1665763093110; Fri, 14 Oct 2022 08:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665763093; cv=none; d=google.com; s=arc-20160816; b=dtL13Jec66ErP5EvlkUAq03G5D+xAxcU+LM2b32gS1zFlrnjTaQK3SGaeMOP3t10QE evkKSZhrL8MmS6gUxhZg8i2QHjSFnQ9TJshoQuf2Dvc5eLO8D0PL58nydoTMSawQQ2S8 YK/9R/xDfG0S2xZ7EVXFp7MrUxozqb7u7B3b/GnHtzDDiaHjQUPMTkFBwAcUNQhQDmpX Q7dlNtdlnh7wBZ0g+lWVKLAEbaqJ7R18efMesJd5oaWMeklY5XEi7yd/G8iaMdTMiLY5 4Dq9W9WCFx49PlE0ys1XoZO74+MxaMpqvrTWuyEkaJ8rCx6QEFpbuGyhPJ7nVS6oOkE9 R0mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=8VViBIvGf0xLap4IT4osWFcZL4+V05jlWQOcRgU4244=; b=H3vSeeAmnyjsTTAXzG2h3bqF7HpHtMtYSW+0p2ooAyFIrNpxcD11Q1NFozOkPYm8nX tg4iUBWvBT1t1URDYw12RuhFuZLkDvrCg7d2FcPfpncTdyqmC+l0C8KMl5u3AlZMq59a KBVVqG7i3Bxm4qBEbMioZL0othhDL8t2gx1Pzx+DlBrldVZTu7zmxdwZlaKibvMqyoIJ 3WULOP6RmLJVPcxtZKnIMWbPyP6dbLnop+NP3NVVmmvHS684YJBPPVLZ6xiQ3tFPy4Ur CaLQ70QRVYRZ9EE0nq8zaA4A26/hVXNotav6HRnj3B+9PL/6I2HTu8HVbWJJHKaNILr9 /rqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=swLD2rfn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc4-20020a1709078a0400b0078d484e0e7esi2391590ejc.488.2022.10.14.08.57.40; Fri, 14 Oct 2022 08:58:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=swLD2rfn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231150AbiJNPqT (ORCPT + 99 others); Fri, 14 Oct 2022 11:46:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230375AbiJNPqM (ORCPT ); Fri, 14 Oct 2022 11:46:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3208236BD2; Fri, 14 Oct 2022 08:46:11 -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 765C261B87; Fri, 14 Oct 2022 15:46:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1483C433C1; Fri, 14 Oct 2022 15:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665762369; bh=JuumaXx2IxKYMQXfElyY3vL4dkIV4dwAE5VQdwWTIDw=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=swLD2rfnIQR1SIaYlYoumovcMVc0soI5XCUzffoIblIPGVfXHXMS/5EuhCcU+TDsp XwVgMdGgB15j4JbYC0HAA2RJMuigxJyeV/HdopMcEPoo4pyimXTuBk3G2RdMdn1Dr2 6OnatiwuFaBxG1ximcmHTEeyzGdd+ROMYru6uFW2YZxOM57eZA/00/nRMrrivUjWa0 +odq1WMQugA1UFaOgscNUwMi+onFIg2fpqLlscIMTbeMURyYuD5CXfFSThs2EwlGU+ FQFeUTnMmrsZiiX9ff9j5CO0R7af9cwZPmxMfWyxfyLYPXZCQHZVjcw9/lOQbPVViD 3yMG18JygqTgw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 96B215C32BF; Fri, 14 Oct 2022 08:46:06 -0700 (PDT) Date: Fri, 14 Oct 2022 08:46:06 -0700 From: "Paul E. McKenney" To: Joel Fernandes Cc: Frederic Weisbecker , rcu@vger.kernel.org, linux-kernel@vger.kernel.org, rushikesh.s.kadam@intel.com, urezki@gmail.com, neeraj.iitr10@gmail.com, rostedt@goodmis.org, youssefesmat@google.com, surenb@google.com Subject: Re: [PATCH v8 01/13] rcu: Fix missing nocb gp wake on rcu_barrier() Message-ID: <20221014154606.GJ4221@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20221011180142.2742289-1-joel@joelfernandes.org> <20221011180142.2742289-2-joel@joelfernandes.org> <20221014142127.GE4221@paulmck-ThinkPad-P17-Gen-1> <20221014144019.GB1108603@lothringen> <20221014150344.GG4221@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 14, 2022 at 11:19:28AM -0400, Joel Fernandes wrote: > On Fri, Oct 14, 2022 at 11:03 AM Paul E. McKenney wrote: > > > > On Fri, Oct 14, 2022 at 04:40:19PM +0200, Frederic Weisbecker wrote: > > > On Fri, Oct 14, 2022 at 07:21:27AM -0700, Paul E. McKenney wrote: > > > > On Tue, Oct 11, 2022 at 06:01:30PM +0000, Joel Fernandes (Google) wrote: > > > > > From: Frederic Weisbecker > > > > > > > > > > Upon entraining a callback to a NOCB CPU, no further wake up is > > > > > issued on the corresponding nocb_gp kthread. As a result, the callback > > > > > and all the subsequent ones on that CPU may be ignored, at least until > > > > > an RCU_NOCB_WAKE_FORCE timer is ever armed or another NOCB CPU belonging > > > > > to the same group enqueues a callback on an empty queue. > > > > > > > > > > Here is a possible bad scenario: > > > > > > > > > > 1) CPU 0 is NOCB unlike all other CPUs. > > > > > 2) CPU 0 queues a callback > > > > > > > > Call it CB1. > > > > > > > > > 2) The grace period related to that callback elapses > > > > > 3) The callback is moved to the done list (but is not invoked yet), > > > > > there are no more pending callbacks for CPU 0 > > > > > > > > So CB1 is on ->cblist waiting to be invoked, correct? > > > > > > > > > 4) CPU 1 calls rcu_barrier() and sends an IPI to CPU 0 > > > > > 5) CPU 0 entrains the callback but doesn't wake up nocb_gp > > > > > > > > And CB1 must still be there because otherwise the IPI handler would not > > > > have entrained the callback, correct? If so, we have both CB1 and the > > > > rcu_barrier() callback (call it CB2) in ->cblist, but on the done list. > > > > > > > > > 6) CPU 1 blocks forever, unless CPU 0 ever queues enough further > > > > > callbacks to arm an RCU_NOCB_WAKE_FORCE timer. > > > > > > > > Except that -something- must have already been prepared to wake up in > > > > order to invoke CB1. And that something would invoke CB2 along with CB1, > > > > given that they are both on the done list. If there is no such wakeup > > > > already, then the hang could occur with just CB1, without the help of CB2. > > > > > > Heh good point. I was confused with CB1 on RCU_DONE_TAIL and the possibility > > > for CB2 to be entrained on RCU_WAIT_TAIL. But that's indeed not supposed to > > > happen. Ok so this patch indeed doesn't make sense outside lazy. > > > > Whew!!! ;-) > > > > > > > This is also required to make sure lazy callbacks in future patches > > > > > don't end up making rcu_barrier() wait for multiple seconds. > > > > > > > > But I do see that the wakeup is needed in the lazy case, and if I remember > > > > correctly, the ten-second rcu_barrier() delay really did happen. If I > > Yes it did happen. Real world device testing confirmed it. Very good, thank you! > > > > understand correctly, for this to happen, all of the callbacks must be > > > > in the bypass list, that is, ->cblist must be empty. > > > > > > > > So has the scenario steps 1-6 called out above actually happened in the > > > > absence of lazy callbacks? > > > > > > Nope, so I guess we can have the pending check around rcu_nocb_flush_bypass() > > > only... > > > > OK, sounds good. > > > > I have put this series on branch lazy.2022.10.14a and am testing it. > > I agree with the discussion, though if all CBs are in the bypass list, > the patch will also save 2 jiffies. > > So just commit messages that need rework then? This one can be taken instead: > https://lore.kernel.org/rcu/21ECDA9F-81B1-4D22-8B03-020FB5DADA4F@joelfernandes.org/T/#m14d21fbce23539a521693a4184b28ddc55d7d2c5 This one looks plausible to me. Thanx, Paul