memcg: fix try_get_mem_cgroup_from_swapcache()
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 memcg: fix try_get_mem_cgroup_from_swapcache()
From: Daisuke Nishimura <[email protected]>
memcg: fix try_get_mem_cgroup_from_swapcache()
This is a bugfix for commit 3c776e64660028236313f0e54f3a9945764422df(included 2.6.30-rc1). Used bit of swapcache is solid under page lock, but considering move_account, pc->mem_cgroup is not.
We need lock_page_cgroup() anyway.
--- mm/memcontrol.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
mm/memcontrol.c +2 -3
@@ -1024,9 +1024,7 @@ static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page)return NULL ; pc =lookup_page_cgroup (page); -/* -* Used bit of swapcache is solid under page lock. -*/ +lock_page_cgroup (pc);if (PageCgroupUsed (pc)) { mem = pc->mem_cgroup;if (mem && !css_tryget (&mem->css))
@@ -1040,6 +1038,7 @@ static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page) mem =NULL ;rcu_read_unlock (); } +unlock_page_cgroup (pc);return mem; }
--
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>
Quoted 11 lines · On Mon, 27 Apr 2009 09:51:00 +0900 Daisuke Nishimura…
From: Daisuke Nishimura <[email protected]>
memcg: fix
try_get_mem_cgroup_from_swapcache()This is a bugfix for commit 3c776e64660028236313f0e54f3a9945764422df(included 2.6.30-rc1). Used bit of swapcache is solid under page lock, but considering
move_account,pc->mem_cgroupis not.We need
lock_page_cgroup()anyway.Signed-off-by Daisuke Nishimura <[email protected]>
you are right.
Quoted 21 lines
--- mm/memcontrol.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)mm/memcontrol.c +1
-3@@ -1024,9 +1024,7 @@ static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page)return NULL ; pc =lookup_page_cgroup (page); -/* -* Used bit of swapcache is solid under page lock. -*/ +lock_page_cgroup (pc);if (PageCgroupUsed (pc)) { mem = pc->mem_cgroup;if (mem && !css_tryget (&mem->css))
mm/memcontrol.c static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page) · line 1044
Quoted 7 lines
mm/memcontrol.c +1
-0@@ -1040,6 +1038,7 @@ static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page) mem =NULL ;rcu_read_unlock (); } +unlock_page_cgroup (pc);return mem; }
--
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>
Quoted 11 lines · * [email protected] <[email protected]> [2009-04-27…
From: Daisuke Nishimura <[email protected]>
memcg: fix
try_get_mem_cgroup_from_swapcache()This is a bugfix for commit 3c776e64660028236313f0e54f3a9945764422df(included 2.6.30-rc1). Used bit of swapcache is solid under page lock, but considering
move_account,pc->mem_cgroupis not.We need
lock_page_cgroup()anyway.Signed-off-by Daisuke Nishimura <[email protected]>
I think we need to start documenting the locks the page_cgroup lock nests under.
If memcg_tasklist were a spinlock instead of mutex, could we use that instead of page_cgroup lock, since we care only about task migration?
Signature · 7 lines
Balbir -- 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>
Quoted 10 lines · On Mon, 27 Apr 2009 12:23:58 +0530 Balbir Singh <[email protected]>…
Quoted 8 lines · * [email protected] <[email protected]> [2009-04-27…
From: Daisuke Nishimura <[email protected]>
memcg: fix
try_get_mem_cgroup_from_swapcache()This is a bugfix for commit 3c776e64660028236313f0e54f3a9945764422df(included 2.6.30-rc1). Used bit of swapcache is solid under page lock, but considering
move_account,pc->mem_cgroupis not.
Quoted 7 lines
Quoted 3 lines
We need
lock_page_cgroup()anyway.Signed-off-by Daisuke Nishimura <[email protected]>I think we need to start documenting the locks the
page_cgrouplock nests under.
Addin some comments on source code may be necessary.
Quoted 3 lines
If
memcg_tasklistwere a spinlock instead of mutex, could we use that instead ofpage_cgrouplock, since we care only about task migration?
Hmm ? Another problem ? I can't catch what you ask. move_account() is a function called by force_empty()->"move account to parent"
Thanks,
-Kame
--
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>
Quoted 20 lines · KAMEZAWA Hiroyuki
Quoted 10 lines · On Mon, 27 Apr 2009 12:23:58 +0530 Balbir Singh <[email protected]>…
Quoted 8 lines · * [email protected] <[email protected]> [2009-04-27…
From: Daisuke Nishimura <[email protected]>
memcg: fix
try_get_mem_cgroup_from_swapcache()This is a bugfix for commit 3c776e64660028236313f0e54f3a9945764422df(included 2.6.30-rc1). Used bit of swapcache is solid under page lock, but considering
move_account,pc->mem_cgroupis not.Quoted 7 lines
Quoted 3 lines
We need
lock_page_cgroup()anyway.Signed-off-by Daisuke Nishimura <[email protected]>I think we need to start documenting the locks the
page_cgrouplock nests under.
Quoted 8 lines
Addin some comments on source code may be necessary.
Quoted 3 lines
If
memcg_tasklistwere a spinlock instead of mutex, could we use that instead ofpage_cgrouplock, since we care only about task migration?Hmm ? Another problem ? I can't catch what you ask.
move_account()is a function called by force_empty()->"move account to parent"
IIUC, pc->mem_cgroup might change due to task migration and that is why we've added the page cgroup lock. If the race is between task migration and force_empty(), we can use the memcg_tasklist by making it a spinlock.
Signature · 7 lines
Balbir -- 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>
Quoted 28 lines · On Mon, 27 Apr 2009 12:33:42 +0530 Balbir Singh <[email protected]>…
Quoted 26 lines · KAMEZAWA Hiroyuki
Quoted 10 lines · On Mon, 27 Apr 2009 12:23:58 +0530 Balbir Singh <[email protected]>…
Quoted 8 lines · * [email protected] <[email protected]> [2009-04-27…
From: Daisuke Nishimura <[email protected]>
memcg: fix
try_get_mem_cgroup_from_swapcache()This is a bugfix for commit 3c776e64660028236313f0e54f3a9945764422df(included 2.6.30-rc1). Used bit of swapcache is solid under page lock, but considering
move_account,pc->mem_cgroupis not.Quoted 7 lines
Quoted 3 lines
We need
lock_page_cgroup()anyway.Signed-off-by Daisuke Nishimura <[email protected]>I think we need to start documenting the locks the
page_cgrouplock nests under.Addin some comments on source code may be necessary.
Quoted 3 lines
If
memcg_tasklistwere a spinlock instead of mutex, could we use that instead ofpage_cgrouplock, since we care only about task migration?
Quoted 5 lines
Quoted 2 lines
Hmm ? Another problem ? I can't catch what you ask.
move_account()is a function called by force_empty()->"move account to parent"IIUC,
pc->mem_cgroupmight change due to task migration and that is why we've added the page cgroup lock.
"task" migration ? I think it's "page" migration.
"page cgroup lock" is necessary because we have to modify 2 params (pc->flags and pc->mem_cgroup) at once.
Quoted 4 lines
If the race is between task
migration andforce_empty(), we can use thememcg_tasklistby making it a spinlock.
The race is between force_empty() and any other swap accounitng ops. This patch is good enough from my point of view.
Thanks,
-kame
--
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>
Balbir Singh
Acked-byQuoted 31 lines · KAMEZAWA Hiroyuki
Quoted 28 lines · On Mon, 27 Apr 2009 12:33:42 +0530 Balbir Singh <[email protected]>…
Quoted 26 lines · KAMEZAWA Hiroyuki
Quoted 10 lines · On Mon, 27 Apr 2009 12:23:58 +0530 Balbir Singh <[email protected]>…
Quoted 8 lines · * [email protected] <[email protected]> [2009-04-27…
From: Daisuke Nishimura <[email protected]>
memcg: fix
try_get_mem_cgroup_from_swapcache()This is a bugfix for commit 3c776e64660028236313f0e54f3a9945764422df(included 2.6.30-rc1). Used bit of swapcache is solid under page lock, but considering
move_account,pc->mem_cgroupis not.Quoted 7 lines
Quoted 3 lines
We need
lock_page_cgroup()anyway.Signed-off-by Daisuke Nishimura <[email protected]>I think we need to start documenting the locks the
page_cgrouplock nests under.Addin some comments on source code may be necessary.
Quoted 3 lines
If
memcg_tasklistwere a spinlock instead of mutex, could we use that instead ofpage_cgrouplock, since we care only about task migration?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Hmm ? Another problem ? I can't catch what you ask.
move_account()is a function called by force_empty()->"move account to parent"IIUC,
pc->mem_cgroupmight change due to task migration and that is why we've added the page cgroup lock."task" migration ? I think it's "page" migration.
OK
Quoted 3 lines
"page cgroup lock" is necessary because we have to modify 2 params (
pc->flagsandpc->mem_cgroup) at once.
Yes, definitely!
Quoted 6 lines
Quoted 4 lines
If the race is between task
migration andforce_empty(), we can use thememcg_tasklistby making it a spinlock.The race is between
force_empty()and any other swap accounitng ops. This patch is good enough from my point of view.
Fair enough
Signature · 7 lines
Balbir -- 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>