Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp91220rbe; Wed, 28 Feb 2024 13:13:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXItM1lxG1s9bS2MXM27Vqw1hb8TQI0sLZFOUbTe+th1/q3CLAfXQaQaRzbmZDMRTeNByDp7bUpLvcgKIQuAjPQbZ9V2qlwH1gF+HbFwQ== X-Google-Smtp-Source: AGHT+IFdgwaFDCN37U0eTXLf7BZIbPKUgxdGTT52mLkAwwoLkyql3sd/HkQ/k2Q4acNAgAj21z+9 X-Received: by 2002:a0c:f091:0:b0:68f:6013:7af7 with SMTP id g17-20020a0cf091000000b0068f60137af7mr322058qvk.57.1709154800851; Wed, 28 Feb 2024 13:13:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709154800; cv=pass; d=google.com; s=arc-20160816; b=Er4/nrf0G8MMpE0ttfBmeYZ9r2lIj5er7G4gv0CXDvJzxvct5l4XR7/bfTHaU03mhC kf3zPWD0tqm4LE1b79n9wYdDwGRFZjP+GEL7RiW/Z6R0KudnINL++S7q59nPb4Nh+V26 ZxMCUTab+lYK8hPv65KxmU23Eqe9LiLrH90V6qmj9xFKc3FCyP7cHDpoph2U3uwbCXW1 GBzfoSlZCVQIK7yYbBQS3E5lp7Y132E58zKPCbSxb6kBdfzlpIEjY5Kt2oKbSzDhr/Qm QdxNCgZAzXx40N9pe2d9haCUZIZxmMN4qwDqVZkXJSI97m+Neh3Da3gZZ3uws4iWV1uQ KWJQ== 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=EYwh8QfKu1CKfOWLstDkWvxbsA8gngC8nodGd/Ezais=; fh=OaBVgKMHIox0Zc3KbxC14IMhyYgMg5MfldLvCk08TLE=; b=ey+wKTsKOFg2lJdnVgOWpTiAoUqrQRdrK5rc2yvsELiE9plQxHghU/fI7n+MDRrvxR RVViLdi39xQLs+/QPWqyUw0R2T3M/PDg4TzkZTpBxLP3urdoBO9RK3sg1Ya2ubnAw0wf HFKkcfvcrR+4eysydoiviYS9VnhKu2HDpeqCfrqtFTLSnmOv2g1S4quU0a7EQBOdVEF3 e2pmYV7b0P49+BVjuk6x31az9owC7oR2v5zetDnp1HK4JSdaDxKgZVytPQrptOSwEwQp LxmreYKWRO9JrdY+dNHlcC9mQzZDKyN9iRnrdlloI0qi5CU7pkFNYFZK+YcpbvOUlM2O DoBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kqarl1gF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85709-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85709-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 a5-20020ad45c45000000b0068fa24e579csi365854qva.555.2024.02.28.13.13.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 13:13:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85709-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=Kqarl1gF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85709-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85709-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 640FB1C24F6D for ; Wed, 28 Feb 2024 21:13:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3694C20DF4; Wed, 28 Feb 2024 21:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Kqarl1gF" 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 4F27686264; Wed, 28 Feb 2024 21:13:05 +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=1709154786; cv=none; b=qgEcygJnDxRSQ7S5e/z1X/rLlc3N2/94iDLEOvu7BTmK7itjcoPILL9MfdZ2wGy4K9q4hqgr6CteyoQa5b25FAk9lYGQ9Q99pxjeKkcD6SysOfL4uhWkMi7T6GiaLJrYLaymmsxOAM4xD6ZMJIbpqoSiom/UhgGoWz7JKXuroT8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709154786; c=relaxed/simple; bh=bvfUvyOHM3B822eF9dQJqvD3Ut/r4uRrCEE6r01GjYw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qLRjYyRxbY9Z+Ux+AxqNb79w9wqIEGM9LPv644e5AOIVmVamNqowvuyx1P/HJtg0Hamj6RUWTeYmFLJEiMG9L6xizzQqLwvZhGft7gAlKtjeZHfnWJ6u0tqaWYGqtcNmBQizgJvl9bnfRQhsXQP0OJgDNiOSZI/JpTPbFXQYMI0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Kqarl1gF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B642EC433F1; Wed, 28 Feb 2024 21:13:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709154785; bh=bvfUvyOHM3B822eF9dQJqvD3Ut/r4uRrCEE6r01GjYw=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=Kqarl1gFzSFgUHKI4+aF3qtI9/m/lCwKKbHSTC+a6BfbeMn7aHR6zeCH+9a0Me85P pCZ28Qjpv5qMPywj2dUTqIG9ZfJitSLdnM2COofeKn7SfJKBSfCN4/3zQj1i+1MP8U bfWE19hieEH58AhQwv7wL40+2kX1PlCdCJ7oqk8Wn0PDjzOjUkRFZJIX++6DjqSto0 N3UvDPyxfiQ3/gh3gnK+p9tRK21b86MQ9nO/KmjAPTNdNQYe7wddoSlLw4//TLzwt5 BT5d2W6O2FuIEbXaKNjZmzu81bOV+9IqQHdnYscjwieDvq2OAB/0wcwdSV1VshZ8ey tvqRwRGOjNAzg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 4CC24CE03F3; Wed, 28 Feb 2024 13:13:05 -0800 (PST) Date: Wed, 28 Feb 2024 13:13:05 -0800 From: "Paul E. McKenney" To: Joel Fernandes Cc: Yan Zhai , 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, rostedt@goodmis.org, mark.rutland@arm.com Subject: Re: [PATCH] net: raise RCU qs after each threaded NAPI poll Message-ID: <5b74968d-fe14-48b4-bb16-6cf098a04ca5@paulmck-laptop> 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 Wed, Feb 28, 2024 at 03:14:34PM -0500, Joel Fernandes wrote: > On Wed, Feb 28, 2024 at 12:18 PM Paul E. McKenney wrote: > > > > On Wed, Feb 28, 2024 at 10:37:51AM -0600, Yan Zhai wrote: > > > On Wed, Feb 28, 2024 at 9:37 AM Joel Fernandes wrote: > > > > Also optionally, I wonder if calling rcu_tasks_qs() directly is better > > > > (for documentation if anything) since the issue is Tasks RCU specific. Also > > > > code comment above the rcu_softirq_qs() call about cond_resched() not taking > > > > care of Tasks RCU would be great! > > > > > > > Yes it's quite surprising to me that cond_resched does not help here, > > > > In theory, it would be possible to make cond_resched() take care of > > Tasks RCU. In practice, the lazy-preemption work is looking to get rid > > of cond_resched(). But if for some reason cond_resched() needs to stay > > around, doing that work might make sense. > > In my opinion, cond_resched() doing Tasks-RCU QS does not make sense > (to me), because cond_resched() is to inform the scheduler to run > something else possibly of higher priority while the current task is > still runnable. On the other hand, what's not permitted in a Tasks RCU > reader is a voluntary sleep. So IMO even though cond_resched() is a > voluntary call, it is still not a sleep but rather a preemption point. From the viewpoint of Task RCU's users, the point is to figure out when it is OK to free an already-removed tracing trampoline. The current Task RCU implementation relies on the fact that tracing trampolines do not do voluntary context switches. > So a Tasks RCU reader should perfectly be able to be scheduled out in > the middle of a read-side critical section (in current code) by > calling cond_resched(). It is just like involuntary preemption in the > middle of a RCU reader, in disguise, Right? You lost me on this one. This for example is not permitted: rcu_read_lock(); cond_resched(); rcu_read_unlock(); But in a CONFIG_PREEMPT=y kernel, that RCU reader could be preempted. So cond_resched() looks like a voluntary context switch to me. Recall that vanilla non-preemptible RCU will treat them as quiescent states if the grace period extends long enough. What am I missing here? Thanx, Paul