]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mm: memcontrol: fix missing wakeup polling thread
authorMuchun Song <songmuchun@bytedance.com>
Sat, 14 Nov 2020 06:52:13 +0000 (22:52 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Nov 2020 18:22:22 +0000 (19:22 +0100)
[ Upstream commit 8b21ca0218d29cc6bb7028125c7e5a10dfb4730c ]

When we poll the swap.events, we can miss being woken up when the swap
event occurs.  Because we didn't notify.

Fixes: f3a53a3a1e5b ("mm, memcontrol: implement memory.swap.events")
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Roman Gushchin <guro@fb.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Yafang Shao <laoar.shao@gmail.com>
Cc: Chris Down <chris@chrisdown.name>
Cc: Tejun Heo <tj@kernel.org>
Link: https://lkml.kernel.org/r/20201105161936.98312-1-songmuchun@bytedance.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/memcontrol.h

index d0b036123c6abd25f5a05d7c647c3c4cd083cbb4..fa635207fe96d88e1a413c3b1c65841aa4e39eae 100644 (file)
@@ -897,12 +897,19 @@ static inline void count_memcg_event_mm(struct mm_struct *mm,
 static inline void memcg_memory_event(struct mem_cgroup *memcg,
                                      enum memcg_memory_event event)
 {
+       bool swap_event = event == MEMCG_SWAP_HIGH || event == MEMCG_SWAP_MAX ||
+                         event == MEMCG_SWAP_FAIL;
+
        atomic_long_inc(&memcg->memory_events_local[event]);
-       cgroup_file_notify(&memcg->events_local_file);
+       if (!swap_event)
+               cgroup_file_notify(&memcg->events_local_file);
 
        do {
                atomic_long_inc(&memcg->memory_events[event]);
-               cgroup_file_notify(&memcg->events_file);
+               if (swap_event)
+                       cgroup_file_notify(&memcg->swap_events_file);
+               else
+                       cgroup_file_notify(&memcg->events_file);
 
                if (!cgroup_subsys_on_dfl(memory_cgrp_subsys))
                        break;