Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Mark Syms <mark.syms@citrix.com>
To: Juergen Gross <jgross@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Jesper Dangaard Brouer <hawk@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	netdev@vger.kernel.org, xen-devel@lists.xenproject.org,
	bpf@vger.kernel.org, Mark Syms <mark.syms@citrix.com>,
	stable@vger.kernel.org
Subject: [PATCH net] xen-netfront: unregister the XDP rxq before destroying its page_pool
Date: Tue, 24 Nov 2026 09:18:06 +0000	[thread overview]
Message-ID: <20261124091806.2736453-1-mark.syms@citrix.com> (raw)

Each receive queue registers its page_pool as the XDP memory model,
which takes a second reference on the pool. On disconnect,
xennet_disconnect_backend() calls page_pool_destroy() but never
unregisters the rxq, so the pool's user count never reaches zero and
the pool is never released, together with the receive buffers that
xennet_release_rx_bufs() has just recycled into it. Every
suspend/resume or backend reconnect therefore leaks one pool per
receive queue. The pool never begins shutdown, so the page_pool stall
warning does not fire and the leak is silent.

Unregister the rxq before destroying the pool, and clear the pointer
so that a second disconnect without a reconnect is harmless.

The leak was observed in CI testing: in XenServer suspend/resume
stress runs, HVM guests lost available memory on every cycle until
they stalled. Over 100 suspend/resume cycles the loss scaled with the
number of VIFs, on Debian 12 (6.1.0-50) and Ubuntu 26.04 (7.0.0-30)
guests alike; the missing unregister was then found by code
inspection. Reproducing it needs no kernel modification: suspend and
resume a guest repeatedly and compare MemAvailable.

Tested on Debian 12 HVM guests on XenServer 9 (Xen 4.21, AMD EPYC),
running two builds of the same 6.1.192 source with and without this
patch. Over 100 suspend/resume cycles the unpatched kernel lost
1107 KiB per cycle with one VIF and 2279 KiB with two; the patched
kernel lost 51 and 42 KiB. On current mainline the patch builds
without warnings at W=1 but was not boot-tested, and kernel selftests
were not run.

An AI coding assistant (Claude Code) was used to locate the cause,
write the fix and draft this changelog.

Fixes: 6c5aa6fc4def ("xen networking: add basic XDP support for xen-netfront")
Cc: stable@vger.kernel.org
Signed-off-by: Mark Syms <mark.syms@citrix.com>
---
 drivers/net/xen-netfront.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index fdcb91042..b82b3bdb2 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1860,7 +1860,10 @@ static void xennet_disconnect_backend(struct netfront_info *info)
 		queue->tx.sring = NULL;
 		queue->rx.sring = NULL;
 
+		if (xdp_rxq_info_is_reg(&queue->xdp_rxq))
+			xdp_rxq_info_unreg(&queue->xdp_rxq);
 		page_pool_destroy(queue->page_pool);
+		queue->page_pool = NULL;
 	}
 }
 
-- 
2.56.0


                 reply	other threads:[~2026-11-24  9:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124091806.2736453-1-mark.syms@citrix.com \
    --to=mark.syms@citrix.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hawk@kernel.org \
    --cc=jgross@suse.com \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=sstabellini@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox