From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Daniil Tatianin <d-tatianin@yandex-team.ru>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Daniil Tatianin <d-tatianin@yandex-team.ru>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net/packet: don't direct reclaim for contiguous ring blocks
Date: Wed, 18 Nov 2026 17:45:52 -0500 [thread overview]
Message-ID: <willemdebruijn.kernel.3b356fe59c775@gmail.com> (raw)
In-Reply-To: <20261117085951.681985-1-d-tatianin@yandex-team.ru>
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")?
> 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
prev parent reply other threads:[~2026-11-18 22:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 8:59 [PATCH net-next] net/packet: don't direct reclaim for contiguous ring blocks Daniil Tatianin
2026-11-18 22:45 ` Willem de Bruijn [this message]
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=willemdebruijn.kernel.3b356fe59c775@gmail.com \
--to=willemdebruijn.kernel@gmail.com \
--cc=d-tatianin@yandex-team.ru \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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