Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp809512pxb; Thu, 31 Mar 2022 18:57:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzBPNfkkOov/efuI5OxdX5ElGuqjeVqJaMRdNbiEBgSDv80sfXxQ1wtY2Iwuy8iBYX10Mx X-Received: by 2002:a05:6a00:1589:b0:4fb:e7c:7c53 with SMTP id u9-20020a056a00158900b004fb0e7c7c53mr8356397pfk.78.1648778250478; Thu, 31 Mar 2022 18:57:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648778250; cv=none; d=google.com; s=arc-20160816; b=K3I9Fe21ys7b1gi256oEbvmqmnWHH3TXicLxzqCDVDIx8X5Ef9u5VNtOnS7u5W4K2Q NFel+wBeTh4TbY5iHTW5ljp5NZuGy2/pFzHnn88dGZnI6eOAlVQpTgX/yToXYdTaXU6Y yY+AiO9uZ+JOYjCvOFYtj1kstizfDhEGe+8I7YYg/iePp1mX4gFIb8yjZQ+kmtb/GOjk 2iG9Bc0nW+s6bpcb7WhC+gkfu+wjfo1m2uLg8g/HwW1Pq7NKWoEdpvjk3fc7yQlZHPWW n3Ylk/ZJVmMzYaT1fhwAttxuj58LTLHyNVCzRV7BasJzTgJXGxzmNuzwfUrNELKdGxKg cupw== 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=SMPrQwRP1sBgF9+FNHNYNiMpJQOs6FhsYJB6Fzdueso=; b=y39nUV9dtZ4IXQQf+iI1AwIKeHkjTuX1WEbLBJhZh/xANptfQV/1jA9T3JIxgkhIqp QDyVoc8xvg/rDb0XYhVOjfxOgz6qDi+TpfOYNcyT3trVKk4TZBM0fF7B8XcbobtMaRJD 1y9va/Qnot682ztZqZQ8yDd7EWnOYStgp7PlKjlpDRyu0rPHUtUKt+qTsslMr1jyVE/m X7pKK1heZL/aSWSH4l7DSu8MRToWkDZsf01pRKRDQqK4IDeFrpiE9ITrhL1YFDgEAMqB pQk1XHp7IYf+OOpQY2CEEE9sHZGaWoKsi1iYX4rNM8geG++Ii6yJ/38wMZIExBe1lw1p FlAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jb3C3btk; 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 f194-20020a6238cb000000b004fa3a8dfffcsi978094pfa.179.2022.03.31.18.57.17; Thu, 31 Mar 2022 18:57:30 -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=Jb3C3btk; 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 S230376AbiCaRbf (ORCPT + 99 others); Thu, 31 Mar 2022 13:31:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230220AbiCaRbe (ORCPT ); Thu, 31 Mar 2022 13:31:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61AA342A02; Thu, 31 Mar 2022 10:29:46 -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 ams.source.kernel.org (Postfix) with ESMTPS id 0FADAB8218F; Thu, 31 Mar 2022 17:29:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A66F5C340ED; Thu, 31 Mar 2022 17:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648747783; bh=h1XiuSYIgdAIxUaaBOhGB1kjwsbePEAFlHK5pZHYeHg=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=Jb3C3btk8HoND9C9FXrW7dJkMaAFpA96M6WhPjMQxob+JlxbgOHgLd1zZJ7HqxlSo 7jN24x5AU2Rd7mS/+7FHMmRGWodqpBeOR6xJdWQCV506kPxJ5HB44IG4xid44kCew9 ROgz2b2IGQrOrFVYg6pVKrYhezemTUopl6sPCESpBtm6Vg3F2x9pxvM9OC6jd7J5bP N515B3kEKYtjS5oTYYMgPU+lyywZD7Xkov914XW3mcNOeyNv7NPMZR9kyan0Msx4uq UG57iq5hJHpTS5KP8UziwgaOotIty7nkzGEl4tGyFFs0D1LJ7M+qIUAU3fjbPlfWsu ZMUqSN2FmZsZg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 458EC5C0A0E; Thu, 31 Mar 2022 10:29:43 -0700 (PDT) Date: Thu, 31 Mar 2022 10:29:43 -0700 From: "Paul E. McKenney" To: "Zhang, Qiang1" Cc: "frederic@kernel.org" , "rcu@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] rcu: Put the irq work into hard interrupt context for execution Message-ID: <20220331172943.GV4285@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20220330060012.2470054-1-qiang1.zhang@intel.com> <20220330201620.GM4285@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,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: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 30, 2022 at 10:47:05PM +0000, Zhang, Qiang1 wrote: > On Wed, Mar 30, 2022 at 02:00:12PM +0800, Zqiang wrote: > > In PREEMPT_RT kernel, if irq work flags is not set, it will be > > executed in per-CPU irq_work kthreads. set IRQ_WORK_HARD_IRQ flags to > > irq work, put it in the context of hard interrupt execution, > > accelerate scheduler to re-evaluate. > > > > Signed-off-by: Zqiang > > --- > > kernel/rcu/tree.c | 2 +- > > kernel/rcu/tree_plugin.h | 2 +- > > 2 files changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index > > e2ffbeceba69..a69587773a85 100644 > > --- a/kernel/rcu/tree.c > > +++ b/kernel/rcu/tree.c > > @@ -678,7 +678,7 @@ static void late_wakeup_func(struct irq_work > > *work) } > > > > static DEFINE_PER_CPU(struct irq_work, late_wakeup_work) = > > - IRQ_WORK_INIT(late_wakeup_func); > > + IRQ_WORK_INIT_HARD(late_wakeup_func); > > >This is used only by rcu_irq_work_resched(), which is invoked only by rcu_user_enter(), which is never invoked until userspace is enabled, by which time all of the various kthreads will have been spawned, correct? > > > >Either way, please show me the exact sequence of events that lead to a problem with the current IRQ_WORK_INIT(). > > > > /* > > * If either: > > diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index > > 3037c2536e1f..cf7bd28af8ef 100644 > > --- a/kernel/rcu/tree_plugin.h > > +++ b/kernel/rcu/tree_plugin.h > > @@ -661,7 +661,7 @@ static void rcu_read_unlock_special(struct task_struct *t) > > expboost && !rdp->defer_qs_iw_pending && cpu_online(rdp->cpu)) { > > // Get scheduler to re-evaluate and call hooks. > > // If !IRQ_WORK, FQS scan will eventually IPI. > > - init_irq_work(&rdp->defer_qs_iw, rcu_preempt_deferred_qs_handler); > > + rdp->defer_qs_iw = > > +IRQ_WORK_INIT_HARD(rcu_preempt_deferred_qs_handler); > > rdp->defer_qs_iw_pending = true; > > irq_work_queue_on(&rdp->defer_qs_iw, rdp->cpu); > > } > > > >OK, in theory, rcu_read_unlock() could get to this point before all of the various kthreads were spawned. In practice, the next time that the boot CPU went idle, the end of the quiescent state would be noticed. > > Through my understanding, use irq_work in order to make the quiescent state be noticed earlier, > Because the irq_work execute in interrupt, this irq_work can be executed in time, but In RT kernel > The irq_work is put into the kthread for execution, when it is executed, it is affected by the scheduling delay. > Is there anything I missed? Yes, in that I am not seeing any actual data showing that this fix really makes things better. Please in mind that IRQ_WORK_INIT_HARD does have performance disadvantages of its own. So although I agree with your words saying that IRQ_WORK_INIT_HARD -might- be helpful, those words are not sufficient. So, can you show a statistically significant benefit on a real system? For example, by measuring the time required for a expedited grace period to complete? That would argue for this change, though it would need to be conditional, so that systems that don't care that much about the latency of expedited RCU grace periods don't need to pay the IRQ_WORK_INIT_HARD performance penalties. Or you would need to demonstrate that these performance penalties don't cause problems. (But such a demonstration is not easy given the wide variety of systems that Linux supports.) Now, I could imagine that the current code could cause problems during boot on CONFIG_PREEMPT_RT kernels. But, believe me, I can imagine all sorts of horrible problems. But we should fix those that happen not just in my imagination, but also in the real world. ;-) So if you can make such a problem happen in real life, then I would be happy to take a patch that fixed this on CONFIG_PREEMPT_RT but kept the current code otherwise. Thanx, Paul > Thanks > Zqiang > > > > >Or has this been failing in some other manner? If so, please let me know the exact sequence of events. > > > > Thanx, Paul