linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone()
@ 2014-04-18 23:01 Jianyu Zhan
  2014-04-22  9:59 ` Michal Hocko
  0 siblings, 1 reply; 11+ messages in thread
From: Jianyu Zhan @ 2014-04-18 23:01 UTC (permalink / raw)
  To: hannes, mhocko, bsingharora, kamezawa.hiroyu
  Cc: cgroups, linux-mm, linux-kernel, nasa4836

introduce helper mem_cgroup_zoneinfo_zone(). This will make
mem_cgroup_iter() code more compact.

Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
---
 mm/memcontrol.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e0ce15c..80d9e38 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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;
@@ -1232,11 +1241,9 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
 
 	rcu_read_lock();
 	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;
@@ -1340,7 +1347,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:
 	/*
-- 
1.9.0.GIT


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone()
  2014-04-18 23:01 [PATCH 2/2] mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone() Jianyu Zhan
@ 2014-04-22  9:59 ` Michal Hocko
  2014-04-28 15:04   ` Michal Hocko
  0 siblings, 1 reply; 11+ messages in thread
From: Michal Hocko @ 2014-04-22  9:59 UTC (permalink / raw)
  To: Jianyu Zhan
  Cc: hannes, bsingharora, kamezawa.hiroyu, cgroups, linux-mm, linux-kernel

On Sat 19-04-14 07:01:43, Jianyu Zhan wrote:
> introduce helper mem_cgroup_zoneinfo_zone(). This will make
> mem_cgroup_iter() code more compact.

I dunno. Helpers are usually nice but this one adds more code then it
removes. It also doesn't help the generated code.

So I don't see any reason to merge it.
 
> Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
> ---
>  mm/memcontrol.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index e0ce15c..80d9e38 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -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;
> @@ -1232,11 +1241,9 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
>  
>  	rcu_read_lock();
>  	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;
> @@ -1340,7 +1347,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:
>  	/*
> -- 
> 1.9.0.GIT
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone()
  2014-04-22  9:59 ` Michal Hocko
@ 2014-04-28 15:04   ` Michal Hocko
  2014-05-01 12:54     ` Johannes Weiner
  0 siblings, 1 reply; 11+ messages in thread
From: Michal Hocko @ 2014-04-28 15:04 UTC (permalink / raw)
  To: Jianyu Zhan
  Cc: hannes, bsingharora, kamezawa.hiroyu, cgroups, linux-mm, linux-kernel

On Tue 22-04-14 11:59:23, Michal Hocko wrote:
> On Sat 19-04-14 07:01:43, Jianyu Zhan wrote:
> > introduce helper mem_cgroup_zoneinfo_zone(). This will make
> > mem_cgroup_iter() code more compact.
> 
> I dunno. Helpers are usually nice but this one adds more code then it
> removes. It also doesn't help the generated code.
> 
> So I don't see any reason to merge it.

So should we drop it from mmotm?

> > Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
> > ---
> >  mm/memcontrol.c | 15 +++++++++++----
> >  1 file changed, 11 insertions(+), 4 deletions(-)
> > 
> > diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> > index e0ce15c..80d9e38 100644
> > --- a/mm/memcontrol.c
> > +++ b/mm/memcontrol.c
> > @@ -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;
> > @@ -1232,11 +1241,9 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
> >  
> >  	rcu_read_lock();
> >  	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;
> > @@ -1340,7 +1347,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:
> >  	/*
> > -- 
> > 1.9.0.GIT
> > 
> 
> -- 
> Michal Hocko
> SUSE Labs
> --
> To unsubscribe from this list: send the line "unsubscribe cgroups" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone()
  2014-04-28 15:04   ` Michal Hocko
@ 2014-05-01 12:54     ` Johannes Weiner
  2014-05-01 13:36       ` Johannes Weiner
  2014-05-02 22:05       ` Andrew Morton
  0 siblings, 2 replies; 11+ messages in thread
From: Johannes Weiner @ 2014-05-01 12:54 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Jianyu Zhan, bsingharora, kamezawa.hiroyu, cgroups, linux-mm,
	linux-kernel, akpm

On Mon, Apr 28, 2014 at 05:04:26PM +0200, Michal Hocko wrote:
> On Tue 22-04-14 11:59:23, Michal Hocko wrote:
> > On Sat 19-04-14 07:01:43, Jianyu Zhan wrote:
> > > introduce helper mem_cgroup_zoneinfo_zone(). This will make
> > > mem_cgroup_iter() code more compact.
> > 
> > I dunno. Helpers are usually nice but this one adds more code then it
> > removes. It also doesn't help the generated code.
> > 
> > So I don't see any reason to merge it.
> 
> So should we drop it from mmotm?

Yes, please.

> > > Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
> > > ---
> > >  mm/memcontrol.c | 15 +++++++++++----
> > >  1 file changed, 11 insertions(+), 4 deletions(-)

This helper adds no value, but more code and indirection.

Cc'd Andrew - this is about
mm-memcontrolc-introduce-helper-mem_cgroup_zoneinfo_zone.patch
mm-memcontrolc-introduce-helper-mem_cgroup_zoneinfo_zone-checkpatch-fixes.patch

Thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone()
  2014-05-01 12:54     ` Johannes Weiner
@ 2014-05-01 13:36       ` Johannes Weiner
  2014-05-02 22:05       ` Andrew Morton
  1 sibling, 0 replies; 11+ messages in thread
From: Johannes Weiner @ 2014-05-01 13:36 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Jianyu Zhan, bsingharora, kamezawa.hiroyu, cgroups, linux-mm,
	linux-kernel, akpm

[fix Andrew's email address]

On Thu, May 01, 2014 at 08:54:50AM -0400, Johannes Weiner wrote:
> On Mon, Apr 28, 2014 at 05:04:26PM +0200, Michal Hocko wrote:
> > On Tue 22-04-14 11:59:23, Michal Hocko wrote:
> > > On Sat 19-04-14 07:01:43, Jianyu Zhan wrote:
> > > > introduce helper mem_cgroup_zoneinfo_zone(). This will make
> > > > mem_cgroup_iter() code more compact.
> > > 
> > > I dunno. Helpers are usually nice but this one adds more code then it
> > > removes. It also doesn't help the generated code.
> > > 
> > > So I don't see any reason to merge it.
> > 
> > So should we drop it from mmotm?
> 
> Yes, please.
> 
> > > > Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
> > > > ---
> > > >  mm/memcontrol.c | 15 +++++++++++----
> > > >  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> This helper adds no value, but more code and indirection.
> 
> Cc'd Andrew - this is about
> mm-memcontrolc-introduce-helper-mem_cgroup_zoneinfo_zone.patch
> mm-memcontrolc-introduce-helper-mem_cgroup_zoneinfo_zone-checkpatch-fixes.patch
> 
> Thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone()
  2014-05-01 12:54     ` Johannes Weiner
  2014-05-01 13:36       ` Johannes Weiner
@ 2014-05-02 22:05       ` Andrew Morton
  2014-05-02 23:29         ` Johannes Weiner
  1 sibling, 1 reply; 11+ messages in thread
From: Andrew Morton @ 2014-05-02 22:05 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Michal Hocko, Jianyu Zhan, bsingharora, kamezawa.hiroyu, cgroups,
	linux-mm, linux-kernel, akpm

On Thu, 1 May 2014 08:54:50 -0400 Johannes Weiner <hannes@cmpxchg.org> wrote:

> On Mon, Apr 28, 2014 at 05:04:26PM +0200, Michal Hocko wrote:
> > On Tue 22-04-14 11:59:23, Michal Hocko wrote:
> > > On Sat 19-04-14 07:01:43, Jianyu Zhan wrote:
> > > > introduce helper mem_cgroup_zoneinfo_zone(). This will make
> > > > mem_cgroup_iter() code more compact.
> > > 
> > > I dunno. Helpers are usually nice but this one adds more code then it
> > > removes. It also doesn't help the generated code.
> > > 
> > > So I don't see any reason to merge it.
> > 
> > So should we drop it from mmotm?
> 
> Yes, please.
> 
> > > > Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
> > > > ---
> > > >  mm/memcontrol.c | 15 +++++++++++----
> > > >  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> This helper adds no value, but more code and indirection.
> 
> Cc'd Andrew - this is about
> mm-memcontrolc-introduce-helper-mem_cgroup_zoneinfo_zone.patch
> mm-memcontrolc-introduce-helper-mem_cgroup_zoneinfo_zone-checkpatch-fixes.patch

The patch seemed rather nice to me.  mem_cgroup_zoneinfo_zone()
encapsulates a particular concept and gives it a name.  That's better
than splattering the logic into callsites.

The patch makes no change to code size but that's because gcc is silly.
Mark mem_cgroup_zoneinfo_zone() as noinline and the patch shrinks
.text by 40 bytes.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone()
  2014-05-02 22:05       ` Andrew Morton
@ 2014-05-02 23:29         ` Johannes Weiner
  2014-05-02 23:31           ` Johannes Weiner
                             ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Johannes Weiner @ 2014-05-02 23:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Michal Hocko, Jianyu Zhan, bsingharora, kamezawa.hiroyu, cgroups,
	linux-mm, linux-kernel, akpm

On Fri, May 02, 2014 at 03:05:16PM -0700, Andrew Morton wrote:
> On Thu, 1 May 2014 08:54:50 -0400 Johannes Weiner <hannes@cmpxchg.org> wrote:
> 
> > On Mon, Apr 28, 2014 at 05:04:26PM +0200, Michal Hocko wrote:
> > > On Tue 22-04-14 11:59:23, Michal Hocko wrote:
> > > > On Sat 19-04-14 07:01:43, Jianyu Zhan wrote:
> > > > > introduce helper mem_cgroup_zoneinfo_zone(). This will make
> > > > > mem_cgroup_iter() code more compact.
> > > > 
> > > > I dunno. Helpers are usually nice but this one adds more code then it
> > > > removes. It also doesn't help the generated code.
> > > > 
> > > > So I don't see any reason to merge it.
> > > 
> > > So should we drop it from mmotm?
> > 
> > Yes, please.
> > 
> > > > > Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
> > > > > ---
> > > > >  mm/memcontrol.c | 15 +++++++++++----
> > > > >  1 file changed, 11 insertions(+), 4 deletions(-)
> > 
> > This helper adds no value, but more code and indirection.
> > 
> > Cc'd Andrew - this is about
> > mm-memcontrolc-introduce-helper-mem_cgroup_zoneinfo_zone.patch
> > mm-memcontrolc-introduce-helper-mem_cgroup_zoneinfo_zone-checkpatch-fixes.patch
> 
> The patch seemed rather nice to me.  mem_cgroup_zoneinfo_zone()
> encapsulates a particular concept and gives it a name.  That's better
> than splattering the logic into callsites.

Yeah, that helper is actually a good idea, for me it was just drowned
out by the diffstat, the naming, and that the zoneinfo lookup overall
was still left in bad shape.  Thanks for prodding ;-) How about this?

---
From: Jianyu Zhan <nasa4836@gmail.com>
Subject: [patch] mm: memcontrol: clean up memcg zoneinfo lookup

Memcg zoneinfo lookup sites have either the page, the zone, or the
node id and zone index, but sites that only have the zone have to look
up the node id and zone index themselves, whereas sites that already
have those two integers use a function for a simple pointer chase.

Provide mem_cgroup_zone_zoneinfo() that takes a zone pointer and let
sites that already have node id and zone index - all for each node,
for each zone iterators - use &memcg->nodeinfo[nid]->zoneinfo[zid].

Rename page_cgroup_zoneinfo() to mem_cgroup_page_zoneinfo() to match.

Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/memcontrol.c | 89 +++++++++++++++++++++++++--------------------------------
 1 file changed, 39 insertions(+), 50 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 29501f040568..83cbd5a0e62f 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -677,9 +677,11 @@ static void disarm_static_keys(struct mem_cgroup *memcg)
 static void drain_all_stock_async(struct mem_cgroup *memcg);
 
 static struct mem_cgroup_per_zone *
-mem_cgroup_zoneinfo(struct mem_cgroup *memcg, int nid, int zid)
+mem_cgroup_zone_zoneinfo(struct mem_cgroup *memcg, struct zone *zone)
 {
-	VM_BUG_ON((unsigned)nid >= nr_node_ids);
+	int nid = zone_to_nid(zone);
+	int zid = zone_idx(zone);
+
 	return &memcg->nodeinfo[nid]->zoneinfo[zid];
 }
 
@@ -689,12 +691,12 @@ struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *memcg)
 }
 
 static struct mem_cgroup_per_zone *
-page_cgroup_zoneinfo(struct mem_cgroup *memcg, struct page *page)
+mem_cgroup_page_zoneinfo(struct mem_cgroup *memcg, struct page *page)
 {
 	int nid = page_to_nid(page);
 	int zid = page_zonenum(page);
 
-	return mem_cgroup_zoneinfo(memcg, nid, zid);
+	return &memcg->nodeinfo[nid]->zoneinfo[zid];
 }
 
 static struct mem_cgroup_tree_per_zone *
@@ -773,16 +775,14 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page)
 	unsigned long long excess;
 	struct mem_cgroup_per_zone *mz;
 	struct mem_cgroup_tree_per_zone *mctz;
-	int nid = page_to_nid(page);
-	int zid = page_zonenum(page);
-	mctz = soft_limit_tree_from_page(page);
 
+	mctz = soft_limit_tree_from_page(page);
 	/*
 	 * Necessary to update all ancestors when hierarchy is used.
 	 * because their event counter is not touched.
 	 */
 	for (; memcg; memcg = parent_mem_cgroup(memcg)) {
-		mz = mem_cgroup_zoneinfo(memcg, nid, zid);
+		mz = mem_cgroup_page_zoneinfo(memcg, page);
 		excess = res_counter_soft_limit_excess(&memcg->res);
 		/*
 		 * We have to update the tree if mz is on RB-tree or
@@ -805,14 +805,14 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page)
 
 static void mem_cgroup_remove_from_trees(struct mem_cgroup *memcg)
 {
-	int node, zone;
-	struct mem_cgroup_per_zone *mz;
 	struct mem_cgroup_tree_per_zone *mctz;
+	struct mem_cgroup_per_zone *mz;
+	int nid, zid;
 
-	for_each_node(node) {
-		for (zone = 0; zone < MAX_NR_ZONES; zone++) {
-			mz = mem_cgroup_zoneinfo(memcg, node, zone);
-			mctz = soft_limit_tree_node_zone(node, zone);
+	for_each_node(nid) {
+		for (zid = 0; zid < MAX_NR_ZONES; zid++) {
+			mz = &memcg->nodeinfo[nid]->zoneinfo[zid];
+			mctz = soft_limit_tree_node_zone(nid, zid);
 			mem_cgroup_remove_exceeded(memcg, mz, mctz);
 		}
 	}
@@ -947,8 +947,7 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *memcg,
 	__this_cpu_add(memcg->stat->nr_page_events, nr_pages);
 }
 
-unsigned long
-mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru)
+unsigned long mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru)
 {
 	struct mem_cgroup_per_zone *mz;
 
@@ -956,46 +955,38 @@ mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru)
 	return mz->lru_size[lru];
 }
 
-static unsigned long
-mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg, int nid, int zid,
-			unsigned int lru_mask)
-{
-	struct mem_cgroup_per_zone *mz;
-	enum lru_list lru;
-	unsigned long ret = 0;
-
-	mz = mem_cgroup_zoneinfo(memcg, nid, zid);
-
-	for_each_lru(lru) {
-		if (BIT(lru) & lru_mask)
-			ret += mz->lru_size[lru];
-	}
-	return ret;
-}
-
-static unsigned long
-mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
-			int nid, unsigned int lru_mask)
+static unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
+						  int nid,
+						  unsigned int lru_mask)
 {
-	u64 total = 0;
+	unsigned long nr = 0;
 	int zid;
 
-	for (zid = 0; zid < MAX_NR_ZONES; zid++)
-		total += mem_cgroup_zone_nr_lru_pages(memcg,
-						nid, zid, lru_mask);
+	VM_BUG_ON((unsigned)nid >= nr_node_ids);
+
+	for (zid = 0; zid < MAX_NR_ZONES; zid++) {
+		struct mem_cgroup_per_zone *mz;
+		enum lru_list lru;
 
-	return total;
+		for_each_lru(lru) {
+			if (!(BIT(lru) & lru_mask))
+				continue;
+			mz = &memcg->nodeinfo[nid]->zoneinfo[zid];
+			nr += mz->lru_size[lru];
+		}
+	}
+	return nr;
 }
 
 static unsigned long mem_cgroup_nr_lru_pages(struct mem_cgroup *memcg,
 			unsigned int lru_mask)
 {
+	unsigned long nr = 0;
 	int nid;
-	u64 total = 0;
 
 	for_each_node_state(nid, N_MEMORY)
-		total += mem_cgroup_node_nr_lru_pages(memcg, nid, lru_mask);
-	return total;
+		nr += mem_cgroup_node_nr_lru_pages(memcg, nid, lru_mask);
+	return nr;
 }
 
 static bool mem_cgroup_event_ratelimit(struct mem_cgroup *memcg,
@@ -1234,11 +1225,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_zone_zoneinfo(root, reclaim->zone);
 			iter = &mz->reclaim_iter[reclaim->priority];
 			if (prev && reclaim->generation != iter->generation) {
 				iter->last_visited = NULL;
@@ -1345,7 +1334,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_zone_zoneinfo(memcg, zone);
 	lruvec = &mz->lruvec;
 out:
 	/*
@@ -1404,7 +1393,7 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct zone *zone)
 	if (!PageLRU(page) && !PageCgroupUsed(pc) && memcg != root_mem_cgroup)
 		pc->mem_cgroup = memcg = root_mem_cgroup;
 
-	mz = page_cgroup_zoneinfo(memcg, page);
+	mz = mem_cgroup_page_zoneinfo(memcg, page);
 	lruvec = &mz->lruvec;
 out:
 	/*
@@ -5412,7 +5401,7 @@ static int memcg_stat_show(struct seq_file *m, void *v)
 
 		for_each_online_node(nid)
 			for (zid = 0; zid < MAX_NR_ZONES; zid++) {
-				mz = mem_cgroup_zoneinfo(memcg, nid, zid);
+				mz = &memcg->nodeinfo[nid]->zoneinfo[zid];
 				rstat = &mz->lruvec.reclaim_stat;
 
 				recent_rotated[0] += rstat->recent_rotated[0];
-- 
1.9.2



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone()
  2014-05-02 23:29         ` Johannes Weiner
@ 2014-05-02 23:31           ` Johannes Weiner
  2014-05-05 15:35             ` Michal Hocko
  2014-05-05 15:31           ` Michal Hocko
  2014-05-05 21:36           ` Andrew Morton
  2 siblings, 1 reply; 11+ messages in thread
From: Johannes Weiner @ 2014-05-02 23:31 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Michal Hocko, Jianyu Zhan, bsingharora, kamezawa.hiroyu, cgroups,
	linux-mm, linux-kernel, akpm

While in that area, I noticed that the soft limit tree updaters don't
actually use the memcg argument anymore...

---
From: Johannes Weiner <hannes@cmpxchg.org>
Subject: [patch] mm: memcontrol: remove unnecessary memcg argument from soft
 limit functions

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/memcontrol.c | 34 ++++++++++++++--------------------
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 83cbd5a0e62f..3381f76df084 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -714,11 +714,9 @@ soft_limit_tree_from_page(struct page *page)
 	return &soft_limit_tree.rb_tree_per_node[nid]->rb_tree_per_zone[zid];
 }
 
-static void
-__mem_cgroup_insert_exceeded(struct mem_cgroup *memcg,
-				struct mem_cgroup_per_zone *mz,
-				struct mem_cgroup_tree_per_zone *mctz,
-				unsigned long long new_usage_in_excess)
+static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_zone *mz,
+					 struct mem_cgroup_tree_per_zone *mctz,
+					 unsigned long long new_usage_in_excess)
 {
 	struct rb_node **p = &mctz->rb_root.rb_node;
 	struct rb_node *parent = NULL;
@@ -748,10 +746,8 @@ __mem_cgroup_insert_exceeded(struct mem_cgroup *memcg,
 	mz->on_tree = true;
 }
 
-static void
-__mem_cgroup_remove_exceeded(struct mem_cgroup *memcg,
-				struct mem_cgroup_per_zone *mz,
-				struct mem_cgroup_tree_per_zone *mctz)
+static void __mem_cgroup_remove_exceeded(struct mem_cgroup_per_zone *mz,
+					 struct mem_cgroup_tree_per_zone *mctz)
 {
 	if (!mz->on_tree)
 		return;
@@ -759,13 +755,11 @@ __mem_cgroup_remove_exceeded(struct mem_cgroup *memcg,
 	mz->on_tree = false;
 }
 
-static void
-mem_cgroup_remove_exceeded(struct mem_cgroup *memcg,
-				struct mem_cgroup_per_zone *mz,
-				struct mem_cgroup_tree_per_zone *mctz)
+static void mem_cgroup_remove_exceeded(struct mem_cgroup_per_zone *mz,
+				       struct mem_cgroup_tree_per_zone *mctz)
 {
 	spin_lock(&mctz->lock);
-	__mem_cgroup_remove_exceeded(memcg, mz, mctz);
+	__mem_cgroup_remove_exceeded(mz, mctz);
 	spin_unlock(&mctz->lock);
 }
 
@@ -792,12 +786,12 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page)
 			spin_lock(&mctz->lock);
 			/* if on-tree, remove it */
 			if (mz->on_tree)
-				__mem_cgroup_remove_exceeded(memcg, mz, mctz);
+				__mem_cgroup_remove_exceeded(mz, mctz);
 			/*
 			 * Insert again. mz->usage_in_excess will be updated.
 			 * If excess is 0, no tree ops.
 			 */
-			__mem_cgroup_insert_exceeded(memcg, mz, mctz, excess);
+			__mem_cgroup_insert_exceeded(mz, mctz, excess);
 			spin_unlock(&mctz->lock);
 		}
 	}
