memcg: enhance memcg iterator to support predicates
authorMichal Hocko <[email protected]>
Thu, 12 Sep 2013 22:13:26 +0000 (15:13 -0700)
committerLinus Torvalds <[email protected]>
Thu, 12 Sep 2013 22:38:00 +0000 (15:38 -0700)
commitde57780dc659f95b17ccb649f003278dde0b5b86
treed2493cc412c16946f3ead9158a61b26dd1f0c45a
parenta5b7c87f92076352dbff2fe0423ec255e1c9a71b
memcg: enhance memcg iterator to support predicates

The caller of the iterator might know that some nodes or even subtrees
should be skipped but there is no way to tell iterators about that so the
only choice left is to let iterators to visit each node and do the
selection outside of the iterating code.  This, however, doesn't scale
well with hierarchies with many groups where only few groups are
interesting.

This patch adds mem_cgroup_iter_cond variant of the iterator with a
callback which gets called for every visited node.  There are three
possible ways how the callback can influence the walk.  Either the node is
visited, it is skipped but the tree walk continues down the tree or the
whole subtree of the current group is skipped.

[[email protected]: fix memcg-less page reclaim]
Signed-off-by: Michal Hocko <[email protected]>
Cc: Balbir Singh <[email protected]>
Cc: Glauber Costa <[email protected]>
Cc: Greg Thelen <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: KAMEZAWA Hiroyuki <[email protected]>
Cc: KOSAKI Motohiro <[email protected]>
Cc: Michel Lespinasse <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Ying Han <[email protected]>
Signed-off-by: Hugh Dickins <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/memcontrol.h
mm/memcontrol.c
mm/vmscan.c