From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2534EB64DB for ; Wed, 14 Jun 2023 15:14:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 62EB661363; Wed, 14 Jun 2023 15:14:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 62EB661363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1686755686; bh=N92UoKk8SOrFgizRoiZDlQAuVayMv//d2NZnrjyqI88=; h=From:To:In-Reply-To:References:Date:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=UQvhMMNtpzhZ5Qt2QDNtzez9ZEzzuAQBeLC5448Bqebqjm2/tLrrk8Z64/XR3RV/r 7AQUa0HdbGGW2qNXD1GUwZvscajSQeu9klnblXPy5Cy/kiCi9zVWLCjMAufiIjL7xb WEVYAWKxlrvXoL8C7r7XfYYkV3v4IPVld1ODsJsNPBLXkUIkQdqxMvXcnW2KIr9t3t B/45iStV6uhwV8a9VeBvAe3OMbxAGRuHjNCLB03S6i+XGzlsy/PhJtbG06+/LYaq49 nt8PRMA08OSFd5wipwQnlcrreozUwYyWFkyR1umTN5QwXMiYrPS9+u2pcEVbAxkCWO eW0wZzOYcH01g== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HMpD5IbOXqaY; Wed, 14 Jun 2023 15:14:45 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 62E4E61346; Wed, 14 Jun 2023 15:14:45 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 62E4E61346 Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id BDA141BF2BA for ; Wed, 14 Jun 2023 13:47:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 90CEF61303 for ; Wed, 14 Jun 2023 13:47:08 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 90CEF61303 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D7hA0HQGH2Aw for ; Wed, 14 Jun 2023 13:47:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org E3F4B612DE Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by smtp3.osuosl.org (Postfix) with ESMTPS id E3F4B612DE for ; Wed, 14 Jun 2023 13:47:07 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2CBD0641ED; Wed, 14 Jun 2023 13:47:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DF82C433C0; Wed, 14 Jun 2023 13:47:06 +0000 (UTC) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id BEE71BBEBC1; Wed, 14 Jun 2023 15:47:02 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Alexander Lobakin , Maciej Fijalkowski In-Reply-To: References: <20230613151005.337462-1-maciej.fijalkowski@intel.com> <9eee635f-0898-f9d3-f3ba-f6da662c90cc@intel.com> <874jnbxmye.fsf@toke.dk> <16f10691-3339-0a18-402a-dc54df5a2e21@intel.com> X-Clacks-Overhead: GNU Terry Pratchett Date: Wed, 14 Jun 2023 15:47:02 +0200 Message-ID: <87sfaujgvd.fsf@toke.dk> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 14 Jun 2023 15:14:34 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686750426; bh=l5n/L5NHjNAUQ1q3ufBr1NoPvkev3JAl2SGy6BnnzGU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=k6kMpmx6XivSeaiPRuwbUD99PRsLTH6oD2s30Cm2DFNMisgGsqfob7OVR7eLuvosP FUbtHWrs66D1t85rZ9Rj72nnnl9xxX0ojxqAx1cpAIKcrI1SAziW9MO9XNbSCIqYt8 NU76sV7E6h3GZz9lfU8nBAKk/zeVWo1iFHvP7zi3bHdj9kI7I0fcXjqnRD4NHCvFXK zfFI596NxDeilaDIGuhudsNoPudhE/vYooZN7zf67RI9bzmdQVIfZ/MxkWEi/ELy6r T2JRPyxk/IfAuQiQHymcYrdGGVRu8mgT+FSSRHd2rBLPQp78KZ8uBXBtyvZTgn5ElB RwjVXQgzzzuEg== X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=k6kMpmx6 Subject: Re: [Intel-wired-lan] [PATCH iwl-next] ice: allow hot-swapping XDP programs X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com, fred@cloudflare.com, magnus.karlsson@intel.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" QWxleGFuZGVyIExvYmFraW4gPGFsZWtzYW5kZXIubG9iYWtpbkBpbnRlbC5jb20+IHdyaXRlczoK Cj4gRnJvbTogTWFjaWVqIEZpamFsa293c2tpIDxtYWNpZWouZmlqYWxrb3dza2lAaW50ZWwuY29t Pgo+IERhdGU6IFdlZCwgMTQgSnVuIDIwMjMgMTQ6NTA6MjggKzAyMDAKPgo+PiBPbiBXZWQsIEp1 biAxNCwgMjAyMyBhdCAwMjo0MDowN1BNICswMjAwLCBBbGV4YW5kZXIgTG9iYWtpbiB3cm90ZToK Pj4+IEZyb206IFRva2UgSMO4aWxhbmQtSsO4cmdlbnNlbiA8dG9rZUBrZXJuZWwub3JnPgo+Pj4g RGF0ZTogVHVlLCAxMyBKdW4gMjAyMyAxOTo1OTozNyArMDIwMAo+Cj4gWy4uLl0KPgo+Pj4gV2hh dCBpZiBhIE5BUEkgcG9sbGluZyBjeWNsZSBpcyBiZWluZyBydW4gb24gb25lIGNvcmUgd2hpbGUg YXQgdGhlIHZlcnkKPj4+IHNhbWUgbW9tZW50IEknbSByZXBsYWNpbmcgdGhlIFhEUCBwcm9nIG9u IGFub3RoZXIgY29yZT8gTm90IGluIHRlcm1zIG9mCj4+PiBwb2ludGVyIHRlYXJpbmcsIEkgc2Vl IG5vdyB0aGF0IHRoaXMgaXMgaGFuZGxlZCBjb3JyZWN0bHksIGJ1dCBpbiB0ZXJtcwo+Pj4gb2Yg cmVmY291bnRzPyBDYW4ndCBicGZfcHJvZ19wdXQoKSBmcmVlIGl0IHdoaWxlIHRoZSBwb2xsaW5n IGlzIHN0aWxsCj4+PiBhY3RpdmU/Cj4+IAo+PiBIbW0geW91IG1lYW4gd2Ugc2hvdWxkIGRvIGJw Zl9wcm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NhbGxf cmN1KCkgdG8gYWN0dWFsbHkgZnJlZSB0aGUKcHJvZ3JhbSwgd2hpY2ggZ3VhcmFudGVlcyB0aGF0 IGFueSBvbmdvaW5nIFJDVSBjcml0aWNhbCBzZWN0aW9ucyBoYXZlCmVuZGVkIGJlZm9yZS4gQW5k IGFzIGV4cGxhaW5lZCBpbiB0aGF0IG90aGVyIHNlcmllcyBvZiBtaW5lLCB0aGlzCmluY2x1ZGVz IGFueSBvbmdvaW5nIE5BUEkgcG9sbCBjeWNsZXMuCgotVG9rZQpfX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fXwpJbnRlbC13aXJlZC1sYW4gbWFpbGluZyBsaXN0 CkludGVsLXdpcmVkLWxhbkBvc3Vvc2wub3JnCmh0dHBzOi8vbGlzdHMub3N1b3NsLm9yZy9tYWls bWFuL2xpc3RpbmZvL2ludGVsLXdpcmVkLWxhbgo= From mboxrd@z Thu Jan 1 00:00:00 1970 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 2818C7FC for ; Wed, 14 Jun 2023 13:47:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DF82C433C0; Wed, 14 Jun 2023 13:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686750426; bh=l5n/L5NHjNAUQ1q3ufBr1NoPvkev3JAl2SGy6BnnzGU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=k6kMpmx6XivSeaiPRuwbUD99PRsLTH6oD2s30Cm2DFNMisgGsqfob7OVR7eLuvosP FUbtHWrs66D1t85rZ9Rj72nnnl9xxX0ojxqAx1cpAIKcrI1SAziW9MO9XNbSCIqYt8 NU76sV7E6h3GZz9lfU8nBAKk/zeVWo1iFHvP7zi3bHdj9kI7I0fcXjqnRD4NHCvFXK zfFI596NxDeilaDIGuhudsNoPudhE/vYooZN7zf67RI9bzmdQVIfZ/MxkWEi/ELy6r T2JRPyxk/IfAuQiQHymcYrdGGVRu8mgT+FSSRHd2rBLPQp78KZ8uBXBtyvZTgn5ElB RwjVXQgzzzuEg== Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id BEE71BBEBC1; Wed, 14 Jun 2023 15:47:02 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Alexander Lobakin , Maciej Fijalkowski Cc: netdev@vger.kernel.org, anthony.l.nguyen@intel.com, intel-wired-lan@lists.osuosl.org, magnus.karlsson@intel.com, fred@cloudflare.com Subject: Re: [Intel-wired-lan] [PATCH iwl-next] ice: allow hot-swapping XDP programs In-Reply-To: References: <20230613151005.337462-1-maciej.fijalkowski@intel.com> <9eee635f-0898-f9d3-f3ba-f6da662c90cc@intel.com> <874jnbxmye.fsf@toke.dk> <16f10691-3339-0a18-402a-dc54df5a2e21@intel.com> X-Clacks-Overhead: GNU Terry Pratchett Date: Wed, 14 Jun 2023 15:47:02 +0200 Message-ID: <87sfaujgvd.fsf@toke.dk> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Alexander Lobakin writes: > From: Maciej Fijalkowski > Date: Wed, 14 Jun 2023 14:50:28 +0200 > >> On Wed, Jun 14, 2023 at 02:40:07PM +0200, Alexander Lobakin wrote: >>> From: Toke H=C3=B8iland-J=C3=B8rgensen >>> Date: Tue, 13 Jun 2023 19:59:37 +0200 > > [...] > >>> What if a NAPI polling cycle is being run on one core while at the very >>> same moment I'm replacing the XDP prog on another core? Not in terms of >>> pointer tearing, I see now that this is handled correctly, but in terms >>> of refcounts? Can't bpf_prog_put() free it while the polling is still >>> active? >>=20 >> Hmm you mean we should do bpf_prog_put() *after* we update bpf_prog on >> ice_rx_ring? I think this is a fair point as we don't bump the refcount >> per each Rx ring that holds the ptr to bpf_prog, we just rely on the main >> one from VSI. > > Not even after we update it there. I believe we should synchronize NAPI > cycles with BPF prog update (have synchronize_rcu() before put or so to > make the config path wait until there's no polling and onstack pointers, > would that be enough?). > > NAPI polling starts > |<--- XDP prog pointer is placed on the stack and used from there > | > | <--- here you do xchg() and bpf_prog_put() > | <--- here you update XDP progs on the rings > | > |<--- polling loop is still using the [now invalid] onstack pointer > | > NAPI polling ends No, this is fine; bpf_prog_put() uses call_rcu() to actually free the program, which guarantees that any ongoing RCU critical sections have ended before. And as explained in that other series of mine, this includes any ongoing NAPI poll cycles. -Toke