Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: clarify GFP_ATOMIC/GFP_NOWAIT doc-comment

The current description of contexts where it's invalid to make GFP_ATOMIC
and GFP_NOWAIT calls is rather vague.

Replace this with a direct description of the actual contexts of concern
and refer to the RT docs where this is explained more discursively.

While rejigging this prose, also move the documentation of GFP_NOWAIT to
the GFP_NOWAIT section.

Link: https://lore.kernel.org/all/d912480a-5229-4efe-9336-b31acded30f5@suse.cz/
Link: https://lkml.kernel.org/r/20251219-b4-gfp_atomic-comment-v2-1-4c4ce274c2b6@google.com
Signed-off-by: Brendan Jackman <jackmanb@google.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Brendan Jackman and committed by
Andrew Morton
241b3a09 7969f305

+5 -2
+5 -2
include/linux/gfp_types.h
··· 309 309 * 310 310 * %GFP_ATOMIC users can not sleep and need the allocation to succeed. A lower 311 311 * watermark is applied to allow access to "atomic reserves". 312 - * The current implementation doesn't support NMI and few other strict 313 - * non-preemptive contexts (e.g. raw_spin_lock). The same applies to %GFP_NOWAIT. 312 + * The current implementation doesn't support NMI, nor contexts that disable 313 + * preemption under PREEMPT_RT. This includes raw_spin_lock() and plain 314 + * preempt_disable() - see "Memory allocation" in 315 + * Documentation/core-api/real-time/differences.rst for more info. 314 316 * 315 317 * %GFP_KERNEL is typical for kernel-internal allocations. The caller requires 316 318 * %ZONE_NORMAL or a lower zone for direct access but can direct reclaim. ··· 323 321 * %GFP_NOWAIT is for kernel allocations that should not stall for direct 324 322 * reclaim, start physical IO or use any filesystem callback. It is very 325 323 * likely to fail to allocate memory, even for very small allocations. 324 + * The same restrictions on calling contexts apply as for %GFP_ATOMIC. 326 325 * 327 326 * %GFP_NOIO will use direct reclaim to discard clean pages or slab pages 328 327 * that do not require the starting of any physical IO.