Skip to content

Commit

Permalink
coding-style.rst: Generic alloc functions do not need OOM logging
Browse files Browse the repository at this point in the history
Generic allocation functions already emit a dump_stack()
so additional error logging isn't useful.

Document it as such and add a reference to the allocation
API.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
  • Loading branch information
Joe Perches authored and Jonathan Corbet committed Apr 1, 2019
1 parent 0663a05 commit bba757d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Documentation/process/coding-style.rst
Original file line number Diff line number Diff line change
@@ -843,7 +843,8 @@ used.
The kernel provides the following general purpose memory allocators:
kmalloc(), kzalloc(), kmalloc_array(), kcalloc(), vmalloc(), and
vzalloc(). Please refer to the API documentation for further information
about them.
about them. :ref:`Documentation/core-api/memory-allocation.rst
<memory_allocation>`

The preferred form for passing a size of a struct is the following:

@@ -874,6 +875,9 @@ The preferred form for allocating a zeroed array is the following:
Both forms check for overflow on the allocation size n * sizeof(...),
and return NULL if that occurred.

These generic allocation functions all emit a stack dump on failure when used
without __GFP_NOWARN so there is no use in emitting an additional failure
message when NULL is returned.

15) The inline disease
----------------------

0 comments on commit bba757d

Please sign in to comment.