Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp115014rbe; Wed, 28 Feb 2024 14:09:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXbdAwxaAjRh2wRc00MzGwabTeKvYuqKuBbIgjEFytpBimHicio/XpeBxaL75CxdZ+moG2Qnjb/EW4ZVkus9BpeRFr2PE3tffldWOtNYg== X-Google-Smtp-Source: AGHT+IFj+HiNMZnlOUE5fcGe7bWfpg1iOfFHSh5Rjq+H4yNMgXCejwsZb+HiAoml2hX1WFADm0vC X-Received: by 2002:a9d:67d0:0:b0:6e4:2769:e9d8 with SMTP id c16-20020a9d67d0000000b006e42769e9d8mr225447otn.22.1709158153056; Wed, 28 Feb 2024 14:09:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709158153; cv=pass; d=google.com; s=arc-20160816; b=Ll9a/BBKenC0VVXeB1YAHmRn6FgW6dDr9hHcc7kj01KyT6iLDxTMJsUzOsBrI/8+hH S6BEJY/vMuOrZ4C+GlJwNZQflJZyM3vbfqGGJ/347C2qnQ4l3ns7CfwbLFmPmgdNZPCd SGWOzeBv2cNAEgpH8qyO3ZnA6Zld+pExYD1UnbIjWrnXtmwf+neg5C4hc0upL4ef5Hz0 04gTVCkuXDuq2wvfbXEyeuIYhk3nSFoHZw/8se3lK56a7AhlQ7WLGRuUo+jVVoS1FR6L XGprPO4VLTKy6Zpa1c9HaiYmyjGaDczXwz/aFjFvqmL7iz9PY5cJo2mYynR//9s1+kK6 iPYQ== 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=SEKGEWa6cJxo9IsMTsOmvwnR+dkUE7FPdKFQmSxnwrA=; fh=OaBVgKMHIox0Zc3KbxC14IMhyYgMg5MfldLvCk08TLE=; b=vYA8ae7L/MRhvv4XhRXkFuD4cRhh8uWCTiS/zyXHpbguV2tVMMJEmKWcHL2SOlKu6u XmjkB+2LuiGSL8zAEptYq+WinKncoNXpUHYtaXfWAMBgEtSvc4KLFKPgsIgS2vlo2io3 qf5HYyv+A0dLTBfVTqX4wLicgCOrYlpDzXdusihNbes0L6bmA2s6Os1oHu9IOUiwgkzU RARTL8WQMswM+0hOaJ7Bueb2hz9DA2ARhYSTkAAZ1vy4ARbWIjfb7v1Dhh3hQSwFzpVE 30KQOv9Ncv9h373C9PziiqFyRdZgrGGgInGqw2++jCHqshI5OOIhjrtyqWJvIJWRYyA3 srGw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lLaHDwKt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85745-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85745-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u185-20020a6379c2000000b005dc89957de5si390031pgc.497.2024.02.28.14.09.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 14:09:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85745-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lLaHDwKt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85745-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85745-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 67F66B259CA for ; Wed, 28 Feb 2024 21:53:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2127672907; Wed, 28 Feb 2024 21:52:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lLaHDwKt" 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 3D9AD8626B; Wed, 28 Feb 2024 21:52:47 +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=1709157168; cv=none; b=RskXWOd6qS8xnOW6jWqz2gbdmIpzyUaZ/7Lohop2QP2uHaBrZq7/mj6G2JjEzru7c8eZEhuZqKWKKfw09pguoydJzcDiEUfIFezbbkSXMuyXtFVXpmkj8toj9Bi0ogVIDoK3ACqwbm08V/jd+70pOrdCrN0uzhAMMx+Bi2Jc+30= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709157168; c=relaxed/simple; bh=hAcOllotrdS9EgbXpniA2u60AjkuJzxlibPgqmRp5RY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EQhVYPOURraOM0q+teg1NMGfbs0DJJpyAPWY72+GWiXcf6kx1T43bR1ih7UhZok7Byec3D2MbfT6l8+84nPXuUxrnJXOdi735YfejyZ3cpqaG7XBxR/MgLUhd7sAJnJIM7AuFTgfDMW8PplEGtkj/pDvAz/AbMTXlf63CV3FtbI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lLaHDwKt; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3A58C433C7; Wed, 28 Feb 2024 21:52:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709157167; bh=hAcOllotrdS9EgbXpniA2u60AjkuJzxlibPgqmRp5RY=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=lLaHDwKt8tLOjzfXjX8yc0frSG1xGDlhScvISRoLiQT6SPFNE24YbRAMdRpwJje9K PquUXH3tCFSvpcUfXPV9KZJ/HEOuCpryiaA69DefTXlCKju/mJXR1ZorxfeIIUmevv GIvopfoaSB5W7/qPG2R+lDCOhH9UjRvoc0p++yCogXsYIJ9DBJLzJB7S0JJACCyCA0 pwUJQOSaFEwmX2GHFMRCwTGv5F8tahd24SRZoMr1TF3UXd0MZhCqQWVA9nDSuS7J9e /1fRnYja9aBcNhO4cWpsK5p7/k9Gm+gx2aPSpOMO519kcPptyPbYWrT0pdFpiKpLe1 aYSqPGW10F+EA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2B3D3CE0F91; Wed, 28 Feb 2024 13:52:47 -0800 (PST) Date: Wed, 28 Feb 2024 13:52:47 -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: <02913b40-7b74-48b3-b15d-53133afd3ba6@paulmck-laptop> Reply-To: paulmck@kernel.org References: <5b74968d-fe14-48b4-bb16-6cf098a04ca5@paulmck-laptop> <4965F5CD-B33C-4B75-818A-021372020881@joelfernandes.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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4965F5CD-B33C-4B75-818A-021372020881@joelfernandes.org> On Wed, Feb 28, 2024 at 04:27:47PM -0500, Joel Fernandes wrote: > > > > On Feb 28, 2024, at 4:13 PM, Paul E. McKenney wrote: > > > > 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. > > Yes. > > > > >> 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? > > That we are discussing Tasks-RCU read side section? Sorry I should have been more clear. I thought sleeping was not permitted in Tasks RCU reader, but non-sleep context switches (example involuntarily getting preempted were). Well, to your initial point, cond_resched() does eventually invoke preempt_schedule_common(), so you are quite correct that as far as Tasks RCU is concerned, cond_resched() is not a quiescent state. Thanx, Paul