]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
memcg: unify force charging conditions
authorShakeel Butt <shakeelb@google.com>
Tue, 22 Mar 2022 21:40:22 +0000 (14:40 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Mar 2022 22:57:02 +0000 (15:57 -0700)
Currently the kernel force charges the allocations which have __GFP_HIGH
flag without triggering the memory reclaim.  __GFP_HIGH indicates that
the caller is high priority and since commit 869712fd3de5 ("mm:
memcontrol: fix network errors from failing __GFP_ATOMIC charges") the
kernel lets such allocations do force charging.  Please note that
__GFP_ATOMIC has been replaced by __GFP_HIGH.

__GFP_HIGH does not tell if the caller can block or can trigger reclaim.
There are separate checks to determine that.  So, there is no need to
skip reclaiming for __GFP_HIGH allocations.  So, handle __GFP_HIGH
together with __GFP_NOFAIL which also does force charging.

Please note that this is a noop change as there are no __GFP_HIGH
allocators in the kernel which also have __GFP_ACCOUNT (or SLAB_ACCOUNT)
and does not allow reclaim for now.

Link: https://lkml.kernel.org/r/20220211064917.2028469-3-shakeelb@google.com
Signed-off-by: Shakeel Butt <shakeelb@google.com>
Reviewed-by: Roman Gushchin <guro@fb.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Chris Down <chris@chrisdown.name>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memcontrol.c

index 0451cc06b157c57cc6f6620fcd1d0ea65a223e15..0e8a58d6e374b06c4b7c3455f503477db5714d2a 100644 (file)
@@ -2565,15 +2565,6 @@ retry:
                goto retry;
        }
 
-       /*
-        * Memcg doesn't have a dedicated reserve for atomic
-        * allocations. But like the global atomic pool, we need to
-        * put the burden of reclaim on regular allocation requests
-        * and let these go through as privileged allocations.
-        */
-       if (gfp_mask & __GFP_ATOMIC)
-               goto force;
-
        /*
         * Prevent unbounded recursion when reclaim operations need to
         * allocate memory. This might exceed the limits temporarily,
@@ -2647,7 +2638,13 @@ retry:
                goto retry;
        }
 nomem:
-       if (!(gfp_mask & __GFP_NOFAIL))
+       /*
+        * Memcg doesn't have a dedicated reserve for atomic
+        * allocations. But like the global atomic pool, we need to
+        * put the burden of reclaim on regular allocation requests
+        * and let these go through as privileged allocations.
+        */
+       if (!(gfp_mask & (__GFP_NOFAIL | __GFP_HIGH)))
                return -ENOMEM;
 force:
        /*