Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2611588rbb; Wed, 28 Feb 2024 07:15:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV89Rljv8ugYbKRGgfARgA0aeNTOidJBirbfDk47pq+IQPUByHTXvWyu8Zih7zT2reDT0GDJlZ0rCRuOvKO++pSFscXliQPIJ+a5cuG3Q== X-Google-Smtp-Source: AGHT+IFjJYoO45YTIxYT63RBtYa7dIMICY3K8fLkIKB5DhqabKGm5cRN/jy2cbj+qbhWl3AtBMJm X-Received: by 2002:a05:6870:aa8d:b0:21f:7ee7:ecc9 with SMTP id gr13-20020a056870aa8d00b0021f7ee7ecc9mr15454800oab.41.1709133355496; Wed, 28 Feb 2024 07:15:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709133355; cv=pass; d=google.com; s=arc-20160816; b=vhB9iL2h2UXo8KIPIiJTy5FsCRhL6XRxFeo0TWi5vdzVC8UQcZVvNKCE8R6269z1OZ hXKM0YiCxiyNw8OvYAy5tUD30SxI/+Bhs18mTWBwGp+4Y9zh45xytT6eG52Gv86Ma0fE tPyOHav9xej5Xr+GdY711xPWZpdRCnVQXnK9k3caOeCy+s5gs8QhlD8QtBdlvQiYvUnM ESmbF82o9numoDwKuX4Ug215ayUJ9WNSLaWlgEd2b4eNQ06blmMVFzMf/iWzj03PuJMu AcJzbXKCXeK0thH3wh7oLy+QSxvYMIFlcE8ZtpHu/rT4Tc9Aokbmg1DD8qHKCJZUWSIO s0zA== 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=IqSck4Z7ESsjuHi6sjvFhS06py3EmQW7+34Pz/OL+3w=; fh=2ni6Ff1EUMCbkXSvNAH7ws4SdqzXtAdwKvEfpeYp/DM=; b=uRqv38fSkx8eWRaa7Lwn+812TZcJrFKLlcZ2orEsvI5DRAUoANms/FjNMTs26YIQmx /Xm1gzR2jgebTYsWGLYV8ni5WXTV5xqZ68QV6RRz3Qu50IvS/hvijx65Hz7g3LDslwse J1vimi+lCaNBcw27C+yVfyhdhbVPjA6tmKjtLTvkgRBx2qo89ePPyWsYGfuWjJX8YDY/ gS4uvpjOZR6KZl5GH1DgTKOxrOTw0Vg4GmIhV9pMhNCW5CkaDMZdgUsG3AQHuIg4Vdpb Fk3xyRb87iaet957G+Pj/zXuhCneOfUzwTVUxIylEMXC0kmVdW2e7C/EM3Ug3w/mIQzr 0LjA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K2qlz3Hk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85248-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85248-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 l24-20020ac848d8000000b0042de72e6f4bsi9438880qtr.792.2024.02.28.07.15.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 07:15:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85248-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=K2qlz3Hk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85248-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85248-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 27FBD1C22EE9 for ; Wed, 28 Feb 2024 15:15:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0230715CD44; Wed, 28 Feb 2024 15:15:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K2qlz3Hk" 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 1E5DA145351; Wed, 28 Feb 2024 15:15:42 +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=1709133343; cv=none; b=A3gmjVa/abASf0MMfMxzRfOjZjnDVfNvcqLuSkBjXIGJjzhEJ8dFAZKkBFSYpOg82iGXyxM9t7feh4pSFbi+mlhbuCYBLxPvbCeKtOL8f+xsjmwtCAc/+GxTPE1nnLJmf7Gkk7CJ51ZkF5qVPEQZwz1JjiOnmmbW7Vo6ywAyyHk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709133343; c=relaxed/simple; bh=n/a5TZj5zgQAI3QJKUDFCp6oKQYRJ0TA2PQIbSDat8s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XARBZWyYG0W+7z1MPg2T4dcfUYUQIXpsr06amYosxEqgV/nzlA6KKpz5v8UJFHW5n0vI3hYRibUJsyZ005gl3T7kHx7DzJYdHZWqA7m1fvf6hZx1+p/bbZYIyA3TOv8sFetFG73/HFWviFGeCtdCQI5/ifQk1gAViQG79DJEs+A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K2qlz3Hk; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC423C433C7; Wed, 28 Feb 2024 15:15:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709133342; bh=n/a5TZj5zgQAI3QJKUDFCp6oKQYRJ0TA2PQIbSDat8s=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=K2qlz3HksEhthbbat+plgwHuxHT6aiChhK7Vizq9KHvm2FVTVy/18RqszB35y5VHx leYHGqW3qlTX2Tommj2xmj+dYHsq6mbGZ4qzYLgz5phkXbsDfYNUcj6cxYls4IanVg oXv08IelN8kPlZlesoWyA3ra1qS7rCTyajAKAoevQ97avzEyJBGgp/XWCAoj6VB+bu UFe28JUHuWZ5WHgsOj1bTeHAr8yK0BiKDRoHZbYhI/skvnSDWXcYBWkWr/01KDHBy+ mJ2Q18mHoo/0Pn4O2jLFw7y5+5iCgjgOrkybM26bcrgN95zwghJGjLh0hSPsKzvk61 blAugI+UNlh+Q== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 53625CE074C; Wed, 28 Feb 2024 07:15:42 -0800 (PST) Date: Wed, 28 Feb 2024 07:15:42 -0800 From: "Paul E. McKenney" To: Jakub Kicinski Cc: Eric Dumazet , Yan Zhai , netdev@vger.kernel.org, "David S. Miller" , 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 Subject: Re: [PATCH] net: raise RCU qs after each threaded NAPI poll Message-ID: <9a0052f9-b022-42c9-a5da-1d6ca3b00885@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20240227191001.0c521b03@kernel.org> <66a81295-ab6f-41f4-a3da-8b5003634c6a@paulmck-laptop> <20240228064343.578a5363@kernel.org> 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: <20240228064343.578a5363@kernel.org> On Wed, Feb 28, 2024 at 06:43:43AM -0800, Jakub Kicinski wrote: > On Tue, 27 Feb 2024 20:42:24 -0800 Paul E. McKenney wrote: > > On Tue, Feb 27, 2024 at 07:10:01PM -0800, Jakub Kicinski wrote: > > > On Tue, 27 Feb 2024 10:32:22 -0800 Paul E. McKenney wrote: > > > > The theory is that PREEMPT_RCU kernels have preemption, and get their > > > > quiescent states that way. > > > > > > But that doesn't work well enough? > > > > > > Assuming that's the case why don't we add it with the inverse ifdef > > > condition next to the cond_resched() which follows a few lines down? > > > > > > skb_defer_free_flush(sd); > > > + > > > + if (!IS_ENABLED(CONFIG_PREEMPT_RT)) > > > + rcu_softirq_qs(); > > > + > > > local_bh_enable(); > > > > > > if (!repoll) > > > break; > > > > > > cond_resched(); > > > } > > > > > > We won't repoll majority of the time. > > > > I am not completely clear on what you are proposing, but one complication > > is that We need preemption disabled across calls to rcu_softirq_qs() > > and we cannot have preemption disabled across calls to cond_resched(). > > I was thinking of using rcu_all_qs(), like cond_resched() does. > Not sure how it compares in terms of functionality and cost. It is probably a bit cheaper, but it does nothing for Tasks RCU. And that "_all" in the name is a holdover from when there were separate mechanisms for bh, sched, and preempt, so maybe we should change that name. > > Another complication is that although CONFIG_PREEMPT_RT kernels are > > built with CONFIG_PREEMPT_RCU, the reverse is not always the case. > > And if we are not repolling, don't we have a high probability of doing > > a voluntary context when we reach napi_thread_wait() at the beginning > > of that loop? > > Very much so, which is why adding the cost of rcu_softirq_qs() > for every NAPI run feels like an overkill. Would it be better to do the rcu_softirq_qs() only once every 1000 times or some such? Or once every HZ jiffies? Or is there a better way? Thanx, Paul