@@ -813,7 +807,7 @@ static void mem_cgroup_remove_from_trees(struct mem_cgroup *memcg)
 		for (zid = 0; zid < MAX_NR_ZONES; zid++) {
 			mz = &memcg->nodeinfo[nid]->zoneinfo[zid];
 			mctz = soft_limit_tree_node_zone(nid, zid);
-			mem_cgroup_remove_exceeded(memcg, mz, mctz);
+			mem_cgroup_remove_exceeded(mz, mctz);
 		}
 	}
 }
@@ -836,7 +830,7 @@ retry:
 	 * we will to add it back at the end of reclaim to its correct
 	 * position in the tree.
 	 */
-	__mem_cgroup_remove_exceeded(mz->memcg, mz, mctz);
+	__mem_cgroup_remove_exceeded(mz, mctz);
 	if (!res_counter_soft_limit_excess(&mz->memcg->res) ||
 		!css_tryget(&mz->memcg->css))
 		goto retry;
@@ -4694,7 +4688,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
 					break;
 			} while (1);
 		}
-		__mem_cgroup_remove_exceeded(mz->memcg, mz, mctz);
+		__mem_cgroup_remove_exceeded(mz, mctz);
 		excess = res_counter_soft_limit_excess(&mz->memcg->res);
 		/*
 		 * One school of thought says that we should not add
@@ -4705,7 +4699,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
 		 * term TODO.
 		 */
 		/* If excess == 0, no tree ops */
