Article View: linux.kernel.netdev
Article #17711[PATCH net-next] net/packet: don't direct reclaim for contiguous ring blocks
From: Daniil Tatianin
Date: Tue, 17 Nov 2026 08:59
Date: Tue, 17 Nov 2026 08:59
48 lines
10115 bytes
10115 bytes
alloc_one_pg_vec_page() first asks the page allocator for a physically
contiguous block and falls back to vmalloc if that fails. The first
attempt uses __GFP_NORETRY, but that still allows one round of direct
compaction and reclaim before giving up. Under fragmentation every
block of a ring pays for that round, so setting up a ring can stall the
caller for seconds even though vmalloc would have worked right away.
On hosts that run tcpdump periodically we saw ring setup (8 order-6
blocks) stall for up to 1.4 s per block and 3.5 s per ring.
The contiguous block is only an optimization. User space maps the ring
page by page either way. So make the first attempt without direct
reclaim, as kvmalloc() already does since commit 46459154f997
("mm: kvmalloc: make kmalloc fast path real fast path"). kswapd is
still woken. The last resort attempt after a failed vmalloc keeps
direct reclaim. Order-0 blocks are left alone, the vmalloc fallback
would reclaim for them anyway.
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
---
net/packet/af_packet.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 8250e6a791f6..38f35a4f9d49 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -4493,8 +4493,16 @@ static char *alloc_one_pg_vec_page(unsigned long order)
char *buffer;
gfp_t gfp_flags = GFP_KERNEL_ACCOUNT | __GFP_COMP |
__GFP_ZERO | __GFP_NOWARN | __GFP_NORETRY;
+ gfp_t first_gfp_flags = gfp_flags;
- buffer = (char *) __get_free_pages(gfp_flags, order);
+ /*
+ * A contiguous block is only an optimization because vmalloc works
+ * too. Do not stall in reclaim or compaction to get one.
+ */
+ if (order)
+ first_gfp_flags &= ~__GFP_DIRECT_RECLAIM;
+
+ buffer = (char *) __get_free_pages(first_gfp_flags, order);
if (buffer)
return buffer;
base-commit: 073d54dc3ccc8c8109c56e4d984d1ad616554463
Technical Details
Message-ID:
<20261117085951.681985-1-d-tatianin@yandex-team.ru>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365073-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365073-linux-kernel-netdev=dewy.ru From: d-tatianin@yandex-team.ru (Daniil Tatianin) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next] net/packet: don't direct reclaim for contiguous ring blocks Date: Tue, 17 Nov 2026 11:59:49 +0300 Organization: Usenet Network Message-ID: <20261117085951.681985-1-d-tatianin@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2285282"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:JR2T10KKmW2ycZp4XEOxWCnvIpw= sha256:d/3xNDijX7ER+yWWrwYZoYVRJvQvhT3F90tTAdNX+m0= sha1:h4H3UOr5FA72S1NZ9KGSFhsTr14= sha256:7QpMJ4f6bG27CBpdzgqgxFiil7zIhdVRtVaU2K8fsvY= 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 A1389114E40; Tue, 17 Nov 2026 12:01:02 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=yandex-team.ru 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 yNLC7JGWjTYL; Tue, 17 Nov 2026 12:00:55 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-365073-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=yandex-team.ru X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 0EAE6114977; Tue, 17 Nov 2026 12:00:37 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id BF7463661A; Tue, 17 Nov 2026 09:00:12 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794906012; b=WNsf7pzJXtXs6rzqkoa2n8ihPv4DU0GOCeN6F4Vpc0VSW+kbw6VCmK92qxjj4a2wYugA /jMriZL036WIunpbZNCe8n2L1h44BLOYqY2N27MmQZH0W6Xo1LKJuznapz9DBF4RIz2GB 9jrFquLvTQR255jEDa6ucraLJUur5QYn3swbr4MFgRzuu2FK7ra5w4/Jg6rAoE6gQFmag ubHy+3BBjwRzXaERXdbqjODaECBb2+oVbQs2cF9OjypNvaiA0xSvZhEBNLPSzpbC1YjLY +limkx4Ah66dP7QaCnUhhMnqWnSFGVfITj78dKA6OFWSCJDKEZ3F5cqXBqh4TFFv24w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794906012; h=X-Original-To:Received:DMARC-Filter:Received:Received:X-Yandex-Fwd: DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=yrf6NhexygXD8i0mMxPEyNZF0DBQgXQ70/ethvzXbKU=; b=QG20Ff2GZo76T2k1Ffy9K2ZVMSIWg6K696Ar8fS2bDZeMTAgiEO+g/JlwbEowHJvq3BT sEBVAl0yJf4ZsmOu/dSJ8lz619FpXSzF65z6px6cWXe6rR8UbQHh+/FiJ75JQLrYTHNfl 0fE2nljeenGgA+Eqoua5blsNxWmRqMe0+N7/yKkv5FAtIuXV1blQH4rdTI3raY847j38o 6E5bZMYeOVm54lejgA84hK1T5rpjUPKZcYqFswvjnlTkmEBiMPbGCnnDR3IFviF++1Ev2 QwHlvmiT+KC5oafChXV0XyMklStWOv47zMw4KzsqjuRpghuVLZSbm2tCUTwYZhPOsgQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=yandex-team.ru header.i=@yandex-team.ru header.a=rsa-sha256 header.s=default header.b=dS98J49f; dmarc=pass header.from=yandex-team.ru; spf=pass smtp.mailfrom=yandex-team.ru; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8457F606A889; Tue, 17 Nov 2026 09:00:12 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex-team.ru header.i=@yandex-team.ru header.a=rsa-sha256 header.s=default header.b=dS98J49f X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=93.77.172.4 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794906011; b=AfdTl9kzWQL/KRAR8OY5UDpF8S2axs/Pc+DwYE+2/u4cuIS30osNXmfn3TYJfjwoUvu2 weRPfgJDkDhsfCeP4WyCvDIazLqZ+C8J5NqQ8r3YiQXja1z8Z2Ws4XE8RVhWiQb17IohG +1OfW5UNIw0cOamvOsUgVh6RRC8v5uYNPBzcbqs8EZ8iHANLN91Ej4tc1Zw+yrx8jB0Yz H4TBdOJUCxpwudaZwIKr1q3d/pXRujumRuPkXS2VI/7hHu53bSV93xSmOwYu2QVLi5er5 wmgf7vfDe3GJhtfSjy3xXo0sauKx0lvdV7bvMbrbmR//2UsBfMwAjjnPO3F+OnTAuhQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794906011; h=DMARC-Filter:Received:Received:X-Yandex-Fwd:DKIM-Signature:From:To: Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=yrf6NhexygXD8i0mMxPEyNZF0DBQgXQ70/ethvzXbKU=; b=GiuN40lLPrJM8JcqFjoo3m7uzjsL9/1TK9pVD2Nc4sJsWSfqjo+3itrno7LBT+l2kdaN wIflJbC3FMRMQPcSbptbw+QMsmqg8Sfol9a3hktKDngpQ2CLLxL8c53xJpBV8MEquIglp Fpny0TIDTGyq0Vo/1X9gDunXMF6yUyeO9acb0mrLOWv41K96sirz/apDIsTmNQRRbFnNB rff4GzIBIZpq6Nq58PadEuqG+aqp3Q4UuMtqKGcGJJcWwLHySqlfTzFEz6NM2d/ib/msO nkFF78fp9wdzXYGDBys1ns9nfS09z2V4W/NR6OLfOFRr7pbYmn4k1vYb+w53AsLY6CA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=yandex-team.ru; spf=pass smtp.mailfrom=yandex-team.ru; dkim=pass header.d=yandex-team.ru header.i=@yandex-team.ru header.a=rsa-sha256 header.s=default header.b=dS98J49f; arc=none smtp.remote-ip=93.77.172.4 X-Received: from forwardcorp1e.mail.yandex.net (forwardcorp1e.mail.yandex.net [93.77.172.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB925606A337; Tue, 17 Nov 2026 09:00:08 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EB925606A337 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex-team.ru X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex-team.ru X-Received: from mail-nwsmtp-smtp-corp-main-66 (unknown) by forwardcorp1e.mail.yandex.net (postfix) with ESMTPS id 61D34100031; Tue, 17 Nov 2026 12:00:01 +0300 (MSK) X-Received: from i101646577.yandex-team.ru by mail-nwsmtp-smtp-corp-main-66 with ESMTPSA id vxUih6Aa6Os0-GGOrX6TZ; Tue, 17 Nov 2026 12:00:00 +0300 X-Yandex-Fwd: 1 X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1794906000; bh=yrf6NhexygXD8i0mMxPEyNZF0DBQgXQ70/ethvzXbKU=; h=Message-ID:Date:Cc:Subject:To:From; b=dS98J49fGR91BqmRBIA9q0XV5r9PXDKuP2QB+LMVxuqUUeemY6pdnp8uPJt/wD2xb Do5GtuC6CDo3uxSUD0WmRac+PXigugeuW0yiApGXe8W1iSiYxef7maXuy1XijcsnHJ f6Buu2A/ZnbRkqaU9TEmEUzYo2xVhQRTsevXQZKE= X-Authentication-Results: mail-nwsmtp-smtp-corp-main-66; dkim=pass header.i=@yandex-team.ru X-Cc: Daniil Tatianin <d-tatianin@yandex-team.ru>, Simon Horman <horms@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: git-send-email 2.43.0 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list