Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F16BC05027 for ; Mon, 6 Feb 2023 17:24:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230352AbjBFRYs (ORCPT ); Mon, 6 Feb 2023 12:24:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230284AbjBFRYg (ORCPT ); Mon, 6 Feb 2023 12:24:36 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D47E2D155 for ; Mon, 6 Feb 2023 09:24:14 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id bi36so18661104lfb.8 for ; Mon, 06 Feb 2023 09:24:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=sS0A0Czb9WxV1S+N4V3EYqAA6ZFJye37GWBGxAs3i/A=; b=cACepK4B4AmB8yeEpssioV1L+mOD8ewu64shYj2TBqsgc+0PB2qHClXuLe7R8qKcjp X5Uy0MDyroxlGGr9NjuMRauLdAHYGy59fOCkmtw34IRatzG40NHxEuit0PvgVak6sDLI cGk/D03z/sxjIRsfc3xNrauCSRi4XZsu7019g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=sS0A0Czb9WxV1S+N4V3EYqAA6ZFJye37GWBGxAs3i/A=; b=lopep5HeWXodOV1PxjmfQfnqOtxCQomyPKzh6qBF8GKsFeal6O9qkj0t4/XQvYfKnl lhqpKp84kn/9DUhl2Lwr94lziQSRlUH4AyuKMRglBkEtTmL7Yxz73XTPdqlNvVJ3/cCy YXPpnY/F/wFgogWtP8Xc0KT1vpoTa/0gFupKGJHa1taV6y7N8rc86LyO9I8GFarGn575 cdUncGVHbwWJ8mpHDfEVkb4x3kDCWTLzuhWj/ytMjKvw0u1dMsmWCooK+BVPO6wRG4Wb OLl2i+Yn4hK9LYDBoRvOgRx3fF/rni0n/0/SLzc/nqU4N6hMbxliiYZngjYCN1N2QQJb 0nHw== X-Gm-Message-State: AO0yUKUlbkKnYw/wm9m21Z2sSp4eHbICXxqFWeHercYz7U1NDapYzD5j 2eICaDBfOhOuZbwfM/MD5+BR/h0ps3l9T3wMrhkNDw== X-Google-Smtp-Source: AK7set/GspoK7qZ5ikAe2UrLJRpGdSd3YUTtughky3DwdCYJoF6bvWrfLL1QDGuCiNEXI7KiIStNE+igcDXMLVWYHuk= X-Received: by 2002:a05:6512:3d29:b0:4d5:7655:95db with SMTP id d41-20020a0565123d2900b004d5765595dbmr4422124lfv.57.1675704252413; Mon, 06 Feb 2023 09:24:12 -0800 (PST) MIME-Version: 1.0 References: <20230204022051.2737724-1-joel@joelfernandes.org> In-Reply-To: From: Joel Fernandes Date: Mon, 6 Feb 2023 12:24:00 -0500 Message-ID: Subject: Re: [PATCH] rcu/tree: Improve comments in rcu_report_qs_rdp() To: "Zhang, Qiang1" Cc: "linux-kernel@vger.kernel.org" , Frederic Weisbecker , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , "Paul E. McKenney" , "rcu@vger.kernel.org" , Steven Rostedt , Boqun Feng Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 6, 2023 at 12:19 PM Joel Fernandes wrote: > > On Sun, Feb 5, 2023 at 10:09 PM Zhang, Qiang1 wrote: > > > > > > >Recent discussion triggered due to a patch linked below, from Qiang, > > >shed light on the need to accelerate from QS reporting paths. > > > > > >Update the comments to capture this piece of knowledge. > > > > > >Link: https://lore.kernel.org/all/20230118073014.2020743-1-qiang1.zhang@intel.com/ > > >Cc: Qiang Zhang > > >Cc: Frederic Weisbecker > > >Signed-off-by: Joel Fernandes (Google) > > > > > >--- > > > kernel/rcu/tree.c | 13 ++++++++++++- > > > 1 file changed, 12 insertions(+), 1 deletion(-) > > > > > >diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > >index 93eb03f8ed99..713eb6ca6902 100644 > > >--- a/kernel/rcu/tree.c > > >+++ b/kernel/rcu/tree.c > > >@@ -1983,7 +1983,12 @@ rcu_report_qs_rdp(struct rcu_data *rdp) > > > } else { > > > /* > > > * This GP can't end until cpu checks in, so all of our > > >- * callbacks can be processed during the next GP. > > >+ * callbacks can be processed during the next GP. Do > > >+ * the acceleration from here otherwise there may be extra > > >+ * grace period delays, as any accelerations from rcu_core() > > > > > > Does the extra grace period delays means that if not accelerate callback, > > the grace period will take more time to end ? or refers to a delay in the > > start time of a new grace period? > > Yes, so IMO it is like this if we don't accelerate: > 1. Start GP 1 > 2. CPU1 queues callback C1 (not accelerated yet) > 3. CPU1 reports QS for GP1 (not accelerating anything). > 4. GP1 ends > 5. CPU1's note_gp_changes() is called, accelerate happens, now the CB > will execute after GP3 (or alternately, rcu_core() on CPU1 does > accelerate). > 6. GP2 ends. > 7. GP3 starts. > 8. GP3 ends. > 9. CB is invoked > > Instead, what we will get the following thanks to the acceleration here is: > 1. Start GP 1 > 2. CPU1 queues callback C1 (not accelerated yet) > 3. CPU1 reports QS for GP1 and acceleration happens as done by the > code this patch adds comments for. > 4. GP1 ends > 5. CPU1's note_gp_changes() is called > 6. GP2 ends. > 7. CB is invoked Sorry I missed some steps, here is the update: 1. Start GP 1 2. CPU1 queues callback C1 (not accelerated yet) 3. CPU1 reports QS for GP1 (not accelerating anything). 4. GP1 ends 5. GP2 starts for some other reason from some other CPU. 6. CPU1's note_gp_changes() is called, acceleration happens, now the CB will execute after GP3. 7. GP2 ends. 8. GP3 starts. 9. GP3 ends. 10. CB is invoked Instead, what we will get the following thanks to the acceleration here is: 1. Start GP 1 2. CPU1 queues callback C1 (not accelerated yet) 3. CPU1 reports QS for GP1 and acceleration happens as done by the code this patch adds comments for. 4. GP1 ends 5. GP2 starts 6. GP2 ends. 7. CB is invoked Does that make sense or is there a subtlety I missed? Thanks, - Joel