Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp745624lql; Mon, 11 Mar 2024 16:55:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX9C3LxyIrSJbL3T1o0OxmjQAtqbQbpWC723OQuHe15GcJ/3BOejzMo85lTGVNL2BZERbWAElQGX5H3AgOc6yt7g9/Suo/6tt90yaJaUQ== X-Google-Smtp-Source: AGHT+IGtqaHf/LD7AwVeXxTmA3XQ1Hr6ydlA1qGpW7IJjQX7Pcid+gVU5J19dPfWDETRgiSZsqyl X-Received: by 2002:ac8:7f95:0:b0:42e:be5c:93b3 with SMTP id z21-20020ac87f95000000b0042ebe5c93b3mr11811060qtj.56.1710201352151; Mon, 11 Mar 2024 16:55:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710201352; cv=pass; d=google.com; s=arc-20160816; b=NMoGXH7kBk63n2htXn8Dpy72MODGb5OyNmdneQaQ4YXEWyq5CArKrJs20HQBFDCYE9 QwRhJHyncl9K2trlYjzFLCLSxszjLZE7onjTFP6ipchjNxqZWJUiEi7uph4Mazr//FfB 4zUxpDU5a2wvecBMqD10tNLrjP00pFVDhJ78KuoUNZ841cQ8ULGlXTPVLKNiZ7Is4HYx jwq6vhgDMtS6Dq2td4kaT3howxeOOM0OiTil5SJLPl39ZYvPug9Y3/3kVkSNLkrB+XRn b6iqVGVWomZ1yrBAtDT10riyYNFgAh+ocjQbpUlnM+6j2deTWoNKVkC2WqIl5vG4epls xACg== 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=Zbx2vGJoA0maul7RsgKxzNRX3JR5a5nGOKSPdXLbkwI=; fh=u7QzCrYxqo2+ARdFwtBioHKBaMchUeDHuk/xzKWpLe8=; b=LbPkyqvWBgM3gy9/SEIXSPm/WEBeoQq/pLZiDsBfT8yWlaLCsj/ZRxpAxRXj0y2UL/ tZurb6Yzv22LR1SDA/ta7TwuP0lrpUX0SxJMwZI1+pD0E/ZIx4TQ7KK/5/pfQnYeK18z 3AR+ohSNI549ooCL9Eqhtp3mPDpjXfemPCj7uH0J29MYJAlR3g6Cip8w1sK3N9lohzhY 2aVHTj6u8A4ziRWsi+44dxxyXn/KSCpAYbDG2NYRwse7n7qTQuQSrFNEhDzokFJun3JV jIz4wcRIdQTh0g3C/umRxPgcvU/XVNvNzmAX1371WpM09lvnlCBpFOz8iTqICOcSEzEP k+ug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RCpIijKg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-99676-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99676-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z10-20020a05622a028a00b0042f11ba682dsi6697167qtw.496.2024.03.11.16.55.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 16:55:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99676-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RCpIijKg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-99676-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99676-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 DD3301C21141 for ; Mon, 11 Mar 2024 23:55:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C592A59B42; Mon, 11 Mar 2024 23:55:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RCpIijKg" 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 DADBA58AAC; Mon, 11 Mar 2024 23:55:38 +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=1710201339; cv=none; b=u7w10IYzYefBFNJXeK+Y93aLlUyztrY4nSU8jNvepm0MyoKY5t67q2vKI3NfK/+RPfTo99P/ESBkMtCyIGoOX3oZS+VjZxdqzcTUZskCZHqxzds+pDtygvneuOJub1Ip7fZl/FN0oB0e5V27FE+J4AZ+Qx2nDfMN8hIrTLiW0GM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710201339; c=relaxed/simple; bh=BuwxzEM/Bxcww15ApUyz1+fwftuGUlKv1u90MSb2jyc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ro3PQcBDB4r/Q15JMucJo/1L+dzMLnX/ExTBf+DF8g41brGlK8zNyVQqxBEfK9j3ae1kPNP7uAF6Ztih4o994XfQOK8nSTqUhzpUKHIPlUD/wxhwkHpe6fZiIqUdVFTkTCakm0AQTbiPRG44CFh3Eu9C3xycqXPVXER4r8awfG0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RCpIijKg; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D1F9C433F1; Mon, 11 Mar 2024 23:55:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710201338; bh=BuwxzEM/Bxcww15ApUyz1+fwftuGUlKv1u90MSb2jyc=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=RCpIijKgQgoTSA/YgO5HGnRv3Hf9/Bg6Rr/EDvLtzPQgyI+KITZQdfzApLBYH/2PR s+tHpIkNnd8px5/X+EeLzzDUEUxl4H6mHKD7AvraOplbNr9dli6MZME3EdEtvGdXmW pYgwXcM/XGtMTZLpBDr1vnz9eKE2woypzmXew2bH20+gC0+Ppn9o7pbtmBsRmcFH9m loWPfwQV4KR5r0ugMkELBAZyXvtHC01/1dYPOrTKg+8ho4iv3F+9jgD25U1TOI/DHW /G2XFIzJ6EOA4Z8DOgLJP87E7bD9F/NFCdNPVlq5ocwS+QZGfqhDQkih2/FSDmDMwq k0zzq9tzTDy1A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 0244FCE1A25; Mon, 11 Mar 2024 16:55:37 -0700 (PDT) Date: Mon, 11 Mar 2024 16:55:37 -0700 From: "Paul E. McKenney" To: Yan Zhai Cc: Eric Dumazet , netdev@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Simon Horman , Daniel Borkmann , Lorenzo Bianconi , Coco Li , Wei Wang , Alexander Duyck , Hannes Frederic Sowa , 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 Brouer Subject: Re: [PATCH v2] net: raise RCU qs after each threaded NAPI poll Message-ID: Reply-To: paulmck@kernel.org References: 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 Mon, Mar 11, 2024 at 05:58:16PM -0500, Yan Zhai wrote: > On Fri, Mar 1, 2024 at 4:29 PM Paul E. McKenney wrote: > > > > On Fri, Mar 01, 2024 at 11:30:29AM -0600, Yan Zhai wrote: > > > Hi Eric, > > > > > > On Fri, Mar 1, 2024 at 2:30 AM Eric Dumazet wrote: > > > > > > > > I could not see the reason for 1sec (HZ) delays. > > > > > > > > Would calling rcu_softirq_qs() every ~10ms instead be a serious issue ? > > > > > > > The trouble scenarios are often when we need to detach an ad-hoc BPF > > > tracing program, or restart a monitoring service. It is fine as long > > > as they do not block for 10+ seconds or even completely stall under > > > heavy traffic. Raising a QS every few ms or HZ both work in such > > > cases. > > > > > > > In anycase, if this all about rcu_tasks, I would prefer using a macro > > > > defined in kernel/rcu/tasks.h > > > > instead of having a hidden constant in a networking core function. > > > > > > Paul E. McKenney was suggesting either current form or > > > > > > local_bh_enable(); > > > if (!IS_ENABLED(CONFIG_PREEMPT_RT)) > > > rcu_softirq_qs_enable(local_bh_enable()); > > > else > > > local_bh_enable(); > > > > > > With an interval it might have to be > > > "rcu_softirq_qs_enable(local_bh_enable(), &next_qs);" to avoid an > > > unnecessary extern/static var. Will it make more sense to you? > > > > I was thinking in terms of something like this (untested): > > > > #define rcu_softirq_qs_enable(enable_stmt, oldj) \ > > do { \ > > if (!IS_ENABLED(CONFIG_PREEMPT_RT) && \ > > time_after(oldj + HZ / 10, jiffies) { \ > > rcu_softirq_qs(); \ > > (oldj) = jiffies; \ > > } \ > > do { enable_stmt; } while (0) \ > > } while (0) > > > > Then the call could be "rcu_softirq_qs_enable(local_bh_enable(), last_qs)", > > where last_qs is initialized by the caller to jiffies. > > > > The reason for putting "enable_stmt;" into anothor do-while loop is > > in case someone typos an "else" as the first part of the "enable_stmt" > > argument. > > > > Would that work? > > > Thanks Paul, just got time to continue this thread as I was > travelling. I think it is probably better to move > preempt_disable/enable into the macro to avoid the friction. And also > since this can affect NAPI thread, NAPI busy loop and XDP cpu map > thread (+Jesper who reminded me about this), let me send a v3 later to > cover all of those places. OK, looking forward to seeing what you come up with. Thanx, Paul