2010-07-29 05:25:44

by KOSAKI Motohiro

[permalink] [raw]
Subject: [PATCH 0/5] memcg: few nit fix and cleanups


This fixes were a part of memcg tracepoint series. and now It was divided
from such series. All patches are trivial.



KOSAKI Motohiro (5):
memcg: sc.nr_to_reclaim should be initialized
memcg: kill unnecessary initialization
memcg: mem_cgroup_shrink_node_zone() doesn't need sc.nodemask
memcg: remove nid and zid argument from mem_cgroup_soft_limit_reclaim()
memcg: convert to use zone_to_nid() from bare zone->zone_pgdat->node_id

include/linux/memcontrol.h | 6 +++---
include/linux/swap.h | 3 +--
mm/memcontrol.c | 14 ++++++--------
mm/vmscan.c | 15 ++++-----------
4 files changed, 14 insertions(+), 24 deletions(-)



2010-07-29 05:26:56

by KOSAKI Motohiro

[permalink] [raw]
Subject: [PATCH 1/5] memcg: sc.nr_to_reclaim should be initialized

Currently, mem_cgroup_shrink_node_zone() initialize sc.nr_to_reclaim as 0.
It mean shrink_zone() only scan 32 pages and immediately return even if
it doesn't reclaim any pages.

This patch fixes it.

Signed-off-by: KOSAKI Motohiro <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
Acked-by: Mel Gorman <[email protected]>
---
mm/vmscan.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index c691967..224184f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1935,6 +1935,7 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
struct zone *zone, int nid)
{
struct scan_control sc = {
+ .nr_to_reclaim = SWAP_CLUSTER_MAX,
.may_writepage = !laptop_mode,
.may_unmap = 1,
.may_swap = !noswap,
--
1.6.5.2


2010-07-29 05:27:43

by KOSAKI Motohiro

[permalink] [raw]
Subject: [PATCH 2/5] memcg: kill unnecessary initialization in mem_cgroup_shrink_node_zone()

sc.nr_reclaimed and sc.nr_scanned have already been initialized
few lines above "struct scan_control sc = {}" statement.

So, This patch remove this unnecessary code.

Signed-off-by: KOSAKI Motohiro <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
---
mm/vmscan.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 224184f..102ee3a 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1948,8 +1948,6 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) |
(GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK);
sc.nodemask = &nm;
- sc.nr_reclaimed = 0;
- sc.nr_scanned = 0;

trace_mm_vmscan_memcg_softlimit_reclaim_begin(0,
sc.may_writepage,
--
1.6.5.2


2010-07-29 05:28:30

by KOSAKI Motohiro

[permalink] [raw]
Subject: [PATCH 3/5] memcg: mem_cgroup_shrink_node_zone() doesn't need sc.nodemask

Currently mem_cgroup_shrink_node_zone() call shrink_zone() directly.
thus it doesn't need to initialize sc.nodemask because shrink_zone()
doesn't use it at all.

Signed-off-by: KOSAKI Motohiro <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
Acked-by: Mel Gorman <[email protected]>
---
include/linux/swap.h | 3 +--
mm/memcontrol.c | 3 +--
mm/vmscan.c | 5 +----
3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/include/linux/swap.h b/include/linux/swap.h
index ff4acea..bf4eb62 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -244,8 +244,7 @@ extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem,
extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
gfp_t gfp_mask, bool noswap,
unsigned int swappiness,
- struct zone *zone,
- int nid);
+ struct zone *zone);
extern int __isolate_lru_page(struct page *page, int mode, int file);
extern unsigned long shrink_all_memory(unsigned long nr_pages);
extern int vm_swappiness;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2600776..fee5cfa 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1282,8 +1282,7 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
/* we use swappiness of local cgroup */
if (check_soft)
ret = mem_cgroup_shrink_node_zone(victim, gfp_mask,
- noswap, get_swappiness(victim), zone,
- zone->zone_pgdat->node_id);
+ noswap, get_swappiness(victim), zone);
else
ret = try_to_free_mem_cgroup_pages(victim, gfp_mask,
noswap, get_swappiness(victim));
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 102ee3a..5e37c84 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1932,7 +1932,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
gfp_t gfp_mask, bool noswap,
unsigned int swappiness,
- struct zone *zone, int nid)
+ struct zone *zone)
{
struct scan_control sc = {
.nr_to_reclaim = SWAP_CLUSTER_MAX,
@@ -1943,11 +1943,8 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
.order = 0,
.mem_cgroup = mem,
};
- nodemask_t nm = nodemask_of_node(nid);
-
sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) |
(GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK);
- sc.nodemask = &nm;

