Skip to content

Commit 8b21ca0

Browse files
songmuchuntorvalds
authored andcommitted
mm: memcontrol: fix missing wakeup polling thread
When we poll the swap.events, we can miss being woken up when the swap event occurs. Because we didn't notify. Fixes: f3a53a3 ("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>
1 parent e7e0461 commit 8b21ca0

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

include/linux/memcontrol.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,12 +900,19 @@ static inline void count_memcg_event_mm(struct mm_struct *mm,
900900
static inline void memcg_memory_event(struct mem_cgroup *memcg,
901901
enum memcg_memory_event event)
902902
{
903+
bool swap_event = event == MEMCG_SWAP_HIGH || event == MEMCG_SWAP_MAX ||
904+
event == MEMCG_SWAP_FAIL;
905+
903906
atomic_long_inc(&memcg->memory_events_local[event]);
904-
cgroup_file_notify(&memcg->events_local_file);
907+
if (!swap_event)
908+
cgroup_file_notify(&memcg->events_local_file);
905909

906910
do {
907911
atomic_long_inc(&memcg->memory_events[event]);
908-
cgroup_file_notify(&memcg->events_file);
912+
if (swap_event)
913+
cgroup_file_notify(&memcg->swap_events_file);
914+
else
915+
cgroup_file_notify(&memcg->events_file);
909916

910917
if (!cgroup_subsys_on_dfl(memory_cgrp_subsys))
911918
break;

0 commit comments

Comments
 (0)