OpenVZ Forum - RDF feed
type: channel
items: [PATCH -mm 0/5] swapcgroup (v3)
items: [PATCH -mm 1/5] swapcgroup (v3): add cgroup files
items: [PATCH -mm 2/5] swapcgroup (v3): add a member to swap_info_struct
items: [PATCH -mm 3/5] swapcgroup (v3): implement charge and uncharge
items: [PATCH -mm 4/5] swapcgroup (v3): modify vm_swap_full()
items: [PATCH -mm 5/5] swapcgroup (v3): implement force_empty
items: Re: [PATCH -mm 5/5] swapcgroup (v3): implement force_empty
items: Re: [PATCH -mm 0/5] swapcgroup (v3)
items: Re: [PATCH -mm 4/5] swapcgroup (v3): modify vm_swap_full()
items: Re: [PATCH -mm 1/5] swapcgroup (v3): add cgroup files

[PATCH -mm 0/5] swapcgroup (v3)
type: item
description: Hi. This is new version of swapcgroup. Major changes from previous version - Rebased on 2.6.26-rc5-mm3. The new -mm has been released, but these patches can be applied on 2.6.26-rc8-mm1 too with only some offset warnings. I tested these patches on 2.6.26-rc5-mm3 with some fixes about memory, and it seems to work fine. - (NEW) Implemented force_empty. Currently, it simply uncharges all the charges from the group. Patches - [1/5] add cgroup files - [2/5] add a member to swap_info_struct - [3/5] implement charge and uncharge - [4/5] modify vm_swap_full() - [5/5] implement force_empty ToDo(in my thought. Feel free to add some others here.) - need some documentation Add to memory.txt? or create a new documentation file? - add option to disable only this feature I'm wondering if this option is needed. memcg has already the boot option to disable it. Is there any case where memory should be accounted but swap should not? - hierarchy support - move charges along with task Both of them need more discussion. Thanks, Daisuke Nishimura. _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Daisuke Nishimura
date: 2008-07-04T06:15:36-00:00

[PATCH -mm 1/5] swapcgroup (v3): add cgroup files
type: item
description: Even if limiting memory usage by memory cgroup, swap space is shared, so resource isolation is not enough. If one group uses up most of the swap space, it can affect other groups anyway. The purpose of swapcgroup is limiting swap usage per group as memory cgroup limits the RSS memory usage. It's now implemented as a add-on to memory cgroup. This patch adds cgroup files(and a member to struct mem_cgroup) for swapcgroup. Files to be added by this patch are: - memory.swap_usage_in_bytes - memory.swap_max_usage_in_bytes - memory.swap_limit_in_bytes - memory.swap_failcnt The meaning of those files are the same as memory cgroup. Change log v2->v3 - Rebased on 2.6.26-rc5-mm3. v1->v2 - Rebased on 2.6.26-rc2-mm1. - Implemented as a add-on to memory cgroup. Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> --- init/Kconfig | 7 +++++ mm/memcontrol.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 0 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index 847931a..c604b6d 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -418,6 +418,13 @@ config CGROUP_MEMRLIMIT_CTLR memory RSS and Page Cache control. Virtual address space control is provided by this controller. +config CGROUP_SWAP_RES_CTLR + bool "Swap Resource Controller for Control Groups" + depends on CGROUP_MEM_RES_CTLR && SWAP + help + Provides a swap resource controller that manages and limits swap usage. + Implemented as a add-on to Memory Resource Controller. + config SYSFS_DEPRECATED bool diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b8fe33c..ddc842b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -133,6 +133,12 @@ struct mem_cgroup { * statistics. */ struct mem_cgroup_stat stat; +#ifdef CONFIG_CGROUP_SWAP_RES_CTLR + /* + * the counter to account for swap usage + */ + struct res_counter swap_res; +#endif }; static struct mem_cgroup init_mem_cgroup; @@ -953,6 +959,39 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft, re…
creator: Daisuke Nishimura
date: 2008-07-04T06:17:47-00:00

