From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
Cc: "Vitaly Wool" <vitaly.wool@konsulko.se>,
"linux-mm" <linux-mm@kvack.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"LKML" <linux-kernel@vger.kernel.org>,
"Uladzislau Rezki" <urezki@gmail.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Vlastimil Babka" <vbabka@suse.cz>,
"rust-for-linux" <rust-for-linux@vger.kernel.org>,
"Lorenzo Stoakes" <lorenzo.stoakes@oracle.com>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
"Kent Overstreet" <kent.overstreet@linux.dev>,
<linux-bcachefs@vger.kernel.org>, "bpf" <bpf@vger.kernel.org>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
"Jann Horn" <jannh@google.com>,
"Pedro Falcato" <pfalcato@suse.de>
Subject: Re: [PATCH v12 1/4] mm/vmalloc: allow to set node and align in vrealloc
Date: Thu, 10 Jul 2025 11:57:50 +0200 [thread overview]
Message-ID: <DB8ABBBNMMVB.1QWW942P0MRJP@kernel.org> (raw)
In-Reply-To: <CAADnVQ+iZbKzx8bje=CLO=OnpmGHmQHpDNC=UjWYfN59bWoN3A@mail.gmail.com>
On Thu Jul 10, 2025 at 2:39 AM CEST, Alexei Starovoitov wrote:
> On Wed, Jul 9, 2025 at 4:26 PM Danilo Krummrich <dakr@kernel.org> wrote:
>>
>> On Thu Jul 10, 2025 at 1:14 AM CEST, Alexei Starovoitov wrote:
>> > On Wed, Jul 9, 2025 at 3:57 PM Danilo Krummrich <dakr@kernel.org> wrote:
>> >>
>> >> On 7/10/25 12:53 AM, Alexei Starovoitov wrote:
>> >> > On Wed, Jul 9, 2025 at 10:25 AM Vitaly Wool <vitaly.wool@konsulko.se> wrote:
>> >> >>
>> >> >>
>> >> >> -void *vrealloc_noprof(const void *p, size_t size, gfp_t flags)
>> >> >> +void *vrealloc_node_align_noprof(const void *p, size_t size, unsigned long align,
>> >> >> + gfp_t flags, int node)
>> >> >> {
>> >> >
>> >> > imo this is a silly pattern to rename functions because they
>> >> > got new arguments.
>> >> > The names of the args are clear enough "align" and "node".
>> >> > I see no point in adding the same suffixes to a function name.
>> >> > In the future this function will receive another argument and
>> >> > the function would be renamed again?!
>> >> > "_noprof" suffix makes sense, since it's there for alloc_hooks,
>> >> > but "_node_align_" is unnecessary.
>> >>
>> >> Do you have an alternative proposal given that we also have vrealloc() and
>> >> vrealloc_node()?
>> >
>> > vrealloc_node()?! There is no such thing in the tree.
>> > There are various k[zm]alloc_node() which are artifacts of the past
>> > when NUMA just appeared and people cared about CONFIG_NUMA vs not.
>> > Nowadays NUMA is everywhere and any new code must support NUMA
>> > from the start. Hence no point in carrying old baggage and obsolete names.
>>
>> This patch adds it; do you suggest to redefine vrealloc_noprof() to take align
>> and nid? If we don't mind being inconsistent with krealloc_noprof() and
>> kvrealloc_noprof() that's fine I guess.
>>
>> FWIW, I prefer consistency.
>
> What inconsistency are you talking about? That
> krealloc_noprof(const void *p, size_t new_size, gfp_t flags)
> and
> vrealloc_noprof(const void *p, size_t size, unsigned long align,
> gfp_t flags, int node)
> have different number of arguments?!
>
> See:
> alloc_pages_noprof(gfp_t gfp, unsigned int order);
> __alloc_pages_noprof(gfp_t gfp, unsigned int order, int preferred_nid,
> nodemask_t *nodemask);
>
> Adding double underscore to keep all existing callers of
> vrealloc_noprof() without changes and do:
>
> vrealloc_noprof(const void *p, size_t size, gfp_t flags);
> __vrealloc_noprof(const void *p, size_t size, unsigned long align,
> gfp_t flags, int node);
>
> is fine and consistent with how things were done in the past,
> but adding "_node_align_" to the function name and code churn to all
> callsites is a cargo cult.
As Vitaly mentioned in a different reply, this would be inconsistent with the
'k' and 'kv' variants, which have the suffix '_node'.
Anyways, in general I don't think that adding underscores for functions that
basically do the same thing but are getting more specialized is a great pattern
for things that are not strictly limited to a narrow context.
Please note, I'm not saying we should encode additional arguments in the name
either. I think it really depends on the actual case.
In this case, it seems to make sense to me that there is e.g. kmalloc() and
kmalloc_node().
For a caller that's much more useful, i.e. I want classic kmalloc(), but want to
set the node, hence kmalloc_node(). Calling it __kmalloc() instead seems a bit
random.
Or do you only refer to the *_noprof() variants, which are not exported to
users? But even then, underscores still don't seem very expressive.
I'm not maintaining this code though, so just take it FWIW. :)
next prev parent reply other threads:[~2025-07-10 9:57 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-09 17:23 [PATCH v12 0/4] support large align and nid in Rust allocators Vitaly Wool
2025-07-09 17:24 ` [PATCH v12 1/4] mm/vmalloc: allow to set node and align in vrealloc Vitaly Wool
2025-07-09 19:01 ` Liam R. Howlett
2025-07-10 6:21 ` Vitaly Wool
2025-07-10 15:09 ` Liam R. Howlett
2025-07-10 15:19 ` Lorenzo Stoakes
2025-07-10 18:57 ` Vitaly Wool
2025-07-10 14:07 ` Vitaly Wool
2025-07-09 22:53 ` Alexei Starovoitov
2025-07-09 22:57 ` Danilo Krummrich
2025-07-09 23:14 ` Alexei Starovoitov
2025-07-09 23:26 ` Danilo Krummrich
2025-07-10 0:39 ` Alexei Starovoitov
2025-07-10 6:16 ` Vitaly Wool
2025-07-10 9:57 ` Danilo Krummrich [this message]
2025-07-09 17:24 ` [PATCH v12 2/4] mm/slub: allow to set node and align in k[v]realloc Vitaly Wool
2025-07-10 7:45 ` Vlastimil Babka
2025-07-11 8:58 ` Harry Yoo
2025-07-11 11:11 ` Kent Overstreet
2025-07-11 15:43 ` Vlastimil Babka
2025-07-12 12:43 ` Vitaly Wool
2025-07-14 8:14 ` Vlastimil Babka
2025-07-14 15:27 ` Vitaly Wool
2025-07-15 7:03 ` Alice Ryhl
2025-07-09 17:24 ` [PATCH v12 3/4] rust: add support for NUMA ids in allocations Vitaly Wool
2025-07-09 20:58 ` Danilo Krummrich
2025-07-09 17:25 ` [PATCH v12 4/4] rust: support large alignments " Vitaly Wool
2025-07-09 21:00 ` Danilo Krummrich
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=DB8ABBBNMMVB.1QWW942P0MRJP@kernel.org \
--to=dakr@kernel.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=alexei.starovoitov@gmail.com \
--cc=aliceryhl@google.com \
--cc=bpf@vger.kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=jannh@google.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=pfalcato@suse.de \
--cc=rust-for-linux@vger.kernel.org \
--cc=urezki@gmail.com \
--cc=vbabka@suse.cz \
--cc=vitaly.wool@konsulko.se \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.