-		__mem_cgroup_insert_exceeded(mz->memcg, mz, mctz, excess);
+		__mem_cgroup_insert_exceeded(mz, mctz, excess);
 		spin_unlock(&mctz->lock);
 		css_put(&mz->memcg->css);
 		loop++;
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone()
  2014-05-02 23:29         ` Johannes Weiner
  2014-05-02 23:31           ` Johannes Weiner
@ 2014-05-05 15:31           ` Michal Hocko
  2014-05-05 21:36           ` Andrew Morton
  2 siblings, 0 replies; 11+ messages in thread
From: Michal Hocko @ 2014-05-05 15:31 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Jianyu Zhan, bsingharora, kamezawa.hiroyu,
	cgroups, linux-mm, linux-kernel, akpm

On Fri 02-05-14 19:29:08, Johannes Weiner wrote:
[...]
> From: Jianyu Zhan <nasa4836@gmail.com>
> Subject: [patch] mm: memcontrol: clean up memcg zoneinfo lookup
> 
> Memcg zoneinfo lookup sites have either the page, the zone, or the
> node id and zone index, but sites that only have the zone have to look
> up the node id and zone index themselves, whereas sites that already
> have those two integers use a function for a simple pointer chase.
> 
> Provide mem_cgroup_zone_zoneinfo() that takes a zone pointer and let
> sites that already have node id and zone index - all for each node,
> for each zone iterators - use &memcg->nodeinfo[nid]->zoneinfo[zid].
> 
> Rename page_cgroup_zoneinfo() to mem_cgroup_page_zoneinfo() to match.
> 
> Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

