Skip to content

Commit

Permalink
mm: memcontrol: fix missing wakeup polling thread
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reviewed-by: Shakeel Butt <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Cc: Roman Gushchin <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Yafang Shao <[email protected]>
Cc: Chris Down <[email protected]>
Cc: Tejun Heo <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Muchun Song authored and torvalds committed Nov 14, 2020
1 parent e7e0461 commit 8b21ca0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions include/linux/memcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -900,12 +900,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;
Expand Down

0 comments on commit 8b21ca0

Please sign in to comment.