[PATCH -mm 2/5] swapcgroup (v3): add a member to swap_info_struct
type: item
description: This patch add a member to swap_info_struct for cgroup. This member, array of pointers to mem_cgroup, is used to remember to which cgroup each swap entries are charged. The memory for this array of pointers is allocated on swapon, and freed on swapoff. Change log v2->v3 - Rebased on 2.6.26-rc5-mm3 - add helper functions and removed #ifdef from sys_swapon()/sys_swapoff(). - add check on mem_cgroup_subsys.disabled v1->v2 - Rebased on 2.6.26-rc2-mm1 - Implemented as a add-on to memory cgroup. Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> --- include/linux/memcontrol.h | 20 +++++++++++++++++++- include/linux/swap.h | 3 +++ mm/memcontrol.c | 36 ++++++++++++++++++++++++++++++++++++ mm/swapfile.c | 11 +++++++++++ 4 files changed, 69 insertions(+), 1 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index ee1b2fc..b6ff509 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -24,6 +24,7 @@ struct mem_cgroup; struct page_cgroup; struct page; struct mm_struct; +struct swap_info_struct; #ifdef CONFIG_CGROUP_MEM_RES_CTLR @@ -165,5 +166,22 @@ static inline long mem_cgroup_calc_reclaim(struct mem_cgroup *mem, } #endif /* CONFIG_CGROUP_MEM_CONT */ -#endif /* _LINUX_MEMCONTROL_H */ +#ifdef CONFIG_CGROUP_SWAP_RES_CTLR +extern struct mem_cgroup **swap_info_clear_memcg(struct swap_info_struct *p); +extern int swap_info_alloc_memcg(struct swap_info_struct *p, + unsigned long maxpages); +#else +static inline +struct mem_cgroup **swap_info_clear_memcg(struct swap_info_struct *p) +{ + return NULL; +} +static inline +int swap_info_alloc_memcg(struct swap_info_struct *p, unsigned long maxpages) +{ + return 0; +} +#endif + +#endif /* _LINUX_MEMCONTROL_H */ diff --git a/include/linux/swap.h b/include/linux/swap.h index a3af95b..6e1b03d 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -142,6 +142,9 @@ struct swap_info_struct { struct swap_extent *curr_swap_extent; unsigned old_block_size; unsigned short * swa…
creator: Daisuke Nishimura
date: 2008-07-04T06:18:51-00:00

