diff options
author | Zefan Li <[email protected]> | 2020-06-01 21:49:55 -0700 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2020-06-02 10:59:09 -0700 |
commit | 50d53d7c724330a0dc4df26c45de2a9a886c5d88 (patch) | |
tree | 78f96ea668cdf25c65c7ebea448f5534b0a0fa1e | |
parent | 4b82ab4f28836646eca12cb37f408568d3cdc5c3 (diff) |
memcg: fix memcg_kmem_bypass() for remote memcg charging
While trying to use remote memcg charging in an out-of-tree kernel
module I found it's not working, because the current thread is a
workqueue thread.
As we will probably encounter this issue in the future as the users of
memalloc_use_memcg() grow, and it's nothing wrong for this usage, it's
better we fix it now.
Signed-off-by: Zefan Li <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reviewed-by: Roman Gushchin <[email protected]>
Reviewed-by: Shakeel Butt <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Cc: Vladimir Davydov <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r-- | mm/memcontrol.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index f3087e22dfa9..f973a025569b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2852,7 +2852,12 @@ static void memcg_schedule_kmem_cache_create(struct mem_cgroup *memcg, static inline bool memcg_kmem_bypass(void) { - if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD)) + if (in_interrupt()) + return true; + + /* Allow remote memcg charging in kthread contexts. */ + if ((!current->mm || (current->flags & PF_KTHREAD)) && + !current->active_memcg) return true; return false; } |