* [PATCH 00/11] memcg: split-lru feature for memcg take2
@ 2008-12-01 12:10 KOSAKI Motohiro
2008-12-01 12:11 ` [PATCH 01/11] inactive_anon_is_low() move to vmscan.c KOSAKI Motohiro
` (11 more replies)
0 siblings, 12 replies; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-01 12:10 UTC (permalink / raw)
To: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki,
Rik van Riel
Cc: kosaki.motohiro
Recently, SplitLRU patch series dramatically improvement VM reclaim
logic.
it have following improvement.
(1) splite lru per page type
(2) introduce inactive/active anon balancing logic
(3) introduce anon/file balancing logic
Unfortunately, the improvement of memcgroup reclaim is incomplete.
Currently, it only has (1), but doesn't have (2) and (3).
This patch introduce (2) and (3) improvements to memcgroup.
this implementation is straightforward porting from global reclaim.
Therefere
- code is simple.
- memcg reclaim become efficiency as global reclaim.
- the logic is the same as global lru.
then, memcg reclaim debugging become easily.
this patch series has five part.
[part 1: global lru clean up]
[PATCH 01/11] inactive_anon_is_low() move to vmscan.c
[PATCH 02/11] introduce zone_reclaim struct
[PATCH 03/11] make zone_nr_pages() helper function
[PATCH 04/11] make get_scan_ratio() to memcg safe
[part 2: memcg: trivial fix]
[PATCH 05/11] memcg: add null check to page_cgroup_zoneinfo()
[part 3: memcg: inactive-anon vs active-anon balancing improvement]
[PATCH 06/11] memcg: make inactive_anon_is_low()
[part 4: anon vs file balancing improvement]
[PATCH 07/11] memcg: make mem_cgroup_zone_nr_pages()
[PATCH 08/11] memcg: make zone_reclaim_stat
[PATCH 09/11] memcg: remove mem_cgroup_calc_reclaim()
[part 5: add split-lru related statics field to /cgroup/memory.stat]
[PATCH 10/11] memcg: show inactive_ratio
[PATCH 11/11] memcg: show reclaim_stat
patch against: mmotm 29 Nov 2008
Andrew, could you please pick 01-04 up to -mm?
01-04 don't have any behavior change.
kamezawwa-san queue 05-11 to his memcg queueue awhile.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 01/11] inactive_anon_is_low() move to vmscan.c
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
@ 2008-12-01 12:11 ` KOSAKI Motohiro
2008-12-01 12:12 ` [PATCH 02/11] introduce zone_reclaim struct KOSAKI Motohiro
` (10 subsequent siblings)
11 siblings, 0 replies; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-01 12:11 UTC (permalink / raw)
To: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki,
Rik van Riel
Cc: kosaki.motohiro
The inactive_anon_is_low() is called only vmscan.
Then it can move to vmscan.c
This patch doesn't have any functional change.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Rik van Riel <riel@redhat.com>
---
include/linux/mm_inline.h | 19 -------------------
mm/vmscan.c | 20 ++++++++++++++++++++
2 files changed, 20 insertions(+), 19 deletions(-)
Index: b/include/linux/mm_inline.h
===================================================================
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -81,23 +81,4 @@ static inline enum lru_list page_lru(str
return lru;
}
-/**
- * inactive_anon_is_low - check if anonymous pages need to be deactivated
- * @zone: zone to check
- *
- * Returns true if the zone does not have enough inactive anon pages,
- * meaning some active anon pages need to be deactivated.
- */
-static inline int inactive_anon_is_low(struct zone *zone)
-{
- unsigned long active, inactive;
-
- active = zone_page_state(zone, NR_ACTIVE_ANON);
- inactive = zone_page_state(zone, NR_INACTIVE_ANON);
-
- if (inactive * zone->inactive_ratio < active)
- return 1;
-
- return 0;
-}
#endif
Index: b/mm/vmscan.c
===================================================================
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1350,6 +1350,26 @@ static void shrink_active_list(unsigned
pagevec_release(&pvec);
}
+/**
+ * inactive_anon_is_low - check if anonymous pages need to be deactivated
+ * @zone: zone to check
+ *
+ * Returns true if the zone does not have enough inactive anon pages,
+ * meaning some active anon pages need to be deactivated.
+ */
+static int inactive_anon_is_low(struct zone *zone)
+{
+ unsigned long active, inactive;
+
+ active = zone_page_state(zone, NR_ACTIVE_ANON);
+ inactive = zone_page_state(zone, NR_INACTIVE_ANON);
+
+ if (inactive * zone->inactive_ratio < active)
+ return 1;
+
+ return 0;
+}
+
static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,
struct zone *zone, struct scan_control *sc, int priority)
{
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 02/11] introduce zone_reclaim struct
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
2008-12-01 12:11 ` [PATCH 01/11] inactive_anon_is_low() move to vmscan.c KOSAKI Motohiro
@ 2008-12-01 12:12 ` KOSAKI Motohiro
2008-12-01 12:13 ` [PATCH 03/11] make zone_nr_pages() helper function KOSAKI Motohiro
` (9 subsequent siblings)
11 siblings, 0 replies; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-01 12:12 UTC (permalink / raw)
To: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki,
Rik van Riel
Cc: kosaki.motohiro
make zone_reclam_stat strcut for latter enhancement.
latter patch use this.
this patch doesn't any behavior change (yet).
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Rik van Riel <riel@redhat.com>
---
include/linux/mmzone.h | 24 ++++++++++++++----------
mm/page_alloc.c | 8 ++++----
mm/swap.c | 12 ++++++++----
mm/vmscan.c | 47 ++++++++++++++++++++++++++++++-----------------
4 files changed, 56 insertions(+), 35 deletions(-)
Index: b/include/linux/mmzone.h
===================================================================
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -263,6 +263,19 @@ enum zone_type {
#error ZONES_SHIFT -- too many zones configured adjust calculation
#endif
+struct zone_reclaim_stat {
+ /*
+ * The pageout code in vmscan.c keeps track of how many of the
+ * mem/swap backed and file backed pages are refeferenced.
+ * The higher the rotated/scanned ratio, the more valuable
+ * that cache is.
+ *
+ * The anon LRU stats live in [0], file LRU stats in [1]
+ */
+ unsigned long recent_rotated[2];
+ unsigned long recent_scanned[2];
+};
+
struct zone {
/* Fields commonly accessed by the page allocator */
unsigned long pages_min, pages_low, pages_high;
@@ -315,16 +328,7 @@ struct zone {
unsigned long nr_scan;
} lru[NR_LRU_LISTS];
- /*
- * The pageout code in vmscan.c keeps track of how many of the
- * mem/swap backed and file backed pages are refeferenced.
- * The higher the rotated/scanned ratio, the more valuable
- * that cache is.
- *
- * The anon LRU stats live in [0], file LRU stats in [1]
- */
- unsigned long recent_rotated[2];
- unsigned long recent_scanned[2];
+ struct zone_reclaim_stat reclaim_stat;
unsigned long pages_scanned; /* since last reclaim */
unsigned long slab_defrag_counter; /* since last defrag */
Index: b/mm/page_alloc.c
===================================================================
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3522,10 +3522,10 @@ static void __paginginit free_area_init_
INIT_LIST_HEAD(&zone->lru[l].list);
zone->lru[l].nr_scan = 0;
}
- zone->recent_rotated[0] = 0;
- zone->recent_rotated[1] = 0;
- zone->recent_scanned[0] = 0;
- zone->recent_scanned[1] = 0;
+ zone->reclaim_stat.recent_rotated[0] = 0;
+ zone->reclaim_stat.recent_rotated[1] = 0;
+ zone->reclaim_stat.recent_scanned[0] = 0;
+ zone->reclaim_stat.recent_scanned[1] = 0;
zap_zone_vm_stats(zone);
zone->flags = 0;
if (!size)
Index: b/mm/swap.c
===================================================================
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -157,6 +157,7 @@ void rotate_reclaimable_page(struct pag
void activate_page(struct page *page)
{
struct zone *zone = page_zone(page);
+ struct zone_reclaim_stat *reclaim_stat = &zone->reclaim_stat;
spin_lock_irq(&zone->lru_lock);
if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) {
@@ -169,8 +170,8 @@ void activate_page(struct page *page)
add_page_to_lru_list(zone, page, lru);
__count_vm_event(PGACTIVATE);
- zone->recent_rotated[!!file]++;
- zone->recent_scanned[!!file]++;
+ reclaim_stat->recent_rotated[!!file]++;
+ reclaim_stat->recent_scanned[!!file]++;
}
spin_unlock_irq(&zone->lru_lock);
}
@@ -398,6 +399,8 @@ void ____pagevec_lru_add(struct pagevec
{
int i;
struct zone *zone = NULL;
+ struct zone_reclaim_stat *reclaim_stat = NULL;
+
VM_BUG_ON(is_unevictable_lru(lru));
for (i = 0; i < pagevec_count(pvec); i++) {
@@ -409,6 +412,7 @@ void ____pagevec_lru_add(struct pagevec
if (zone)
spin_unlock_irq(&zone->lru_lock);
zone = pagezone;
+ reclaim_stat = &zone->reclaim_stat;
spin_lock_irq(&zone->lru_lock);
}
VM_BUG_ON(PageActive(page));
@@ -416,10 +420,10 @@ void ____pagevec_lru_add(struct pagevec
VM_BUG_ON(PageLRU(page));
SetPageLRU(page);
file = is_file_lru(lru);
- zone->recent_scanned[file]++;
+ reclaim_stat->recent_scanned[file]++;
if (is_active_lru(lru)) {
SetPageActive(page);
- zone->recent_rotated[file]++;
+ reclaim_stat->recent_rotated[file]++;
}
add_page_to_lru_list(zone, page, lru);
}
Index: b/mm/vmscan.c
===================================================================
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -131,6 +131,12 @@ static DECLARE_RWSEM(shrinker_rwsem);
#define scan_global_lru(sc) (1)
#endif
+static struct zone_reclaim_stat *get_reclaim_stat(struct zone *zone,
+ struct scan_control *sc)
+{
+ return &zone->reclaim_stat;
+}
+
/*
* Add a shrinker callback to be called from the vm
*/
@@ -1083,6 +1089,7 @@ static unsigned long shrink_inactive_lis
struct pagevec pvec;
unsigned long nr_scanned = 0;
unsigned long nr_reclaimed = 0;
+ struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc);
pagevec_init(&pvec, 1);
@@ -1126,10 +1133,14 @@ static unsigned long shrink_inactive_lis
if (scan_global_lru(sc)) {
zone->pages_scanned += nr_scan;
- zone->recent_scanned[0] += count[LRU_INACTIVE_ANON];
- zone->recent_scanned[0] += count[LRU_ACTIVE_ANON];
- zone->recent_scanned[1] += count[LRU_INACTIVE_FILE];
- zone->recent_scanned[1] += count[LRU_ACTIVE_FILE];
+ reclaim_stat->recent_scanned[0] +=
+ count[LRU_INACTIVE_ANON];
+ reclaim_stat->recent_scanned[0] +=
+ count[LRU_ACTIVE_ANON];
+ reclaim_stat->recent_scanned[1] +=
+ count[LRU_INACTIVE_FILE];
+ reclaim_stat->recent_scanned[1] +=
+ count[LRU_ACTIVE_FILE];
}
spin_unlock_irq(&zone->lru_lock);
@@ -1190,7 +1201,7 @@ static unsigned long shrink_inactive_lis
add_page_to_lru_list(zone, page, lru);
if (PageActive(page) && scan_global_lru(sc)) {
int file = !!page_is_file_cache(page);
- zone->recent_rotated[file]++;
+ reclaim_stat->recent_rotated[file]++;
}
if (!pagevec_add(&pvec, page)) {
spin_unlock_irq(&zone->lru_lock);
@@ -1255,6 +1266,7 @@ static void shrink_active_list(unsigned
struct page *page;
struct pagevec pvec;
enum lru_list lru;
+ struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc);
lru_add_drain();
spin_lock_irq(&zone->lru_lock);
@@ -1267,7 +1279,7 @@ static void shrink_active_list(unsigned
*/
if (scan_global_lru(sc)) {
zone->pages_scanned += pgscanned;
- zone->recent_scanned[!!file] += pgmoved;
+ reclaim_stat->recent_scanned[!!file] += pgmoved;
}
if (file)
@@ -1302,7 +1314,7 @@ static void shrink_active_list(unsigned
* pages in get_scan_ratio.
*/
if (scan_global_lru(sc))
- zone->recent_rotated[!!file] += pgmoved;
+ reclaim_stat->recent_rotated[!!file] += pgmoved;
/*
* Move the pages to the [file or anon] inactive list.
@@ -1403,6 +1415,7 @@ static void get_scan_ratio(struct zone *
unsigned long anon, file, free;
unsigned long anon_prio, file_prio;
unsigned long ap, fp;
+ struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc);
/* If we have no swap space, do not bother scanning anon pages. */
if (nr_swap_pages <= 0) {
@@ -1435,17 +1448,17 @@ static void get_scan_ratio(struct zone *
*
* anon in [0], file in [1]
*/
- if (unlikely(zone->recent_scanned[0] > anon / 4)) {
+ if (unlikely(reclaim_stat->recent_scanned[0] > anon / 4)) {
spin_lock_irq(&zone->lru_lock);
- zone->recent_scanned[0] /= 2;
- zone->recent_rotated[0] /= 2;
+ reclaim_stat->recent_scanned[0] /= 2;
+ reclaim_stat->recent_rotated[0] /= 2;
spin_unlock_irq(&zone->lru_lock);
}
- if (unlikely(zone->recent_scanned[1] > file / 4)) {
+ if (unlikely(reclaim_stat->recent_scanned[1] > file / 4)) {
spin_lock_irq(&zone->lru_lock);
- zone->recent_scanned[1] /= 2;
- zone->recent_rotated[1] /= 2;
+ reclaim_stat->recent_scanned[1] /= 2;
+ reclaim_stat->recent_rotated[1] /= 2;
spin_unlock_irq(&zone->lru_lock);
}
@@ -1461,11 +1474,11 @@ static void get_scan_ratio(struct zone *
* proportional to the fraction of recently scanned pages on
* each list that were recently referenced and in active use.
*/
- ap = (anon_prio + 1) * (zone->recent_scanned[0] + 1);
- ap /= zone->recent_rotated[0] + 1;
+ ap = (anon_prio + 1) * (reclaim_stat->recent_scanned[0] + 1);
+ ap /= reclaim_stat->recent_rotated[0] + 1;
- fp = (file_prio + 1) * (zone->recent_scanned[1] + 1);
- fp /= zone->recent_rotated[1] + 1;
+ fp = (file_prio + 1) * (reclaim_stat->recent_scanned[1] + 1);
+ fp /= reclaim_stat->recent_rotated[1] + 1;
/* Normalize to percentages */
percent[0] = 100 * ap / (ap + fp + 1);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 03/11] make zone_nr_pages() helper function
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
2008-12-01 12:11 ` [PATCH 01/11] inactive_anon_is_low() move to vmscan.c KOSAKI Motohiro
2008-12-01 12:12 ` [PATCH 02/11] introduce zone_reclaim struct KOSAKI Motohiro
@ 2008-12-01 12:13 ` KOSAKI Motohiro
2008-12-01 12:14 ` [PATCH 04/11] make get_scan_ratio() to memcg safe KOSAKI Motohiro
` (8 subsequent siblings)
11 siblings, 0 replies; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-01 12:13 UTC (permalink / raw)
To: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki,
Rik van Riel
Cc: kosaki.motohiro
make zone_nr_pages() helper function.
it is used by latter patch.
this patch doesn't have any functional change.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Rik van Riel <riel@redhat.com>
---
mm/vmscan.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
Index: b/mm/vmscan.c
===================================================================
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -137,6 +137,13 @@ static struct zone_reclaim_stat *get_rec
return &zone->reclaim_stat;
}
+static unsigned long zone_nr_pages(struct zone *zone, struct scan_control *sc,
+ enum lru_list lru)
+{
+ return zone_page_state(zone, NR_LRU_BASE + lru);
+}
+
+
/*
* Add a shrinker callback to be called from the vm
*/
@@ -1424,10 +1431,10 @@ static void get_scan_ratio(struct zone *
return;
}
- anon = zone_page_state(zone, NR_ACTIVE_ANON) +
- zone_page_state(zone, NR_INACTIVE_ANON);
- file = zone_page_state(zone, NR_ACTIVE_FILE) +
- zone_page_state(zone, NR_INACTIVE_FILE);
+ anon = zone_nr_pages(zone, sc, LRU_ACTIVE_ANON) +
+ zone_nr_pages(zone, sc, LRU_INACTIVE_ANON);
+ file = zone_nr_pages(zone, sc, LRU_ACTIVE_FILE) +
+ zone_nr_pages(zone, sc, LRU_INACTIVE_FILE);
free = zone_page_state(zone, NR_FREE_PAGES);
/* If we have very few page cache pages, force-scan anon pages. */
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 04/11] make get_scan_ratio() to memcg safe
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
` (2 preceding siblings ...)
2008-12-01 12:13 ` [PATCH 03/11] make zone_nr_pages() helper function KOSAKI Motohiro
@ 2008-12-01 12:14 ` KOSAKI Motohiro
2008-12-01 14:50 ` Rik van Riel
2008-12-01 12:14 ` [PATCH 05/11] memcg: add null check to page_cgroup_zoneinfo() KOSAKI Motohiro
` (7 subsequent siblings)
11 siblings, 1 reply; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-01 12:14 UTC (permalink / raw)
To: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki,
Rik van Riel
Cc: kosaki.motohiro
Currently, get_scan_ratio() always calculate the balancing value for global reclaim and
memcg reclaim doesn't use it.
Therefore it doesn't have scan_global_lru() condition.
However, we plan to expand get_scan_ratio() to be usable for memcg too, latter.
Then, The dependency code of global reclaim in the get_scan_ratio() insert into
scan_global_lru() condision explictly.
this patch doesn't have any functional change.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
mm/vmscan.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
Index: b/mm/vmscan.c
===================================================================
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1435,13 +1435,16 @@ static void get_scan_ratio(struct zone *
zone_nr_pages(zone, sc, LRU_INACTIVE_ANON);
file = zone_nr_pages(zone, sc, LRU_ACTIVE_FILE) +
zone_nr_pages(zone, sc, LRU_INACTIVE_FILE);
- free = zone_page_state(zone, NR_FREE_PAGES);
- /* If we have very few page cache pages, force-scan anon pages. */
- if (unlikely(file + free <= zone->pages_high)) {
- percent[0] = 100;
- percent[1] = 0;
- return;
+ if (scan_global_lru(sc)) {
+ free = zone_page_state(zone, NR_FREE_PAGES);
+ /* If we have very few page cache pages,
+ force-scan anon pages. */
+ if (unlikely(file + free <= zone->pages_high)) {
+ percent[0] = 100;
+ percent[1] = 0;
+ return;
+ }
}
/*
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 05/11] memcg: add null check to page_cgroup_zoneinfo()
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
` (3 preceding siblings ...)
2008-12-01 12:14 ` [PATCH 04/11] make get_scan_ratio() to memcg safe KOSAKI Motohiro
@ 2008-12-01 12:14 ` KOSAKI Motohiro
2008-12-01 14:52 ` Rik van Riel
2008-12-01 12:15 ` [PATCH 06/11] memcg: make inactive_anon_is_low() KOSAKI Motohiro
` (6 subsequent siblings)
11 siblings, 1 reply; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-01 12:14 UTC (permalink / raw)
To: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki,
Rik van Riel
Cc: kosaki.motohiro
if CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y, page_cgroup::mem_cgroup can be NULL.
Therefore null checking is better.
latter patch use this function.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
mm/memcontrol.c | 3 +++
1 file changed, 3 insertions(+)
Index: b/mm/memcontrol.c
===================================================================
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -231,6 +231,9 @@ page_cgroup_zoneinfo(struct page_cgroup
int nid = page_cgroup_nid(pc);
int zid = page_cgroup_zid(pc);
+ if (!mem)
+ return NULL;
+
return mem_cgroup_zoneinfo(mem, nid, zid);
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 06/11] memcg: make inactive_anon_is_low()
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
` (4 preceding siblings ...)
2008-12-01 12:14 ` [PATCH 05/11] memcg: add null check to page_cgroup_zoneinfo() KOSAKI Motohiro
@ 2008-12-01 12:15 ` KOSAKI Motohiro
2008-12-03 13:52 ` Balbir Singh
2008-12-01 12:16 ` [PATCH 07/11] memcg: make mem_cgroup_zone_nr_pages() KOSAKI Motohiro
` (5 subsequent siblings)
11 siblings, 1 reply; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-01 12:15 UTC (permalink / raw)
To: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki,
Rik van Riel
Cc: kosaki.motohiro
Changelog:
v1 -> v2:
- add detail patch description
- fix coding style in mem_cgroup_set_inactive_ratio()
- add comment to mem_cgroup_set_inactive_ratio
- remove extra newline
- memcg::inactiveratio change type to unsigned int
The inactive_anon_is_low() is key component of active/inactive anon balancing on reclaim.
However current inactive_anon_is_low() function only consider global reclaim.
Therefore, we need following ugly scan_global_lru() condision.
if (lru == LRU_ACTIVE_ANON &&
(!scan_global_lru(sc) || inactive_anon_is_low(zone))) {
shrink_active_list(nr_to_scan, zone, sc, priority, file);
return 0;
it cause that memcg reclaim always deactivate pages when shrink_list() is called.
To make mem_cgroup_inactive_anon_is_low() improve active/inactive anon balancing of memcgroup.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Cyrill Gorcunov <gorcunov@gmail.com>
CC: "Pekka Enberg" <penberg@cs.helsinki.fi>
Acked-by: Rik van Riel <riel@redhat.com>
---
include/linux/memcontrol.h | 9 ++++++++
mm/memcontrol.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-
mm/vmscan.c | 36 ++++++++++++++++++++++-------------
3 files changed, 77 insertions(+), 14 deletions(-)
Index: b/include/linux/memcontrol.h
===================================================================
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -90,6 +90,8 @@ extern void mem_cgroup_record_reclaim_pr
extern long mem_cgroup_calc_reclaim(struct mem_cgroup *mem, struct zone *zone,
int priority, enum lru_list lru);
+int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg,
+ struct zone *zone);
#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
extern int do_swap_account;
@@ -241,6 +243,13 @@ static inline bool mem_cgroup_oom_called
{
return false;
}
+
+static inline int
+mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg, struct zone *zone)
+{
+ return 1;
+}
+
#endif /* CONFIG_CGROUP_MEM_CONT */
#endif /* _LINUX_MEMCONTROL_H */
Index: b/mm/memcontrol.c
===================================================================
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -156,6 +156,9 @@ struct mem_cgroup {
unsigned long last_oom_jiffies;
int obsolete;
atomic_t refcnt;
+
+ unsigned int inactive_ratio;
+
/*
* statistics. This must be placed at the end of memcg.
*/
@@ -431,6 +434,20 @@ long mem_cgroup_calc_reclaim(struct mem_
return (nr_pages >> priority);
}
+int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg, struct zone *zone)
+{
+ unsigned long active;
+ unsigned long inactive;
+
+ inactive = mem_cgroup_get_all_zonestat(memcg, LRU_INACTIVE_ANON);
+ active = mem_cgroup_get_all_zonestat(memcg, LRU_ACTIVE_ANON);
+
+ if (inactive * memcg->inactive_ratio < active)
+ return 1;
+
+ return 0;
+}
+
unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
struct list_head *dst,
unsigned long *scanned, int order,
@@ -1346,6 +1363,29 @@ int mem_cgroup_shrink_usage(struct mm_st
return 0;
}
+/*
+ * The inactive anon list should be small enough that the VM never has to
+ * do too much work, but large enough that each inactive page has a chance
+ * to be referenced again before it is swapped out.
+ *
+ * this calculation is straightforward porting from
+ * page_alloc.c::setup_per_zone_inactive_ratio().
+ * it describe more detail.
+ */
+static void mem_cgroup_set_inactive_ratio(struct mem_cgroup *memcg)
+{
+ unsigned int gb, ratio;
+
+ gb = res_counter_read_u64(&memcg->res, RES_LIMIT) >> 30;
+ if (gb)
+ ratio = int_sqrt(10 * gb);
+ else
+ ratio = 1;
+
+ memcg->inactive_ratio = ratio;
+
+}
+
static DEFINE_MUTEX(set_limit_mutex);
static int mem_cgroup_resize_limit(struct mem_cgroup *memcg,
@@ -1384,6 +1424,10 @@ static int mem_cgroup_resize_limit(struc
GFP_HIGHUSER_MOVABLE, false);
if (!progress) retry_count--;
}
+
+ if (!ret)
+ mem_cgroup_set_inactive_ratio(memcg);
+
return ret;
}
@@ -1968,7 +2012,7 @@ mem_cgroup_create(struct cgroup_subsys *
res_counter_init(&mem->res, NULL);
res_counter_init(&mem->memsw, NULL);
}
-
+ mem_cgroup_set_inactive_ratio(mem);
mem->last_scanned_child = NULL;
return &mem->css;
Index: b/mm/vmscan.c
===================================================================
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1369,14 +1369,7 @@ static void shrink_active_list(unsigned
pagevec_release(&pvec);
}
-/**
- * inactive_anon_is_low - check if anonymous pages need to be deactivated
- * @zone: zone to check
- *
- * Returns true if the zone does not have enough inactive anon pages,
- * meaning some active anon pages need to be deactivated.
- */
-static int inactive_anon_is_low(struct zone *zone)
+static int inactive_anon_is_low_global(struct zone *zone)
{
unsigned long active, inactive;
@@ -1389,6 +1382,25 @@ static int inactive_anon_is_low(struct z
return 0;
}
+/**
+ * inactive_anon_is_low - check if anonymous pages need to be deactivated
+ * @zone: zone to check
+ * @sc: scan control of this context
+ *
+ * Returns true if the zone does not have enough inactive anon pages,
+ * meaning some active anon pages need to be deactivated.
+ */
+static int inactive_anon_is_low(struct zone *zone, struct scan_control *sc)
+{
+ int low;
+
+ if (scan_global_lru(sc))
+ low = inactive_anon_is_low_global(zone);
+ else
+ low = mem_cgroup_inactive_anon_is_low(sc->mem_cgroup, zone);
+ return low;
+}
+
static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,
struct zone *zone, struct scan_control *sc, int priority)
{
@@ -1400,7 +1412,7 @@ static unsigned long shrink_list(enum lr
}
if (lru == LRU_ACTIVE_ANON &&
- (!scan_global_lru(sc) || inactive_anon_is_low(zone))) {
+ inactive_anon_is_low(zone, sc)) {
shrink_active_list(nr_to_scan, zone, sc, priority, file);
return 0;
}
@@ -1565,9 +1577,7 @@ static void shrink_zone(int priority, st
* Even if we did not try to evict anon pages at all, we want to
* rebalance the anon lru active/inactive ratio.
*/
- if (!scan_global_lru(sc) || inactive_anon_is_low(zone))
- shrink_active_list(SWAP_CLUSTER_MAX, zone, sc, priority, 0);
- else if (!scan_global_lru(sc))
+ if (inactive_anon_is_low(zone, sc))
shrink_active_list(SWAP_CLUSTER_MAX, zone, sc, priority, 0);
throttle_vm_writeout(sc->gfp_mask);
@@ -1863,7 +1873,7 @@ loop_again:
* Do some background aging of the anon list, to give
* pages a chance to be referenced before reclaiming.
*/
- if (inactive_anon_is_low(zone))
+ if (inactive_anon_is_low(zone, &sc))
shrink_active_list(SWAP_CLUSTER_MAX, zone,
&sc, priority, 0);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 07/11] memcg: make mem_cgroup_zone_nr_pages()
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
` (5 preceding siblings ...)
2008-12-01 12:15 ` [PATCH 06/11] memcg: make inactive_anon_is_low() KOSAKI Motohiro
@ 2008-12-01 12:16 ` KOSAKI Motohiro
2008-12-01 16:31 ` Rik van Riel
2008-12-03 13:58 ` Balbir Singh
2008-12-01 12:17 ` [PATCH 08/11] memcg: make zone_reclaim_stat KOSAKI Motohiro
` (4 subsequent siblings)
11 siblings, 2 replies; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-01 12:16 UTC (permalink / raw)
To: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki,
Rik van Riel
Cc: kosaki.motohiro
introduce mem_cgroup_zone_nr_pages().
it is called by zone_nr_pages() helper function.
this patch doesn't have any behavior change.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
include/linux/memcontrol.h | 11 +++++++++++
mm/memcontrol.c | 12 +++++++++++-
mm/vmscan.c | 3 +++
3 files changed, 25 insertions(+), 1 deletion(-)
Index: b/include/linux/memcontrol.h
===================================================================
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -92,6 +92,9 @@ extern long mem_cgroup_calc_reclaim(stru
int priority, enum lru_list lru);
int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg,
struct zone *zone);
+unsigned long mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg,
+ struct zone *zone,
+ enum lru_list lru);
#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
extern int do_swap_account;
@@ -250,6 +253,14 @@ mem_cgroup_inactive_anon_is_low(struct m
return 1;
}
+static inline unsigned long
+mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg, struct zone *zone,
+ enum lru_list lru)
+{
+ return 0;
+}
+
+
#endif /* CONFIG_CGROUP_MEM_CONT */
#endif /* _LINUX_MEMCONTROL_H */
Index: b/mm/memcontrol.c
===================================================================
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -186,7 +186,6 @@ pcg_default_flags[NR_CHARGE_TYPE] = {
0, /* FORCE */
};
-
/* for encoding cft->private value on file */
#define _MEM (0)
#define _MEMSWAP (1)
@@ -448,6 +447,17 @@ int mem_cgroup_inactive_anon_is_low(stru
return 0;
}
+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 zid = zone_idx(zone);
+ struct mem_cgroup_per_zone *mz = mem_cgroup_zoneinfo(memcg, nid, zid);
+
+ return MEM_CGROUP_ZSTAT(mz, lru);
+}
+
unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
struct list_head *dst,
unsigned long *scanned, int order,
Index: b/mm/vmscan.c
===================================================================
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -140,6 +140,9 @@ static struct zone_reclaim_stat *get_rec
static unsigned long zone_nr_pages(struct zone *zone, struct scan_control *sc,
enum lru_list lru)
{
+ if (!scan_global_lru(sc))
+ return mem_cgroup_zone_nr_pages(sc->mem_cgroup, zone, lru);
+
return zone_page_state(zone, NR_LRU_BASE + lru);
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 08/11] memcg: make zone_reclaim_stat
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
` (6 preceding siblings ...)
2008-12-01 12:16 ` [PATCH 07/11] memcg: make mem_cgroup_zone_nr_pages() KOSAKI Motohiro
@ 2008-12-01 12:17 ` KOSAKI Motohiro
2008-12-01 16:33 ` Rik van Riel
2008-12-03 14:06 ` Balbir Singh
2008-12-01 12:18 ` [PATCH 09/11] memcg: remove mem_cgroup_calc_reclaim() KOSAKI Motohiro
` (3 subsequent siblings)
11 siblings, 2 replies; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-01 12:17 UTC (permalink / raw)
To: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki,
Rik van Riel
Cc: kosaki.motohiro
introduce mem_cgroup_per_zone::reclaim_stat member and its statics collecting
function.
Now, get_scan_ratio() can calculate correct value although memcg reclaim.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
include/linux/memcontrol.h | 16 ++++++++++++++++
mm/memcontrol.c | 23 +++++++++++++++++++++++
mm/swap.c | 14 ++++++++++++++
mm/vmscan.c | 27 +++++++++++++--------------
4 files changed, 66 insertions(+), 14 deletions(-)
Index: b/include/linux/memcontrol.h
===================================================================
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -95,6 +95,10 @@ int mem_cgroup_inactive_anon_is_low(stru
unsigned long mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg,
struct zone *zone,
enum lru_list lru);
+struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat(struct mem_cgroup *memcg,
+ struct zone *zone);
+struct zone_reclaim_stat*
+mem_cgroup_get_reclaim_stat_by_page(struct page *page);
#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
extern int do_swap_account;
@@ -261,6 +265,18 @@ mem_cgroup_zone_nr_pages(struct mem_cgro
}
+static inline struct zone_reclaim_stat*
+mem_cgroup_get_reclaim_stat(struct mem_cgroup *memcg, struct zone *zone)
+{
+ return NULL;
+}
+
+static inline struct zone_reclaim_stat*
+mem_cgroup_get_reclaim_stat_by_page(struct page *page)
+{
+ return NULL;
+}
+
#endif /* CONFIG_CGROUP_MEM_CONT */
#endif /* _LINUX_MEMCONTROL_H */
Index: b/mm/memcontrol.c
===================================================================
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -103,6 +103,8 @@ struct mem_cgroup_per_zone {
*/
struct list_head lists[NR_LRU_LISTS];
unsigned long count[NR_LRU_LISTS];
+
+ struct zone_reclaim_stat reclaim_stat;
};
/* Macro for accessing counter */
#define MEM_CGROUP_ZSTAT(mz, idx) ((mz)->count[(idx)])
@@ -458,6 +460,27 @@ unsigned long mem_cgroup_zone_nr_pages(s
return MEM_CGROUP_ZSTAT(mz, lru);
}
+struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat(struct mem_cgroup *memcg,
+ struct zone *zone)
+{
+ int nid = zone->zone_pgdat->node_id;
+ int zid = zone_idx(zone);
+ struct mem_cgroup_per_zone *mz = mem_cgroup_zoneinfo(memcg, nid, zid);
+
+ return &mz->reclaim_stat;
+}
+
+struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat_by_page(struct page *page)
+{
+ struct page_cgroup *pc = lookup_page_cgroup(page);
+ struct mem_cgroup_per_zone *mz = page_cgroup_zoneinfo(pc);
+
+ if (!mz)
+ return NULL;
+
+ return &mz->reclaim_stat;
+}
+
unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
struct list_head *dst,
unsigned long *scanned, int order,
Index: b/mm/swap.c
===================================================================
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -158,6 +158,7 @@ void activate_page(struct page *page)
{
struct zone *zone = page_zone(page);
struct zone_reclaim_stat *reclaim_stat = &zone->reclaim_stat;
+ struct zone_reclaim_stat *memcg_reclaim_stat;
spin_lock_irq(&zone->lru_lock);
if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) {
@@ -172,6 +173,12 @@ void activate_page(struct page *page)
reclaim_stat->recent_rotated[!!file]++;
reclaim_stat->recent_scanned[!!file]++;
+
+ memcg_reclaim_stat = mem_cgroup_get_reclaim_stat_by_page(page);
+ if (memcg_reclaim_stat) {
+ memcg_reclaim_stat->recent_rotated[!!file]++;
+ memcg_reclaim_stat->recent_scanned[!!file]++;
+ }
}
spin_unlock_irq(&zone->lru_lock);
}
@@ -400,6 +407,7 @@ void ____pagevec_lru_add(struct pagevec
int i;
struct zone *zone = NULL;
struct zone_reclaim_stat *reclaim_stat = NULL;
+ struct zone_reclaim_stat *memcg_reclaim_stat = NULL;
VM_BUG_ON(is_unevictable_lru(lru));
@@ -413,6 +421,8 @@ void ____pagevec_lru_add(struct pagevec
spin_unlock_irq(&zone->lru_lock);
zone = pagezone;
reclaim_stat = &zone->reclaim_stat;
+ memcg_reclaim_stat =
+ mem_cgroup_get_reclaim_stat_by_page(page);
spin_lock_irq(&zone->lru_lock);
}
VM_BUG_ON(PageActive(page));
@@ -421,9 +431,13 @@ void ____pagevec_lru_add(struct pagevec
SetPageLRU(page);
file = is_file_lru(lru);
reclaim_stat->recent_scanned[file]++;
+ if (memcg_reclaim_stat)
+ memcg_reclaim_stat->recent_scanned[file]++;
if (is_active_lru(lru)) {
SetPageActive(page);
reclaim_stat->recent_rotated[file]++;
+ if (memcg_reclaim_stat)
+ memcg_reclaim_stat->recent_rotated[file]++;
}
add_page_to_lru_list(zone, page, lru);
}
Index: b/mm/vmscan.c
===================================================================
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -134,6 +134,9 @@ static DECLARE_RWSEM(shrinker_rwsem);
static struct zone_reclaim_stat *get_reclaim_stat(struct zone *zone,
struct scan_control *sc)
{
+ if (!scan_global_lru(sc))
+ mem_cgroup_get_reclaim_stat(sc->mem_cgroup, zone);
+
return &zone->reclaim_stat;
}
@@ -1141,17 +1144,14 @@ static unsigned long shrink_inactive_lis
__mod_zone_page_state(zone, NR_INACTIVE_ANON,
-count[LRU_INACTIVE_ANON]);
- if (scan_global_lru(sc)) {
+ if (scan_global_lru(sc))
zone->pages_scanned += nr_scan;
- reclaim_stat->recent_scanned[0] +=
- count[LRU_INACTIVE_ANON];
- reclaim_stat->recent_scanned[0] +=
- count[LRU_ACTIVE_ANON];
- reclaim_stat->recent_scanned[1] +=
- count[LRU_INACTIVE_FILE];
- reclaim_stat->recent_scanned[1] +=
- count[LRU_ACTIVE_FILE];
- }
+
+ reclaim_stat->recent_scanned[0] += count[LRU_INACTIVE_ANON];
+ reclaim_stat->recent_scanned[0] += count[LRU_ACTIVE_ANON];
+ reclaim_stat->recent_scanned[1] += count[LRU_INACTIVE_FILE];
+ reclaim_stat->recent_scanned[1] += count[LRU_ACTIVE_FILE];
+
spin_unlock_irq(&zone->lru_lock);
nr_scanned += nr_scan;
@@ -1209,7 +1209,7 @@ static unsigned long shrink_inactive_lis
SetPageLRU(page);
lru = page_lru(page);
add_page_to_lru_list(zone, page, lru);
- if (PageActive(page) && scan_global_lru(sc)) {
+ if (PageActive(page)) {
int file = !!page_is_file_cache(page);
reclaim_stat->recent_rotated[file]++;
}
@@ -1289,8 +1289,8 @@ static void shrink_active_list(unsigned
*/
if (scan_global_lru(sc)) {
zone->pages_scanned += pgscanned;
- reclaim_stat->recent_scanned[!!file] += pgmoved;
}
+ reclaim_stat->recent_scanned[!!file] += pgmoved;
if (file)
__mod_zone_page_state(zone, NR_ACTIVE_FILE, -pgmoved);
@@ -1323,8 +1323,7 @@ static void shrink_active_list(unsigned
* This helps balance scan pressure between file and anonymous
* pages in get_scan_ratio.
*/
- if (scan_global_lru(sc))
- reclaim_stat->recent_rotated[!!file] += pgmoved;
+ reclaim_stat->recent_rotated[!!file] += pgmoved;
/*
* Move the pages to the [file or anon] inactive list.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 09/11] memcg: remove mem_cgroup_calc_reclaim()
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
` (7 preceding siblings ...)
2008-12-01 12:17 ` [PATCH 08/11] memcg: make zone_reclaim_stat KOSAKI Motohiro
@ 2008-12-01 12:18 ` KOSAKI Motohiro
2008-12-01 17:09 ` Rik van Riel
2008-12-01 12:19 ` [PATCH 10/11] memcg: show inactive_ratio KOSAKI Motohiro
` (2 subsequent siblings)
11 siblings, 1 reply; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-01 12:18 UTC (permalink / raw)
To: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki,
Rik van Riel
Cc: kosaki.motohiro
Now, get_scan_ratio() return correct value although memcg reclaim.
Then, mem_cgroup_calc_reclaim() can be removed.
So, memcg reclaim get the same capability of anon/file reclaim balancing as global reclaim now.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
include/linux/memcontrol.h | 10 ----------
mm/memcontrol.c | 21 ---------------------
mm/vmscan.c | 27 ++++++++++-----------------
3 files changed, 10 insertions(+), 48 deletions(-)
Index: b/include/linux/memcontrol.h
===================================================================
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -87,9 +87,6 @@ extern void mem_cgroup_note_reclaim_prio
int priority);
extern void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem,
int priority);
-
-extern long mem_cgroup_calc_reclaim(struct mem_cgroup *mem, struct zone *zone,
- int priority, enum lru_list lru);
int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg,
struct zone *zone);
struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat(struct mem_cgroup *memcg,
@@ -234,13 +231,6 @@ static inline void mem_cgroup_record_rec
{
}
-static inline long mem_cgroup_calc_reclaim(struct mem_cgroup *mem,
- struct zone *zone, int priority,
- enum lru_list lru)
-{
- return 0;
-}
-
static inline bool mem_cgroup_disabled(void)
{
return true;
Index: b/mm/memcontrol.c
===================================================================
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -414,27 +414,6 @@ void mem_cgroup_record_reclaim_priority(
mem->prev_priority = priority;
}
-/*
- * Calculate # of pages to be scanned in this priority/zone.
- * See also vmscan.c
- *
- * priority starts from "DEF_PRIORITY" and decremented in each loop.
- * (see include/linux/mmzone.h)
- */
-
-long mem_cgroup_calc_reclaim(struct mem_cgroup *mem, struct zone *zone,
- int priority, enum lru_list lru)
-{
- long nr_pages;
- int nid = zone->zone_pgdat->node_id;
- int zid = zone_idx(zone);
- struct mem_cgroup_per_zone *mz = mem_cgroup_zoneinfo(mem, nid, zid);
-
- nr_pages = MEM_CGROUP_ZSTAT(mz, lru);
-
- return (nr_pages >> priority);
-}
-
int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg, struct zone *zone)
{
unsigned long active;
Index: b/mm/vmscan.c
===================================================================
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1524,30 +1524,23 @@ static void shrink_zone(int priority, st
get_scan_ratio(zone, sc, percent);
for_each_evictable_lru(l) {
- if (scan_global_lru(sc)) {
- int file = is_file_lru(l);
- int scan;
+ int file = is_file_lru(l);
+ int scan;
- scan = zone_page_state(zone, NR_LRU_BASE + l);
- if (priority) {
- scan >>= priority;
- scan = (scan * percent[file]) / 100;
- }
+ scan = zone_page_state(zone, NR_LRU_BASE + l);
+ if (priority) {
+ scan >>= priority;
+ scan = (scan * percent[file]) / 100;
+ }
+ if (scan_global_lru(sc)) {
zone->lru[l].nr_scan += scan;
nr[l] = zone->lru[l].nr_scan;
if (nr[l] >= sc->swap_cluster_max)
zone->lru[l].nr_scan = 0;
else
nr[l] = 0;
- } else {
- /*
- * This reclaim occurs not because zone memory shortage
- * but because memory controller hits its limit.
- * Don't modify zone reclaim related data.
- */
- nr[l] = mem_cgroup_calc_reclaim(sc->mem_cgroup, zone,
- priority, l);
- }
+ } else
+ nr[l] = scan;
}
while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] ||
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 10/11] memcg: show inactive_ratio
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
` (8 preceding siblings ...)
2008-12-01 12:18 ` [PATCH 09/11] memcg: remove mem_cgroup_calc_reclaim() KOSAKI Motohiro
@ 2008-12-01 12:19 ` KOSAKI Motohiro
2008-12-01 17:10 ` Rik van Riel
2008-12-02 9:05 ` KAMEZAWA Hiroyuki
2008-12-01 12:19 ` [PATCH 11/11] memcg: show reclaim_stat KOSAKI Motohiro
2008-12-02 4:25 ` [PATCH 00/11] memcg: split-lru feature for memcg take2 KAMEZAWA Hiroyuki
11 siblings, 2 replies; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-01 12:19 UTC (permalink / raw)
To: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki,
Rik van Riel
Cc: kosaki.motohiro
add inactive_ratio field to memory.stat file.
it is useful for memcg reclam debugging.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
mm/memcontrol.c | 3 +++
1 file changed, 3 insertions(+)
Index: b/mm/memcontrol.c
===================================================================
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1796,6 +1796,9 @@ static int mem_control_stat_show(struct
cb->fill(cb, "unevictable", unevictable * PAGE_SIZE);
}
+
+ cb->fill(cb, "inactive_ratio", mem_cont->inactive_ratio);
+
return 0;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 11/11] memcg: show reclaim_stat
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
` (9 preceding siblings ...)
2008-12-01 12:19 ` [PATCH 10/11] memcg: show inactive_ratio KOSAKI Motohiro
@ 2008-12-01 12:19 ` KOSAKI Motohiro
2008-12-01 17:11 ` Rik van Riel
2008-12-02 9:05 ` KAMEZAWA Hiroyuki
2008-12-02 4:25 ` [PATCH 00/11] memcg: split-lru feature for memcg take2 KAMEZAWA Hiroyuki
11 siblings, 2 replies; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-01 12:19 UTC (permalink / raw)
To: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki,
Rik van Riel
Cc: kosaki.motohiro
added following four field to memory.stat file.
- recent_rotated_anon
- recent_rotated_file
- recent_scanned_anon
- recent_scanned_file
it is useful for memcg reclaim debugging.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
mm/memcontrol.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
Index: b/mm/memcontrol.c
===================================================================
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1799,6 +1799,31 @@ static int mem_control_stat_show(struct
cb->fill(cb, "inactive_ratio", mem_cont->inactive_ratio);
+ {
+ int nid, zid;
+ struct mem_cgroup_per_zone *mz;
+ unsigned long recent_rotated[2] = {0, 0};
+ unsigned long recent_scanned[2] = {0, 0};
+
+ for_each_online_node(nid)
+ for (zid = 0; zid < MAX_NR_ZONES; zid++) {
+ mz = mem_cgroup_zoneinfo(mem_cont, nid, zid);
+
+ recent_rotated[0] +=
+ mz->reclaim_stat.recent_rotated[0];
+ recent_rotated[1] +=
+ mz->reclaim_stat.recent_rotated[1];
+ recent_scanned[0] +=
+ mz->reclaim_stat.recent_scanned[0];
+ recent_scanned[1] +=
+ mz->reclaim_stat.recent_scanned[1];
+ }
+ cb->fill(cb, "recent_rotated_anon", recent_rotated[0]);
+ cb->fill(cb, "recent_rotated_file", recent_rotated[1]);
+ cb->fill(cb, "recent_scanned_anon", recent_scanned[0]);
+ cb->fill(cb, "recent_scanned_file", recent_scanned[1]);
+ }
+
return 0;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 04/11] make get_scan_ratio() to memcg safe
2008-12-01 12:14 ` [PATCH 04/11] make get_scan_ratio() to memcg safe KOSAKI Motohiro
@ 2008-12-01 14:50 ` Rik van Riel
0 siblings, 0 replies; 29+ messages in thread
From: Rik van Riel @ 2008-12-01 14:50 UTC (permalink / raw)
To: KOSAKI Motohiro
Cc: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki
KOSAKI Motohiro wrote:
> Currently, get_scan_ratio() always calculate the balancing value for global reclaim and
> memcg reclaim doesn't use it.
> Therefore it doesn't have scan_global_lru() condition.
>
> However, we plan to expand get_scan_ratio() to be usable for memcg too, latter.
> Then, The dependency code of global reclaim in the get_scan_ratio() insert into
> scan_global_lru() condision explictly.
>
>
> this patch doesn't have any functional change.
>
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Good in principle, though of course this particular corner
case is not going to change when reclaiming a memcg :)
Acked-by: Rik van Riel <riel@redhat.com>
--
All rights reversed.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 05/11] memcg: add null check to page_cgroup_zoneinfo()
2008-12-01 12:14 ` [PATCH 05/11] memcg: add null check to page_cgroup_zoneinfo() KOSAKI Motohiro
@ 2008-12-01 14:52 ` Rik van Riel
0 siblings, 0 replies; 29+ messages in thread
From: Rik van Riel @ 2008-12-01 14:52 UTC (permalink / raw)
To: KOSAKI Motohiro
Cc: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki
KOSAKI Motohiro wrote:
> if CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y, page_cgroup::mem_cgroup can be NULL.
> Therefore null checking is better.
>
> latter patch use this function.
>
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Rik van Riel <riel@redhat.com>
--
All rights reversed.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 07/11] memcg: make mem_cgroup_zone_nr_pages()
2008-12-01 12:16 ` [PATCH 07/11] memcg: make mem_cgroup_zone_nr_pages() KOSAKI Motohiro
@ 2008-12-01 16:31 ` Rik van Riel
2008-12-03 13:58 ` Balbir Singh
1 sibling, 0 replies; 29+ messages in thread
From: Rik van Riel @ 2008-12-01 16:31 UTC (permalink / raw)
To: KOSAKI Motohiro
Cc: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki
KOSAKI Motohiro wrote:
> introduce mem_cgroup_zone_nr_pages().
> it is called by zone_nr_pages() helper function.
>
>
> this patch doesn't have any behavior change.
>
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Rik van Riel <riel@redhat.com>
--
All rights reversed.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 08/11] memcg: make zone_reclaim_stat
2008-12-01 12:17 ` [PATCH 08/11] memcg: make zone_reclaim_stat KOSAKI Motohiro
@ 2008-12-01 16:33 ` Rik van Riel
2008-12-03 14:06 ` Balbir Singh
1 sibling, 0 replies; 29+ messages in thread
From: Rik van Riel @ 2008-12-01 16:33 UTC (permalink / raw)
To: KOSAKI Motohiro
Cc: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki
KOSAKI Motohiro wrote:
> introduce mem_cgroup_per_zone::reclaim_stat member and its statics collecting
> function.
>
> Now, get_scan_ratio() can calculate correct value although memcg reclaim.
>
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Rik van Riel <riel@redhat.com>
--
All rights reversed.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 09/11] memcg: remove mem_cgroup_calc_reclaim()
2008-12-01 12:18 ` [PATCH 09/11] memcg: remove mem_cgroup_calc_reclaim() KOSAKI Motohiro
@ 2008-12-01 17:09 ` Rik van Riel
0 siblings, 0 replies; 29+ messages in thread
From: Rik van Riel @ 2008-12-01 17:09 UTC (permalink / raw)
To: KOSAKI Motohiro
Cc: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki
KOSAKI Motohiro wrote:
> Now, get_scan_ratio() return correct value although memcg reclaim.
> Then, mem_cgroup_calc_reclaim() can be removed.
>
> So, memcg reclaim get the same capability of anon/file reclaim balancing as global reclaim now.
>
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Rik van Riel <riel@redhat.com>
--
All rights reversed.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 10/11] memcg: show inactive_ratio
2008-12-01 12:19 ` [PATCH 10/11] memcg: show inactive_ratio KOSAKI Motohiro
@ 2008-12-01 17:10 ` Rik van Riel
2008-12-02 9:05 ` KAMEZAWA Hiroyuki
1 sibling, 0 replies; 29+ messages in thread
From: Rik van Riel @ 2008-12-01 17:10 UTC (permalink / raw)
To: KOSAKI Motohiro
Cc: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki
KOSAKI Motohiro wrote:
> add inactive_ratio field to memory.stat file.
> it is useful for memcg reclam debugging.
>
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Rik van Riel <riel@redhat.com>
--
All rights reversed.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 11/11] memcg: show reclaim_stat
2008-12-01 12:19 ` [PATCH 11/11] memcg: show reclaim_stat KOSAKI Motohiro
@ 2008-12-01 17:11 ` Rik van Riel
2008-12-02 9:05 ` KAMEZAWA Hiroyuki
1 sibling, 0 replies; 29+ messages in thread
From: Rik van Riel @ 2008-12-01 17:11 UTC (permalink / raw)
To: KOSAKI Motohiro
Cc: LKML, linux-mm, Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki
KOSAKI Motohiro wrote:
> added following four field to memory.stat file.
>
> - recent_rotated_anon
> - recent_rotated_file
> - recent_scanned_anon
> - recent_scanned_file
>
> it is useful for memcg reclaim debugging.
>
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Rik van Riel <riel@redhat.com>
--
All rights reversed.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 00/11] memcg: split-lru feature for memcg take2
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
` (10 preceding siblings ...)
2008-12-01 12:19 ` [PATCH 11/11] memcg: show reclaim_stat KOSAKI Motohiro
@ 2008-12-02 4:25 ` KAMEZAWA Hiroyuki
11 siblings, 0 replies; 29+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-12-02 4:25 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: LKML, linux-mm, Andrew Morton, Balbir Singh, Rik van Riel
On Mon, 1 Dec 2008 21:10:59 +0900 (JST)
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> Recently, SplitLRU patch series dramatically improvement VM reclaim
> logic.
>
> it have following improvement.
> (1) splite lru per page type
> (2) introduce inactive/active anon balancing logic
> (3) introduce anon/file balancing logic
>
> Unfortunately, the improvement of memcgroup reclaim is incomplete.
> Currently, it only has (1), but doesn't have (2) and (3).
>
>
> This patch introduce (2) and (3) improvements to memcgroup.
> this implementation is straightforward porting from global reclaim.
>
> Therefere
> - code is simple.
> - memcg reclaim become efficiency as global reclaim.
> - the logic is the same as global lru.
> then, memcg reclaim debugging become easily.
>
>
> this patch series has five part.
>
> [part 1: global lru clean up]
> [PATCH 01/11] inactive_anon_is_low() move to vmscan.c
> [PATCH 02/11] introduce zone_reclaim struct
> [PATCH 03/11] make zone_nr_pages() helper function
> [PATCH 04/11] make get_scan_ratio() to memcg safe
>
> [part 2: memcg: trivial fix]
> [PATCH 05/11] memcg: add null check to page_cgroup_zoneinfo()
>
> [part 3: memcg: inactive-anon vs active-anon balancing improvement]
> [PATCH 06/11] memcg: make inactive_anon_is_low()
>
> [part 4: anon vs file balancing improvement]
> [PATCH 07/11] memcg: make mem_cgroup_zone_nr_pages()
> [PATCH 08/11] memcg: make zone_reclaim_stat
> [PATCH 09/11] memcg: remove mem_cgroup_calc_reclaim()
>
> [part 5: add split-lru related statics field to /cgroup/memory.stat]
> [PATCH 10/11] memcg: show inactive_ratio
> [PATCH 11/11] memcg: show reclaim_stat
>
>
> patch against: mmotm 29 Nov 2008
>
> Andrew, could you please pick 01-04 up to -mm?
> 01-04 don't have any behavior change.
> kamezawwa-san queue 05-11 to his memcg queueue awhile.
>
Thanks, I'll try weekly update queue for memcg.
(includes 01-04 if necessary)
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 10/11] memcg: show inactive_ratio
2008-12-01 12:19 ` [PATCH 10/11] memcg: show inactive_ratio KOSAKI Motohiro
2008-12-01 17:10 ` Rik van Riel
@ 2008-12-02 9:05 ` KAMEZAWA Hiroyuki
1 sibling, 0 replies; 29+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-12-02 9:05 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: LKML, linux-mm, Andrew Morton, Balbir Singh, Rik van Riel
On Mon, 1 Dec 2008 21:19:08 +0900 (JST)
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> add inactive_ratio field to memory.stat file.
> it is useful for memcg reclam debugging.
>
Hmm...it seems no requirement for showing this in usual use.
I'll put this under CONFIG_DEBUG_VM.
Thanks,
-Kame
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> ---
> mm/memcontrol.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> Index: b/mm/memcontrol.c
> ===================================================================
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1796,6 +1796,9 @@ static int mem_control_stat_show(struct
> cb->fill(cb, "unevictable", unevictable * PAGE_SIZE);
>
> }
> +
> + cb->fill(cb, "inactive_ratio", mem_cont->inactive_ratio);
> +
> return 0;
> }
>
>
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 11/11] memcg: show reclaim_stat
2008-12-01 12:19 ` [PATCH 11/11] memcg: show reclaim_stat KOSAKI Motohiro
2008-12-01 17:11 ` Rik van Riel
@ 2008-12-02 9:05 ` KAMEZAWA Hiroyuki
2008-12-03 14:19 ` Balbir Singh
1 sibling, 1 reply; 29+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-12-02 9:05 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: LKML, linux-mm, Andrew Morton, Balbir Singh, Rik van Riel
On Mon, 1 Dec 2008 21:19:49 +0900 (JST)
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> added following four field to memory.stat file.
>
> - recent_rotated_anon
> - recent_rotated_file
> - recent_scanned_anon
> - recent_scanned_file
>
> it is useful for memcg reclaim debugging.
>
I'll put this under CONFIG_DEBUG_VM.
Thanks,
-Kame
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> ---
> mm/memcontrol.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> Index: b/mm/memcontrol.c
> ===================================================================
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1799,6 +1799,31 @@ static int mem_control_stat_show(struct
>
> cb->fill(cb, "inactive_ratio", mem_cont->inactive_ratio);
>
> + {
> + int nid, zid;
> + struct mem_cgroup_per_zone *mz;
> + unsigned long recent_rotated[2] = {0, 0};
> + unsigned long recent_scanned[2] = {0, 0};
> +
> + for_each_online_node(nid)
> + for (zid = 0; zid < MAX_NR_ZONES; zid++) {
> + mz = mem_cgroup_zoneinfo(mem_cont, nid, zid);
> +
> + recent_rotated[0] +=
> + mz->reclaim_stat.recent_rotated[0];
> + recent_rotated[1] +=
> + mz->reclaim_stat.recent_rotated[1];
> + recent_scanned[0] +=
> + mz->reclaim_stat.recent_scanned[0];
> + recent_scanned[1] +=
> + mz->reclaim_stat.recent_scanned[1];
> + }
> + cb->fill(cb, "recent_rotated_anon", recent_rotated[0]);
> + cb->fill(cb, "recent_rotated_file", recent_rotated[1]);
> + cb->fill(cb, "recent_scanned_anon", recent_scanned[0]);
> + cb->fill(cb, "recent_scanned_file", recent_scanned[1]);
> + }
> +
> return 0;
> }
>
>
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 06/11] memcg: make inactive_anon_is_low()
2008-12-01 12:15 ` [PATCH 06/11] memcg: make inactive_anon_is_low() KOSAKI Motohiro
@ 2008-12-03 13:52 ` Balbir Singh
2008-12-04 6:14 ` KOSAKI Motohiro
0 siblings, 1 reply; 29+ messages in thread
From: Balbir Singh @ 2008-12-03 13:52 UTC (permalink / raw)
To: KOSAKI Motohiro
Cc: LKML, linux-mm, Andrew Morton, KAMEZAWA Hiroyuki, Rik van Riel
* KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> [2008-12-01 21:15:46]:
> Changelog:
> v1 -> v2:
> - add detail patch description
> - fix coding style in mem_cgroup_set_inactive_ratio()
> - add comment to mem_cgroup_set_inactive_ratio
> - remove extra newline
> - memcg::inactiveratio change type to unsigned int
>
[snip]
> +/*
> + * The inactive anon list should be small enough that the VM never has to
> + * do too much work, but large enough that each inactive page has a chance
> + * to be referenced again before it is swapped out.
> + *
> + * this calculation is straightforward porting from
> + * page_alloc.c::setup_per_zone_inactive_ratio().
> + * it describe more detail.
> + */
> +static void mem_cgroup_set_inactive_ratio(struct mem_cgroup *memcg)
> +{
> + unsigned int gb, ratio;
> +
> + gb = res_counter_read_u64(&memcg->res, RES_LIMIT) >> 30;
> + if (gb)
> + ratio = int_sqrt(10 * gb);
I don't understand where the magic number 10 comes from?
> + else
> + ratio = 1;
> +
> + memcg->inactive_ratio = ratio;
> +
> +}
> +
> static DEFINE_MUTEX(set_limit_mutex);
>
> static int mem_cgroup_resize_limit(struct mem_cgroup *memcg,
> @@ -1384,6 +1424,10 @@ static int mem_cgroup_resize_limit(struc
> GFP_HIGHUSER_MOVABLE, false);
> if (!progress) retry_count--;
> }
> +
> + if (!ret)
> + mem_cgroup_set_inactive_ratio(memcg);
> +
> return ret;
> }
>
> @@ -1968,7 +2012,7 @@ mem_cgroup_create(struct cgroup_subsys *
> res_counter_init(&mem->res, NULL);
> res_counter_init(&mem->memsw, NULL);
> }
> -
> + mem_cgroup_set_inactive_ratio(mem);
> mem->last_scanned_child = NULL;
>
> return &mem->css;
> Index: b/mm/vmscan.c
> ===================================================================
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1369,14 +1369,7 @@ static void shrink_active_list(unsigned
> pagevec_release(&pvec);
> }
>
> -/**
> - * inactive_anon_is_low - check if anonymous pages need to be deactivated
> - * @zone: zone to check
> - *
> - * Returns true if the zone does not have enough inactive anon pages,
> - * meaning some active anon pages need to be deactivated.
> - */
> -static int inactive_anon_is_low(struct zone *zone)
> +static int inactive_anon_is_low_global(struct zone *zone)
> {
> unsigned long active, inactive;
>
> @@ -1389,6 +1382,25 @@ static int inactive_anon_is_low(struct z
> return 0;
> }
>
> +/**
> + * inactive_anon_is_low - check if anonymous pages need to be deactivated
> + * @zone: zone to check
> + * @sc: scan control of this context
> + *
> + * Returns true if the zone does not have enough inactive anon pages,
> + * meaning some active anon pages need to be deactivated.
> + */
> +static int inactive_anon_is_low(struct zone *zone, struct scan_control *sc)
> +{
> + int low;
> +
> + if (scan_global_lru(sc))
> + low = inactive_anon_is_low_global(zone);
> + else
> + low = mem_cgroup_inactive_anon_is_low(sc->mem_cgroup, zone);
> + return low;
> +}
> +
> static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,
> struct zone *zone, struct scan_control *sc, int priority)
> {
> @@ -1400,7 +1412,7 @@ static unsigned long shrink_list(enum lr
> }
>
> if (lru == LRU_ACTIVE_ANON &&
> - (!scan_global_lru(sc) || inactive_anon_is_low(zone))) {
> + inactive_anon_is_low(zone, sc)) {
Can't we merge the line with the "if" statement
> shrink_active_list(nr_to_scan, zone, sc, priority, file);
> return 0;
> }
> @@ -1565,9 +1577,7 @@ static void shrink_zone(int priority, st
> * Even if we did not try to evict anon pages at all, we want to
> * rebalance the anon lru active/inactive ratio.
> */
> - if (!scan_global_lru(sc) || inactive_anon_is_low(zone))
> - shrink_active_list(SWAP_CLUSTER_MAX, zone, sc, priority, 0);
> - else if (!scan_global_lru(sc))
> + if (inactive_anon_is_low(zone, sc))
> shrink_active_list(SWAP_CLUSTER_MAX, zone, sc, priority, 0);
>
> throttle_vm_writeout(sc->gfp_mask);
> @@ -1863,7 +1873,7 @@ loop_again:
> * Do some background aging of the anon list, to give
> * pages a chance to be referenced before reclaiming.
> */
> - if (inactive_anon_is_low(zone))
> + if (inactive_anon_is_low(zone, &sc))
> shrink_active_list(SWAP_CLUSTER_MAX, zone,
> &sc, priority, 0);
>
>
>
--
Balbir
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 07/11] memcg: make mem_cgroup_zone_nr_pages()
2008-12-01 12:16 ` [PATCH 07/11] memcg: make mem_cgroup_zone_nr_pages() KOSAKI Motohiro
2008-12-01 16:31 ` Rik van Riel
@ 2008-12-03 13:58 ` Balbir Singh
1 sibling, 0 replies; 29+ messages in thread
From: Balbir Singh @ 2008-12-03 13:58 UTC (permalink / raw)
To: KOSAKI Motohiro
Cc: LKML, linux-mm, Andrew Morton, KAMEZAWA Hiroyuki, Rik van Riel
* KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> [2008-12-01 21:16:48]:
> introduce mem_cgroup_zone_nr_pages().
> it is called by zone_nr_pages() helper function.
>
>
> this patch doesn't have any behavior change.
>
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> ---
> include/linux/memcontrol.h | 11 +++++++++++
> mm/memcontrol.c | 12 +++++++++++-
> mm/vmscan.c | 3 +++
> 3 files changed, 25 insertions(+), 1 deletion(-)
>
> Index: b/include/linux/memcontrol.h
> ===================================================================
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -92,6 +92,9 @@ extern long mem_cgroup_calc_reclaim(stru
> int priority, enum lru_list lru);
> int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg,
> struct zone *zone);
> +unsigned long mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg,
> + struct zone *zone,
> + enum lru_list lru);
>
> #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
> extern int do_swap_account;
> @@ -250,6 +253,14 @@ mem_cgroup_inactive_anon_is_low(struct m
> return 1;
> }
>
> +static inline unsigned long
> +mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg, struct zone *zone,
> + enum lru_list lru)
> +{
> + return 0;
> +}
> +
> +
> #endif /* CONFIG_CGROUP_MEM_CONT */
>
> #endif /* _LINUX_MEMCONTROL_H */
> Index: b/mm/memcontrol.c
> ===================================================================
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -186,7 +186,6 @@ pcg_default_flags[NR_CHARGE_TYPE] = {
> 0, /* FORCE */
> };
>
> -
> /* for encoding cft->private value on file */
> #define _MEM (0)
> #define _MEMSWAP (1)
> @@ -448,6 +447,17 @@ int mem_cgroup_inactive_anon_is_low(stru
> return 0;
> }
>
> +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 zid = zone_idx(zone);
> + struct mem_cgroup_per_zone *mz = mem_cgroup_zoneinfo(memcg, nid, zid);
> +
> + return MEM_CGROUP_ZSTAT(mz, lru);
> +}
> +
> unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
> struct list_head *dst,
> unsigned long *scanned, int order,
> Index: b/mm/vmscan.c
> ===================================================================
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -140,6 +140,9 @@ static struct zone_reclaim_stat *get_rec
> static unsigned long zone_nr_pages(struct zone *zone, struct scan_control *sc,
> enum lru_list lru)
> {
> + if (!scan_global_lru(sc))
> + return mem_cgroup_zone_nr_pages(sc->mem_cgroup, zone, lru);
> +
> return zone_page_state(zone, NR_LRU_BASE + lru);
> }
>
Seems reasonable
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
--
Balbir
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 08/11] memcg: make zone_reclaim_stat
2008-12-01 12:17 ` [PATCH 08/11] memcg: make zone_reclaim_stat KOSAKI Motohiro
2008-12-01 16:33 ` Rik van Riel
@ 2008-12-03 14:06 ` Balbir Singh
2008-12-04 7:15 ` KOSAKI Motohiro
1 sibling, 1 reply; 29+ messages in thread
From: Balbir Singh @ 2008-12-03 14:06 UTC (permalink / raw)
To: KOSAKI Motohiro
Cc: LKML, linux-mm, Andrew Morton, KAMEZAWA Hiroyuki, Rik van Riel
* KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> [2008-12-01 21:17:44]:
> introduce mem_cgroup_per_zone::reclaim_stat member and its statics collecting
> function.
>
> Now, get_scan_ratio() can calculate correct value although memcg reclaim.
>
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> ---
> include/linux/memcontrol.h | 16 ++++++++++++++++
> mm/memcontrol.c | 23 +++++++++++++++++++++++
> mm/swap.c | 14 ++++++++++++++
> mm/vmscan.c | 27 +++++++++++++--------------
> 4 files changed, 66 insertions(+), 14 deletions(-)
>
> Index: b/include/linux/memcontrol.h
> ===================================================================
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -95,6 +95,10 @@ int mem_cgroup_inactive_anon_is_low(stru
> unsigned long mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg,
> struct zone *zone,
> enum lru_list lru);
> +struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat(struct mem_cgroup *memcg,
> + struct zone *zone);
> +struct zone_reclaim_stat*
> +mem_cgroup_get_reclaim_stat_by_page(struct page *page);
>
> #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
> extern int do_swap_account;
> @@ -261,6 +265,18 @@ mem_cgroup_zone_nr_pages(struct mem_cgro
> }
>
>
> +static inline struct zone_reclaim_stat*
> +mem_cgroup_get_reclaim_stat(struct mem_cgroup *memcg, struct zone *zone)
> +{
> + return NULL;
> +}
> +
> +static inline struct zone_reclaim_stat*
> +mem_cgroup_get_reclaim_stat_by_page(struct page *page)
> +{
> + return NULL;
> +}
> +
> #endif /* CONFIG_CGROUP_MEM_CONT */
>
> #endif /* _LINUX_MEMCONTROL_H */
> Index: b/mm/memcontrol.c
> ===================================================================
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -103,6 +103,8 @@ struct mem_cgroup_per_zone {
> */
> struct list_head lists[NR_LRU_LISTS];
> unsigned long count[NR_LRU_LISTS];
> +
> + struct zone_reclaim_stat reclaim_stat;
> };
> /* Macro for accessing counter */
> #define MEM_CGROUP_ZSTAT(mz, idx) ((mz)->count[(idx)])
> @@ -458,6 +460,27 @@ unsigned long mem_cgroup_zone_nr_pages(s
> return MEM_CGROUP_ZSTAT(mz, lru);
> }
>
> +struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat(struct mem_cgroup *memcg,
> + struct zone *zone)
> +{
> + int nid = zone->zone_pgdat->node_id;
> + int zid = zone_idx(zone);
> + struct mem_cgroup_per_zone *mz = mem_cgroup_zoneinfo(memcg, nid, zid);
> +
> + return &mz->reclaim_stat;
> +}
> +
> +struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat_by_page(struct page *page)
> +{
I would prefer to use stat_from_page instead of stat_by_page, by page
is confusing.
> + struct page_cgroup *pc = lookup_page_cgroup(page);
> + struct mem_cgroup_per_zone *mz = page_cgroup_zoneinfo(pc);
> +
> + if (!mz)
> + return NULL;
> +
> + return &mz->reclaim_stat;
> +}
> +
> unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
> struct list_head *dst,
> unsigned long *scanned, int order,
> Index: b/mm/swap.c
> ===================================================================
> --- a/mm/swap.c
> +++ b/mm/swap.c
> @@ -158,6 +158,7 @@ void activate_page(struct page *page)
> {
> struct zone *zone = page_zone(page);
> struct zone_reclaim_stat *reclaim_stat = &zone->reclaim_stat;
> + struct zone_reclaim_stat *memcg_reclaim_stat;
>
> spin_lock_irq(&zone->lru_lock);
> if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) {
> @@ -172,6 +173,12 @@ void activate_page(struct page *page)
>
> reclaim_stat->recent_rotated[!!file]++;
> reclaim_stat->recent_scanned[!!file]++;
> +
> + memcg_reclaim_stat = mem_cgroup_get_reclaim_stat_by_page(page);
> + if (memcg_reclaim_stat) {
> + memcg_reclaim_stat->recent_rotated[!!file]++;
> + memcg_reclaim_stat->recent_scanned[!!file]++;
> + }
Does it make sense to write two inline routines like
update_recent_rotated(page)
{
zone = page_zone(page);
zone->reclaim_stat->recent_rotated[!!file]++;
mem_reclaim_stat = mem_cgroup_get_reclaim_stat_by_page(page);
if (mem_reclaim_stat)
mem_cg_reclaim_stat->recent_rotated[!!file]++;
...
}
and similarly update_recent_reclaimed(page)
> }
> spin_unlock_irq(&zone->lru_lock);
> }
> @@ -400,6 +407,7 @@ void ____pagevec_lru_add(struct pagevec
> int i;
> struct zone *zone = NULL;
> struct zone_reclaim_stat *reclaim_stat = NULL;
> + struct zone_reclaim_stat *memcg_reclaim_stat = NULL;
>
> VM_BUG_ON(is_unevictable_lru(lru));
>
> @@ -413,6 +421,8 @@ void ____pagevec_lru_add(struct pagevec
> spin_unlock_irq(&zone->lru_lock);
> zone = pagezone;
> reclaim_stat = &zone->reclaim_stat;
> + memcg_reclaim_stat =
> + mem_cgroup_get_reclaim_stat_by_page(page);
> spin_lock_irq(&zone->lru_lock);
> }
> VM_BUG_ON(PageActive(page));
> @@ -421,9 +431,13 @@ void ____pagevec_lru_add(struct pagevec
> SetPageLRU(page);
> file = is_file_lru(lru);
> reclaim_stat->recent_scanned[file]++;
> + if (memcg_reclaim_stat)
> + memcg_reclaim_stat->recent_scanned[file]++;
> if (is_active_lru(lru)) {
> SetPageActive(page);
> reclaim_stat->recent_rotated[file]++;
> + if (memcg_reclaim_stat)
> + memcg_reclaim_stat->recent_rotated[file]++;
> }
> add_page_to_lru_list(zone, page, lru);
> }
> Index: b/mm/vmscan.c
> ===================================================================
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -134,6 +134,9 @@ static DECLARE_RWSEM(shrinker_rwsem);
> static struct zone_reclaim_stat *get_reclaim_stat(struct zone *zone,
> struct scan_control *sc)
> {
> + if (!scan_global_lru(sc))
> + mem_cgroup_get_reclaim_stat(sc->mem_cgroup, zone);
What do we gain by just calling mem_cgroup_get_reclaim_stat? Where do
we return/use this value?
> +
> return &zone->reclaim_stat;
> }
>
> @@ -1141,17 +1144,14 @@ static unsigned long shrink_inactive_lis
> __mod_zone_page_state(zone, NR_INACTIVE_ANON,
> -count[LRU_INACTIVE_ANON]);
>
> - if (scan_global_lru(sc)) {
> + if (scan_global_lru(sc))
> zone->pages_scanned += nr_scan;
> - reclaim_stat->recent_scanned[0] +=
> - count[LRU_INACTIVE_ANON];
> - reclaim_stat->recent_scanned[0] +=
> - count[LRU_ACTIVE_ANON];
> - reclaim_stat->recent_scanned[1] +=
> - count[LRU_INACTIVE_FILE];
> - reclaim_stat->recent_scanned[1] +=
> - count[LRU_ACTIVE_FILE];
> - }
> +
> + reclaim_stat->recent_scanned[0] += count[LRU_INACTIVE_ANON];
> + reclaim_stat->recent_scanned[0] += count[LRU_ACTIVE_ANON];
> + reclaim_stat->recent_scanned[1] += count[LRU_INACTIVE_FILE];
> + reclaim_stat->recent_scanned[1] += count[LRU_ACTIVE_FILE];
> +
> spin_unlock_irq(&zone->lru_lock);
>
> nr_scanned += nr_scan;
> @@ -1209,7 +1209,7 @@ static unsigned long shrink_inactive_lis
> SetPageLRU(page);
> lru = page_lru(page);
> add_page_to_lru_list(zone, page, lru);
> - if (PageActive(page) && scan_global_lru(sc)) {
> + if (PageActive(page)) {
> int file = !!page_is_file_cache(page);
> reclaim_stat->recent_rotated[file]++;
> }
> @@ -1289,8 +1289,8 @@ static void shrink_active_list(unsigned
> */
> if (scan_global_lru(sc)) {
> zone->pages_scanned += pgscanned;
> - reclaim_stat->recent_scanned[!!file] += pgmoved;
> }
> + reclaim_stat->recent_scanned[!!file] += pgmoved;
>
> if (file)
> __mod_zone_page_state(zone, NR_ACTIVE_FILE, -pgmoved);
> @@ -1323,8 +1323,7 @@ static void shrink_active_list(unsigned
> * This helps balance scan pressure between file and anonymous
> * pages in get_scan_ratio.
> */
> - if (scan_global_lru(sc))
> - reclaim_stat->recent_rotated[!!file] += pgmoved;
> + reclaim_stat->recent_rotated[!!file] += pgmoved;
>
> /*
> * Move the pages to the [file or anon] inactive list.
>
>
--
Balbir
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 11/11] memcg: show reclaim_stat
2008-12-02 9:05 ` KAMEZAWA Hiroyuki
@ 2008-12-03 14:19 ` Balbir Singh
2008-12-03 16:15 ` KAMEZAWA Hiroyuki
0 siblings, 1 reply; 29+ messages in thread
From: Balbir Singh @ 2008-12-03 14:19 UTC (permalink / raw)
To: KAMEZAWA Hiroyuki
Cc: KOSAKI Motohiro, LKML, linux-mm, Andrew Morton, Rik van Riel
* KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> [2008-12-02 18:05:25]:
> On Mon, 1 Dec 2008 21:19:49 +0900 (JST)
> KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
>
> > added following four field to memory.stat file.
> >
> > - recent_rotated_anon
> > - recent_rotated_file
> > - recent_scanned_anon
> > - recent_scanned_file
> >
> > it is useful for memcg reclaim debugging.
> >
> I'll put this under CONFIG_DEBUG_VM.
>
I think they'll be useful even outside for tasks that need to take
decisions, it will be nice to see what sort of reclaim is going on. I
would like to see them outside, there is no cost associated with them
and assuming we'll not change the LRU logic very frequently, we don't
need to be afraid of breaking ABI either :)
> Thanks,
> -Kame
>
> >
> > Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> > ---
> > mm/memcontrol.c | 25 +++++++++++++++++++++++++
> > 1 file changed, 25 insertions(+)
> >
> > Index: b/mm/memcontrol.c
> > ===================================================================
> > --- a/mm/memcontrol.c
> > +++ b/mm/memcontrol.c
> > @@ -1799,6 +1799,31 @@ static int mem_control_stat_show(struct
> >
> > cb->fill(cb, "inactive_ratio", mem_cont->inactive_ratio);
> >
> > + {
> > + int nid, zid;
> > + struct mem_cgroup_per_zone *mz;
> > + unsigned long recent_rotated[2] = {0, 0};
> > + unsigned long recent_scanned[2] = {0, 0};
> > +
> > + for_each_online_node(nid)
> > + for (zid = 0; zid < MAX_NR_ZONES; zid++) {
> > + mz = mem_cgroup_zoneinfo(mem_cont, nid, zid);
> > +
> > + recent_rotated[0] +=
> > + mz->reclaim_stat.recent_rotated[0];
> > + recent_rotated[1] +=
> > + mz->reclaim_stat.recent_rotated[1];
> > + recent_scanned[0] +=
> > + mz->reclaim_stat.recent_scanned[0];
> > + recent_scanned[1] +=
> > + mz->reclaim_stat.recent_scanned[1];
> > + }
> > + cb->fill(cb, "recent_rotated_anon", recent_rotated[0]);
> > + cb->fill(cb, "recent_rotated_file", recent_rotated[1]);
> > + cb->fill(cb, "recent_scanned_anon", recent_scanned[0]);
> > + cb->fill(cb, "recent_scanned_file", recent_scanned[1]);
> > + }
> > +
> > return 0;
> > }
> >
> >
> >
> > --
> > To unsubscribe, send a message with 'unsubscribe linux-mm' in
> > the body to majordomo@kvack.org. For more info on Linux MM,
> > see: http://www.linux-mm.org/ .
> > Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
> >
>
--
Balbir
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 11/11] memcg: show reclaim_stat
2008-12-03 14:19 ` Balbir Singh
@ 2008-12-03 16:15 ` KAMEZAWA Hiroyuki
0 siblings, 0 replies; 29+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-12-03 16:15 UTC (permalink / raw)
To: balbir
Cc: KAMEZAWA Hiroyuki, KOSAKI Motohiro, LKML, linux-mm,
Andrew Morton, Rik van Riel
Balbir Singh said:
> * KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> [2008-12-02
> 18:05:25]:
>
>> On Mon, 1 Dec 2008 21:19:49 +0900 (JST)
>> KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
>>
>> > added following four field to memory.stat file.
>> >
>> > - recent_rotated_anon
>> > - recent_rotated_file
>> > - recent_scanned_anon
>> > - recent_scanned_file
>> >
>> > it is useful for memcg reclaim debugging.
>> >
>> I'll put this under CONFIG_DEBUG_VM.
>>
>
> I think they'll be useful even outside for tasks that need to take
> decisions, it will be nice to see what sort of reclaim is going on.
There are already pgin/pgout value.
> I
> would like to see them outside, there is no cost associated with them
> and assuming we'll not change the LRU logic very frequently, we don't
> need to be afraid of breaking ABI either :)
>
There are 2 reasons to put this under DEBUG
1. This is not exported as this value under /proc by global VM management.
2. Few people can explain what this really means. No documentation in
Docunemtation/ directory. I can't add precise explanation by myself.
As Kosaki wrote, this is for his debug, IMHO.
If you want to show this, please add above two first.
Thanks,
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 06/11] memcg: make inactive_anon_is_low()
2008-12-03 13:52 ` Balbir Singh
@ 2008-12-04 6:14 ` KOSAKI Motohiro
0 siblings, 0 replies; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-04 6:14 UTC (permalink / raw)
To: KOSAKI Motohiro, LKML, linux-mm, Andrew Morton,
KAMEZAWA Hiroyuki, Rik van Riel
> > +/*
> > + * The inactive anon list should be small enough that the VM never has to
> > + * do too much work, but large enough that each inactive page has a chance
> > + * to be referenced again before it is swapped out.
> > + *
> > + * this calculation is straightforward porting from
> > + * page_alloc.c::setup_per_zone_inactive_ratio().
> > + * it describe more detail.
> > + */
> > +static void mem_cgroup_set_inactive_ratio(struct mem_cgroup *memcg)
> > +{
> > + unsigned int gb, ratio;
> > +
> > + gb = res_counter_read_u64(&memcg->res, RES_LIMIT) >> 30;
> > + if (gb)
> > + ratio = int_sqrt(10 * gb);
>
> I don't understand where the magic number 10 comes from?
the function comment write to
this calculation is straightforward porting from
page_alloc.c::setup_per_zone_inactive_ratio().
it describe more detail.
> > @@ -1400,7 +1412,7 @@ static unsigned long shrink_list(enum lr
> > }
> >
> > if (lru == LRU_ACTIVE_ANON &&
> > - (!scan_global_lru(sc) || inactive_anon_is_low(zone))) {
> > + inactive_anon_is_low(zone, sc)) {
>
> Can't we merge the line with the "if" statement
Will fix.
thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 08/11] memcg: make zone_reclaim_stat
2008-12-03 14:06 ` Balbir Singh
@ 2008-12-04 7:15 ` KOSAKI Motohiro
0 siblings, 0 replies; 29+ messages in thread
From: KOSAKI Motohiro @ 2008-12-04 7:15 UTC (permalink / raw)
To: KOSAKI Motohiro, LKML, linux-mm, Andrew Morton,
KAMEZAWA Hiroyuki, Rik van Riel
> > +struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat(struct mem_cgroup *memcg,
> > + struct zone *zone)
> > +{
> > + int nid = zone->zone_pgdat->node_id;
> > + int zid = zone_idx(zone);
> > + struct mem_cgroup_per_zone *mz = mem_cgroup_zoneinfo(memcg, nid, zid);
> > +
> > + return &mz->reclaim_stat;
> > +}
> > +
> > +struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat_by_page(struct page *page)
> > +{
>
> I would prefer to use stat_from_page instead of stat_by_page, by page
> is confusing.
ok.
will fix.
> > @@ -172,6 +173,12 @@ void activate_page(struct page *page)
> >
> > reclaim_stat->recent_rotated[!!file]++;
> > reclaim_stat->recent_scanned[!!file]++;
> > +
> > + memcg_reclaim_stat = mem_cgroup_get_reclaim_stat_by_page(page);
> > + if (memcg_reclaim_stat) {
> > + memcg_reclaim_stat->recent_rotated[!!file]++;
> > + memcg_reclaim_stat->recent_scanned[!!file]++;
> > + }
>
> Does it make sense to write two inline routines like
>
> update_recent_rotated(page)
> {
> zone = page_zone(page);
>
> zone->reclaim_stat->recent_rotated[!!file]++;
> mem_reclaim_stat = mem_cgroup_get_reclaim_stat_by_page(page);
> if (mem_reclaim_stat)
> mem_cg_reclaim_stat->recent_rotated[!!file]++;
> ...
>
> }
>
> and similarly update_recent_reclaimed(page)
makes sense. good cleanup.
will fix.
> > Index: b/mm/vmscan.c
> > ===================================================================
> > --- a/mm/vmscan.c
> > +++ b/mm/vmscan.c
> > @@ -134,6 +134,9 @@ static DECLARE_RWSEM(shrinker_rwsem);
> > static struct zone_reclaim_stat *get_reclaim_stat(struct zone *zone,
> > struct scan_control *sc)
> > {
> > + if (!scan_global_lru(sc))
> > + mem_cgroup_get_reclaim_stat(sc->mem_cgroup, zone);
>
> What do we gain by just calling mem_cgroup_get_reclaim_stat? Where do
> we return/use this value?
Agghh.
My last cleanup is _not_ cleanup..
thanks! will fix.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2008-12-04 7:15 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
2008-12-01 12:11 ` [PATCH 01/11] inactive_anon_is_low() move to vmscan.c KOSAKI Motohiro
2008-12-01 12:12 ` [PATCH 02/11] introduce zone_reclaim struct KOSAKI Motohiro
2008-12-01 12:13 ` [PATCH 03/11] make zone_nr_pages() helper function KOSAKI Motohiro
2008-12-01 12:14 ` [PATCH 04/11] make get_scan_ratio() to memcg safe KOSAKI Motohiro
2008-12-01 14:50 ` Rik van Riel
2008-12-01 12:14 ` [PATCH 05/11] memcg: add null check to page_cgroup_zoneinfo() KOSAKI Motohiro
2008-12-01 14:52 ` Rik van Riel
2008-12-01 12:15 ` [PATCH 06/11] memcg: make inactive_anon_is_low() KOSAKI Motohiro
2008-12-03 13:52 ` Balbir Singh
2008-12-04 6:14 ` KOSAKI Motohiro
2008-12-01 12:16 ` [PATCH 07/11] memcg: make mem_cgroup_zone_nr_pages() KOSAKI Motohiro
2008-12-01 16:31 ` Rik van Riel
2008-12-03 13:58 ` Balbir Singh
2008-12-01 12:17 ` [PATCH 08/11] memcg: make zone_reclaim_stat KOSAKI Motohiro
2008-12-01 16:33 ` Rik van Riel
2008-12-03 14:06 ` Balbir Singh
2008-12-04 7:15 ` KOSAKI Motohiro
2008-12-01 12:18 ` [PATCH 09/11] memcg: remove mem_cgroup_calc_reclaim() KOSAKI Motohiro
2008-12-01 17:09 ` Rik van Riel
2008-12-01 12:19 ` [PATCH 10/11] memcg: show inactive_ratio KOSAKI Motohiro
2008-12-01 17:10 ` Rik van Riel
2008-12-02 9:05 ` KAMEZAWA Hiroyuki
2008-12-01 12:19 ` [PATCH 11/11] memcg: show reclaim_stat KOSAKI Motohiro
2008-12-01 17:11 ` Rik van Riel
2008-12-02 9:05 ` KAMEZAWA Hiroyuki
2008-12-03 14:19 ` Balbir Singh
2008-12-03 16:15 ` KAMEZAWA Hiroyuki
2008-12-02 4:25 ` [PATCH 00/11] memcg: split-lru feature for memcg take2 KAMEZAWA Hiroyuki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox