Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1168041lqt; Tue, 19 Mar 2024 15:08:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUraDrdAalxeIAEjFxlorNW47TCES9ELPl1MbKytJAvHJAPKxWXmaE4ZQpp3PVd08Iv7vB5Inz6TkZdsuIlB6igka9x77/a1yDqo4BIOA== X-Google-Smtp-Source: AGHT+IHJ9JKJc3PXQ3iBxGTddRoPVM/dpUVP8229W500qD746xxEWNjyDLzdU+ZkeR7pfjHO9ihM X-Received: by 2002:a17:906:ca03:b0:a46:f279:8f69 with SMTP id jt3-20020a170906ca0300b00a46f2798f69mr109757ejb.54.1710886116621; Tue, 19 Mar 2024 15:08:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710886116; cv=pass; d=google.com; s=arc-20160816; b=l+pHCEsk+jVUzvOSh1GlMZxh0gfY+NUADXz3+X8Xno2fw+ucOpe1Q7vbybFdG4vto7 obG/7iaNtK2tDqQpe9yvhynv1XEx2lj0yxoLBnZbqmf8E07Dw+fozmHhuCVkD2+Ej1ia LeAMarDEkpVo85H/rV3yRcEfgE2/vAU+tkU2G5HIIEeC3vRu5EZfrFzm4G4a8oa8Q8vy qEg7x+fnhZ/7AxE4mdzkHaSHkxsMbv0mlvilkOUo7aA7TKvKFURhcdPjccybvmIxr60u LUv5hxHkgkA0ojsYggbdgXJE5t/B2jEn9A8iMQZNabWv390RNnejVuOldawu+JM7AkFU jLIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=YtWgdF4wMNo49qm3Hl5bccuf/VRYcsrMMiR3Yni/iQU=; fh=IPfoympBUn2hmjH/3zoAae5/cm+1JOfoMlFH2h+zs8Q=; b=Hf5kYEc3WBjpCDHsQpCA2reuhOXcb0JiBqpwTApVJXPO3w7znCOtvLHT7QgXsueDWp qqEaxa7258wOKxKmY6VO3YXXr8w9qq20rPeNt09jIh8bpMCsHFHXlgGuvXwdi6WBiuLK 5VFuoOzonTdc6yDzHp2dY7qkROfSTPvGuo1bc7VJ7HC0UldJKZ5G897qxIC2THCTwZM+ tb92vmFnRJJb2gFaiPV/9Aa73FGzDJht5H3nrjGx1wa8iavgfiaWE4dbUTH+DfBlIEKE YDA0N/J4xltMpXC4kzo5OrkbbQovo3NAYw20NyG6c0fEZv4GZll8qL+2Fm3iYbEocOLW ug8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pjNvqjWu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-108177-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108177-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u26-20020a1709064ada00b00a46da15d0ccsi1171116ejt.537.2024.03.19.15.08.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 15:08:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108177-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pjNvqjWu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-108177-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108177-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 58C3E1F22D8C for ; Tue, 19 Mar 2024 22:08:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A0AB54BC3; Tue, 19 Mar 2024 22:08:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pjNvqjWu" 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 2BD9B101D4; Tue, 19 Mar 2024 22:08:22 +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=1710886103; cv=none; b=MkH+XCXF3Sbv+dcMXFqYsvkRt3ItPjAN+a0Yi/cn+3zpnTORXMBVriu2hcrwIf0gbgY0bkZ5M7V7ltlcQv8aZW19gQYkrJXCPbIcW1+VJM3rDE/sP9KJAd/9RNwKjhIFrfW+QyraWYItKAZNJxKUX0b1EqDhHzWBciIT6ahgI/U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710886103; c=relaxed/simple; bh=WcCaSmpe1k7crBhFeryrbsZ45VTv5HnczafsdmzvbAc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nE4+2budFzj4XWw3vLyZmWOYlwL8yR4KBlJqnOFqdD3/tFYkwNnli3c3TSjUWj8TJk08/n8PX1a2b/hTT12GQLuRkBthaupIgZoAuVGAIjhlGeC9/O/MBTh/5f3ng5cmPcrfgkcTqInUQte7PemEExCczN3UhS4htY5TklxF7ms= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pjNvqjWu; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3622FC433C7; Tue, 19 Mar 2024 22:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710886102; bh=WcCaSmpe1k7crBhFeryrbsZ45VTv5HnczafsdmzvbAc=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=pjNvqjWu7SS1lVhwfopRltqQj2f2HQwzEpTwOzD/by69cdGPVzBWtYZ9zRVLlPLwo KBcwTfy2Csatl/iTFZR8GuqQVhlFfEvyXkLPmEXmu+8olSgr+54GNGpWqZpXS+DtIy FkVuAX2fEyAflnXW8s/zgI+CBoKbbQd4+zD1289I47d9NIoZ93DwvLf6RQYIOqzcP8 S2erPo8Ui55ejoLYfP6PoqnjPlrBXQcMyqqSUGzTdJ4igufxDNYtGZt7ERkGLCRZBB E8kZ/TkCXfYTI25BiRCd8IpWGtvAq0eDjxl4mLIYf0SY9tjfI2a4bfkLkdIv6UH0k9 fCKlpbs77LjQQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 5159ECE16D7; Tue, 19 Mar 2024 15:08:19 -0700 (PDT) Date: Tue, 19 Mar 2024 15:08:19 -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: <7d86bfd6-353f-425b-ab69-ae5e3309f5bb@paulmck-laptop> Reply-To: paulmck@kernel.org References: <90431d46ee112d2b0af04dbfe936faaca11810a5.1710877680.git.yan@cloudflare.com> <6149ecfc-2a3b-4bea-a79f-ef5be0a36cd7@paulmck-laptop> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Mar 19, 2024 at 05:00:24PM -0500, Yan Zhai wrote: > Hi Paul, > > On Tue, Mar 19, 2024 at 4:31 PM Paul E. McKenney wrote: > > > > 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 > > Since the whole series aims at fixing net problems, going through net > is probably more consistent. Very good! I will let you push it along. > Also, thank you for your help through the series! No, thank you! I had just been asked to find this slowdown when you posted the patch. So it worked out extremely well for me! ;-) Thanx, Paul > Yan > > > > --- > > > 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 > > > > > >