Received: by 2002:a05:7208:13ca:b0:7f:395a:35b6 with SMTP id r10csp21093rbe; Wed, 28 Feb 2024 09:19:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWFHNFFeDngANDbaiat3v/gw1acHQ2fv1EMYyJ+YbosY+I3kCm4GYFJ2wFUBOV1ZlXINH2h+H/aWd79Trk4cj8PA4lN9Jrg9TuGvzq1Qg== X-Google-Smtp-Source: AGHT+IGVWlVHiMyphi5X7ZatEzx1X91mTzRuaY33bEDomXU2M+/1tappIR9Hy7+kX7Y0uqt91+UI X-Received: by 2002:a17:90a:d3ca:b0:29a:a39e:e651 with SMTP id d10-20020a17090ad3ca00b0029aa39ee651mr353923pjw.11.1709140742186; Wed, 28 Feb 2024 09:19:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709140742; cv=pass; d=google.com; s=arc-20160816; b=BWeKgqiTA7/aqhFOGUsmj7S6aH2JzQpArNXoNqyNjYjd0HyNN9fwd5xce6rAwcDzuW vDDFtW+yW7FyQYzrC+k6RthELk1pp+9/TH4v4qn21oQkR+sNS+S9KH+arueW2FeE4NOR fEzK7nGE75bJ8Qoo9DEk4eEqKJs01fdkHyvBH7vFDqjkusf6VkJl4eDVaY2ug8piyljP xp2Rhf1CZhhA+VxX5OQCISGBNsmO7muROLziyI+WR9IBVufSt7Yh7qg+nTulCzhdlD+d LQMmI/Av0PSczV/udTaFMumJ5WhdahrSaT7BWg7XLPVC1Yk+h+GLRyGiYfXM/Cob4iwo cPxA== 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=tXaP9ScQFK8EYNryjexRh199W+x2WgWojj1IzyzeAKE=; fh=0ihMC2jx1qFPMffj33NnRW6mj4mFqfA9ykya3Bz6ZxQ=; b=R/3NAEepS3m/XWDfG2/avs0+4pODt8qcwpCEKP9ib4IUxj111mdY6Spu0+2yKrHVoY rAaak6ZzgN31mzOZfoXvVgu958BS4sjP8AXD+5fsI03ap+nrqiiXyJrgiB6e7aQAu2Ep CMvAwAYMuhG/fjF3KDXQmZPZD7qkS0Huv+lUWSJAYrgCpVPhAWyy5u/L6cdpB/iuOkFF 1OSE0fhxpBpyunfxA+7emvg4Tkk+yk1dwn6f99CtrtLccpEAnZPUgv1StMFJEt0roJm3 8YKIBrtQSNr5eE5jxTev+UvZ5Y+5Z3Cllgye5BcYI+B5DX+uaNKj+J+A3lBBuJiPM1zW glxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VAX+x29n; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85424-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85424-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j21-20020a17090a841500b0029a5eba078asi1676502pjn.142.2024.02.28.09.19.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 09:19:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85424-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VAX+x29n; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85424-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85424-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DEF0D288F06 for ; Wed, 28 Feb 2024 17:19:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94A1C15B10D; Wed, 28 Feb 2024 17:18:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VAX+x29n" 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 A77E73FBB9; Wed, 28 Feb 2024 17:18:46 +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=1709140726; cv=none; b=JUi7WGAsQoPh2yzLn57yXqvuNPt8zQJrbVXhIb9YeDjYgIJgW5dMejqMjmDVsYadc0thg8epEeqs7pZ5k/9bXpvzAkGyfQRipFM+86u05dgo7a7QFqnVL/vQbmHslFJP/OjBG1HYk8W+mhK4M7pOu4Ibx4jvwJY7FcO/suzxDaU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709140726; c=relaxed/simple; bh=7Np/zr7DLGjyYYuEcCZgtLSlELCkIkd/WVEd69z0kMc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hlNhS5cv4yPn2aaKHaYgbeTUSzgNAYC11WAM7qpT5Ze5wk9Lig2uUDIlUtOFAhW+LeJBDjxvVhsR7bwN5w6H/J9/dwa9ovm8df6gOObxeIJtoa3FJx3ZZ3uCoUFAOBeSebsxLNBSK9a1JL4MsH42zhEP8O/BdTvI22Kk4+LiGO0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VAX+x29n; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E491C433F1; Wed, 28 Feb 2024 17:18:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709140726; bh=7Np/zr7DLGjyYYuEcCZgtLSlELCkIkd/WVEd69z0kMc=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=VAX+x29njD0xyB/7dX1OBluP0fZD01XLb/o6qWLQZ2NdW1DHt1rHYqynOg+cg78KY MdOE7NTHMQqZWU5MV7j2CL/6pBhnQVQYkThsu1lLFcoT9f6/oS+NE/iLkfE5MfmT5g APD05lDataW1ksboB3PUyNrEKksUgdQHHrz09vHuVrhpkr0i2ty2ZJdKY+qCL/859/ R8a9UB3WItSLzZvXj2HRRqv0ydrN849cM1ZV75tfsT7nwMWfvN8vbakpXb6GqIT2bl MVOQ52AXKs/rtcGOtf7eX0I3gfZgZfcPWHQHBe6g8sjTE3fUUYT7uZJ2jM3wbTpUrM glSDi+5RaFrRQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id BEA77CE0350; Wed, 28 Feb 2024 09:18:45 -0800 (PST) Date: Wed, 28 Feb 2024 09:18:45 -0800 From: "Paul E. McKenney" To: Yan Zhai Cc: Joel Fernandes , 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: 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 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. > I will include that comment. Raising just the task RCU QS seems > sufficient to the problem we encountered. But according to commit > d28139c4e967 ("rcu: Apply RCU-bh QSes to RCU-sched and RCU-preempt > when safe"), there might be additional threat factor in __do_softirq > that also applies to threaded poll. We did look into more focused alternatives for Tasks RCU a few days ago, but they all had problems, for example, requiring that it be possible to get exact information on the instruction pointers for interrupts on any given CPU's stack. The key point of Tasks RCU is to work out when an old tracing trampoline may safely be freed, so a better way of doing that would remove the need for this sort of addition to NAPI polling. (Adding Steve and Mark for their thoughts.) Thanx, Paul > Yan > > > > Reviewed-by: Joel Fernandes (Google) > > > > thanks, > > > > - Joel > > [1] > > @@ -381,8 +553,10 @@ asmlinkage __visible void __softirq_entry __do_softirq(void) > > pending >>= softirq_bit; > > } > > > > - if (__this_cpu_read(ksoftirqd) == current) > > + if (!IS_ENABLED(CONFIG_PREEMPT_RT) && > > + __this_cpu_read(ksoftirqd) == current) > > rcu_softirq_qs(); > > + > > local_irq_disable();