From: Kohei Enju <enjuk@amazon.com>
To: <vbabka@suse.cz>
Cc: <42.hyeyoo@gmail.com>, <akpm@linux-foundation.org>,
<cl@linux.com>, <davem@davemloft.net>, <edumazet@google.com>,
<enjuk@amazon.com>, <gnaaman@drivenets.com>, <horms@kernel.org>,
<iamjoonsoo.kim@lge.com>, <joel.granados@kernel.org>,
<kohei.enju@gmail.com>, <kuba@kernel.org>, <kuniyu@amazon.com>,
<linux-kernel@vger.kernel.org>, <lizetao1@huawei.com>,
<netdev@vger.kernel.org>, <pabeni@redhat.com>,
<penberg@kernel.org>, <rientjes@google.com>,
<roman.gushchin@linux.dev>
Subject: Re: [PATCH net-next v1] neighbour: Replace kvzalloc() with kzalloc() when GFP_ATOMIC is specified
Date: Tue, 18 Feb 2025 13:22:16 +0900 [thread overview]
Message-ID: <20250218042216.30357-1-enjuk@amazon.com> (raw)
In-Reply-To: <b4a2bf18-c1ec-4ccd-bed9-671a2fd543a9@suse.cz>
>>> > From: Kohei Enju <enjuk@amazon.com>
>>> > Date: Mon, 17 Feb 2025 01:30:16 +0900
>>> > > Replace kvzalloc()/kvfree() with kzalloc()/kfree() when GFP_ATOMIC is
>>> > > specified, since kvzalloc() doesn't support non-sleeping allocations such
>>> > > as GFP_ATOMIC.
>>> > >
>>> > > With incompatible gfp flags, kvzalloc() never falls back to the vmalloc
>>> > > path and returns immediately after the kmalloc path fails.
>>> > > Therefore, using kzalloc() is sufficient in this case.
>>> > >
>>> > > Fixes: 41b3caa7c076 ("neighbour: Add hlist_node to struct neighbour")
>>> >
>>> > This commit followed the old hash_buckets allocation, so I'd add
>>> >
>>> > Fixes: ab101c553bc1 ("neighbour: use kvzalloc()/kvfree()")
>>> >
>>> > too.
>>> >
>>> > Both commits were introduced in v6.13, so there's no difference in terms
>>> > of backporting though.
>>> >
>>> > Also, it would be nice to CC mm maintainers in case they have some
>>> > comments.
>>>
>>> Oh well, we need to trigger neigh_hash_grow() from a process context,
>>> or convert net/core/neighbour.c to modern rhashtable.
>>
>> Hi all, thanks for your comments.
>>
>> kzalloc() uses page allocator when size is larger than
>> KMALLOC_MAX_CACHE_SIZE, so I think what commit ab101c553bc1 ("neighbour:
>> use kvzalloc()/kvfree()") intended could be achieved by using kzalloc().
>
>Indeed, kzalloc() should be equivalent to pre-ab101c553bc1 code. kvmalloc()
>would only be necessary if you need more than order-3 page worth of memory
>and don't want it to fail because of fragmentation (but indeed it's not
>supported in GFP_ATOMIC context). But since you didn't need such large
>allocations before, you probably don't need them now too?
Yes, from pre-ab101c553bc1 code, it looks like we don't need the vmalloc
path for large allocations now too.
>> As mentioned, when using GFP_ATOMIC, kvzalloc() only tries the kmalloc
>> path, since the vmalloc path doesn't support the flag.
>> In this case, kvzalloc() is equivalent to kzalloc() in that neither try
>> the vmalloc path, so there is no functional change between this patch and
>> either commit ab101c553bc1 ("neighbour: use kvzalloc()/kvfree()") or
>
>Agreed.
>
>> commit 41b3caa7c076 ("neighbour: Add hlist_node to struct neighbour").
>>
>> Actually there's no real bug in the current code so the Fixes tag was not
>> appropriate. I shall remove the tag.
>
>True, the code is just more clear.
Thank you for looking at the patches and providing your comments.
I'll send out v2 with the revised commit message, removing the Fixes tag.
Regards,
Kohei
prev parent reply other threads:[~2025-02-18 4:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-16 16:30 [PATCH net-next v1] neighbour: Replace kvzalloc() with kzalloc() when GFP_ATOMIC is specified Kohei Enju
2025-02-16 19:06 ` Kuniyuki Iwashima
2025-02-17 8:56 ` Eric Dumazet
2025-02-17 16:52 ` Kohei Enju
2025-02-17 18:43 ` Vlastimil Babka
2025-02-18 4:22 ` Kohei Enju [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=20250218042216.30357-1-enjuk@amazon.com \
--to=enjuk@amazon.com \
--cc=42.hyeyoo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gnaaman@drivenets.com \
--cc=horms@kernel.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=joel.granados@kernel.org \
--cc=kohei.enju@gmail.com \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizetao1@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=vbabka@suse.cz \
/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