Skip to content

Commit 99b80ac

Browse files
dchinnerakpm00
authored andcommitted
mm/page-owner: use gfp_nested_mask() instead of open coded masking
The page-owner tracking code records stack traces during page allocation. To do this, it must do a memory allocation for the stack information from inside an existing memory allocation context. This internal allocation must obey the high level caller allocation constraints to avoid generating false positive warnings that have nothing to do with the code they are instrumenting/tracking (e.g. through lockdep reclaim state 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 stack tracking allocation masking to use gfp_nested_mask() to address these issues. gfp_nested_mask() naturally strips GFP_ZONEMASK, too, which greatly simplifies this code. Link: https://lkml.kernel.org/r/20240430054604.4169568-4-david@fromorbit.com Signed-off-by: Dave Chinner <dchinner@redhat.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> Cc: Marco Elver <elver@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 70c435c commit 99b80ac

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

mm/page_owner.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,8 @@ static void add_stack_record_to_list(struct stack_record *stack_record,
168168
unsigned long flags;
169169
struct stack *stack;
170170

171-
/* Filter gfp_mask the same way stackdepot does, for consistency */
172-
gfp_mask &= ~GFP_ZONEMASK;
173-
gfp_mask &= (GFP_ATOMIC | GFP_KERNEL | __GFP_NOLOCKDEP);
174-
gfp_mask |= __GFP_NOWARN;
175-
176171
set_current_in_page_owner();
177-
stack = kmalloc(sizeof(*stack), gfp_mask);
172+
stack = kmalloc(sizeof(*stack), gfp_nested_mask(gfp_mask));
178173
if (!stack) {
179174
unset_current_in_page_owner();
180175
return;

0 commit comments

Comments
 (0)