From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj2-f6.google.com (mail-pj2-f6.google.com [74.125.227.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A364F36A341 for ; Wed, 7 Oct 2026 18:51:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.227.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791399085; cv=none; b=Mwrv0w5bfpEgV7eKjAOC8RS98YmHv4QYlS+ScfbbBivXAOiWAuaSlW0X1dsppWuTLRXpCP1mQHGfGmlMIsEJhAFWnRNTOKLB9HyehxXk8n2gdUPVka2mFXiW++NLGr9D/GpWZcovYb5ywn+EJEmVLRFFxgoXE2YfT17BWN3rPfg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791399085; c=relaxed/simple; bh=ooFE7wgNH86QzW50A74Hxs0eR/QZYfgdmjGkzqzYeSs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Fh5Bq63mjt328D+5bjgpAcEFlYe7BKvoERmYvfTCYLOAE8D0VyNLOYwy4OoRJqn+dOmlNj+q0SF9lwlxq2nfZ+39Hwt1pqpI+RxQtMjtANo2l4eXv2EhlC2wYmv+ewqgqyRUYPc1CAMkeOgOOYlzYitXT0Cz4Q/oUrNWMSN0sJY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UYU9wJxU; arc=none smtp.client-ip=74.125.227.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UYU9wJxU" Received: by mail-pj2-f6.google.com with SMTP id 98e67ed59e1d1-3964e7720afso1544661a91.1 for ; Wed, 07 Oct 2026 11:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791399084; x=1792003884; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=X71f5KGOL/rbhedaUKsgXlp/Wmx4B13NNF0vqiORCgc=; b=UYU9wJxUW8RQY34jHuYGL+FPkvRW3Y1QTJlT6kUlCrIKZ33cSWo37k3aZJPIEtPbcS iw31KIb2d+7FQI6Q+ZziZA55y7RM/YrMwHbRxH8BqMBoyUcShZ4ZfkMWHVbQ+XZpRnO7 M/0YLM/npZ2WdSIoKh+PS2kUsACPPJ2gqrCKu2b9ItB+d5Z9UiM2tk/t5feiZX86VWDJ /29KL+C4+nsdKLD4pRCtndiKyMRN0640JoEA2+ShJ992wRIaEvV5kw2v2J/Vh2uDfxq5 REn95bUX+yA8WeYzTuZseAyGP+ynjCnUpz61kzeLC+LQ2odxjZQXnB/6ug7iF0uI0VUG j1SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791399084; x=1792003884; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=X71f5KGOL/rbhedaUKsgXlp/Wmx4B13NNF0vqiORCgc=; b=HOMCJrSaDNjNg11nfYzSQt4J29YMvQvspe4cPEXIrk/tYftKlolS26ggf2lZbz0JB5 qWA2fZBkcuh6OLmBge18/KJdORwRk5xQF0jxQjOGgQF1lPesUue+7PxkaoKY10EjZN2B xvNyc/z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oct 2026 11:51:23 -0700 (PDT) Received: from localhost ([2a03:2880:2ff:4e::]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3a9f1a23c82sm754330a91.1.2026.10.07.11.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Oct 2026 11:51:23 -0700 (PDT) Date: Wed, 7 Oct 2026 11:51:19 -0700 From: Stanislav Fomichev To: James Hilliard Cc: netdev@vger.kernel.org, Paolo Abeni , Jakub Kicinski , Magnus Karlsson , Maciej Fijalkowski , Stanislav Fomichev , Simon Horman , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Eric Dumazet , "David S. Miller" , =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Lunn Subject: Re: [PATCH net v2] xsk: freeze deferred pool teardown without blocking unregister Message-ID: References: <20261005-xsk-suspend-teardown-v2-1-2d87228f4329@gmail.com> 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: <20261005-xsk-suspend-teardown-v2-1-2d87228f4329@gmail.com> 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. > > 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 > --- > 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" > To: Eric Dumazet > To: Jakub Kicinski > To: Paolo Abeni > To: Simon Horman > To: Andrew Lunn > To: Magnus Karlsson > To: Maciej Fijalkowski > To: Stanislav Fomichev > To: Alexei Starovoitov > To: Daniel Borkmann > To: Jesper Dangaard Brouer > To: John Fastabend > To: Björn Töpel > 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) ? 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.