Commit 55a68c82 authored by Vasily Averin's avatar Vasily Averin Committed by Linus Torvalds

memcg: replace in_interrupt() by !in_task() in active_memcg()

set_active_memcg() uses in_interrupt() check to select proper storage for
cgroup: pointer on task struct or per-cpu pointer.

It isn't fully correct: obsoleted in_interrupt() includes tasks with
disabled BH.  It's better to use '!in_task()' instead.

Link: https://lkml.org/lkml/2021/7/26/487
Link: https://lkml.kernel.org/r/ed4448b0-4970-616f-7368-ef9dd3cb628d@virtuozzo.com
Fixes: 37d5985c ("mm: kmem: prepare remote memcg charging infra for interrupt contexts")
Signed-off-by: default avatarVasily Averin <vvs@virtuozzo.com>
Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Roman Gushchin <guro@fb.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 96e51ccf
...@@ -306,7 +306,7 @@ set_active_memcg(struct mem_cgroup *memcg) ...@@ -306,7 +306,7 @@ set_active_memcg(struct mem_cgroup *memcg)
{ {
struct mem_cgroup *old; struct mem_cgroup *old;
if (in_interrupt()) { if (!in_task()) {
old = this_cpu_read(int_active_memcg); old = this_cpu_read(int_active_memcg);
this_cpu_write(int_active_memcg, memcg); this_cpu_write(int_active_memcg, memcg);
} else { } else {
......
...@@ -878,7 +878,7 @@ EXPORT_SYMBOL(mem_cgroup_from_task); ...@@ -878,7 +878,7 @@ EXPORT_SYMBOL(mem_cgroup_from_task);
static __always_inline struct mem_cgroup *active_memcg(void) static __always_inline struct mem_cgroup *active_memcg(void)
{ {
if (in_interrupt()) if (!in_task())
return this_cpu_read(int_active_memcg); return this_cpu_read(int_active_memcg);
else else
return current->active_memcg; return current->active_memcg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment