OpenVZ Forum - RDF feed
type: channel
items: [RFC][PATCH] memory controller per zone patches take 2 [0/10] introduction
items: [RFC][PATCH] memory controller per zone patches take 2 [1/10] add scan_global_lru() macro
items: [RFC][PATCH] memory controller per zone patches take 2 [2/10] add nid/zid function for page_cgroup
items: [RFC][PATCH] memory controller per zone patches take 2 [3/10] add per zone active/inactive counter t
items: [RFC][PATCH] memory controller per zone patches take 2 [4/10] calculate mapped ratio for memory cgro
items: [RFC][PATCH] memory controller per zone patches take 2 [5/10] calculate active/inactive balance for
items: [RFC][PATCH] memory controller per zone patches take 2 [6/10] remember reclaim priority for memory c
items: [RFC][PATCH] memory controller per zone patches take 2 [7/10] calculate reclaim scan number for memo
items: [RFC][PATCH] memory controller per zone patches take 2 [8/10] changes in vmscan.c
items: [RFC][PATCH] memory controller per zone patches take 2 [9/10] per-zone-lru for memory cgroup
items: [RFC][PATCH] memory controller per zone patches take 2 [10/10] per-zone-lock for memory cgroup
items: Re: [RFC][PATCH] memory controller per zone patches take 2 [1/10] add scan_global_lru() macro
items: Re: [RFC][PATCH] memory controller per zone patches take 2 [2/10] add nid/zid function for page_cgro
items: Re: [RFC][PATCH] memory controller per zone patches take 2 [3/10] add per zone active/inactive count
items: Re: [RFC][PATCH] memory controller per zone patches take 2 [4/10] calculate mapped ratio for memory
items: Re: [RFC][PATCH] memory controller per zone patches take 2 [8/10] changes in vmscan.c
items: Re: [RFC][PATCH] memory controller per zone patches take 2 [9/10] per-zone-lru for memory cgroup
items: Re: Re: [RFC][PATCH] memory controller per zone patches take 2 [4/10] calculate mapped ratio for mem

[RFC][PATCH] memory controller per zone patches take 2 [0/10] introduction
type: item
description: Hi, this is updated version of patch set implementing per-zone on memory cgroup. I still uses x86_64/fake NUMA (my ia64/NUMA box is under maintainance....) So, RFC again. (I'd like to do 3rd update in the next week.) Major Changes from previous one. - per-zone-lru_lock patch is added. - all per-zone objects of memory cgroup are treated in same way. - page migration is handled. - restructured and cleaned up. Todo: - do test on "real" NUMA. - merge YAMAMOTO-san's background page reclaim patch set on this. (If I can) - performance measurement at some point - more cleanup and adding meaningful comments - confirm added logic in vmscan.c is really sane. Overview: All per-zone obects are put into == struct mem_cgroup_per_zone { /* * spin_lock to protect the per cgroup LRU */ spinlock_t lru_lock; struct list_head active_list; struct list_head inactive_list; unsigned long count[NR_MEM_CGROUP_ZSTAT]; }; == And this per-zone area is accessed by following functions. == mem_cgroup_zoneinfo(struct mem_cgroup *mem, int nid, int zid) page_cgroup_zoneinfo(struct page_cgroup *pc) == Typical usage is following. == mz = page_cgroup_zoneinfo(pc); spin_lock_irqsave(&mz->lru_lock, flags); __mem_cgroup_add_list(pc); spin_unlock_irqrestore(&mz->lru_lock, flags); == Thanks, -Kame _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: KAMEZAWA Hiroyuki
date: 2007-11-16T10:11:07-00:00

[RFC][PATCH] memory controller per zone patches take 2 [1/10] add scan_global_lru() macro
type: item
description: add macro scan_global_lru(). This is used to detect which scan_control scans global lru or mem_cgroup lru. And compiled to be static value (1) when memory controller is not configured. (maybe good for compiler) Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> mm/vmscan.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) Index: linux-2.6.24-rc2-mm1/mm/vmscan.c =================================================================== --- linux-2.6.24-rc2-mm1.orig/mm/vmscan.c +++ linux-2.6.24-rc2-mm1/mm/vmscan.c @@ -127,6 +127,12 @@ long vm_total_pages; /* The total number static LIST_HEAD(shrinker_list); static DECLARE_RWSEM(shrinker_rwsem); +#ifdef CONFIG_CGROUP_MEM_CONT +#define scan_global_lru(sc) (!(sc)->mem_cgroup) +#else +#define scan_global_lru(sc) (1) +#endif + /* * Add a shrinker callback to be called from the vm */ @@ -1290,11 +1296,12 @@ static unsigned long do_try_to_free_page * Don't shrink slabs when reclaiming memory from * over limit cgroups */ - if (sc->mem_cgroup == NULL) + if (scan_global_lru(sc)) { shrink_slab(sc->nr_scanned, gfp_mask, lru_pages); - if (reclaim_state) { - nr_reclaimed += reclaim_state->reclaimed_slab; - reclaim_state->reclaimed_slab = 0; + if (reclaim_state) { + nr_reclaimed += reclaim_state->reclaimed_slab; + reclaim_state->reclaimed_slab = 0; + } } total_scanned += sc->nr_scanned; if (nr_reclaimed >= sc->swap_cluster_max) { @@ -1321,7 +1328,7 @@ static unsigned long do_try_to_free_page congestion_wait(WRITE, HZ/10); } /* top priority shrink_caches still had more to do? don't OOM, then */ - if (!sc->all_unreclaimable && sc->mem_cgroup == NULL) + if (!sc->all_unreclaimable && scan_global_lru(sc)) ret = 1; out: /* _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: KAMEZAWA Hiroyuki
date: 2007-11-16T10:14:45-00:00

[RFC][PATCH] memory controller per zone patches take 2 [2/10] add nid/zid function for page_cgroup
type: item
description: Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> mm/memcontrol.c | 10 ++++++++++ 1 file changed, 10 insertions(+) Index: linux-2.6.24-rc2-mm1/mm/memcontrol.c =================================================================== --- linux-2.6.24-rc2-mm1.orig/mm/memcontrol.c +++ linux-2.6.24-rc2-mm1/mm/memcontrol.c @@ -135,6 +135,16 @@ struct page_cgroup { #define PAGE_CGROUP_FLAG_CACHE (0x1) /* charged as cache */ #define PAGE_CGROUP_FLAG_ACTIVE (0x2) /* page is active in this cgroup */ +static inline int page_cgroup_nid(struct page_cgroup *pc) +{ + return page_to_nid(pc->page); +} + +static inline int page_cgroup_zid(struct page_cgroup *pc) +{ + return page_zonenum(pc->page); +} + enum { MEM_CGROUP_TYPE_UNSPEC = 0, MEM_CGROUP_TYPE_MAPPED, _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: KAMEZAWA Hiroyuki
date: 2007-11-16T10:15:45-00:00

[RFC][PATCH] memory controller per zone patches take 2 [3/10] add per zone active/inactive counter t
type: item
description: Counting active/inactive per-zone in memory controller. This patch adds per-zone status in memory cgroup. These values are often read (as per-zone value) by page reclaiming. In current design, per-zone stat is just a unsigned long value and not an atomic value because they are modified only under lru_lock. (for avoiding atomic_t ops.) This patch adds ACTIVE and INACTIVE per-zone status values. For handling per-zone status, this patch adds struct mem_cgroup_per_zone { ... } and some helper functions. This will be useful to add per-zone objects in mem_cgroup. This patch turns memory controller's early_init to be 0 for calling kmalloc(). Changelog V1 -> V2 - added mem_cgroup_per_zone struct. This will help following patches to implement per-zone objects and pack them into a struct. - added __mem_cgroup_add_list() and __mem_cgroup_remove_list() - fixed page migration handling. - renamed zstat to info (per-zone-info) This will be place for per-zone information(lru, lock, ..) - use page_cgroup_nid()/zid() funcs. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> mm/memcontrol.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 159 insertions(+), 7 deletions(-) Index: linux-2.6.24-rc2-mm1/mm/memcontrol.c =================================================================== --- linux-2.6.24-rc2-mm1.orig/mm/memcontrol.c +++ linux-2.6.24-rc2-mm1/mm/memcontrol.c @@ -78,6 +78,32 @@ static s64 mem_cgroup_read_stat(struct m } /* + * per-zone information in memory controller. + */ + +enum mem_cgroup_zstat_index { + MEM_CGROUP_ZSTAT_ACTIVE, + MEM_CGROUP_ZSTAT_INACTIVE, /* Active = Total - Inactive */ + + NR_MEM_CGROUP_ZSTAT, +}; + +struct mem_cgroup_per_zone { + unsigned long count[NR_MEM_CGROUP_ZSTAT]; +}; +/* Macro for accessing counter */ +#define MEM_CGROUP_ZSTAT(mz, idx) ((mz)->count[(idx)]) + +struct mem_cgroup_per_node { + struct mem_cgroup_per_zone zoneinfo[MAX_NR_ZONES]; +}; + +struct mem_cgroup_lru_info { + struct mem_cgroup_per_n…
creator: KAMEZAWA Hiroyuki
date: 2007-11-16T10:17:24-00:00

[RFC][PATCH] memory controller per zone patches take 2 [4/10] calculate mapped ratio for memory cgro
type: item
description: Define function for calculating mapped_ratio in memory cgroup. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> include/linux/memcontrol.h | 11 ++++++++++- mm/memcontrol.c | 13 +++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) Index: linux-2.6.24-rc2-mm1/mm/memcontrol.c =================================================================== --- linux-2.6.24-rc2-mm1.orig/mm/memcontrol.c +++ linux-2.6.24-rc2-mm1/mm/memcontrol.c @@ -423,6 +423,19 @@ void mem_cgroup_move_lists(struct page_c spin_unlock(&mem->lru_lock); } +/* + * Calculate mapped_ratio under memory controller. + */ +int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem) +{ + s64 total, rss; + + /* usage is recorded in bytes */ + total = mem->res.usage >> PAGE_SHIFT; + rss = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS); + return (rss * 100) / total; +} + unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, struct list_head *dst, unsigned long *scanned, int order, Index: linux-2.6.24-rc2-mm1/include/linux/memcontrol.h =================================================================== --- linux-2.6.24-rc2-mm1.orig/include/linux/memcontrol.h +++ linux-2.6.24-rc2-mm1/include/linux/memcontrol.h @@ -61,6 +61,12 @@ extern int mem_cgroup_prepare_migration( extern void mem_cgroup_end_migration(struct page *page); extern void mem_cgroup_page_migration(struct page *page, struct page *newpage); +/* + * For memory reclaim. + */ +extern int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem); + + #else /* CONFIG_CGROUP_MEM_CONT */ static inline void mm_init_cgroup(struct mm_struct *mm, struct task_struct *p) @@ -132,7 +138,10 @@ mem_cgroup_page_migration(struct page *p { } - +static inline int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem) +{ + return 0; +} #endif /* CONFIG_CGROUP_MEM_CONT */ #endif /* _LINUX_MEMCONTROL_H */ _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation…
creator: KAMEZAWA Hiroyuki
date: 2007-11-16T10:17:43-00:00

[RFC][PATCH] memory controller per zone patches take 2 [5/10] calculate active/inactive balance for
type: item
description: Define function for determining active/inactive balance in memory cgroup. * just use res.usage as total value and assumes total = active + inactive. * and yes, we can use mem_cgroup_get_all_zonestat(mem, MEM_CGROUP_ZSTAT_ACTIVE) Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> include/linux/memcontrol.h | 8 ++++++++ mm/memcontrol.c | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) Index: linux-2.6.24-rc2-mm1/mm/memcontrol.c =================================================================== --- linux-2.6.24-rc2-mm1.orig/mm/memcontrol.c +++ linux-2.6.24-rc2-mm1/mm/memcontrol.c @@ -435,6 +435,22 @@ int mem_cgroup_calc_mapped_ratio(struct rss = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS); return (rss * 100) / total; } +/* + * Uses mem_cgroup's imbalance instead of zone's lru imbalance. + * This will be used for determining whether page out routine try to free + * mapped pages or not. + */ +int mem_cgroup_reclaim_imbalance(struct mem_cgroup *mem) +{ + s64 total, active, inactive; + + /* usage is recorded in bytes */ + total = mem->res.usage >> PAGE_SHIFT; + inactive = mem_cgroup_get_all_zonestat(mem, MEM_CGROUP_ZSTAT_INACTIVE); + active = total - inactive; + + return active / (inactive + 1); +} unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, struct list_head *dst, Index: linux-2.6.24-rc2-mm1/include/linux/memcontrol.h =================================================================== --- linux-2.6.24-rc2-mm1.orig/include/linux/memcontrol.h +++ linux-2.6.24-rc2-mm1/include/linux/memcontrol.h @@ -65,6 +65,8 @@ extern void mem_cgroup_page_migration(st * For memory reclaim. */ extern int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem); +extern int mem_cgroup_reclaim_imbalance(struct mem_cgroup *mem); + #else /* CONFIG_CGROUP_MEM_CONT */ @@ -142,6 +144,12 @@ static inline int mem_cgroup_calc_mapped { return 0; } + +static inline int mem_cgroup_reclaim_imbalance(struct mem_cgroup *mem) +{ + return 0; +} + #endif /* CONFI…
creator: KAMEZAWA Hiroyuki
date: 2007-11-16T10:21:49-00:00

[RFC][PATCH] memory controller per zone patches take 2 [6/10] remember reclaim priority for memory c
type: item
description: Define function to remember reclaim priority (as zone->prev_priority) Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> include/linux/memcontrol.h | 23 +++++++++++++++++++++++ mm/memcontrol.c | 20 ++++++++++++++++++++ 2 files changed, 43 insertions(+) Index: linux-2.6.24-rc2-mm1/mm/memcontrol.c =================================================================== --- linux-2.6.24-rc2-mm1.orig/mm/memcontrol.c +++ linux-2.6.24-rc2-mm1/mm/memcontrol.c @@ -133,6 +133,7 @@ struct mem_cgroup { */ spinlock_t lru_lock; unsigned long control_type; /* control RSS or RSS+Pagecache */ + int prev_priority; /* for recording reclaim priority */ /* * statistics. */ @@ -452,6 +453,25 @@ int mem_cgroup_reclaim_imbalance(struct return active / (inactive + 1); } +/* + * prev_priority control...this will be used in memory reclaim path. + */ +int mem_cgroup_get_reclaim_priority(struct mem_cgroup *mem) +{ + return mem->prev_priority; +} + +void mem_cgroup_note_reclaim_priority(struct mem_cgroup *mem, int priority) +{ + if (priority < mem->prev_priority) + mem->prev_priority = priority; +} + +void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, int priority) +{ + mem->prev_priority = priority; +} + unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, struct list_head *dst, unsigned long *scanned, int order, Index: linux-2.6.24-rc2-mm1/include/linux/memcontrol.h =================================================================== --- linux-2.6.24-rc2-mm1.orig/include/linux/memcontrol.h +++ linux-2.6.24-rc2-mm1/include/linux/memcontrol.h @@ -67,6 +67,11 @@ extern void mem_cgroup_page_migration(st extern int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem); extern int mem_cgroup_reclaim_imbalance(struct mem_cgroup *mem); +extern int mem_cgroup_get_reclaim_priority(struct mem_cgroup *mem); +extern void mem_cgroup_note_reclaim_priority(struct mem_cgroup *mem, + int priority); +extern void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, + int pr…
creator: KAMEZAWA Hiroyuki
date: 2007-11-16T10:23:30-00:00

[RFC][PATCH] memory controller per zone patches take 2 [7/10] calculate reclaim scan number for memo
type: item
description: Define function for calculating the number of scan target on each Zone/LRU. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> include/linux/memcontrol.h | 15 +++++++++++++++ mm/memcontrol.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) Index: linux-2.6.24-rc2-mm1/include/linux/memcontrol.h =================================================================== --- linux-2.6.24-rc2-mm1.orig/include/linux/memcontrol.h +++ linux-2.6.24-rc2-mm1/include/linux/memcontrol.h @@ -73,6 +73,10 @@ extern void mem_cgroup_note_reclaim_prio extern void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, int priority); +extern long mem_cgroup_calc_reclaim_active(struct mem_cgroup *mem, + struct zone *zone, int priority); +extern long mem_cgroup_calc_reclaim_inactive(struct mem_cgroup *mem, + struct zone *zone, int priority); #else /* CONFIG_CGROUP_MEM_CONT */ static inline void mm_init_cgroup(struct mm_struct *mm, @@ -173,6 +177,17 @@ static inline void mem_cgroup_record_rec return 0; } +static inline long mem_cgroup_calc_reclaim_active(struct mem_cgroup *mem, + struct zone *zone, int priority) +{ + return 0; +} + +static inline long mem_cgroup_calc_reclaim_inactive(struct mem_cgroup *mem, + struct zone *zone, int priority) +{ + return 0; +} #endif /* CONFIG_CGROUP_MEM_CONT */ #endif /* _LINUX_MEMCONTROL_H */ Index: linux-2.6.24-rc2-mm1/mm/memcontrol.c =================================================================== --- linux-2.6.24-rc2-mm1.orig/mm/memcontrol.c +++ linux-2.6.24-rc2-mm1/mm/memcontrol.c @@ -472,6 +472,39 @@ 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_active(struct mem_cgroup *mem, + struct zone *zone, int priority) +{ + s64 nr_active; + int nid = zone->zone_pgda…
creator: KAMEZAWA Hiroyuki
date: 2007-11-16T10:24:02-00:00

[RFC][PATCH] memory controller per zone patches take 2 [8/10] changes in vmscan.c
type: item
description: When using memory controller, there are 2 levels of memory reclaim. 1. zone memory reclaim because of system/zone memory shortage. 2. memory cgroup memory reclaim because of hitting limit. These two can be distinguished by sc->mem_cgroup parameter. This patch tries to make memory cgroup reclaim routine avoid affecting system/zone memory reclaim. This patch inserts if (!sc->mem_cgroup) and hook to memory_cgroup reclaim support functions. This patch can be a help for isolating system lru activity and group lru activity and shows what additional functions are necessary. * mem_cgroup_calc_mapped_ratio() ... calculate mapped ratio for cgroup. * mem_cgroup_reclaim_imbalance() ... calculate active/inactive balance in cgroup. * mem_cgroup_calc_reclaim_active() ... calculate the number of active pages to be scanned in this priority in mem_cgroup. * mem_cgroup_calc_reclaim_inactive() ... calculate the number of inactive pages to be scanned in this priority in mem_cgroup. * mem_cgroup_all_unreclaimable() .. checks cgroup's page is all unreclaimable or not. * mem_cgroup_get_reclaim_priority() ... * mem_cgroup_note_reclaim_priority() ... record reclaim priority (temporal) * mem_cgroup_remember_reclaim_priority() .... record reclaim priority as zone->prev_priority. This value is used for calc reclaim_mapped. Changelog: - merged calc_reclaim_mapped patch in previous version. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> mm/vmscan.c | 326 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 197 insertions(+), 129 deletions(-) Index: linux-2.6.24-rc2-mm1/mm/vmscan.c =================================================================== --- linux-2.6.24-rc2-mm1.orig/mm/vmscan.c +++ linux-2.6.24-rc2-mm1/mm/vmscan.c @@ -863,7 +863,8 @@ static unsigned long shrink_inactive_lis __mod_zone_page_state(zone, NR_ACTIVE, -nr_active); __mod_zone_page_state(zone, NR_INACTIVE, -(nr_taken - nr_active)); - zone->pages_scanned += nr_scan; + if (scan_global_l…
creator: KAMEZAWA Hiroyuki
date: 2007-11-16T10:25:12-00:00

[RFC][PATCH] memory controller per zone patches take 2 [9/10] per-zone-lru for memory cgroup
type: item
description: This patch implements per-zone lru for memory cgroup. This patch makes use of mem_cgroup_per_zone struct for per zone lru. LRU can be accessed by mz = mem_cgroup_zoneinfo(mem_cgroup, node, zone); &mz->active_list &mz->inactive_list or mz = page_cgroup_zoneinfo(page_cgroup, node, zone); &mz->active_list &mz->inactive_list Changelog v1->v2 - merged to mem_cgroup_per_zone struct. - handle page migraiton. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> mm/memcontrol.c | 63 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 24 deletions(-) Index: linux-2.6.24-rc2-mm1/mm/memcontrol.c =================================================================== --- linux-2.6.24-rc2-mm1.orig/mm/memcontrol.c +++ linux-2.6.24-rc2-mm1/mm/memcontrol.c @@ -89,6 +89,8 @@ enum mem_cgroup_zstat_index { }; struct mem_cgroup_per_zone { + struct list_head active_list; + struct list_head inactive_list; unsigned long count[NR_MEM_CGROUP_ZSTAT]; }; /* Macro for accessing counter */ @@ -123,10 +125,7 @@ struct mem_cgroup { /* * Per cgroup active and inactive list, similar to the * per zone LRU lists. - * TODO: Consider making these lists per zone */ - struct list_head active_list; - struct list_head inactive_list; struct mem_cgroup_lru_info info; /* * spin_lock to protect the per cgroup LRU @@ -369,10 +368,10 @@ static void __mem_cgroup_add_list(struct if (!to) { MEM_CGROUP_ZSTAT(mz, MEM_CGROUP_ZSTAT_INACTIVE) += 1; - list_add(&pc->lru, &pc->mem_cgroup->inactive_list); + list_add(&pc->lru, &mz->inactive_list); } else { MEM_CGROUP_ZSTAT(mz, MEM_CGROUP_ZSTAT_ACTIVE) += 1; - list_add(&pc->lru, &pc->mem_cgroup->active_list); + list_add(&pc->lru, &mz->active_list); } mem_cgroup_charge_statistics(pc->mem_cgroup, pc->flags, true); } @@ -390,11 +389,11 @@ static void __mem_cgroup_move_lists(stru if (active) { MEM_CGROUP_ZSTAT(mz, MEM_CGROUP_ZSTAT_ACTIVE) += 1; pc->flags |= PAGE_CGROUP_FLAG_ACTIVE; - list_move(&pc->lru, &pc->mem_cgroup->active_list);…
creator: KAMEZAWA Hiroyuki
date: 2007-11-16T10:25:51-00:00

[RFC][PATCH] memory controller per zone patches take 2 [10/10] per-zone-lock for memory cgroup
type: item
description: Now, lru is per-zone. Then, lru_lock can be (should be) per-zone, too. This patch implementes per-zone lru lock. lru_lock is placed into mem_cgroup_per_zone struct. lock can be accessed by mz = mem_cgroup_zoneinfo(mem_cgroup, node, zone); &mz->lru_lock or mz = page_cgroup_zoneinfo(page_cgroup, node, zone); &mz->lru_lock Signed-off-by: KAMEZAWA hiroyuki <kmaezawa.hiroyu@jp.fujitsu.com> mm/memcontrol.c | 71 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 27 deletions(-) Index: linux-2.6.24-rc2-mm1/mm/memcontrol.c =================================================================== --- linux-2.6.24-rc2-mm1.orig/mm/memcontrol.c +++ linux-2.6.24-rc2-mm1/mm/memcontrol.c @@ -89,6 +89,10 @@ enum mem_cgroup_zstat_index { }; struct mem_cgroup_per_zone { + /* + * spin_lock to protect the per cgroup LRU + */ + spinlock_t lru_lock; struct list_head active_list; struct list_head inactive_list; unsigned long count[NR_MEM_CGROUP_ZSTAT]; @@ -127,10 +131,7 @@ struct mem_cgroup { * per zone LRU lists. */ struct mem_cgroup_lru_info info; - /* - * spin_lock to protect the per cgroup LRU - */ - spinlock_t lru_lock; + unsigned long control_type; /* control RSS or RSS+Pagecache */ int prev_priority; /* for recording reclaim priority */ /* @@ -412,15 +413,16 @@ int task_in_mem_cgroup(struct task_struc */ void mem_cgroup_move_lists(struct page_cgroup *pc, bool active) { - struct mem_cgroup *mem; + struct mem_cgroup_per_zone *mz; + unsigned long flags; + if (!pc) return; - mem = pc->mem_cgroup; - - spin_lock(&mem->lru_lock); + mz = page_cgroup_zoneinfo(pc); + spin_lock_irqsave(&mz->lru_lock, flags); __mem_cgroup_move_lists(pc, active); - spin_unlock(&mem->lru_lock); + spin_unlock_irqrestore(&mz->lru_lock, flags); } /* @@ -528,7 +530,7 @@ unsigned long mem_cgroup_isolate_pages(u src = &mz->inactive_list; - spin_lock(&mem_cont->lru_lock); + spin_lock(&mz->lru_lock); scan = 0; list_for_each_entry_safe_reverse(pc, tmp, src, lru) { if (scan >= nr_to_scan) …
creator: KAMEZAWA Hiroyuki
date: 2007-11-16T10:27:33-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [1/10] add scan_global_lru() macro
type: item
description: KAMEZAWA Hiroyuki wrote: > add macro scan_global_lru(). > > This is used to detect which scan_control scans global lru or > mem_cgroup lru. And compiled to be static value (1) when > memory controller is not configured. (maybe good for compiler) > > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Looks good to me Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> -- Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Balbir Singh
date: 2007-11-17T09:03:46-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [2/10] add nid/zid function for page_cgro
type: item
description: KAMEZAWA Hiroyuki wrote: > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > mm/memcontrol.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > Index: linux-2.6.24-rc2-mm1/mm/memcontrol.c > =================================================================== > --- linux-2.6.24-rc2-mm1.orig/mm/memcontrol.c > +++ linux-2.6.24-rc2-mm1/mm/memcontrol.c > @@ -135,6 +135,16 @@ struct page_cgroup { > #define PAGE_CGROUP_FLAG_CACHE (0x1) /* charged as cache */ > #define PAGE_CGROUP_FLAG_ACTIVE (0x2) /* page is active in this cgroup */ > > +static inline int page_cgroup_nid(struct page_cgroup *pc) > +{ > + return page_to_nid(pc->page); > +} > + > +static inline int page_cgroup_zid(struct page_cgroup *pc) > +{ > + return page_zonenum(pc->page); page_zonenum returns zone_type, isn't it better we carry the type through to the caller? > +} > + > enum { > MEM_CGROUP_TYPE_UNSPEC = 0, > MEM_CGROUP_TYPE_MAPPED, > -- Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Balbir Singh
date: 2007-11-17T09:15:45-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [3/10] add per zone active/inactive count
type: item
description: KAMEZAWA Hiroyuki wrote: > Counting active/inactive per-zone in memory controller. > > This patch adds per-zone status in memory cgroup. > These values are often read (as per-zone value) by page reclaiming. > > In current design, per-zone stat is just a unsigned long value and > not an atomic value because they are modified only under lru_lock. > (for avoiding atomic_t ops.) > > This patch adds ACTIVE and INACTIVE per-zone status values. > > For handling per-zone status, this patch adds > struct mem_cgroup_per_zone { > ... > } > and some helper functions. This will be useful to add per-zone objects > in mem_cgroup. > > This patch turns memory controller's early_init to be 0 for calling > kmalloc(). > > Changelog V1 -> V2 > - added mem_cgroup_per_zone struct. > This will help following patches to implement per-zone objects and > pack them into a struct. > - added __mem_cgroup_add_list() and __mem_cgroup_remove_list() > - fixed page migration handling. > - renamed zstat to info (per-zone-info) > This will be place for per-zone information(lru, lock, ..) > - use page_cgroup_nid()/zid() funcs. > > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> The code looks OK to me, pending test on a real NUMA box Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> -- Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Balbir Singh
date: 2007-11-17T16:07:17-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [4/10] calculate mapped ratio for memory
type: item
description: KAMEZAWA Hiroyuki wrote: > Define function for calculating mapped_ratio in memory cgroup. > Could you explain what the ratio is used for? Is it for reclaim later? > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > > include/linux/memcontrol.h | 11 ++++++++++- > mm/memcontrol.c | 13 +++++++++++++ > 2 files changed, 23 insertions(+), 1 deletion(-) > > Index: linux-2.6.24-rc2-mm1/mm/memcontrol.c > =================================================================== > --- linux-2.6.24-rc2-mm1.orig/mm/memcontrol.c > +++ linux-2.6.24-rc2-mm1/mm/memcontrol.c > @@ -423,6 +423,19 @@ void mem_cgroup_move_lists(struct page_c > spin_unlock(&mem->lru_lock); > } > > +/* > + * Calculate mapped_ratio under memory controller. > + */ > +int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem) > +{ > + s64 total, rss; > + > + /* usage is recorded in bytes */ > + total = mem->res.usage >> PAGE_SHIFT; > + rss = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS); > + return (rss * 100) / total; Never tried 64 bit division on a 32 bit system. I hope we don't have to resort to do_div() sort of functionality. > +} > + > unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, > struct list_head *dst, > unsigned long *scanned, int order, > Index: linux-2.6.24-rc2-mm1/include/linux/memcontrol.h > =================================================================== > --- linux-2.6.24-rc2-mm1.orig/include/linux/memcontrol.h > +++ linux-2.6.24-rc2-mm1/include/linux/memcontrol.h > @@ -61,6 +61,12 @@ extern int mem_cgroup_prepare_migration( > extern void mem_cgroup_end_migration(struct page *page); > extern void mem_cgroup_page_migration(struct page *page, struct page *newpage); > > +/* > + * For memory reclaim. > + */ > +extern int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem); > + > + > #else /* CONFIG_CGROUP_MEM_CONT */ > static inline void mm_init_cgroup(struct mm_struct *mm, > struct task_struct *p) > @@ -132,7 +138,10 @@ mem_cgroup_page_migration(struct pag…
creator: Balbir Singh
date: 2007-11-17T16:12:06-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [8/10] changes in vmscan.c
type: item
description: KAMEZAWA Hiroyuki wrote: > When using memory controller, there are 2 levels of memory reclaim. > 1. zone memory reclaim because of system/zone memory shortage. > 2. memory cgroup memory reclaim because of hitting limit. > > These two can be distinguished by sc->mem_cgroup parameter. > > This patch tries to make memory cgroup reclaim routine avoid affecting > system/zone memory reclaim. This patch inserts if (!sc->mem_cgroup) and > hook to memory_cgroup reclaim support functions. > > This patch can be a help for isolating system lru activity and group lru > activity and shows what additional functions are necessary. > > * mem_cgroup_calc_mapped_ratio() ... calculate mapped ratio for cgroup. > * mem_cgroup_reclaim_imbalance() ... calculate active/inactive balance in > cgroup. > * mem_cgroup_calc_reclaim_active() ... calculate the number of active pages to > be scanned in this priority in mem_cgroup. > > * mem_cgroup_calc_reclaim_inactive() ... calculate the number of inactive pages > to be scanned in this priority in mem_cgroup. > > * mem_cgroup_all_unreclaimable() .. checks cgroup's page is all unreclaimable > or not. > * mem_cgroup_get_reclaim_priority() ... > * mem_cgroup_note_reclaim_priority() ... record reclaim priority (temporal) > * mem_cgroup_remember_reclaim_priority() > .... record reclaim priority as > zone->prev_priority. > This value is used for calc reclaim_mapped. > Changelog: > - merged calc_reclaim_mapped patch in previous version. > > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> The overall idea looks good, it brings the two reclaims closer. The one pending to do for memory controllers is to make the reclaim lumpy reclaim aware. But at this point, I don't see a need for it, since we track only order 1 allocations in the memory controller. -- Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux…
creator: Balbir Singh
date: 2007-11-17T17:37:46-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [9/10] per-zone-lru for memory cgroup
type: item
description: KAMEZAWA Hiroyuki wrote: > This patch implements per-zone lru for memory cgroup. > This patch makes use of mem_cgroup_per_zone struct for per zone lru. > > LRU can be accessed by > > mz = mem_cgroup_zoneinfo(mem_cgroup, node, zone); > &mz->active_list > &mz->inactive_list > > or > mz = page_cgroup_zoneinfo(page_cgroup, node, zone); > &mz->active_list > &mz->inactive_list > > > Changelog v1->v2 > - merged to mem_cgroup_per_zone struct. > - handle page migraiton. > > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > Thanks, this has been a long pending TODO. What is pending now on my plate is re-organizing res_counter to become aware of the filesystem hierarchy. I want to split out the LRU lists from the memory controller and resource counters. -- Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Balbir Singh
date: 2007-11-17T17:51:22-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [2/10] add nid/zid function for page_cgro
type: item
description: On Sat, 17 Nov 2007 14:45:45 +0530 Balbir Singh <balbir@linux.vnet.ibm.com> wrote: > KAMEZAWA Hiroyuki wrote: > > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > > mm/memcontrol.c | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > Index: linux-2.6.24-rc2-mm1/mm/memcontrol.c > > =================================================================== > > --- linux-2.6.24-rc2-mm1.orig/mm/memcontrol.c > > +++ linux-2.6.24-rc2-mm1/mm/memcontrol.c > > @@ -135,6 +135,16 @@ struct page_cgroup { > > #define PAGE_CGROUP_FLAG_CACHE (0x1) /* charged as cache */ > > #define PAGE_CGROUP_FLAG_ACTIVE (0x2) /* page is active in this cgroup */ > > > > +static inline int page_cgroup_nid(struct page_cgroup *pc) > > +{ > > + return page_to_nid(pc->page); > > +} > > + > > +static inline int page_cgroup_zid(struct page_cgroup *pc) > > +{ > > + return page_zonenum(pc->page); > > page_zonenum returns zone_type, isn't it better we carry the > type through to the caller? > seems resonable. ok. I will fix. -Kame _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: KAMEZAWA Hiroyuki
date: 2007-11-19T01:37:20-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [4/10] calculate mapped ratio for memory
type: item
description: On Sat, 17 Nov 2007 21:42:06 +0530 Balbir Singh <balbir@linux.vnet.ibm.com> wrote: > KAMEZAWA Hiroyuki wrote: > > Define function for calculating mapped_ratio in memory cgroup. > > > > Could you explain what the ratio is used for? Is it for reclaim > later? > Yes, for later. > > + /* usage is recorded in bytes */ > > + total = mem->res.usage >> PAGE_SHIFT; > > + rss = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS); > > + return (rss * 100) / total; > > Never tried 64 bit division on a 32 bit system. I hope we don't > have to resort to do_div() sort of functionality. > Hmm, maybe it's better to make these numebrs be just "long". I'll try to change per-cpu-counter implementation. Thanks, -Kame _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: KAMEZAWA Hiroyuki
date: 2007-11-19T01:41:44-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [9/10] per-zone-lru for memory cgroup
type: item
description: On Sat, 17 Nov 2007 23:21:22 +0530 Balbir Singh <balbir@linux.vnet.ibm.com> wrote: > Thanks, this has been a long pending TODO. What is pending now on my > plate is re-organizing res_counter to become aware of the filesystem > hierarchy. I want to split out the LRU lists from the memory controller > and resource counters. > Does "file system hierarchy" here means "control group hierarchy" ? like = /cgroup/group_A/group_A_1 . /group_A_2 /group_A_3 (LRU(s) will be used for maintaining parent/child groups.) Thanks, -Kame _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: KAMEZAWA Hiroyuki
date: 2007-11-19T01:47:09-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [9/10] per-zone-lru for memory cgroup
type: item
description: KAMEZAWA Hiroyuki wrote: > On Sat, 17 Nov 2007 23:21:22 +0530 > Balbir Singh <balbir@linux.vnet.ibm.com> wrote: > >> Thanks, this has been a long pending TODO. What is pending now on my >> plate is re-organizing res_counter to become aware of the filesystem >> hierarchy. I want to split out the LRU lists from the memory controller >> and resource counters. >> > Does "file system hierarchy" here means "control group hierarchy" ? > like Yes, you are right > = > /cgroup/group_A/group_A_1 > . /group_A_2 > /group_A_3 > (LRU(s) will be used for maintaining parent/child groups.) > The LRU's will be shared, my vision is LRU ^ ^ | | Mem-----+ +----Mem That two or more mem_cgroup's can refer to the same LRU list and have their own resource counters. This setup will be used in the case of a hierarchy, so that a child can share memory with its parent and have it's own limit. The mem_cgroup will basically then only contain a reference to the LRU list. -- Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Balbir Singh
date: 2007-11-19T06:21:15-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [9/10] per-zone-lru for memory cgroup
type: item
description: On Mon, 19 Nov 2007 11:51:15 +0530 Balbir Singh <balbir@linux.vnet.ibm.com> wrote: > > = > > /cgroup/group_A/group_A_1 > > . /group_A_2 > > /group_A_3 > > (LRU(s) will be used for maintaining parent/child groups.) > > > > The LRU's will be shared, my vision is > > LRU > ^ ^ > | | > Mem-----+ +----Mem > > > That two or more mem_cgroup's can refer to the same LRU list and have > their own resource counters. This setup will be used in the case > of a hierarchy, so that a child can share memory with its parent > and have it's own limit. > > The mem_cgroup will basically then only contain a reference > to the LRU list. > Hmm, interesting. Then, group_A_1's usage + group_A_2's usage + group_A_3's usgae < group_A's limit. group_A_1, group_A_2, group_A_3 has its own limit. In plan. I wonder if we want rich control functions, we need "share" or "priority" among childs. (but maybe this will be complicated one.) Thank you for explanation. Regards, -Kame _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: KAMEZAWA Hiroyuki
date: 2007-11-19T06:35:49-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [9/10] per-zone-lru for memory cgroup
type: item
description: KAMEZAWA Hiroyuki wrote: > On Mon, 19 Nov 2007 11:51:15 +0530 > Balbir Singh <balbir@linux.vnet.ibm.com> wrote: >>> = >>> /cgroup/group_A/group_A_1 >>> . /group_A_2 >>> /group_A_3 >>> (LRU(s) will be used for maintaining parent/child groups.) >>> >> The LRU's will be shared, my vision is >> >> LRU >> ^ ^ >> | | >> Mem-----+ +----Mem >> >> >> That two or more mem_cgroup's can refer to the same LRU list and have >> their own resource counters. This setup will be used in the case >> of a hierarchy, so that a child can share memory with its parent >> and have it's own limit. >> >> The mem_cgroup will basically then only contain a reference >> to the LRU list. >> > Hmm, interesting. > > Then, > group_A_1's usage + group_A_2's usage + group_A_3's usgae < group_A's limit. > group_A_1, group_A_2, group_A_3 has its own limit. Yes that is correct > In plan. > > I wonder if we want rich control functions, we need "share" or "priority" among > childs. (but maybe this will be complicated one.) > That would nice and the end goal of providing this feature. We also need to provide soft-limits (more complex) and guarantees (with the kernel memory controller coming in - nice to have, but not necessary for now) > Thank you for explanation. > > Regards, > -Kame > Thanks for helping out the memory controller. -- Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Balbir Singh
date: 2007-11-19T08:34:23-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [4/10] calculate mapped ratio for memory
type: item
description: > > > + /* usage is recorded in bytes */ > > > + total = mem->res.usage >> PAGE_SHIFT; > > > + rss = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS); > > > + return (rss * 100) / total; > > > > Never tried 64 bit division on a 32 bit system. I hope we don't > > have to resort to do_div() sort of functionality. > > > Hmm, maybe it's better to make these numebrs be just "long". > I'll try to change per-cpu-counter implementation. > > Thanks, > -Kame besides that, i think 'total' can be zero here. YAMAMOTO Takashi _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: yamamoto
date: 2007-11-22T08:34:20-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [4/10] calculate mapped ratio for memory
type: item
description: On Thu, 22 Nov 2007 17:34:20 +0900 (JST) yamamoto@valinux.co.jp (YAMAMOTO Takashi) wrote: > > > > + /* usage is recorded in bytes */ > > > > + total = mem->res.usage >> PAGE_SHIFT; > > > > + rss = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS); > > > > + return (rss * 100) / total; > > > > > > Never tried 64 bit division on a 32 bit system. I hope we don't > > > have to resort to do_div() sort of functionality. > > > > > Hmm, maybe it's better to make these numebrs be just "long". > > I'll try to change per-cpu-counter implementation. > > > > Thanks, > > -Kame > > besides that, i think 'total' can be zero here. > Ah, This is what I do now. == +/* + * Calculate mapped_ratio under memory controller. This will be used in + * vmscan.c for deteremining we have to reclaim mapped pages. + */ +int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem) +{ + long total, rss; + + /* + * usage is recorded in bytes. But, here, we assume the number of + * physical pages can be represented by "long" on any arch. + */ + total = (long) (mem->res.usage >> PAGE_SHIFT); + rss = (long)mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS); + return (int)((rss * 100L) / total); +} == maybe works well. -Kame _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: KAMEZAWA Hiroyuki
date: 2007-11-22T08:40:15-00:00

Re: [RFC][PATCH] memory controller per zone patches take 2 [4/10] calculate mapped ratio for memory
type: item
description: > On Thu, 22 Nov 2007 17:34:20 +0900 (JST) > yamamoto@valinux.co.jp (YAMAMOTO Takashi) wrote: > > > > > > + /* usage is recorded in bytes */ > > > > > + total = mem->res.usage >> PAGE_SHIFT; > > > > > + rss = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS); > > > > > + return (rss * 100) / total; > > > > > > > > Never tried 64 bit division on a 32 bit system. I hope we don't > > > > have to resort to do_div() sort of functionality. > > > > > > > Hmm, maybe it's better to make these numebrs be just "long". > > > I'll try to change per-cpu-counter implementation. > > > > > > Thanks, > > > -Kame > > > > besides that, i think 'total' can be zero here. > > > Ah, This is what I do now. > == > +/* > + * Calculate mapped_ratio under memory controller. This will be used in > + * vmscan.c for deteremining we have to reclaim mapped pages. > + */ > +int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem) > +{ > + long total, rss; > + > + /* > + * usage is recorded in bytes. But, here, we assume the number of > + * physical pages can be represented by "long" on any arch. > + */ > + total = (long) (mem->res.usage >> PAGE_SHIFT); > + rss = (long)mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS); > + return (int)((rss * 100L) / total); > +} > == > > maybe works well. > > -Kame i meant that "/ total" can cause a division-by-zero exception. YAMAMOTO Takashi _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: yamamoto
date: 2007-11-22T08:46:47-00:00

Re: Re: [RFC][PATCH] memory controller per zone patches take 2 [4/10] calculate mapped ratio for mem
type: item
description: >> Ah, This is what I do now. >> == >> +/* >> + * Calculate mapped_ratio under memory controller. This will be used in >> + * vmscan.c for deteremining we have to reclaim mapped pages. >> + */ >> +int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem) >> +{ >> + long total, rss; >> + >> + /* >> + * usage is recorded in bytes. But, here, we assume the number of >> + * physical pages can be represented by "long" on any arch. >> + */ >> + total = (long) (mem->res.usage >> PAGE_SHIFT); >> + rss = (long)mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS); >> + return (int)((rss * 100L) / total); >> +} >> == >> >> maybe works well. >> >> -Kame > >i meant that "/ total" can cause a division-by-zero exception. > ouch, ok, will fix. -Kame _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: KAMEZAWA Hiroyuki
date: 2007-11-22T13:31:10-00:00