Skip to contentSkip to conversation

mm, memcg: fix mem_cgroup_swapout() for THPs

PATCH Applied Shakeel Butt 4 participants 5 messages Nov 28, 2017 – Nov 29, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm, memcg: fix mem_cgroup_swapout() for THPs

The commit d6810d730022 ("memcg, THP, swap: make mem_cgroup_swapout() support THP") changed mem_cgroup_swapout() to support transparent huge page (THP). However the patch missed one location which should be changed for correctly handling THPs. The resulting bug will cause the memory cgroups whose THPs were swapped out to become zombies on deletion.

Fixes d6810d730022 ("memcg, THP, swap: make mem_cgroup_swapout() support THP")
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
index 50e6906314f8..ac2ffd5e02b9 100644
@@ -6044,7 +6044,7 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry)
 	memcg_check_events(memcg, page);
 
 	if (!mem_cgroup_is_root(memcg))
-		css_put(&memcg->css);
+		css_put_many(&memcg->css, nr_entries);
 }
 
 /**
Signature · 7 lines
2.15.0.417.g466bffb3ac-goog

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Shakeel Butt

The commit d6810d730022 ("memcg, THP, swap: make mem_cgroup_swapout() support THP") changed mem_cgroup_swapout() to support transparent huge page (THP). However the patch missed one location which should be changed for correctly handling THPs. The resulting bug will cause the memory cgroups whose THPs were swapped out to become zombies on deletion.

Very well spotted! Have you seen this triggering or you found it by the code inspection?

Quoted 1 line
Fixes d6810d730022 ("memcg, THP, swap: make mem_cgroup_swapout() support THP")

To be honest I am not really happy how the whole THP swapout thing has been rushed in without a proper review. I am partly guildy for not find time for the proper review but this is not something that really had to be merged without a single ack or reviewed-by.

Quoted 2 lines

Thanks!

Quoted 19 lines
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
index 50e6906314f8..ac2ffd5e02b9 100644
@@ -6044,7 +6044,7 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry)
 	memcg_check_events(memcg, page);
 
 	if (!mem_cgroup_is_root(memcg))
-		css_put(&memcg->css);
+		css_put_many(&memcg->css, nr_entries);
 }
 
 /**
Signature · 1 line
2.15.0.417.g466bffb3ac-goog
Signature · 2 lines
Michal Hocko
SUSE Labs
#2 lore raw
Quoted 11 lines · Michal Hocko
Quoted 6 lines · Shakeel Butt

The commit d6810d730022 ("memcg, THP, swap: make mem_cgroup_swapout() support THP") changed mem_cgroup_swapout() to support transparent huge page (THP). However the patch missed one location which should be changed for correctly handling THPs. The resulting bug will cause the memory cgroups whose THPs were swapped out to become zombies on deletion.

Very well spotted! Have you seen this triggering or you found it by the code inspection?

By code inspection.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
In reply to Shakeel Butt
Quoted 6 lines · Shakeel Butt

The commit d6810d730022 ("memcg, THP, swap: make mem_cgroup_swapout() support THP") changed mem_cgroup_swapout() to support transparent huge page (THP). However the patch missed one location which should be changed for correctly handling THPs. The resulting bug will cause the memory cgroups whose THPs were swapped out to become zombies on deletion.

Good catch! Thanks a lot for fixing!

Best Regards,
Huang, Ying

Quoted 20 lines
Fixes d6810d730022 ("memcg, THP, swap: make mem_cgroup_swapout() support THP")
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
index 50e6906314f8..ac2ffd5e02b9 100644
@@ -6044,7 +6044,7 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry)
 	memcg_check_events(memcg, page);
 
 	if (!mem_cgroup_is_root(memcg))
-		css_put(&memcg->css);
+		css_put_many(&memcg->css, nr_entries);
 }
 
 /**
maintainer Acked-by on v1 1/1
#4 lore raw
In reply to Shakeel Butt
Quoted 10 lines · Shakeel Butt

The commit d6810d730022 ("memcg, THP, swap: make mem_cgroup_swapout() support THP") changed mem_cgroup_swapout() to support transparent huge page (THP). However the patch missed one location which should be changed for correctly handling THPs. The resulting bug will cause the memory cgroups whose THPs were swapped out to become zombies on deletion.

Fixes d6810d730022 ("memcg, THP, swap: make mem_cgroup_swapout() support THP")

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>