Article View: linux.kernel.netdev
Article #686Re: [PATCH net v2] xsk: freeze deferred pool teardown without blocking unregister
From: Björn Töpel
Date: Thu, 08 Oct 2026 13:13
Date: Thu, 08 Oct 2026 13:13
100 lines
9849 bytes
9849 bytes
Stanislav Fomichev <sdf.kernel@gmail.com> writes:
> On 10/05, James Hilliard wrote:
>> Deferred pool destruction calls ndo_bpf() under RTNL. system_wq is
>> not frozen during system sleep, so that callback can run after a
>> device has suspended and gated its clocks. Use system_freezable_wq
>> so running destruction finishes before device suspend and new work
>> waits until process thaw.
...more PM suspend/resume issues...
I'd say this a bad smell/poor XSK contract that we need to use wq
freezable here. XSK capable drivers (and the core) should tolerate
calling the pool-removal path on suspended hardware and failed
resume/unregister.
Now that poor design leaks into net_device. :/
>> Keep assigned pools visible to NETDEV_UNREGISTER independently of
>> the socket list. A released socket has already left that list, but
>> its final pool put can queue destruction after workqueues freeze.
>> A resume-time unregister would then wait for a device reference
>> whose release cannot run until the resume completes.
>>
>> Track assigned pools per netdev under RTNL and detach remaining pools
>> after the notifier socket walk, including copy-mode pools. This also
>> covers leased queues without scanning pools from unrelated devices or
>> network namespaces. Remove the entry on assignment failure and normal
>> teardown. The deferred worker still owns the pool and later observes
>> the cleared device pointer, avoiding a second driver detach or put.
>>
>> The lifetime problem was identified by code inspection of the deferred
>> release and system-sleep paths.
>>
>> Fixes: 1c1efc2af158 ("xsk: Create and free buffer pool independently from umem")
>> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
>> ---
>> Changes in v2:
>> - Track assigned pools per netdev instead of scanning a global pool list.
>> - Keep deferred releases visible across queue changes and queue leases.
>> - Rebase onto current net.
>> - Link to v1: https://patch.msgid.link/20260930-xsk-suspend-teardown-v1-1-a6cac8c030be@gmail.com
>>
>> To: "David S. Miller" <davem@davemloft.net>
>> To: Eric Dumazet <edumazet@kernel.org>
>> To: Jakub Kicinski <kuba@kernel.org>
>> To: Paolo Abeni <pabeni@redhat.com>
>> To: Simon Horman <horms@kernel.org>
>> To: Andrew Lunn <andrew+netdev@lunn.ch>
>> To: Magnus Karlsson <magnus.karlsson@intel.com>
>> To: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
>> To: Stanislav Fomichev <sdf@fomichev.me>
>> To: Alexei Starovoitov <ast@kernel.org>
>> To: Daniel Borkmann <daniel@iogearbox.net>
>> To: Jesper Dangaard Brouer <hawk@kernel.org>
>> To: John Fastabend <john.fastabend@gmail.com>
>> To: Björn Töpel <bjorn@kernel.org>
>> Cc: netdev@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> Cc: bpf@vger.kernel.org
>> ---
>> include/linux/netdevice.h | 5 +++++
>> include/net/xsk_buff_pool.h | 3 +++
>> net/xdp/xsk.c | 5 +++++
>> net/xdp/xsk_buff_pool.c | 25 ++++++++++++++++++++++++-
>> 4 files changed, 37 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>> index 3cff2174dc03..72091938f6e6 100644
>> --- a/include/linux/netdevice.h
>> +++ b/include/linux/netdevice.h
>> @@ -2545,6 +2545,11 @@ struct net_device {
>> /* protected by rtnl_lock */
>> struct bpf_xdp_entity xdp_state[__MAX_XDP_MODE];
>>
>> +#ifdef CONFIG_XDP_SOCKETS
>> + /** @xsk_pools: assigned AF_XDP pools, protected by rtnl_lock */
>
>
> Can we mark this as being ops protected (net_device::lock) ?
+1
> xp_clear_dev calls netdev_lock_ops, but xp_assign_dev
> has netdev_assert_locked_ops_compat, so maybe there needs to be a bit more
> care. We don't want to add new ASSERT_RTNL if possible (and extend new
> netdev lock semantics).
>
> The rest looks good.
+1
I've made a mental note to try to improve this, and hopefully the we can
get rid of this in the future.
Björn
Technical Details
Message-ID:
<8733ug2v4b.fsf@all.your.base.are.belong.to.us>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342989-linux-kernel-netdev=dewy.ruReferences:
<20261005-xsk-suspend-teardown-v2-1-2d87228f4329@gmail.com> <asaTvPO05EpmUEgN@devvm7509.cco0.facebook.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342989-linux-kernel-netdev=dewy.ru From: bjorn@kernel.org (Björn Töpel) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2] xsk: freeze deferred pool teardown without blocking unregister Date: Thu, 08 Oct 2026 15:13:24 +0200 Organization: Usenet Network Message-ID: <8733ug2v4b.fsf@all.your.base.are.belong.to.us> References: <20261005-xsk-suspend-teardown-v2-1-2d87228f4329@gmail.com> <asaTvPO05EpmUEgN@devvm7509.cco0.facebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="888350"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:DGAKncZo69CGaHxxZ17j99oon24= sha256:TIiluK47d7bUEPKfTJhFwMpn/Zj+T0cOcEJCCkgezwU= sha1:iIEZb8E/yS8/kycMlQolYqb2ew4= sha256:OR96QX6eXOMK3ZDOm3f3mTobnPLAF/i0AUjXUf6inU8= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 2BCEE10F3FB; Thu, 8 Oct 2026 16:18:11 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.641 X-Spam-Status: No, score=-3.641 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.241, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bj6VTWJZ6Vat; Thu, 8 Oct 2026 16:18:03 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-342989-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id E7A4A10F3D0; Thu, 8 Oct 2026 16:17:59 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 35EA332C8C; Thu, 8 Oct 2026 13:13:30 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB5E149DBBE; Thu, 8 Oct 2026 13:13:29 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BkWI8EJs" X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 8F25322F767; Thu, 8 Oct 2026 13:13:28 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791465209; cv=none; b=M40jGoCR+id1niTKF8SvY0k64u3++xEV+wZyvg8T+YIFA84uGz0uXg9VxbunBzBP83nR7TMBXBiMN59VxVieDUQVbwlAxDzXcvRtkrcJ7GGU1WPiyDBEhQxWzjsCoyAHJNDPukTP1JXdRWlacfGP2TwnKgdS6F3oRs3hRj0Omgk= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791465209; c=relaxed/simple; bh=k1TJBFkSAk3KtFliSXk0zhsSmUITNqHtxPWRH4+FByc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=qRCHanlbA9zIoAIDIAfegczCSCSj82HnCFxr+oaGd6x1+clX+W6Ch8VLTK1IGHb+rIYVRsgHIBgJsjnDo4tQLTA57PRd3Vx2qn3J1AA6OXUvWGjtjF1aon3LPYpm7IH28ipcW1If1bINr/RgaUjoS8W9Ui1PL7eVtmxdv5Sttko= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BkWI8EJs; arc=none smtp.client-ip=100.103.45.18 X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B790F1F000FF; Thu, 8 Oct 2026 13:13:27 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791465208; bh=f5PLISdsbHKFluYJ5yvZ5YvG5VrlUsaLajuhgKm/fUw=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=BkWI8EJsBXHH0wrpbxOqswQs8kxgxYXVUniGBKWDEdcDw7XxDYbWym2WUHNNR0fBa fDFrOd83swNWnluQ/buMEf50XvzoHCiwdzJbAIQimdk2cMIT+Udzs3ULu4wm0HyIxR Pr1VAxeakLwNVW4MdicIz/0ZIfym5gRIU+QCjfxOj3nL2xQ/AQJZA2wGScrtzWgXEn JZDKGeaDTLeiWLTs9mSgRByKY7FP6v6yuX0ye6UkVdPljkgVIkQA5gtfioJoFBweow zvO9TUXpo8sthTAnzoH2T7GTIsYIZRF7MbLwTM6/xT/VemRN1mOLW8tyJr+Cmc1oVC HbTbi9Kdsynnw== X-Cc: netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>, Magnus Karlsson <magnus.karlsson@intel.com>, Maciej Fijalkowski <maciej.fijalkowski@intel.com>, Stanislav Fomichev <sdf@fomichev.me>, Simon Horman <horms@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Jesper Dangaard Brouer <hawk@kernel.org>, John Fastabend <john.fastabend@gmail.com>, Eric Dumazet <edumazet@kernel.org>, "David S. Miller" <davem@davemloft.net>, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch> X-In-Reply-To: <asaTvPO05EpmUEgN@devvm7509.cco0.facebook.com> X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>