stackdepot: use gfp_nested_mask() instead of open coded masking
authorDave Chinner <dchinner@redhat.com>
Tue, 30 Apr 2024 05:28:24 +0000 (15:28 +1000)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 19 May 2024 21:40:44 +0000 (14:40 -0700)
commit70c435ca8dcb64e3d7983a30a14484aa163bb2d2
tree3dfbbdc2f925ab1c6026f8da4514bff2c693c748
parent1c00f9368628dde7337defd3699025e3611a816f
stackdepot: use gfp_nested_mask() instead of open coded masking

The stackdepot code is used by KASAN and lockdep for recoding stack
traces.  Both of these track allocation context information, and so their
internal allocations must obey the caller allocation contexts to avoid
generating their own false positive warnings that have nothing to do with
the code they are instrumenting/tracking.

We also don't want recording stack traces to deplete emergency memory
reserves - debug code is useless if it creates new issues that can't be
replicated when the debug code is disabled.

Switch the stackdepot allocation masking to use gfp_nested_mask() to
address these issues.  gfp_nested_mask() also strips GFP_ZONEMASK
naturally, so that greatly simplifies this code.

Link: https://lkml.kernel.org/r/20240430054604.4169568-3-david@fromorbit.com
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Marco Elver <elver@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/stackdepot.c