mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniil Tatianin <d-tatianin@yandex-team.ru>
To: 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: 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: Thu, 19 Nov 2026 02:12:19 +0300	[thread overview]
Message-ID: <b01826d2-63b9-4e2d-8857-a8cb72cd6ed5@yandex-team.ru> (raw)
In-Reply-To: <willemdebruijn.kernel.3b356fe59c775@gmail.com>

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

      reply	other threads:[~2026-11-18 23:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  8:59 Daniil Tatianin
2026-11-18 22:45 ` Willem de Bruijn
2026-11-18 23:12   ` Daniil Tatianin [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=b01826d2-63b9-4e2d-8857-a8cb72cd6ed5@yandex-team.ru \
    --to=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 \
    --cc=willemdebruijn.kernel@gmail.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

all inboxes | Powered by JetHome®