Skip to contentSkip to conversation

docs/core-api: memory-allocation: clarify when to use kzalloc_obj and kzalloc

PATCH Applied Mike Rapoport 4 participants 4 messages Sep 7

Subsystems (3)
lore
Share & tools
lore

Mike Rapoport

author reviewer
#0 lore raw

PATCH 1/1 docs/core-api: memory-allocation: clarify when to use kzalloc_obj and kzalloc

From: "Mike Rapoport (Microsoft)" <[email protected]>

Make it abundantly clear that in the most cases objects should be allocated with kzalloc_obj() and buffers should be allocated with kzalloc().

---

This applies on top of "docs/core-api: memory-allocation: add k[mz]alloc_obj() and clarify kmalloc" series

https://lore.kernel.org/all/[email protected]

 Documentation/core-api/memory-allocation.rst | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/core-api/memory-allocation.rst +3 -1
index 823f7fa57429b..648222b6c8576 100644
@@ -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

Signature · 1 line
2.53.0
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

Make it abundantly clear that in the most cases objects should be allocated with kzalloc_obj() and buffers should be allocated with kzalloc().

Quoted 32 lines

---

This applies on top of "docs/core-api: memory-allocation: add k[mz]alloc_obj() and clarify kmalloc" series

https://lore.kernel.org/all/[email protected]

 Documentation/core-api/memory-allocation.rst | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/core-api/memory-allocation.rst +3 -1
index 823f7fa57429b..648222b6c8576 100644
@@ -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

reviewer Acked-by on v1 1/1
#2 lore raw
In reply to Mike Rapoport
Quoted 7 lines · Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

Make it abundantly clear that in the most cases objects should be allocated with kzalloc_obj() and buffers should be allocated with kzalloc().

LGTM so

Quoted 31 lines

---

This applies on top of "docs/core-api: memory-allocation: add k[mz]alloc_obj() and clarify kmalloc" series

https://lore.kernel.org/all/[email protected]

 Documentation/core-api/memory-allocation.rst | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/core-api/memory-allocation.rst +3 -1
index 823f7fa57429b..648222b6c8576 100644
@@ -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.
 
Quoted 4 lines

base-commit: d7dd88ed029164fe0a959e126d0ce18dd3719f89 --
2.53.0

--
Cheers, Lorenzo