OK, this looks better. The naming is more descriptive and it even
removes some code. Good. The opencoded zoneinfo dereference is not that
nice but I guess I can live with it.

Acked-by: Michal Hocko <mhocko@suse.cz>

> ---
>  mm/memcontrol.c | 89 +++++++++++++++++++++++++--------------------------------
>  1 file changed, 39 insertions(+), 50 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 29501f040568..83cbd5a0e62f 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -677,9 +677,11 @@ static void disarm_static_keys(struct mem_cgroup *memcg)
>  static void drain_all_stock_async(struct mem_cgroup *memcg);
>  
>  static struct mem_cgroup_per_zone *
> -mem_cgroup_zoneinfo(struct mem_cgroup *memcg, int nid, int zid)
> +mem_cgroup_zone_zoneinfo(struct mem_cgroup *memcg, struct zone *zone)
>  {
> -	VM_BUG_ON((unsigned)nid >= nr_node_ids);
> +	int nid = zone_to_nid(zone);
> +	int zid = zone_idx(zone);
> +
>  	return &memcg->nodeinfo[nid]->zoneinfo[zid];
>  }
>  
> @@ -689,12 +691,12 @@ struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *memcg)
>  }
>  
>  static struct mem_cgroup_per_zone *
> -page_cgroup_zoneinfo(struct mem_cgroup *memcg, struct page *page)
> +mem_cgroup_page_zoneinfo(struct mem_cgroup *memcg, struct page *page)
>  {
>  	int nid = page_to_nid(page);
>  	int zid = page_zonenum(page);
>  
> -	return mem_cgroup_zoneinfo(memcg, nid, zid);
> +	return &memcg->nodeinfo[nid]->zoneinfo[zid];
>  }
>  
>  static struct mem_cgroup_tree_per_zone *
> @@ -773,16 +775,14 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page)
>  	unsigned long long excess;
>  	struct mem_cgroup_per_zone *mz;
>  	struct mem_cgroup_tree_per_zone *mctz;
> -	int nid = page_to_nid(page);
> -	int zid = page_zonenum(page);
> -	mctz = soft_limit_tree_from_page(page);
>  
> +	mctz = soft_limit_tree_from_page(page);
>  	/*
>  	 * Necessary to update all ancestors when hierarchy is used.
>  	 * because their event counter is not touched.
>  	 */
>  	for (; memcg; memcg = parent_mem_cgroup(memcg)) {
> -		mz = mem_cgroup_zoneinfo(memcg, nid, zid);
> +		mz = mem_cgroup_page_zoneinfo(memcg, page);
>  		excess = res_counter_soft_limit_excess(&memcg->res);
>  		/*
>  		 * We have to update the tree if mz is on RB-tree or
> @@ -805,14 +805,14 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page)
>  
>  static void mem_cgroup_remove_from_trees(struct mem_cgroup *memcg)
>  {
> -	int node, zone;
> -	struct mem_cgroup_per_zone *mz;
>  	struct mem_cgroup_tree_per_zone *mctz;
> +	struct mem_cgroup_per_zone *mz;
> +	int nid, zid;
>  
> -	for_each_node(node) {
> -		for (zone = 0; zone < MAX_NR_ZONES; zone++) {
> -			mz = mem_cgroup_zoneinfo(memcg, node, zone);
> -			mctz = soft_limit_tree_node_zone(node, zone);
> +	for_each_node(nid) {
> +		for (zid = 0; zid < MAX_NR_ZONES; zid++) {
> +			mz = &memcg->nodeinfo[nid]->zoneinfo[zid];
> +			mctz = soft_limit_tree_node_zone(nid, zid);
>  			mem_cgroup_remove_exceeded(memcg, mz, mctz);
>  		}
>  	}
> @@ -947,8 +947,7 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *memcg,
>  	__this_cpu_add(memcg->stat->nr_page_events, nr_pages);
>  }
>  
> -unsigned long
> -mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru)
> +unsigned long mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru)
>  {
>  	struct mem_cgroup_per_zone *mz;
>  
> @@ -956,46 +955,38 @@ mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru)
>  	return mz->lru_size[lru];
>  }
>  
> -static unsigned long
> -mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg, int nid, int zid,
> -			unsigned int lru_mask)
> -{
> -	struct mem_cgroup_per_zone *mz;
> -	enum lru_list lru;
> -	unsigned long ret = 0;
> -
> -	mz = mem_cgroup_zoneinfo(memcg, nid, zid);
> -
> -	for_each_lru(lru) {
> -		if (BIT(lru) & lru_mask)
> -			ret += mz->lru_size[lru];
> -	}
> -	return ret;
> -}
> -
> -static unsigned long
> -mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
> -			int nid, unsigned int lru_mask)
> +static unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
> +						  int nid,
> +						  unsigned int lru_mask)
>  {
> -	u64 total = 0;
> +	unsigned long nr = 0;
>  	int zid;
>  
> -	for (zid = 0; zid < MAX_NR_ZONES; zid++)
> -		total += mem_cgroup_zone_nr_lru_pages(memcg,
> -						nid, zid, lru_mask);
> +	VM_BUG_ON((unsigned)nid >= nr_node_ids);
> +
> +	for (zid = 0; zid < MAX_NR_ZONES; zid++) {
> +		struct mem_cgroup_per_zone *mz;
> +		enum lru_list lru;
>  
> -	return total;
> +		for_each_lru(lru) {
> +			if (!(BIT(lru) & lru_mask))
> +				continue;
> +			mz = &memcg->nodeinfo[nid]->zoneinfo[zid];
> +			nr += mz->lru_size[lru];
> +		}
> +	}
> +	return nr;
>  }
>  
>  static unsigned long mem_cgroup_nr_lru_pages(struct mem_cgroup *memcg,
>  			unsigned int lru_mask)
>  {
> +	unsigned long nr = 0;
>  	int nid;
> -	u64 total = 0;
>  
>  	for_each_node_state(nid, N_MEMORY)
> -		total += mem_cgroup_node_nr_lru_pages(memcg, nid, lru_mask);
> -	return total;
> +		nr += mem_cgroup_node_nr_lru_pages(memcg, nid, lru_mask);
> +	return nr;
>  }
>  
>  static bool mem_cgroup_event_ratelimit(struct mem_cgroup *memcg,
> @@ -1234,11 +1225,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_zone_zoneinfo(root, reclaim->zone);
>  			iter = &mz->reclaim_iter[reclaim->priority];
>  			if (prev && reclaim->generation != iter->generation) {
>  				iter->last_visited = NULL;
> @@ -1345,7 +1334,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_zone_zoneinfo(memcg, zone);
>  	lruvec = &mz->lruvec;
>  out:
>  	/*
> @@ -1404,7 +1393,7 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct zone *zone)
>  	if (!PageLRU(page) && !PageCgroupUsed(pc) && memcg != root_mem_cgroup)
>  		pc->mem_cgroup = memcg = root_mem_cgroup;
>  
> -	mz = page_cgroup_zoneinfo(memcg, page);
> +	mz = mem_cgroup_page_zoneinfo(memcg, page);
>  	lruvec = &mz->lruvec;
>  out:
>  	/*
> @@ -5412,7 +5401,7 @@ static int memcg_stat_show(struct seq_file *m, void *v)
>  
>  		for_each_online_node(nid)
>  			for (zid = 0; zid < MAX_NR_ZONES; zid++) {
> -				mz = mem_cgroup_zoneinfo(memcg, nid, zid);
> +				mz = &memcg->nodeinfo[nid]->zoneinfo[zid];
>  				rstat = &mz->lruvec.reclaim_stat;
>  
>  				recent_rotated[0] += rstat->recent_rotated[0];
> -- 
> 1.9.2
> 
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone()
  2014-05-02 23:31           ` Johannes Weiner
@ 2014-05-05 15:35             ` Michal Hocko
  0 siblings, 0 replies; 11+ messages in thread
From: Michal Hocko @ 2014-05-05 15:35 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Jianyu Zhan, bsingharora, kamezawa.hiroyu,
	cgroups, linux-mm, linux-kernel, akpm

On Fri 02-05-14 19:31:38, Johannes Weiner wrote:
> While in that area, I noticed that the soft limit tree updaters don't
> actually use the memcg argument anymore...
> 
> ---
> From: Johannes Weiner <hannes@cmpxchg.org>
> Subject: [patch] mm: memcontrol: remove unnecessary memcg argument from soft
>  limit functions
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Michal Hocko <mhocko@suse.cz>

> ---
>  mm/memcontrol.c | 34 ++++++++++++++--------------------
>  1 file changed, 14 insertions(+), 20 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 83cbd5a0e62f..3381f76df084 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -714,11 +714,9 @@ soft_limit_tree_from_page(struct page *page)
>  	return &soft_limit_tree.rb_tree_per_node[nid]->rb_tree_per_zone[zid];
>  }
>  
> -static void
> -__mem_cgroup_insert_exceeded(struct mem_cgroup *memcg,
> -				struct mem_cgroup_per_zone *mz,
> -				struct mem_cgroup_tree_per_zone *mctz,
> -				unsigned long long new_usage_in_excess)
> +static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_zone *mz,
> +					 struct mem_cgroup_tree_per_zone *mctz,
> +					 unsigned long long new_usage_in_excess)
>  {
>  	struct rb_node **p = &mctz->rb_root.rb_node;
>  	struct rb_node *parent = NULL;
> @@ -748,10 +746,8 @@ __mem_cgroup_insert_exceeded(struct mem_cgroup *memcg,
>  	mz->on_tree = true;
>  }
>  
> -static void
> -__mem_cgroup_remove_exceeded(struct mem_cgroup *memcg,
> -				struct mem_cgroup_per_zone *mz,
> -				struct mem_cgroup_tree_per_zone *mctz)
> +static void __mem_cgroup_remove_exceeded(struct mem_cgroup_per_zone *mz,
> +					 struct mem_cgroup_tree_per_zone *mctz)
>  {
>  	if (!mz->on_tree)
>  		return;
> @@ -759,13 +755,11 @@ __mem_cgroup_remove_exceeded(struct mem_cgroup *memcg,
>  	mz->on_tree = false;
>  }
>  
> -static void
> -mem_cgroup_remove_exceeded(struct mem_cgroup *memcg,
> -				struct mem_cgroup_per_zone *mz,
> -				struct mem_cgroup_tree_per_zone *mctz)
> +static void mem_cgroup_remove_exceeded(struct mem_cgroup_per_zone *mz,
> +				       struct mem_cgroup_tree_per_zone *mctz)
>  {
>  	spin_lock(&mctz->lock);
> -	__mem_cgroup_remove_exceeded(memcg, mz, mctz);
> +	__mem_cgroup_remove_exceeded(mz, mctz);
>  	spin_unlock(&mctz->lock);
>  }
>  
> @@ -792,12 +786,12 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page)
>  			spin_lock(&mctz->lock);
>  			/* if on-tree, remove it */
>  			if (mz->on_tree)
> -				__mem_cgroup_remove_exceeded(memcg, mz, mctz);
> +				__mem_cgroup_remove_exceeded(mz, mctz);
>  			/*
>  			 * Insert again. mz->usage_in_excess will be updated.
>  			 * If excess is 0, no tree ops.
>  			 */
> -			__mem_cgroup_insert_exceeded(memcg, mz, mctz, excess);
> +			__mem_cgroup_insert_exceeded(mz, mctz, excess);
>  			spin_unlock(&mctz->lock);
>  		}
>  	}
> @@ -813,7 +807,7 @@ static void mem_cgroup_remove_from_trees(struct mem_cgroup *memcg)
>  		for (zid = 0; zid < MAX_NR_ZONES; zid++) {
>  			mz = &memcg->nodeinfo[nid]->zoneinfo[zid];
>  			mctz = soft_limit_tree_node_zone(nid, zid);
> -			mem_cgroup_remove_exceeded(memcg, mz, mctz);
> +			mem_cgroup_remove_exceeded(mz, mctz);
>  		}
>  	}
>  }
> @@ -836,7 +830,7 @@ retry:
>  	 * we will to add it back at the end of reclaim to its correct
>  	 * position in the tree.
>  	 */
> -	__mem_cgroup_remove_exceeded(mz->memcg, mz, mctz);
> +	__mem_cgroup_remove_exceeded(mz, mctz);
>  	if (!res_counter_soft_limit_excess(&mz->memcg->res) ||
>  		!css_tryget(&mz->memcg->css))
>  		goto retry;
> @@ -4694,7 +4688,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
>  					break;
>  			} while (1);
>  		}
> -		__mem_cgroup_remove_exceeded(mz->memcg, mz, mctz);
> +		__mem_cgroup_remove_exceeded(mz, mctz);
>  		excess = res_counter_soft_limit_excess(&mz->memcg->res);
>  		/*
>  		 * One school of thought says that we should not add
> @@ -4705,7 +4699,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
>  		 * term TODO.
>  		 */
>  		/* If excess == 0, no tree ops */
> -		__mem_cgroup_insert_exceeded(mz->memcg, mz, mctz, excess);
> +		__mem_cgroup_insert_exceeded(mz, mctz, excess);
>  		spin_unlock(&mctz->lock);
>  		css_put(&mz->memcg->css);
>  		loop++;
> -- 
> 1.9.2
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone()
  2014-05-02 23:29         ` Johannes Weiner
  2014-05-02 23:31           ` Johannes Weiner
  2014-05-05 15:31           ` Michal Hocko
@ 2014-05-05 21:36           ` Andrew Morton
  2 siblings, 0 replies; 11+ messages in thread
