Re: [PATCH v2 1/3] Documentation: adopt new coding style of type-aware kmalloc-family

Manuel Ebner
2026-04-21T19:50:42Z

On Tue, 2026-04-21 at 20:24 +0100, Matthew Wilcox wrote:
> On Tue, Apr 21, 2026 at 08:01:58PM +0200, Manuel Ebner wrote:
> > +++ b/Documentation/core-api/memory-allocation.rst
> > @@ -135,7 +135,7 @@ Selecting memory allocator
> >  The most straightforward way to allocate memory is to use a function
> >  from the kmalloc() family. And, to be on the safe side it's best to use
> >  routines that set memory to zero, like kzalloc(). If you need to
> > -allocate memory for an array, there are kmalloc_array() and kcalloc()
> > +allocate memory for an array, there are kmalloc_objs() and kzalloc_objs()
> >  helpers. The helpers struct_size(), array_size() and array3_size() can
> >  be used to safely calculate object sizes without overflowing.
>
> This seems to have been done without any thought.  kmalloc_array() still
> exists and has over 500 callers.  It should not be de-documented.

you are right

> > @@ -151,7 +151,7 @@ sizes, the alignment is guaranteed to be at least the
> > largest power-of-two
> >  divisor of the size.
> >
> >  Chunks allocated with kmalloc() can be resized with krealloc(). Similarly
> > -to kmalloc_array(): a helper for resizing arrays is provided in the form of
> > +to kmalloc_objs(): a helper for resizing arrays is provided in the form of
> >  krealloc_array().
>
> Think about why this is wrong too.

i see now.

> And you should have cc'd linux-mm on this.

will add in [v3]

thanks,

manuel