Article View: linux.kernel.netdev
Article #18795Re: [PATCH net-next] net/packet: don't direct reclaim for contiguous ring blocks
From: Daniil Tatianin
Date: Wed, 18 Nov 2026 23:12
Date: Wed, 18 Nov 2026 23:12
58 lines
11001 bytes
11001 bytes
On 11/19/26 1:45 AM, Willem de Bruijn wrote:
> Daniil Tatianin wrote:
>> 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.
> Is this still the case with recent commit 0e05a469c294 ("mm/page_alloc:
> avoid direct reclaim and compaction for costly __GFP_NORETRY allocations")?
I think this fixes the issue for order > 3, so my patch is not needed
anymore.
Thanks for pointing it out!
>
>> 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:
<b01826d2-63b9-4e2d-8857-a8cb72cd6ed5@yandex-team.ru>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366498-linux-kernel-netdev=dewy.ruReferences:
<20261117085951.681985-1-d-tatianin@yandex-team.ru> <willemdebruijn.kernel.3b356fe59c775@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366498-linux-kernel-netdev=dewy.ru From: d-tatianin@yandex-team.ru (Daniil Tatianin) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next] net/packet: don't direct reclaim for contiguous ring blocks Date: Thu, 19 Nov 2026 02:12:19 +0300 Organization: Usenet Network Message-ID: <b01826d2-63b9-4e2d-8857-a8cb72cd6ed5@yandex-team.ru> References: <20261117085951.681985-1-d-tatianin@yandex-team.ru> <willemdebruijn.kernel.3b356fe59c775@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="2725376"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:XcUqzqjqSvz0buZx7MCDT1UMUr0= sha256:TNoNpq0nyV1hrnYYwrlMd4OAD4MTYp7ou25slxHcFOE= sha1:bpf2iCRFkf+/E5fpdQWp5ybpb5k= sha256:nQIdXv8lUrNAa6e8nyc2MqC4D1hZ3Hv/YxkT065UhQY= Content-Language: en-US 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 20F7911540F; Thu, 19 Nov 2026 02:12:51 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.049 X-Spam-Status: No, score=-3.049 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, URIBL_BLOCKED=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 5D_AMYmcocMx; Thu, 19 Nov 2026 02:12:47 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366498-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 35C6A11540A; Thu, 19 Nov 2026 02:12:38 +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 BA97F2291C8; Wed, 18 Nov 2026 23:12:34 +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=1795043554; b=uJ5w9CSU1qSurDXM1jKz9rDSqP17xmJKojnK2m+cbftB8MsyHzj7dW1/42cupx4uadOV ybP7oaewpUdUCrrP1a0CHeaT7LZZ5hibEwJBrtRkRYPyCEs+gpYSi5HnwadvypLiTpf1I +OqJPmAOzarU/6BmKEkO+EJUbNc8e7avZOiMAFVkiym6fGox0Ci+v7bBno9s+Q/AYIlld bHTyCvgeHUpd9OL0ThD6MsRi7V5Vq+LeUukUbj/cv1cehOjUwCbgFbhkCJ5U0QhrNhbnw 7DyZNqHtZAn1qG3/XS1n2ZDFy/Gg0WCwiODH9qTUjo3/HA+6p9290qvVy8TypAanHPA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795043554; h=X-Original-To:Received:DMARC-Filter:Received:Received:X-Yandex-Fwd: DKIM-Signature:Message-ID:Date:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=YVDspEK0iLkF1tAiZM9WXoiqd71MESnJ392z8YtPtdQ=; b=RFGeKh5IwVSsh5MXY89+qUjAyNsusRSALATCxG2Mv/QXYHCm3sWNkcIChse/BsBmVirL e+FbyQpRE823vXj3NS0aK47I2b/XPM55uEgIW+XCRaac0uUQ0d1ldjgYOd/P8btbgOv6f Ddh2zo98CDH8gvCzbrrf1hnAPFbR8JgaagI9KFeTgoAgtAXZ0aClQU8snaa/NSrLv0W+0 zfixOU1cirl6idjuO8k9UK4ljxTySTnrubTytMSpJP4XuQzJ8Ooi01WsFIpmbKXReaT8i RL83X09NmG8TzbnIGxIIm+6XIBEyS7HkWAXqk3EjySxZ2nM/owm5fKsYT65nYsBSAtQ== 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=A+SBiDxM; 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 0A6A6606A338; Wed, 18 Nov 2026 23:12:34 +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=A+SBiDxM X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=178.154.239.200 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795043553; b=xYyxhqElalgkACjL2KJxH88DNvPG0omIC3EyIGlTgjDI3xWgW7ytvmQNUcRwODxA5JEP W940vLkOyQ9HEqIM+SjNthzD8n6rZo6VtU3ePudgfhrHgcFLRkNj/lqNWqBBItfUAGwam g7hh/FMQyOLwGeNSZn+NhSAAbdqWlMkfNVEJYE9Uef5F/SkCXFeYnM/xu+NW/G1ZkYTnY KpLHztONBNoT0yyy8X9U3xVm0qzjeh19IFPPJJe1wol5iHvpQ6RsCEDsGIBowUqeh9c3B I9FuIMvwoMb3QMP48COWIC7X0mI0H0t24KS3/iLCnhaldSWonDky7sopsTGhz5SKung== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795043553; h=DMARC-Filter:Received:Received:X-Yandex-Fwd:DKIM-Signature: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=YVDspEK0iLkF1tAiZM9WXoiqd71MESnJ392z8YtPtdQ=; b=y6is2zV1S6TVZXIHazTngg0Y9rU5mb9VUYlCAHI0Ik+q6V8QglIijG3qyyCrV8skQx2T URlpU1taVDy+WtfKTznzMIXfba84Ju8XyX349apJ2o0Jexk+iHK+QwPEduvFsiGb4/CkK dFyRy6sMd1MyTleHgXzWHJpJHC13gyEzHRqOMdfnBrC4NcOCsSPTQ/WI8F9jLhTZG95i/ Ru+Qvrkv5jHt/FCIrjwLIea4GPnzubQvl/i7tj+h/LChifDtvLlqTk4al8xtmQpaw4BRj L9i4uXuiWEwCeORhablda/wXg0OpFM6/GoovB4EZRGUdGYkdxv8U7yzu8oJ15SpsnFg== 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=A+SBiDxM; arc=none smtp.remote-ip=178.154.239.200 X-Received: from forwardcorp1d.mail.yandex.net (forwardcorp1d.mail.yandex.net [178.154.239.200]) (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 75F0A606A320; Wed, 18 Nov 2026 23:12:30 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 75F0A606A320 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-57 (mail-nwsmtp-smtp-corp-main-57.yp-c.yandex.net) by forwardcorp1d.mail.yandex.net (postfix) with ESMTPS id 35A3580E78; Thu, 19 Nov 2026 02:12:21 +0300 (MSK) X-Received: from [IPV6:2a02:6bf:8080:a88::1:1b] by mail-nwsmtp-smtp-corp-main-57 with ESMTPSA id JCkYfr0vwW20-hJIPHIu7; Thu, 19 Nov 2026 02:12:20 +0300 X-Yandex-Fwd: 1 X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1795043540; bh=YVDspEK0iLkF1tAiZM9WXoiqd71MESnJ392z8YtPtdQ=; h=From:In-Reply-To:Cc:Date:References:To:Subject:Message-ID; b=A+SBiDxMIEUT0J6uZtYuI730PtZZpPLYU7cYw/Ls2+RDYHodrDacY46IuaQGz9PXi gRzw3DIux8SDSvu6PoryMe2ov2hP1dfROPkoTxDiWucwHV1KDtMKwc/B88wNESMwuo 4k/PXv+eVQ7KgZZNCiCLc7/DsDFGvG9CwFR7lkV4= X-Authentication-Results: mail-nwsmtp-smtp-corp-main-57; dkim=pass header.i=@yandex-team.ru 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 X-User-Agent: Mozilla Thunderbird X-Cc: Simon Horman <horms@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <willemdebruijn.kernel.3b356fe59c775@gmail.com>