Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

Commit

Permalink
mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone()
Browse files Browse the repository at this point in the history
Introduce helper mem_cgroup_zoneinfo_zone().  This makes mem_cgroup_iter()
code more compact.

Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Jianyu Zhan <nasa4836@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
JianyuZhan authored and sfrothwell committed Apr 22, 2014
1 parent 5a22594 commit d1bb310
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,15 @@ mem_cgroup_zoneinfo(struct mem_cgroup *memcg, int nid, int zid)
return &memcg->nodeinfo[nid]->zoneinfo[zid];
}

static struct mem_cgroup_per_zone *
mem_cgroup_zoneinfo_zone(struct mem_cgroup *memcg, struct zone *zone)
{
int nid = zone_to_nid(zone);
int zid = zone_idx(zone);

return mem_cgroup_zoneinfo(memcg, nid, zid);
}

struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *memcg)
{
return &memcg->css;
Expand Down Expand Up @@ -1234,11 +1243,9 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
int uninitialized_var(seq);

if (reclaim) {
int nid = zone_to_nid(reclaim->zone);
int zid = zone_idx(reclaim->zone);
struct mem_cgroup_per_zone *mz;

mz = mem_cgroup_zoneinfo(root, nid, zid);
mz = mem_cgroup_zoneinfo_zone(root, reclaim->zone);
iter = &mz->reclaim_iter[reclaim->priority];
if (prev && reclaim->generation != iter->generation) {
iter->last_visited = NULL;
Expand Down Expand Up @@ -1345,7 +1352,7 @@ struct lruvec *mem_cgroup_zone_lruvec(struct zone *zone,
goto out;
}

mz = mem_cgroup_zoneinfo(memcg, zone_to_nid(zone), zone_idx(zone));
mz = mem_cgroup_zoneinfo_zone(memcg, zone);
lruvec = &mz->lruvec;
out:
/*
Expand Down

0 comments on commit d1bb310

Please sign in to comment.