memcg: improve performance in moving charge
authorDaisuke Nishimura <[email protected]>
Wed, 10 Mar 2010 23:22:15 +0000 (15:22 -0800)
committerLinus Torvalds <[email protected]>
Fri, 12 Mar 2010 23:52:36 +0000 (15:52 -0800)
commit854ffa8d104e44111fec96764c0e0cb29223d54c
treeca4d19407e35e1888e210fed150d5fb98be36cc8
parent4ffef5feff4e4240e767d2f1144b1634a41762e3
memcg: improve performance in moving charge

Try to reduce overheads in moving charge by:

- Instead of calling res_counter_uncharge() against the old cgroup in
  __mem_cgroup_move_account() everytime, call res_counter_uncharge() at the end
  of task migration once.
- removed css_get(&to->css) from __mem_cgroup_move_account() because callers
  should have already called css_get(). And removed css_put(&to->css) too,
  which was called by callers of move_account on success of move_account.
- Instead of calling __mem_cgroup_try_charge(), i.e. res_counter_charge(),
  repeatedly, call res_counter_charge(PAGE_SIZE * count) in can_attach() if
  possible.
- Instead of calling css_get()/css_put() repeatedly, make use of coalesce
  __css_get()/__css_put() if possible.

These changes reduces the overhead from 1.7sec to 0.6sec to move charges
of 1G anonymous memory in my test environment.

Signed-off-by: Daisuke Nishimura <[email protected]>
Cc: Balbir Singh <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
Cc: Li Zefan <[email protected]>
Cc: Paul Menage <[email protected]>
Cc: Daisuke Nishimura <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/memcontrol.c