trace_mm_vmscan_memcg_softlimit_reclaim_begin(0,
sc.may_writepage,
--
1.6.5.2


2010-07-29 05:29:18

by KOSAKI Motohiro

[permalink] [raw]
Subject: [PATCH 4/5] memcg: remove nid and zid argument from mem_cgroup_soft_limit_reclaim()

mem_cgroup_soft_limit_reclaim() has zone, nid and zid argument. but nid
and zid can be calculated from zone. So remove it.

Signed-off-by: KOSAKI Motohiro <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
Acked-by: Mel Gorman <[email protected]>

---
include/linux/memcontrol.h | 6 +++---
mm/memcontrol.c | 5 ++---
mm/vmscan.c | 7 ++-----
3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 9f1afd3..fd8ddbd 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -123,8 +123,8 @@ static inline bool mem_cgroup_disabled(void)

void mem_cgroup_update_file_mapped(struct page *page, int val);
unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
- gfp_t gfp_mask, int nid,
- int zid);
+ gfp_t gfp_mask);
+
#else /* CONFIG_CGROUP_MEM_RES_CTLR */
struct mem_cgroup;

@@ -299,7 +299,7 @@ static inline void mem_cgroup_update_file_mapped(struct page *page,

static inline
unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
- gfp_t gfp_mask, int nid, int zid)
+ gfp_t gfp_mask)
{
return 0;
}
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index fee5cfa..b9ffc0c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2847,8 +2847,7 @@ static int mem_cgroup_resize_memsw_limit(struct mem_cgroup *memcg,
}

unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
- gfp_t gfp_mask, int nid,
- int zid)
+ gfp_t gfp_mask)
{
unsigned long nr_reclaimed = 0;
struct mem_cgroup_per_zone *mz, *next_mz = NULL;
@@ -2860,7 +2859,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
if (order > 0)
return 0;

- mctz = soft_limit_tree_node_zone(nid, zid);
+ mctz = soft_limit_tree_node_zone(zone_to_nid(zone), zone_idx(zone));
/*
* This loop can run a while, specially if mem_cgroup's continuously
* keep exceeding their soft limit and putting the system under
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 5e37c84..6faae10 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2131,7 +2131,6 @@ loop_again:
for (i = 0; i <= end_zone; i++) {
struct zone *zone = pgdat->node_zones + i;
int nr_slab;
- int nid, zid;

if (!populated_zone(zone))
continue;
@@ -2141,14 +2140,12 @@ loop_again:

sc.nr_scanned = 0;

- nid = pgdat->node_id;
- zid = zone_idx(zone);
/*
* Call soft limit reclaim before calling shrink_zone.
* For now we ignore the return value
*/
- mem_cgroup_soft_limit_reclaim(zone, order, sc.gfp_mask,
- nid, zid);
+ mem_cgroup_soft_limit_reclaim(zone, order, sc.gfp_mask);
+
/*
* We put equal pressure on every zone, unless one
* zone has way too many pages free already.
--
1.6.5.2


2010-07-29 05:29:55

by KOSAKI Motohiro

[permalink] [raw]
Subject: [PATCH 5/5] memcg: convert to use zone_to_nid() from bare zone->zone_pgdat->node_id


We have zone_to_nid(). this patch convert all existing users of
zone->zone_pgdat->node_id.

Signed-off-by: KOSAKI Motohiro <[email protected]>
Acked-by: Balbir Singh <[email protected]>
---
mm/memcontrol.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b9ffc0c..b7bb7d9 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -919,7 +919,7 @@ unsigned long mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg,
struct zone *zone,
enum lru_list lru)
{
- int nid = zone->zone_pgdat->node_id;
+ int nid = zone_to_nid(zone);
int zid = zone_idx(zone);
struct mem_cgroup_per_zone *mz = mem_cgroup_zoneinfo(memcg, nid, zid);

@@ -929,7 +929,7 @@ unsigned long mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg,
struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat(struct mem_cgroup *memcg,
struct zone *zone)
{
- int nid = zone->zone_pgdat->node_id;
+ int nid = zone_to_nid(zone);
int zid = zone_idx(zone);
struct mem_cgroup_per_zone *mz = mem_cgroup_zoneinfo(memcg, nid, zid);

@@ -974,7 +974,7 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
LIST_HEAD(pc_list);
struct list_head *src;
struct page_cgroup *pc, *tmp;
- int nid = z->zone_pgdat->node_id;
+ int nid = zone_to_nid(z);
int zid = zone_idx(z);
struct mem_cgroup_per_zone *mz;
int lru = LRU_FILE * file + active;
--
1.6.5.2