Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1152798lqt; Tue, 19 Mar 2024 14:32:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWg8wKrt+iWXyigAa4jBvdsoHpyE0LGhlYR+JBWL3phKcbpYUaZG1poMgHcEr7MIQN3nl2SbegmiythbEjx/2XtqKNmIO4h5CggPqbncw== X-Google-Smtp-Source: AGHT+IF2GR9Af6465+a9WeWkhZmAeo1lHmX6u3Rg2yuWdNd83PX0XSKt1VMEYeY2+552cNL+dTvv X-Received: by 2002:a0c:f882:0:b0:690:b9a7:7c72 with SMTP id u2-20020a0cf882000000b00690b9a77c72mr16582964qvn.42.1710883924365; Tue, 19 Mar 2024 14:32:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710883924; cv=pass; d=google.com; s=arc-20160816; b=h8qIaQUWcGXOGoz0Ktm2FsNCFjcz+NRviebglucawXtHacvnvoD7W692g47mA4oRsk U1Ie30ofB0LELUD5qL7JdODj1ipC/Mn5Q2NLc+9T70iTm4X+rraurLteZzRUUos1jF7P S8aTBrIuQWXXJX0MlvwmvSBnClcf6plMoqLgsDcYrDVhf9yVen2zVc6/Myl3d7psO7Qy bC/a44sTiI3nMTjgOkmgdTrIYx+bqeSLkUwUGkJxZKpUa9Op/ubRBX/4eVs1qq14gTeX Dq54umSmS4FXcvGIckTl+3uXYg1wE9w8BnbRv7UkoP5tuFRAr+FERlUophT2azV4AtyA 4uBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=vovbbIk3I9MypCS1fPMg7nB16N56zxs7aMygQC+y+Bk=; fh=IPfoympBUn2hmjH/3zoAae5/cm+1JOfoMlFH2h+zs8Q=; b=hc676fjZuU6+xdi3VAeO9KdBmQtkinO6wAdgkDtrXGbAu9rrxQeOxcSZYP0Z/RVM7f 40CJW8jPo33kGR1FoLJChXU3PXwYY46lgCfuj1gWMv3Ma+o4tu+WwVQQqSxhwG4xl78y vpgnSZZuwGBAtuy69f5MurUqQbvLK5ZSMnPSGVxJ+jIxHQy7zkc4/eNN2UyNEXrkZMxv UnuTFDMNKu6AIERRkrkdSV2p+BSgEqy+undOeB5DE9M/9FOduYSYM1qtdUssmGoilQ24 3pY9a9omg6L5VJrL3q06zyvizEtltEzc9BRRZYktnhhTFLjsH5If64d1fD3tEt8Odvur IK8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gNqxTTDm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-108154-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108154-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jn9-20020ad45de9000000b00696140e2878si5784765qvb.240.2024.03.19.14.32.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 14:32:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108154-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gNqxTTDm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-108154-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108154-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1A1201C222F5 for ; Tue, 19 Mar 2024 21:32:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CD8F4EB55; Tue, 19 Mar 2024 21:31:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gNqxTTDm" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E4AF3FBBF; Tue, 19 Mar 2024 21:31:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710883915; cv=none; b=iQyutkMj49GOMucjWH+yrNSqFjYHacUtjQh19w2k5/iAS9rw5OsChS+xktRaRiSarzo00EEHL28erlq5Z4RT1VM1PY9v2Pm8FylLTOel/AJvPTAGLjzuk5Rzj9Q5dYLf2X10UWahppbQq8+9AYwxYlBkcKnffPP3ZEcayf+k6N4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710883915; c=relaxed/simple; bh=fUaALyLJ2vU18yvgwRSHObW1ENVTzQxDLGlJ50YixzU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AZadhEQii6lTwC7fhxV0psnDELtKy7MWhQW4USh4o9WpK+dB/eCQYZoNqpQ7e5UqEX6jRXoqMzwu7R+mFrW9+sRGAHsdn0RXZrAz+N86Y5FbSMTNCoynduFrHrt+G2Rw4DgdUIxm+/+4Y6puYqRtjgDij0Kl7XywO/F1S6NXIo4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gNqxTTDm; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49AF9C433C7; Tue, 19 Mar 2024 21:31:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710883914; bh=fUaALyLJ2vU18yvgwRSHObW1ENVTzQxDLGlJ50YixzU=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=gNqxTTDm2rAVbiV2JjEQ55WiDnbEqbvhFrgXjeSj/7E0j/hVfMyE15Ocidyef4VIc Uat8d4qhOkfOolvFjBxsk54tqQCwgx6f0RTaAbSK4c4ecOMcT27iyEUkClsGEgvjIj 646ddwAbhWPhJssYtzGlEFr+W+F0nWEZL1fqBFay/o0WylnzGqblvFXqO3fRszR//F eJ9a6cMUzdPWxGklY5H49oG7E5ePfQxOT5CQ8ZoS5+BocQHlYnfPViuwcG/QneJjIs 1RFl9YXQcruJvWSffyc0oiGBVn05ugJF8Fs3XpMK4FbM54WwLq1QErkmAP73TyugyR Jaqe+J8eMr6gA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 7D064CE16D7; Tue, 19 Mar 2024 14:31:51 -0700 (PDT) Date: Tue, 19 Mar 2024 14:31:51 -0700 From: "Paul E. McKenney" To: Yan Zhai Cc: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Simon Horman , Daniel Borkmann , Lorenzo Bianconi , Coco Li , Wei Wang , Alexander Duyck , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, bpf@vger.kernel.org, kernel-team@cloudflare.com, Joel Fernandes , Toke =?iso-8859-1?Q?H=F8iland-J=F8rgensen?= , Alexei Starovoitov , Steven Rostedt , mark.rutland@arm.com, Jesper Dangaard Brouer , Sebastian Andrzej Siewior Subject: Re: [PATCH v5 net 1/3] rcu: add a helper to report consolidated flavor QS Message-ID: <6149ecfc-2a3b-4bea-a79f-ef5be0a36cd7@paulmck-laptop> Reply-To: paulmck@kernel.org References: <90431d46ee112d2b0af04dbfe936faaca11810a5.1710877680.git.yan@cloudflare.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <90431d46ee112d2b0af04dbfe936faaca11810a5.1710877680.git.yan@cloudflare.com> On Tue, Mar 19, 2024 at 01:44:34PM -0700, Yan Zhai wrote: > When under heavy load, network processing can run CPU-bound for many > tens of seconds. Even in preemptible kernels (non-RT kernel), this can > block RCU Tasks grace periods, which can cause trace-event removal to > take more than a minute, which is unacceptably long. > > This commit therefore creates a new helper function that passes through > both RCU and RCU-Tasks quiescent states every 100 milliseconds. This > hard-coded value suffices for current workloads. > > Suggested-by: Paul E. McKenney > Reviewed-by: Jesper Dangaard Brouer > Signed-off-by: Yan Zhai If you would like me to take this one via -rcu, I would be happy to take it. If it would be easier for you to push these as a group though networking: Reviewed-by: Paul E. McKenney > --- > v4->v5: adjusted kernel docs and commit message > v3->v4: kernel docs error > > --- > include/linux/rcupdate.h | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h > index 16f519914415..17d7ed5f3ae6 100644 > --- a/include/linux/rcupdate.h > +++ b/include/linux/rcupdate.h > @@ -247,6 +247,37 @@ do { \ > cond_resched(); \ > } while (0) > > +/** > + * rcu_softirq_qs_periodic - Report RCU and RCU-Tasks quiescent states > + * @old_ts: jiffies at start of processing. > + * > + * This helper is for long-running softirq handlers, such as NAPI threads in > + * networking. The caller should initialize the variable passed in as @old_ts > + * at the beginning of the softirq handler. When invoked frequently, this macro > + * will invoke rcu_softirq_qs() every 100 milliseconds thereafter, which will > + * provide both RCU and RCU-Tasks quiescent states. Note that this macro > + * modifies its old_ts argument. > + * > + * Because regions of code that have disabled softirq act as RCU read-side > + * critical sections, this macro should be invoked with softirq (and > + * preemption) enabled. > + * > + * The macro is not needed when CONFIG_PREEMPT_RT is defined. RT kernels would > + * have more chance to invoke schedule() calls and provide necessary quiescent > + * states. As a contrast, calling cond_resched() only won't achieve the same > + * effect because cond_resched() does not provide RCU-Tasks quiescent states. > + */ > +#define rcu_softirq_qs_periodic(old_ts) \ > +do { \ > + if (!IS_ENABLED(CONFIG_PREEMPT_RT) && \ > + time_after(jiffies, (old_ts) + HZ / 10)) { \ > + preempt_disable(); \ > + rcu_softirq_qs(); \ > + preempt_enable(); \ > + (old_ts) = jiffies; \ > + } \ > +} while (0) > + > /* > * Infrastructure to implement the synchronize_() primitives in > * TREE_RCU and rcu_barrier_() primitives in TINY_RCU. > -- > 2.30.2 > >