linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm: memcontrol: fix missing wakeup polling thread
@ 2020-11-05 16:19 Muchun Song
  2020-11-05 16:25 ` Johannes Weiner
  2020-11-06 16:27 ` Shakeel Butt
  0 siblings, 2 replies; 3+ messages in thread
From: Muchun Song @ 2020-11-05 16:19 UTC (permalink / raw)
  To: akpm, hannes, shakeelb, guro, mhocko, laoar.shao, chris, tj
  Cc: linux-kernel, Muchun Song

When wen poll the swap.events, we can miss being waked 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>
---
 changelog in v2:
 - Fix problem, thanks Johannes.

 include/linux/memcontrol.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 0f4dd7829fb2..4f7821be5561 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1074,12 +1074,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;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mm: memcontrol: fix missing wakeup polling thread
  2020-11-05 16:19 [PATCH v2] mm: memcontrol: fix missing wakeup polling thread Muchun Song
@ 2020-11-05 16:25 ` Johannes Weiner
  2020-11-06 16:27 ` Shakeel Butt
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Weiner @ 2020-11-05 16:25 UTC (permalink / raw)
  To: Muchun Song
  Cc: akpm, shakeelb, guro, mhocko, laoar.shao, chris, tj, linux-kernel

On Fri, Nov 06, 2020 at 12:19:36AM +0800, Muchun Song wrote:
> When wen poll the swap.events, we can miss being waked 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>

Cool, thanks!

Acked-by: Johannes Weiner <hannes@cmpxchg.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mm: memcontrol: fix missing wakeup polling thread
  2020-11-05 16:19 [PATCH v2] mm: memcontrol: fix missing wakeup polling thread Muchun Song
  2020-11-05 16:25 ` Johannes Weiner
@ 2020-11-06 16:27 ` Shakeel Butt
  1 sibling, 0 replies; 3+ messages in thread
From: Shakeel Butt @ 2020-11-06 16:27 UTC (permalink / raw)
  To: Muchun Song
  Cc: Andrew Morton, Johannes Weiner, Roman Gushchin, Michal Hocko,
	Yafang Shao, Chris Down, Tejun Heo, LKML

On Thu, Nov 5, 2020 at 8:20 AM Muchun Song <songmuchun@bytedance.com> wrote:
>
> When wen poll the swap.events,

we*

> we can miss being waked up when the swap

being woken up

> event occurs. Because we didn't notify.
>
> Fixes: f3a53a3a1e5b ("mm, memcontrol: implement memory.swap.events")
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>

Reviewed-by: Shakeel Butt <shakeelb@google.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-06 16:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05 16:19 [PATCH v2] mm: memcontrol: fix missing wakeup polling thread Muchun Song
2020-11-05 16:25 ` Johannes Weiner
2020-11-06 16:27 ` Shakeel Butt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).