[PATCH -mm 3/5] swapcgroup (v3): implement charge and uncharge
type: item
description: This patch implements charge and uncharge of swapcgroup. - what will be charged ? charge the number of swap entries in bytes. - when to charge/uncharge ? charge at get_swap_entry(), and uncharge at swap_entry_free(). - to what group charge the swap entry ? To determine to what mem_cgroup the swap entry should be charged, I changed the argument of get_swap_entry() from (void) to (struct page *). As a result, get_swap_entry() can determine to what mem_cgroup it should charge the swap entry by referring to page->page_cgroup->mem_cgroup. - from what group uncharge the swap entry ? I added in previous patch to swap_info_struct a member 'struct swap_cgroup **', array of pointer to which swap_cgroup the swap entry is charged. Change log v2->v3 - Rebased on 2.6.26-rc5-mm3 - make swap_cgroup_charge() fail when !pc. - add check on mem_cgroup_subsys.disabled v1->v2 - Rebased on 2.6.26-rc2-mm1 - Implemented as a add-on to memory cgroup. Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> --- include/linux/memcontrol.h | 17 ++++++++++++++ include/linux/swap.h | 4 +- mm/memcontrol.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ mm/shmem.c | 2 +- mm/swap_state.c | 2 +- mm/swapfile.c | 13 ++++++++++- 6 files changed, 86 insertions(+), 5 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index b6ff509..f3c84f7 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -170,6 +170,11 @@ static inline long mem_cgroup_calc_reclaim(struct mem_cgroup *mem, extern struct mem_cgroup **swap_info_clear_memcg(struct swap_info_struct *p); extern int swap_info_alloc_memcg(struct swap_info_struct *p, unsigned long maxpages); +extern int swap_cgroup_charge(struct page *page, + struct swap_info_struct *si, + unsigned long offset); +extern void swap_cgroup_uncharge(struct swap_info_struct *si, + unsigned long offset); #else static inline struct mem_cgroup **swap_info_clear_memcg(struct swap_info_struct *p) @@ -182,6 +187,18 @@ int swap_…
creator: Daisuke Nishimura
date: 2008-07-04T06:20:14-00:00

[PATCH -mm 4/5] swapcgroup (v3): modify vm_swap_full()
type: item
description: This patch modifies vm_swap_full() to calculate the rate of swap usage per cgroup. The purpose of this change is to free freeable swap caches (that is, swap entries) per cgroup, so that swap_cgroup_charge() fails less frequently. I tested whether this patch can reduce the swap usage or not, by running qsbench (8 x 40M) 10 times in mem:128M/swap:256M group and mem:256M/swap:128M group. And I confirmed that this patch can keep swap usage to (half of the limit < usage < the limit), whereas without this patch, swap usage tends to keep near to the limit. Change log v2->v3 - Rebased on 2.6.26-rc5-mm3 - take into account global swap usage. - change arg of vm_swap_full from page to memcg. - add check on mem_cgroup_subsys.disabled v1->v2 - new patch Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> --- include/linux/memcontrol.h | 12 ++++++++++++ include/linux/swap.h | 4 +++- mm/memcontrol.c | 18 ++++++++++++++++++ mm/memory.c | 4 +++- mm/swapfile.c | 38 +++++++++++++++++++++++++++++++++++++- mm/vmscan.c | 6 +++--- 6 files changed, 76 insertions(+), 6 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index f3c84f7..1e6eb0c 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -175,6 +175,8 @@ extern int swap_cgroup_charge(struct page *page, unsigned long offset); extern void swap_cgroup_uncharge(struct swap_info_struct *si, unsigned long offset); +extern struct mem_cgroup *page_to_memcg(struct page *page); +extern int swap_cgroup_vm_swap_full(struct mem_cgroup *memcg); #else static inline struct mem_cgroup **swap_info_clear_memcg(struct swap_info_struct *p) @@ -199,6 +201,16 @@ static inline void swap_cgroup_uncharge(struct swap_info_struct *si, unsigned long offset) { } + +static inline struct mem_cgroup *page_to_memcg(struct page *page) +{ + return NULL; +} + +static inline int swap_cgroup_vm_swap_full(struct mem_cgroup *memcg) +{ + return 0; +} #endif #endif /* _LINUX_MEMCONTROL_H */ diff --git a/include/l…
creator: Daisuke Nishimura
date: 2008-07-04T06:22:44-00:00

[PATCH -mm 5/5] swapcgroup (v3): implement force_empty
type: item
description: This patch implements force_empty of swapcgroup. Currently, it simply uncharges all the charges from the group. I think there can be other implementations. What I thought are: - move all the charges to its parent. - unuse(swap in) all the swap charged to the group. But in any case, I think before implementing this way, hierarchy and move charges support are needed. So I think this is enough for the first step. Change log v2->v3 - new patch Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> --- include/linux/memcontrol.h | 5 ++++ mm/memcontrol.c | 47 +++++++++++++++++++++++++++++++-------- mm/swapfile.c | 52 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 91 insertions(+), 13 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 1e6eb0c..8c4bad0 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -177,6 +177,7 @@ extern void swap_cgroup_uncharge(struct swap_info_struct *si, unsigned long offset); extern struct mem_cgroup *page_to_memcg(struct page *page); extern int swap_cgroup_vm_swap_full(struct mem_cgroup *memcg); +extern void __swap_cgroup_force_empty(struct mem_cgroup *mem); #else static inline struct mem_cgroup **swap_info_clear_memcg(struct swap_info_struct *p) @@ -211,6 +212,10 @@ static inline int swap_cgroup_vm_swap_full(struct mem_cgroup *memcg) { return 0; } + +static inline void __swap_cgroup_force_empty(struct mem_cgroup *mem) +{ +} #endif #endif /* _LINUX_MEMCONTROL_H */ diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 160fca1..f93907c 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -826,6 +826,34 @@ static void mem_cgroup_force_empty_list(struct mem_cgroup *mem, spin_unlock_irqrestore(&mz->lru_lock, flags); } +static inline int mem_cgroup_in_use(struct mem_cgroup *mem) +{ + return mem->res.usage > 0; +} + +static inline int swap_cgroup_in_use(struct mem_cgroup *mem) +{ +#ifdef CONFIG_CGROUP_SWAP_RES_CTLR + return mem->swap_res.usage > 0; +#else + return 0; +#e…
creator: Daisuke Nishimura
date: 2008-07-04T06:24:23-00:00

Re: [PATCH -mm 5/5] swapcgroup (v3): implement force_empty
type: item
description: hi, > +/* > + * uncharge all the entries that are charged to the group. > + */ > +void __swap_cgroup_force_empty(struct mem_cgroup *mem) > +{ > + struct swap_info_struct *p; > + int type; > + > + spin_lock(&swap_lock); > + for (type = swap_list.head; type >= 0; type = swap_info[type].next) { > + p = swap_info + type; > + > + if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) { > + unsigned int i = 0; > + > + spin_unlock(&swap_lock); what prevents the device from being swapoff'ed while you drop swap_lock? YAMAMOTO Takashi > + while ((i = find_next_to_unuse(p, i, mem)) != 0) { > + spin_lock(&swap_lock); > + if (p->swap_map[i] && p->memcg[i] == mem) > + swap_cgroup_uncharge(p, i); > + spin_unlock(&swap_lock); > + } > + spin_lock(&swap_lock); > + } > + } > + spin_unlock(&swap_lock); > + > + return; > +} > #endif _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: yamamoto
date: 2008-07-04T06:54:31-00:00

Re: [PATCH -mm 5/5] swapcgroup (v3): implement force_empty
type: item
description: Hi, Yamamoto-san. Thank you for your comment. On Fri, 4 Jul 2008 15:54:31 +0900 (JST), yamamoto@valinux.co.jp (YAMAMOTO Takashi) wrote: > hi, > > > +/* > > + * uncharge all the entries that are charged to the group. > > + */ > > +void __swap_cgroup_force_empty(struct mem_cgroup *mem) > > +{ > > + struct swap_info_struct *p; > > + int type; > > + > > + spin_lock(&swap_lock); > > + for (type = swap_list.head; type >= 0; type = swap_info[type].next) { > > + p = swap_info + type; > > + > > + if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) { > > + unsigned int i = 0; > > + > > + spin_unlock(&swap_lock); > > what prevents the device from being swapoff'ed while you drop swap_lock? > Nothing. After searching the entry to be uncharged(find_next_to_unuse below), I recheck under swap_lock whether the entry is charged to the group. Even if the device is swapoff'ed, swap_off must have uncharged the entry, so I don't think it's needed anyway. > YAMAMOTO Takashi > > > + while ((i = find_next_to_unuse(p, i, mem)) != 0) { > > + spin_lock(&swap_lock); > > + if (p->swap_map[i] && p->memcg[i] == mem) Ah, I think it should be added !p->swap_map to check the device has not been swapoff'ed. Thanks, Daisuke Nishimura. > > + swap_cgroup_uncharge(p, i); > > + spin_unlock(&swap_lock); > > + } > > + spin_lock(&swap_lock); > > + } > > + } > > + spin_unlock(&swap_lock); > > + > > + return; > > +} > > #endif _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Daisuke Nishimura
date: 2008-07-04T07:26:29-00:00

Re: [PATCH -mm 5/5] swapcgroup (v3): implement force_empty
type: item
description: > Hi, Yamamoto-san. > > Thank you for your comment. > > On Fri, 4 Jul 2008 15:54:31 +0900 (JST), yamamoto@valinux.co.jp (YAMAMOTO Takashi) wrote: > > hi, > > > > > +/* > > > + * uncharge all the entries that are charged to the group. > > > + */ > > > +void __swap_cgroup_force_empty(struct mem_cgroup *mem) > > > +{ > > > + struct swap_info_struct *p; > > > + int type; > > > + > > > + spin_lock(&swap_lock); > > > + for (type = swap_list.head; type >= 0; type = swap_info[type].next) { > > > + p = swap_info + type; > > > + > > > + if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) { > > > + unsigned int i = 0; > > > + > > > + spin_unlock(&swap_lock); > > > > what prevents the device from being swapoff'ed while you drop swap_lock? > > > Nothing. > > After searching the entry to be uncharged(find_next_to_unuse below), > I recheck under swap_lock whether the entry is charged to the group. > Even if the device is swapoff'ed, swap_off must have uncharged the entry, > so I don't think it's needed anyway. > > > YAMAMOTO Takashi > > > > > + while ((i = find_next_to_unuse(p, i, mem)) != 0) { > > > + spin_lock(&swap_lock); > > > + if (p->swap_map[i] && p->memcg[i] == mem) > Ah, I think it should be added !p->swap_map to check the device has not > been swapoff'ed. find_next_to_unuse seems to have fragile assumptions and can dereference p->swap_map as well. YAMAMOTO Takashi > > > Thanks, > Daisuke Nishimura. > > > > + swap_cgroup_uncharge(p, i); > > > + spin_unlock(&swap_lock); > > > + } > > > + spin_lock(&swap_lock); > > > + } > > > + } > > > + spin_unlock(&swap_lock); > > > + > > > + return; > > > +} > > > #endif _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: yamamoto
date: 2008-07-04T07:48:28-00:00

Re: [PATCH -mm 5/5] swapcgroup (v3): implement force_empty
type: item
description: On Fri, 4 Jul 2008 16:48:28 +0900 (JST), yamamoto@valinux.co.jp (YAMAMOTO Takashi) wrote: > > Hi, Yamamoto-san. > > > > Thank you for your comment. > > > > On Fri, 4 Jul 2008 15:54:31 +0900 (JST), yamamoto@valinux.co.jp (YAMAMOTO Takashi) wrote: > > > hi, > > > > > > > +/* > > > > + * uncharge all the entries that are charged to the group. > > > > + */ > > > > +void __swap_cgroup_force_empty(struct mem_cgroup *mem) > > > > +{ > > > > + struct swap_info_struct *p; > > > > + int type; > > > > + > > > > + spin_lock(&swap_lock); > > > > + for (type = swap_list.head; type >= 0; type = swap_info[type].next) { > > > > + p = swap_info + type; > > > > + > > > > + if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) { > > > > + unsigned int i = 0; > > > > + > > > > + spin_unlock(&swap_lock); > > > > > > what prevents the device from being swapoff'ed while you drop swap_lock? > > > > > Nothing. > > > > After searching the entry to be uncharged(find_next_to_unuse below), > > I recheck under swap_lock whether the entry is charged to the group. > > Even if the device is swapoff'ed, swap_off must have uncharged the entry, > > so I don't think it's needed anyway. > > > > > YAMAMOTO Takashi > > > > > > > + while ((i = find_next_to_unuse(p, i, mem)) != 0) { > > > > + spin_lock(&swap_lock); > > > > + if (p->swap_map[i] && p->memcg[i] == mem) > > Ah, I think it should be added !p->swap_map to check the device has not > > been swapoff'ed. > > find_next_to_unuse seems to have fragile assumptions and > can dereference p->swap_map as well. > You're right. Thank you for pointing it out! I'll consider more. Thanks, Daisuke Nishimura. _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Daisuke Nishimura
date: 2008-07-04T07:56:05-00:00

Re: [PATCH -mm 0/5] swapcgroup (v3)
type: item
description: On Fri, 4 Jul 2008 15:15:36 +0900 Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote: > Hi. > > This is new version of swapcgroup. > > Major changes from previous version > - Rebased on 2.6.26-rc5-mm3. > The new -mm has been released, but these patches > can be applied on 2.6.26-rc8-mm1 too with only some offset warnings. > I tested these patches on 2.6.26-rc5-mm3 with some fixes about memory, > and it seems to work fine. > - (NEW) Implemented force_empty. > Currently, it simply uncharges all the charges from the group. > > Patches > - [1/5] add cgroup files > - [2/5] add a member to swap_info_struct > - [3/5] implement charge and uncharge > - [4/5] modify vm_swap_full() > - [5/5] implement force_empty > > ToDo(in my thought. Feel free to add some others here.) > - need some documentation > Add to memory.txt? or create a new documentation file? > Maybe new documentation file is better. > - add option to disable only this feature > I'm wondering if this option is needed. > memcg has already the boot option to disable it. > Is there any case where memory should be accounted but swap should not? On x86-32, area for vmalloc() is very small and array of swap_info_struct[] will use much amount of it. If vmalloc() area is too small, the kernel cannot load modules. Thanks, -Kame > - hierarchy support > - move charges along with task > Both of them need more discussion. > > > Thanks, > Daisuke Nishimura. > _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: KAMEZAWA Hiroyuki
date: 2008-07-04T09:38:25-00:00

Re: [PATCH -mm 4/5] swapcgroup (v3): modify vm_swap_full()
type: item
description: On Fri, 4 Jul 2008 15:22:44 +0900 Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote: > /* Swap 50% full? Release swapcache more aggressively.. */ > -#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages) > +#define vm_swap_full(memcg) ((nr_swap_pages*2 < total_swap_pages) \ > + || swap_cgroup_vm_swap_full(memcg)) > + > Maybe nitpick but I like == vm_swap_full(page) ((nr_swap_pages *2 < total_swap_pages) || swap_cgroup_vm_swap_full_page(page)) == rather than vm_swap_full(memcg) And could you change this to inline funcition ? > /* linux/mm/page_alloc.c */ > extern unsigned long totalram_pages; > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index d16d0a5..160fca1 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -1296,5 +1296,23 @@ void swap_cgroup_uncharge(struct swap_info_struct *si, > css_put(&mem->css); > } > } > + > +int swap_cgroup_vm_swap_full(struct mem_cgroup *memcg) > +{ > + u64 usage; > + u64 limit; > + > + if (memcg) > + css_get(&memcg->css); > + else > + return 0; > + > + usage = res_counter_read_u64(&memcg->swap_res, RES_USAGE); > + limit = res_counter_read_u64(&memcg->swap_res, RES_LIMIT); > + > + css_put(&memcg->css); > + > + return usage * 2 > limit; > +} > #endif > How about this under above my changes ? == int memcg_swap_full(struct mem_cgroup *mem) { if (!mem) return 0; usage = res_counter_read_u64(&memcg->swap_res, RES_USAGE); limit = res_counter_read_u64(&memcg->swap_res, RES_LIMIT); return (usage *2 > limit); } int swap_cgroup_vm_swap_full_page(struct page *page) { struct page_cgroup *pc; int ret = 0; if (mem_cgroup_subsys.disabled) return 0; if (!PageSwapCache(page)) return 0; entry.val = page_private(page); p = swap_info_get(entry); if (!p) goto out; mem = p->memcg[swp_offset(entry)]; /* becasue we get swap_lock here, access to memcg is safe.*/ ret = memcg_swap_full(mem); spin_unlock(&swap_lock); out: return ret; } == Thanks, -Kame > diff --git a/mm/memory.c b/mm/memory.c > index 536d748..afcf737 100644 > --- a/mm/memory.…
creator: KAMEZAWA Hiroyuki
date: 2008-07-04T09:58:45-00:00

Re: [PATCH -mm 5/5] swapcgroup (v3): implement force_empty
type: item
description: On Fri, 4 Jul 2008 15:24:23 +0900 Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote: > This patch implements force_empty of swapcgroup. > > Currently, it simply uncharges all the charges from the group. > > I think there can be other implementations. > > What I thought are: > - move all the charges to its parent. > - unuse(swap in) all the swap charged to the group. > 3. move all swap back to memory (see swapoff.) > But in any case, I think before implementing this way, > hierarchy and move charges support are needed. > > So I think this is enough for the first step. > I don't think hierarchy/automatic-load-balancer for swap cg is necessary. Hmm...but handling limit_change (at least, returns -EBUSY) will be necessary. Do you consider a some magical way to move pages in swap back to memory ? In general, I like this set but we can't change the limit on demand. (maybe) (just putting it to TO-DO-List is okay to me.) Thanks, -Kame > > Change log > v2->v3 > - new patch > > > Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> > > --- > include/linux/memcontrol.h | 5 ++++ > mm/memcontrol.c | 47 +++++++++++++++++++++++++++++++-------- > mm/swapfile.c | 52 +++++++++++++++++++++++++++++++++++++++++-- > 3 files changed, 91 insertions(+), 13 deletions(-) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index 1e6eb0c..8c4bad0 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -177,6 +177,7 @@ extern void swap_cgroup_uncharge(struct swap_info_struct *si, > unsigned long offset); > extern struct mem_cgroup *page_to_memcg(struct page *page); > extern int swap_cgroup_vm_swap_full(struct mem_cgroup *memcg); > +extern void __swap_cgroup_force_empty(struct mem_cgroup *mem); > #else > static inline > struct mem_cgroup **swap_info_clear_memcg(struct swap_info_struct *p) > @@ -211,6 +212,10 @@ static inline int swap_cgroup_vm_swap_full(struct mem_cgroup *memcg) > { > return 0; > } > + > +static inline void __swap_cgro…
creator: KAMEZAWA Hiroyuki
date: 2008-07-04T10:15:11-00:00

Re: [PATCH -mm 4/5] swapcgroup (v3): modify vm_swap_full()
type: item
description: Hi, Kamezawa-san. On Fri, 4 Jul 2008 18:58:45 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote: > On Fri, 4 Jul 2008 15:22:44 +0900 > Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote: > > > /* Swap 50% full? Release swapcache more aggressively.. */ > > -#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages) > > +#define vm_swap_full(memcg) ((nr_swap_pages*2 < total_swap_pages) \ > > + || swap_cgroup_vm_swap_full(memcg)) > > + > > > Maybe nitpick but I like > == > vm_swap_full(page) ((nr_swap_pages *2 < total_swap_pages) > || swap_cgroup_vm_swap_full_page(page)) > == > rather than vm_swap_full(memcg) > Well, I used "page" in v2, but Kosaki-san said vm_swap_full() is not page-granularity operation so it should be changed. And more, > > @@ -1317,7 +1317,7 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone, > > __mod_zone_page_state(zone, NR_LRU_BASE + lru, pgmoved); > > pgmoved = 0; > > spin_unlock_irq(&zone->lru_lock); > > - if (vm_swap_full()) > > + if (vm_swap_full(sc->mem_cgroup)) > > pagevec_swap_free(&pvec); > > __pagevec_release(&pvec); > > spin_lock_irq(&zone->lru_lock); > > @@ -1328,7 +1328,7 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone, > > __count_zone_vm_events(PGREFILL, zone, pgscanned); > > __count_vm_events(PGDEACTIVATE, pgdeactivate); > > spin_unlock_irq(&zone->lru_lock); > > - if (vm_swap_full()) > > + if (vm_swap_full(sc->mem_cgroup)) > > pagevec_swap_free(&pvec); > > > > pagevec_release(&pvec); "page" cannot be determined in those places. I don't want to change pagevec_swap_free(), so I changed the argument of vm_swap_full(). > And could you change this to inline funcition ? > Of course. I think it would be better. Thanks, Daisuke Nishimura. _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Daisuke Nishimura
date: 2008-07-04T10:40:59-00:00

Re: [PATCH -mm 0/5] swapcgroup (v3)
type: item
description: On Fri, 4 Jul 2008 18:40:33 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote: > On Fri, 4 Jul 2008 15:15:36 +0900 > Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote: > > > Hi. > > > > This is new version of swapcgroup. > > > > Major changes from previous version > > - Rebased on 2.6.26-rc5-mm3. > > The new -mm has been released, but these patches > > can be applied on 2.6.26-rc8-mm1 too with only some offset warnings. > > I tested these patches on 2.6.26-rc5-mm3 with some fixes about memory, > > and it seems to work fine. > > - (NEW) Implemented force_empty. > > Currently, it simply uncharges all the charges from the group. > > > > Patches > > - [1/5] add cgroup files > > - [2/5] add a member to swap_info_struct > > - [3/5] implement charge and uncharge > > - [4/5] modify vm_swap_full() > > - [5/5] implement force_empty > > > > ToDo(in my thought. Feel free to add some others here.) > > - need some documentation > > Add to memory.txt? or create a new documentation file? > > > Maybe new documentation file is better. > O.K. > > - add option to disable only this feature > > I'm wondering if this option is needed. > > memcg has already the boot option to disable it. > > Is there any case where memory should be accounted but swap should not? > > On x86-32, area for vmalloc() is very small and array of swap_info_struct[] > will use much amount of it. If vmalloc() area is too small, the kernel cannot > load modules. > It would be critical. I'll add an option. Thanks, Daisuke Nishimura. _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Daisuke Nishimura
date: 2008-07-04T10:58:36-00:00

Re: [PATCH -mm 5/5] swapcgroup (v3): implement force_empty
type: item
description: On Fri, 4 Jul 2008 19:16:38 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote: > On Fri, 4 Jul 2008 15:24:23 +0900 > Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote: > > > This patch implements force_empty of swapcgroup. > > > > Currently, it simply uncharges all the charges from the group. > > > > I think there can be other implementations. > > > > What I thought are: > > - move all the charges to its parent. > > - unuse(swap in) all the swap charged to the group. > > > 3. move all swap back to memory (see swapoff.) > > Do you mean swapping in all the swap including used by other groups? It would be one choice anyway. > > But in any case, I think before implementing this way, > > hierarchy and move charges support are needed. > > > > So I think this is enough for the first step. > > > > I don't think hierarchy/automatic-load-balancer for swap cg is necessary. It's the problem of how the "hierarchy" would be, I think. I'm saying "hierarchy" here just to mean "some kind of feature where a parent includes their children". I think "hierarchy" is needed if we implement the choice 1 above, and I personally think it would be the best choice. > Hmm...but handling limit_change (at least, returns -EBUSY) will be necessary. I think so too. But I'm not sure now it's good or bad to support shrinking at limit_change about swap. Shrinking swap means increasing the memory usage and that may cause another swapout. > Do you consider a some magical way to move pages in swap back to memory ? > In this patch, I modified the find_next_to_unuse() to find the entry charged to a specific group. It might be possible to modify try_to_unuse()(or define another function based on try_to_unuse()) to reduce swap usage of a specified group down to some threashold. But, I think, one problem here is from which device the swaps should be back to memory, or usage balance between swap devices. > In general, I like this set but we can't change the limit on demand. (maybe) > (just put…
creator: Daisuke Nishimura
date: 2008-07-04T12:33:01-00:00

Re: [PATCH -mm 5/5] swapcgroup (v3): implement force_empty
type: item
description: On Fri, 4 Jul 2008 21:33:01 +0900 Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote: > On Fri, 4 Jul 2008 19:16:38 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote: > > On Fri, 4 Jul 2008 15:24:23 +0900 > > Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote: > > > > > This patch implements force_empty of swapcgroup. > > > > > > Currently, it simply uncharges all the charges from the group. > > > > > > I think there can be other implementations. > > > > > > What I thought are: > > > - move all the charges to its parent. > > > - unuse(swap in) all the swap charged to the group. > > > > > 3. move all swap back to memory (see swapoff.) > > > > > Do you mean swapping in all the swap including used by > other groups? swapping in all swap used by the group (not by all group) > It would be one choice anyway. > > > > But in any case, I think before implementing this way, > > > hierarchy and move charges support are needed. > > > > > > So I think this is enough for the first step. > > > > > > > I don't think hierarchy/automatic-load-balancer for swap cg is necessary. > It's the problem of how the "hierarchy" would be, I think. yes. > I'm saying "hierarchy" here just to mean "some kind of feature > where a parent includes their children". > I think "hierarchy" is needed if we implement the choice 1 above, > and I personally think it would be the best choice. > > > Hmm...but handling limit_change (at least, returns -EBUSY) will be necessary. > I think so too. > But I'm not sure now it's good or bad to support shrinking at limit_change > about swap. > Shrinking swap means increasing the memory usage and that may cause > another swapout. yes. but who reduce the limit ? it's the admin or users. At leaset, returning -EBUSY is necesary. You can use res_counter: check limit change patch which I posted yesterday. > > > Do you consider a some magical way to move pages in swap back to memory ? > > > In this patch, I modified the find_next_to_unuse() to find > the e…
creator: KAMEZAWA Hiroyuki
date: 2008-07-05T04:27:31-00:00

Re: [PATCH -mm 0/5] swapcgroup (v3)
type: item
description: Daisuke Nishimura wrote: > Hi. > > This is new version of swapcgroup. > > Major changes from previous version > - Rebased on 2.6.26-rc5-mm3. > The new -mm has been released, but these patches > can be applied on 2.6.26-rc8-mm1 too with only some offset warnings. > I tested these patches on 2.6.26-rc5-mm3 with some fixes about memory, > and it seems to work fine. > - (NEW) Implemented force_empty. > Currently, it simply uncharges all the charges from the group. > > Patches > - [1/5] add cgroup files > - [2/5] add a member to swap_info_struct > - [3/5] implement charge and uncharge > - [4/5] modify vm_swap_full() > - [5/5] implement force_empty > > ToDo(in my thought. Feel free to add some others here.) > - need some documentation > Add to memory.txt? or create a new documentation file? > I think memory.txt is good. But then, we'll need to add a Table of Contents to it, so that swap controller documentation can be located easily. > - add option to disable only this feature > I'm wondering if this option is needed. > memcg has already the boot option to disable it. > Is there any case where memory should be accounted but swap should not? > That depends on what use case you are trying to provide. Let's say I needed backward compatibility with 2.6.25, then I would account for memory and leave out swap (even though we have swap controller). > - hierarchy support > - move charges along with task > Both of them need more discussion. > Yes, they do. -- 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: 2008-07-05T06:52:25-00:00

Re: [PATCH -mm 5/5] swapcgroup (v3): implement force_empty
type: item
description: On Sat, 5 Jul 2008 13:29:44 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote: > On Fri, 4 Jul 2008 21:33:01 +0900 > Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote: > > > On Fri, 4 Jul 2008 19:16:38 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote: > > > On Fri, 4 Jul 2008 15:24:23 +0900 > > > Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote: > > > > > > > This patch implements force_empty of swapcgroup. > > > > > > > > Currently, it simply uncharges all the charges from the group. > > > > > > > > I think there can be other implementations. > > > > > > > > What I thought are: > > > > - move all the charges to its parent. > > > > - unuse(swap in) all the swap charged to the group. > > > > > > > 3. move all swap back to memory (see swapoff.) > > > > > > > > Do you mean swapping in all the swap including used by > > other groups? > > swapping in all swap used by the group (not by all group) > O.K. I intended to say the same thing in 2. I'll try it and I think some part of this implementation can be used by shrinking support too. (snip) > > > Hmm...but handling limit_change (at least, returns -EBUSY) will be necessary. > > I think so too. > > But I'm not sure now it's good or bad to support shrinking at limit_change > > about swap. > > Shrinking swap means increasing the memory usage and that may cause > > another swapout. > yes. but who reduce the limit ? it's the admin or users. > > At leaset, returning -EBUSY is necesary. You can use > res_counter: check limit change patch which I posted yesterday. > I saw your patch, and I agree that returning -EBUSY is the first step. > > > Do you consider a some magical way to move pages in swap back to memory ? > > > > > In this patch, I modified the find_next_to_unuse() to find > > the entry charged to a specific group. > > It might be possible to modify try_to_unuse()(or define another function > > based on try_to_unuse()) to reduce swap usage of a specified group > > down to some threas…
creator: Daisuke Nishimura
date: 2008-07-07T06:23:51-00:00

Re: [PATCH -mm 0/5] swapcgroup (v3)
type: item
description: Hi, Balbir-san. On Sat, 05 Jul 2008 12:22:25 +0530, Balbir Singh <balbir@linux.vnet.ibm.com> wrote: > Daisuke Nishimura wrote: > > Hi. > > > > This is new version of swapcgroup. > > > > Major changes from previous version > > - Rebased on 2.6.26-rc5-mm3. > > The new -mm has been released, but these patches > > can be applied on 2.6.26-rc8-mm1 too with only some offset warnings. > > I tested these patches on 2.6.26-rc5-mm3 with some fixes about memory, > > and it seems to work fine. > > - (NEW) Implemented force_empty. > > Currently, it simply uncharges all the charges from the group. > > > > Patches > > - [1/5] add cgroup files > > - [2/5] add a member to swap_info_struct > > - [3/5] implement charge and uncharge > > - [4/5] modify vm_swap_full() > > - [5/5] implement force_empty > > > > ToDo(in my thought. Feel free to add some others here.) > > - need some documentation > > Add to memory.txt? or create a new documentation file? > > > > I think memory.txt is good. But then, we'll need to add a Table of Contents to > it, so that swap controller documentation can be located easily. > I think memory.txt is a self-closed documentation, so I don't want to change it, honestlly. I'll write a documentation for swap as a new file first for review. > > - add option to disable only this feature > > I'm wondering if this option is needed. > > memcg has already the boot option to disable it. > > Is there any case where memory should be accounted but swap should not? > > > > That depends on what use case you are trying to provide. Let's say I needed > backward compatibility with 2.6.25, then I would account for memory and leave > out swap (even though we have swap controller). > O.K. I'll add option. Thanks, Daisuke Nishimura. _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Daisuke Nishimura
date: 2008-07-07T06:48:30-00:00

Re: [PATCH -mm 1/5] swapcgroup (v3): add cgroup files
type: item
description: On Fri, 2008-07-04 at 15:17 +0900, Daisuke Nishimura wrote: > +config CGROUP_SWAP_RES_CTLR > + bool "Swap Resource Controller for Control Groups" > + depends on CGROUP_MEM_RES_CTLR && SWAP > + help > + Provides a swap resource controller that manages and limits swap usage. > + Implemented as a add-on to Memory Resource Controller. Could you make this just plain depend on 'CGROUP_MEM_RES_CTLR && SWAP' and not make it configurable? I don't think the resource usage really justifies yet another .config knob to tune and break. :) -- Dave _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Dave Hansen
date: 2008-07-10T20:35:36-00:00

Re: [PATCH -mm 1/5] swapcgroup (v3): add cgroup files
type: item
description: Hi, Dave-san. On Thu, 10 Jul 2008 13:35:36 -0700, Dave Hansen <dave@linux.vnet.ibm.com> wrote: > On Fri, 2008-07-04 at 15:17 +0900, Daisuke Nishimura wrote: > > +config CGROUP_SWAP_RES_CTLR > > + bool "Swap Resource Controller for Control Groups" > > + depends on CGROUP_MEM_RES_CTLR && SWAP > > + help > > + Provides a swap resource controller that manages and limits swap usage. > > + Implemented as a add-on to Memory Resource Controller. > > Could you make this just plain depend on 'CGROUP_MEM_RES_CTLR && SWAP' > and not make it configurable? I don't think the resource usage really > justifies yet another .config knob to tune and break. :) > I don't stick to using kernel config option. As I said in my ToDo, I'm going to implement another method (boot option or something) to disable(or enable?) this feature, so I can make this config not configurable after it. Thanks, Daisuke Nishimura. _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Daisuke Nishimura
date: 2008-07-11T11:02:28-00:00