diff --git a/mm/memcontrol.c b/mm/memcontrol.c index f3087e22dfa91e..f973a025569bc6 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; }