]> Git Repo - linux.git/commitdiff
mm/page-owner: use gfp_nested_mask() instead of open coded masking
authorDave Chinner <[email protected]>
Tue, 30 Apr 2024 05:28:25 +0000 (15:28 +1000)
committerAndrew Morton <[email protected]>
Sun, 19 May 2024 21:40:44 +0000 (14:40 -0700)
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/[email protected]
Signed-off-by: Dave Chinner <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Vlastimil Babka <[email protected]>
Reviewed-by: Oscar Salvador <[email protected]>
Cc: Andrey Konovalov <[email protected]>
Cc: Marco Elver <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
mm/page_owner.c

index 0a448d76e0af731efe259e5cc93f05cf48e7eba5..2d6360eaccbb6ee34bd3654823fa1e687a407a05 100644 (file)
@@ -168,13 +168,8 @@ static void add_stack_record_to_list(struct stack_record *stack_record,
        unsigned long flags;
        struct stack *stack;
 
-       /* Filter gfp_mask the same way stackdepot does, for consistency */
-       gfp_mask &= ~GFP_ZONEMASK;
-       gfp_mask &= (GFP_ATOMIC | GFP_KERNEL | __GFP_NOLOCKDEP);
-       gfp_mask |= __GFP_NOWARN;
-
        set_current_in_page_owner();
-       stack = kmalloc(sizeof(*stack), gfp_mask);
+       stack = kmalloc(sizeof(*stack), gfp_nested_mask(gfp_mask));
        if (!stack) {
                unset_current_in_page_owner();
                return;
This page took 0.066953 seconds and 4 git commands to generate.