Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2592025rbb; Wed, 28 Feb 2024 06:44:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVgMiigkABh/HMRpT81uU2HQQFJYcjKPNAuaaS8sq24ncOmV3HafFDRzHlVvrU1JNb/fmqTDLN/1RTM7b1viY6od1SrzWTXF4xGPhVcrg== X-Google-Smtp-Source: AGHT+IGPZ4NlirAKW/mK2t8V7iVeBhFlfv19N/TFP6lhymo2DgvgeWzzoGjntU6FThPOU6V7mIv0 X-Received: by 2002:a05:6a21:3482:b0:1a1:aad:5d5c with SMTP id yo2-20020a056a21348200b001a10aad5d5cmr5255206pzb.42.1709131481789; Wed, 28 Feb 2024 06:44:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709131481; cv=pass; d=google.com; s=arc-20160816; b=sf7Bn9iVRFAPc16TatQX9zxyNEoIa7K79YMX+znXoI6pMZZSEBH5f+gf3lQlwVBIxS ACgZzGlSwjpR/wiU8H4ltWs0Hi1us882vGRfhXHWA35jy86ETIb8r8wLrYQxyDin7dZI Jlb4nweQRTgNNhsX7e5tsQf7l2yT+0RF9HTX/iZ2zXgzB9g/Nd7WAnunsjg6E8OVjayN 5ioIKAGvcNkvz1K5nN1Mi0sjUPt2vRk1hFjn0MFAVu0suKrPAsV2ORtdOYWBQgvyDu3C rFqehnkbT4mXtk7ZKdYgCqwQ5tcwgOzwXC0uaZD7fyQWdwmzu12h1mjucwOPaA0x3GkY UnCQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=unqkiusjJaFOMOgtqt6vSfJjdr/0oMIfWONWTmyiA4s=; fh=ErtXUfiESczMFfh3pQaMrgg4ClyJpxfILPPKN+9WSyo=; b=Y+j6fW6eElwkFfDyCFECOT3QhYNDERwLBlvJ0yWvmNn1GrFwO65S++XTYxgnhl9HLg UR6wljPOx6xs/Efx1WNQpxDKOdrV3RfWEjueQdsWsFEtc8kreVv4MqNRWaEOtzAzlbkX 906401cEco4SMuopyWYJ3OzzsV76famD0UEKVZcrc3jbGjgA/SfH1t1vW/5JjJ6zL41x 5II3pFc2b2sFOUAhx/ZPWt75zeZNL5NcqkyMxyBt3ccZ0xcisL3l+67IijIOTzSgaYKn V47XNH0mcgc09P3Jcwa5i+VqxTh0GS02K2RCAhjczHPpFdNKvn9LjOisskma5dgom3ih 0fuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n4Z9GmA0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85199-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85199-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 z14-20020a63190e000000b005dc4baf54desi7385161pgl.769.2024.02.28.06.44.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 06:44:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85199-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=n4Z9GmA0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85199-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85199-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 7C60E2885D4 for ; Wed, 28 Feb 2024 14:44:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 811C015B968; Wed, 28 Feb 2024 14:43:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="n4Z9GmA0" 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 96E00158D95; Wed, 28 Feb 2024 14:43:45 +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=1709131425; cv=none; b=FBS1RjeU33IPZQs0Bz725OCa3CxT77XuzOZK30x8LPrgUxp73OTgOSbCFjSD4N1mXCj405Y7BsDPGnRMoBHMVaF1RQkP+wU5Pu3ZtMUjXK4326V3mUYgINOmxg4oe97lpq6P1YCT6RvpuWAl5KTFgdEpXgtZ++TcXreIwlpAWqE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709131425; c=relaxed/simple; bh=wvEapABnIlz3cWAlJclMlhGCT209K3a/fzamCpEyPdQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ajcY4byRkY/3sh/tyiIwNyysZehxSJE8oV03pzV+ASrz3GNRKD6euPbQd1x950byC0Lo+ApIdvAcn5p5A+AJs2K1KctjFflaCPr6RvLjc9sWQl965gYDTqkMSscl1quxAilxJsMaxaC4zyiXi3WWJbj2rDHZzmII8YSdteVbdQw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n4Z9GmA0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77D85C433C7; Wed, 28 Feb 2024 14:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709131425; bh=wvEapABnIlz3cWAlJclMlhGCT209K3a/fzamCpEyPdQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=n4Z9GmA0bQq97/493YJupgjJBZsDOPLYgiZML8s/f0fQ1rBOqUaSOR7in+Q3338N8 o0Z2vXW1+8p9G14v+gzNL9hzT+MQCc0qRu9UqDdPD9ut88cgy/tp4ojSBggScSh5Xr V4dfQy6Ev21c5onwhuhpFpoQio/iQzzdIm3RWPVPTCBBA0+Z2hMkQrRQ99zCX+ZpLn vgeWznAeQ2hElj3Daj7RX5MvNNWnaQx4ionAbDW7p9cPlul2mxdTJMMXyp+lgpp78r PTGq4TcgNbb/yehJy0dc6eZgk6Kljka29fsGTO0eV3f4D6AiG1JeAKvZfloWAVYMlr 62rumrOhqKlpA== Date: Wed, 28 Feb 2024 06:43:43 -0800 From: Jakub Kicinski To: "Paul E. McKenney" 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: <20240228064343.578a5363@kernel.org> In-Reply-To: <66a81295-ab6f-41f4-a3da-8b5003634c6a@paulmck-laptop> References: <20240227191001.0c521b03@kernel.org> <66a81295-ab6f-41f4-a3da-8b5003634c6a@paulmck-laptop> 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-Transfer-Encoding: 7bit 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. > 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.