Documentation/core-api/memory-allocation.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
Make it abundantly clear that in the most cases objects should be
allocated with kzalloc_obj() and buffers should be allocated with
kzalloc().
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
This applies on top of "docs/core-api: memory-allocation: add
k[mz]alloc_obj() and clarify kmalloc" series
https://lore.kernel.org/all/20260902-docs-memalloc-guide-v2-0-218c1a4dcb80@kernel.org
Documentation/core-api/memory-allocation.rst | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Documentation/core-api/memory-allocation.rst b/Documentation/core-api/memory-allocation.rst
index 823f7fa57429b..648222b6c8576 100644
--- a/Documentation/core-api/memory-allocation.rst
+++ b/Documentation/core-api/memory-allocation.rst
@@ -23,12 +23,14 @@ answer, although very likely you should use
kzalloc_obj(<VAR_OR_TYPE>);
-or
+if you need memory for an object and
::
kzalloc(<size>, GFP_KERNEL);
+if you need memory for a buffer.
+
Of course there are cases when other allocation APIs and different GFP
flags must be used.
base-commit: d7dd88ed029164fe0a959e126d0ce18dd3719f89
--
2.53.0
On 9/7/26 08:36, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> > > Make it abundantly clear that in the most cases objects should be > allocated with kzalloc_obj() and buffers should be allocated with > kzalloc(). > > Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> > --- Reviewed-by: David Hildenbrand (Arm) <david@kernel.org> -- Cheers, David
On Mon, Sep 07, 2026 at 09:36:54AM +0300, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> > > Make it abundantly clear that in the most cases objects should be > allocated with kzalloc_obj() and buffers should be allocated with > kzalloc(). > > Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> LGTM so Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org> > --- > > This applies on top of "docs/core-api: memory-allocation: add > k[mz]alloc_obj() and clarify kmalloc" series > > https://lore.kernel.org/all/20260902-docs-memalloc-guide-v2-0-218c1a4dcb80@kernel.org > > Documentation/core-api/memory-allocation.rst | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/Documentation/core-api/memory-allocation.rst b/Documentation/core-api/memory-allocation.rst > index 823f7fa57429b..648222b6c8576 100644 > --- a/Documentation/core-api/memory-allocation.rst > +++ b/Documentation/core-api/memory-allocation.rst > @@ -23,12 +23,14 @@ answer, although very likely you should use > > kzalloc_obj(<VAR_OR_TYPE>); > > -or > +if you need memory for an object and > > :: > > kzalloc(<size>, GFP_KERNEL); > > +if you need memory for a buffer. > + > Of course there are cases when other allocation APIs and different GFP > flags must be used. > > > base-commit: d7dd88ed029164fe0a959e126d0ce18dd3719f89 > -- > 2.53.0 > -- Cheers, Lorenzo
On 9/7/26 08:36, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> > > Make it abundantly clear that in the most cases objects should be > allocated with kzalloc_obj() and buffers should be allocated with > kzalloc(). > > Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> > --- > > This applies on top of "docs/core-api: memory-allocation: add > k[mz]alloc_obj() and clarify kmalloc" series > > https://lore.kernel.org/all/20260902-docs-memalloc-guide-v2-0-218c1a4dcb80@kernel.org > > Documentation/core-api/memory-allocation.rst | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/Documentation/core-api/memory-allocation.rst b/Documentation/core-api/memory-allocation.rst > index 823f7fa57429b..648222b6c8576 100644 > --- a/Documentation/core-api/memory-allocation.rst > +++ b/Documentation/core-api/memory-allocation.rst > @@ -23,12 +23,14 @@ answer, although very likely you should use > > kzalloc_obj(<VAR_OR_TYPE>); > > -or > +if you need memory for an object and > > :: > > kzalloc(<size>, GFP_KERNEL); > > +if you need memory for a buffer. > + > Of course there are cases when other allocation APIs and different GFP > flags must be used. > > > base-commit: d7dd88ed029164fe0a959e126d0ce18dd3719f89
© 2016 - 2026 Red Hat, Inc.