From: Andrew Morton @ 2014-05-05 21:36 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Michal Hocko, Jianyu Zhan, bsingharora, kamezawa.hiroyu, cgroups,
	linux-mm, linux-kernel, akpm

On Fri, 2 May 2014 19:29:08 -0400 Johannes Weiner <hannes@cmpxchg.org> wrote:

> Memcg zoneinfo lookup sites have either the page, the zone, or the
> node id and zone index, but sites that only have the zone have to look
> up the node id and zone index themselves, whereas sites that already
> have those two integers use a function for a simple pointer chase.
> 
> Provide mem_cgroup_zone_zoneinfo() that takes a zone pointer and let
> sites that already have node id and zone index - all for each node,
> for each zone iterators - use &memcg->nodeinfo[nid]->zoneinfo[zid].
> 
> Rename page_cgroup_zoneinfo() to mem_cgroup_page_zoneinfo() to match.

Patch shrinks my mm/memcontrol.o nicely:

   text    data     bss     dec     hex filename
  55702   15681   24560   95943   176c7 mm/memcontrol.o-before
  55489   15681   24464   95634   17592 mm/memcontrol.o-after

The bss size changes are weird - the patch doesn't touch bss afaict. 
This often happens.  One day I'll get in there and work out why.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-05-05 21:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-18 23:01 [PATCH 2/2] mm/memcontrol.c: introduce helper mem_cgroup_zoneinfo_zone() Jianyu Zhan
2014-04-22  9:59 ` Michal Hocko
2014-04-28 15:04   ` Michal Hocko
2014-05-01 12:54     ` Johannes Weiner
2014-05-01 13:36       ` Johannes Weiner
2014-05-02 22:05       ` Andrew Morton
2014-05-02 23:29         ` Johannes Weiner
2014-05-02 23:31           ` Johannes Weiner
2014-05-05 15:35             ` Michal Hocko
2014-05-05 15:31           ` Michal Hocko
2014-05-05 21:36           ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).