Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp12585lqc; Thu, 29 Feb 2024 09:01:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXrc1GTcu8AhvLaKk6AZtEsD0vCHkcusEIGCVHHMy202HJh5em2bKdD3COFkCAerNNH23k3S3im8xa6xtORJNHcnIF4mIRvwL6WdU7Eig== X-Google-Smtp-Source: AGHT+IHcZ1xRkUsyGjoEuspMHx3nTJaGdieFf7ue2srMBy1AMSRDN4a6V5TqQkCzut/HCyLtULq9 X-Received: by 2002:a50:8e1a:0:b0:566:7250:9ea2 with SMTP id 26-20020a508e1a000000b0056672509ea2mr1689150edw.34.1709226107091; Thu, 29 Feb 2024 09:01:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709226107; cv=pass; d=google.com; s=arc-20160816; b=rBpT7Qp6pQTFzmUkTOB382Bp0AdeD29vkw2JvFKn/tCPkPdG1fPznbGMkntIneTZ1e 5zS+ZYdnGwQs2KLpONwsfty2USQ/gEmtLbpglpaK68IymGukxDo2rSo8gwsB1Rjcmryy 2yc/IpEmR37iRhmBYwpGHlPNAqnLKcVmAaFBMvt4w4wMJfPY60b9yFgkLGeOGmIOoR9j AzlARDKNSLdfpbjsTN4HwAyHv4D9SfvXak768tubNQrLQQlVZATDvQpWK0tkNunzHJi2 xVZZvo20lMR/VtiIKHvZpNAP/ElSUD9IoeITU3oDAqhWJWiwHmbrDah3/DyV/UetTUbO MdZA== 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=UAVbNJHYpot3msGewDr60jmmwrUXtugfsEPOQQ4ms6Y=; fh=K2+ovTQ1sBb/jvD+/oKpXKkXTfD9L7AsnApa2IR/q/g=; b=oUyZ4pnW9GGppkcVtPdcHXh7fSaBsoTGHpR9vB/qYXCV2ms9cuiXOdP3mqZs4n9WoT Jt49bXVwUKYtJZkkWEveLkZ4g+AeMeCSNlyLbo3Lv5qNsBqjNapOqinyUliWONqknNx1 TJ4JgvBzoB6qan6QcK/cnnWHcYL/hPWrUrkOyoYcVYEIPiXph0lAA8XBnOlfO54jutrp +sZGHG1i/G3gye4fyHfP8FmUBK5hjStGFtzzCBqXeN7paUpnFODQfb5DymLQseIn6MBm RGXXpJpvTuYGGzuE5n9/9vdvufd4xEV/vo0lmBAUPGUP65bZrmW1FN5shQwN7+C5f3A6 eu7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ChYI0Izp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-87130-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87130-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y1-20020a50eb01000000b00566ac5d3a94si446785edp.264.2024.02.29.09.01.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 09:01:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87130-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ChYI0Izp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-87130-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87130-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0D5521F2296C for ; Thu, 29 Feb 2024 17:01:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40379757FA; Thu, 29 Feb 2024 16:57:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ChYI0Izp" 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 458D04AECA; Thu, 29 Feb 2024 16:57:07 +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=1709225828; cv=none; b=P9MHXHKIt4g6kiEYGOPOEM7hw62/jnjDercmNhO5wio0s20CUYIb1YqhEMyg2q3FAo6aHYD9vPpRsNkHIpcbJwqFKqBCHobMyC8woZC8yC5PfC0tVNlDI+ZautRmVcrtYd3zcjHHZ/xL+AqVhbJLsRy8Vs0lt8forOLRQSMB/XQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709225828; c=relaxed/simple; bh=Mwc8vNp+uod54n1G0L5TDfKxmF1IHGJ1xIbnsW3iay4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=H6qVWQ5CEVYR9+HvbSl7i/WZEXJDpBnhOcRl9ZWMrKg3AUOrMu8F3m77FVKhEt1XtvKET4lsnmOS5dzpTJy4RLofgNj4du+WFyX0l3Vgh0+9xsDKoGlkrKUlN+83pQmolp8kFhh30y/3kxhfnHEI4FLRcA0TXavWpwN/6XUtmqc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ChYI0Izp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E7DAC433F1; Thu, 29 Feb 2024 16:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709225827; bh=Mwc8vNp+uod54n1G0L5TDfKxmF1IHGJ1xIbnsW3iay4=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=ChYI0Izpo0ktPuD4KG2X/yX16oi6tuLY10Q9/6jSNsqXSGeF7eaifXryORkS7c+mW cziaoYXUMWtTDW3EJAcmL1i67/U8mXCXgyjqpojAlwHpaU9Mbk0CSHw86LLa4dWa4b RpQPrsPvx56wayKNkkqAiJZgcNt2hhtKOlvUAcHBWBdmBmV8jR74rmrpWbrXmFofcJ sfdFIz14cK0wLBpjC09qmVaZ6a19d+hbql12/3zcDELL4gosCQU5gFfmWDgzn7XM48 It0/2Ty27HpMKTZUQmpDwhNYNj7ZaxXMgR7VnbBlnbSKV7sDzrcjkAmp19pJUbI/G9 1GwJOE0rCVxqQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 3BF06CE1382; Thu, 29 Feb 2024 08:57:07 -0800 (PST) Date: Thu, 29 Feb 2024 08:57:07 -0800 From: "Paul E. McKenney" To: Joel Fernandes Cc: Alexei Starovoitov , Steven Rostedt , Yan Zhai , Eric Dumazet , Network Development , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Simon Horman , Daniel Borkmann , Lorenzo Bianconi , Coco Li , Wei Wang , Alexander Duyck , Hannes Frederic Sowa , LKML , rcu@vger.kernel.org, bpf , kernel-team , Mark Rutland Subject: Re: [PATCH] net: raise RCU qs after each threaded NAPI poll Message-ID: <55900c6a-f181-4c5c-8de2-bca640c4af3e@paulmck-laptop> Reply-To: paulmck@kernel.org References: <02913b40-7b74-48b3-b15d-53133afd3ba6@paulmck-laptop> <3D27EFEF-0452-4555-8277-9159486B41BF@joelfernandes.org> <20240228173307.529d11ee@gandalf.local.home> <8ae889cb-ee1d-4c72-9414-e21258118ce3@paulmck-laptop> <888d2f90-6d2f-4d4f-a9f6-fbf2f2611821@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: <888d2f90-6d2f-4d4f-a9f6-fbf2f2611821@joelfernandes.org> On Thu, Feb 29, 2024 at 09:21:48AM -0500, Joel Fernandes wrote: > > > On 2/28/2024 5:58 PM, Paul E. McKenney wrote: > > On Wed, Feb 28, 2024 at 02:48:44PM -0800, Alexei Starovoitov wrote: > >> On Wed, Feb 28, 2024 at 2:31 PM Steven Rostedt wrote: > >>> > >>> On Wed, 28 Feb 2024 14:19:11 -0800 > >>> "Paul E. McKenney" wrote: > >>> > >>>>>> > >>>>>> 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. > >>>>> > >>>>> Thanks for confirming. :-) > >>>> > >>>> However, given that the current Tasks RCU use cases wait for trampolines > >>>> to be evacuated, Tasks RCU could make the choice that cond_resched() > >>>> be a quiescent state, for example, by adjusting rcu_all_qs() and > >>>> .rcu_urgent_qs accordingly. > >>>> > >>>> But this seems less pressing given the chance that cond_resched() might > >>>> go away in favor of lazy preemption. > >>> > >>> Although cond_resched() is technically a "preemption point" and not truly a > >>> voluntary schedule, I would be happy to state that it's not allowed to be > >>> called from trampolines, or their callbacks. Now the question is, does BPF > >>> programs ever call cond_resched()? I don't think they do. > >>> > >>> [ Added Alexei ] > >> > >> I'm a bit lost in this thread :) > >> Just answering the above question. > >> bpf progs never call cond_resched() directly. > >> But there are sleepable (aka faultable) bpf progs that > >> can call some helper or kfunc that may call cond_resched() > >> in some path. > >> sleepable bpf progs are protected by rcu_tasks_trace. > >> That's a very different one vs rcu_tasks. > > > > Suppose that the various cond_resched() invocations scattered throughout > > the kernel acted as RCU Tasks quiescent states, so that as soon as a > > given task executed a cond_resched(), synchronize_rcu_tasks() might > > return or call_rcu_tasks() might invoke its callback. > > > > Would that cause BPF any trouble? > > > > My guess is "no", because it looks like BPF is using RCU Tasks (as you > > say, as opposed to RCU Tasks Trace) only to wait for execution to leave a > > trampoline. But I trust you much more than I trust myself on this topic! > > But it uses RCU Tasks Trace as well (for sleepable bpf programs), not just > Tasks? Looks like that's what Alexei said above as well, and I confirmed it in > bpf/trampoline.c > > /* The trampoline without fexit and fmod_ret progs doesn't call original > * function and doesn't use percpu_ref. > * Use call_rcu_tasks_trace() to wait for sleepable progs to finish. > * Then use call_rcu_tasks() to wait for the rest of trampoline asm > * and normal progs. > */ > call_rcu_tasks_trace(&im->rcu, __bpf_tramp_image_put_rcu_tasks); > > The code comment says it uses both. BPF does quite a few interesting things with these. But would you like to look at the update-side uses of RCU Tasks Rude to see if lazy preemption affects them? I don't believe that there are any problems here, but we do need to check. Thanx, Paul