Home » Mailing lists » Devel » [RFC][PATCH 0/7] Resource controllers based on process containers
Re: [RFC][PATCH 2/7] RSS controller core [message #10909 is a reply to message #10890] |
Wed, 07 March 2007 05:37 |
Balbir Singh
Messages: 491 Registered: August 2006
|
Senior Member |
|
|
Pavel Emelianov wrote:
> This includes setup of RSS container within generic
> process containers, all the declarations used in RSS
> accounting, and core code responsible for accounting.
>
>
> ------------------------------------------------------------ ------------
>
> diff -upr linux-2.6.20.orig/include/linux/rss_container.h linux-2.6.20-0/include/linux/rss_container.h
> --- linux-2.6.20.orig/include/linux/rss_container.h 2007-03-06 13:39:17.000000000 +0300
> +++ linux-2.6.20-0/include/linux/rss_container.h 2007-03-06 13:33:28.000000000 +0300
> @@ -0,0 +1,68 @@
> +#ifndef __RSS_CONTAINER_H__
> +#define __RSS_CONTAINER_H__
> +/*
> + * RSS container
> + *
> + * Copyright 2007 OpenVZ SWsoft Inc
> + *
> + * Author: Pavel Emelianov <xemul@openvz.org>
> + *
> + */
> +
> +struct page_container;
> +struct rss_container;
> +
> +#ifdef CONFIG_RSS_CONTAINER
> +int container_rss_prepare(struct page *, struct vm_area_struct *vma,
> + struct page_container **);
> +
> +void container_rss_add(struct page_container *);
> +void container_rss_del(struct page_container *);
> +void container_rss_release(struct page_container *);
> +
> +int mm_init_container(struct mm_struct *mm, struct task_struct *tsk);
> +void mm_free_container(struct mm_struct *mm);
> +
> +unsigned long container_isolate_pages(unsigned long nr_to_scan,
> + struct rss_container *rss, struct list_head *dst,
> + int active, unsigned long *scanned);
> +unsigned long container_nr_physpages(struct rss_container *rss);
> +
> +unsigned long container_try_to_free_pages(struct rss_container *);
> +void container_out_of_memory(struct rss_container *);
> +
> +void container_rss_init_early(void);
> +#else
> +static inline int container_rss_prepare(struct page *pg,
> + struct vm_area_struct *vma, struct page_container **pc)
> +{
> + *pc = NULL; /* to make gcc happy */
> + return 0;
> +}
> +
> +static inline void container_rss_add(struct page_container *pc)
> +{
> +}
> +
> +static inline void container_rss_del(struct page_container *pc)
> +{
> +}
> +
> +static inline void container_rss_release(struct page_container *pc)
> +{
> +}
> +
> +static inline int mm_init_container(struct mm_struct *mm, struct task_struct *t)
> +{
> + return 0;
> +}
> +
> +static inline void mm_free_container(struct mm_struct *mm)
> +{
> +}
> +
> +static inline void container_rss_init_early(void)
> +{
> +}
> +#endif
> +#endif
> diff -upr linux-2.6.20.orig/init/Kconfig linux-2.6.20-0/init/Kconfig
> --- linux-2.6.20.orig/init/Kconfig 2007-03-06 13:33:28.000000000 +0300
> +++ linux-2.6.20-0/init/Kconfig 2007-03-06 13:33:28.000000000 +0300
> @@ -265,6 +265,13 @@ config CPUSETS
> bool
> select CONTAINERS
>
> +config RSS_CONTAINER
> + bool "RSS accounting container"
> + select RESOURCE_COUNTERS
> + help
> + Provides a simple Resource Controller for monitoring and
> + controlling the total Resident Set Size of the tasks in a container
> +
The wording looks very familiar :-). It would be useful to add
"The reclaim logic is now container aware, when the container goes overlimit
the page reclaimer reclaims pages belonging to this container. If we are
unable to reclaim enough pages to satisfy the request, the process is
killed with an out of memory warning"
> config SYSFS_DEPRECATED
> bool "Create deprecated sysfs files"
> default y
> diff -upr linux-2.6.20.orig/mm/Makefile linux-2.6.20-0/mm/Makefile
> --- linux-2.6.20.orig/mm/Makefile 2007-02-04 21:44:54.000000000 +0300
> +++ linux-2.6.20-0/mm/Makefile 2007-03-06 13:33:28.000000000 +0300
> @@ -29,3 +29,5 @@ obj-$(CONFIG_MEMORY_HOTPLUG) += memory_h
> obj-$(CONFIG_FS_XIP) += filemap_xip.o
> obj-$(CONFIG_MIGRATION) += migrate.o
> obj-$(CONFIG_SMP) += allocpercpu.o
> +
> +obj-$(CONFIG_RSS_CONTAINER) += rss_container.o
> diff -upr linux-2.6.20.orig/mm/rss_container.c linux-2.6.20-0/mm/rss_container.c
> --- linux-2.6.20.orig/mm/rss_container.c 2007-03-06 13:39:17.000000000 +0300
> +++ linux-2.6.20-0/mm/rss_container.c 2007-03-06 13:33:28.000000000 +0300
> @@ -0,0 +1,307 @@
> +/*
> + * RSS accounting container
> + *
> + * Copyright 2007 OpenVZ SWsoft Inc
> + *
> + * Author: Pavel Emelianov <xemul@openvz.org>
> + *
> + */
> +
> +#include <linux/list.h>
> +#include <linux/sched.h>
> +#include <linux/mm.h>
> +#include <linux/res_counter.h>
> +#include <linux/rss_container.h>
> +
> +static struct container_subsys rss_subsys;
> +
> +struct rss_container {
> + struct res_counter res;
> + struct list_head page_list;
> + struct container_subsys_state css;
> +};
> +
> +struct page_container {
> + struct page *page;
> + struct rss_container *cnt;
> + struct list_head list;
> +};
> +
Yes, this is what I was planning to get to -- a per container LRU list.
But you have just one list, don't you need active and inactive lists?
When the global LRU is manipulated, shouldn't this list be updated as
well, so that reclaim will pick the best pages.
> +static inline struct rss_container *rss_from_cont(struct container *cnt)
> +{
> + return container_of(container_subsys_state(cnt, &rss_subsys),
> + struct rss_container, css);
> +}
> +
> +int mm_init_container(struct mm_struct *mm, struct task_struct *tsk)
> +{
> + struct rss_container *cnt;
> +
> + cnt = rss_from_cont(task_container(tsk, &rss_subsys));
> + if (css_get(&cnt->css))
> + return -EBUSY;
> +
> + mm->rss_container = cnt;
> + return 0;
> +}
> +
> +void mm_free_container(struct mm_struct *mm)
> +{
> + css_put(&mm->rss_container->css);
> +}
> +
> +int container_rss_prepare(struct page *page, struct vm_area_struct *vma,
> + struct page_container **ppc)
> +{
> + struct rss_container *rss;
> + struct page_container *pc;
> +
> + rcu_read_lock();
> + rss = rcu_dereference(vma->vm_mm->rss_container);
> + css_get_current(&rss->css);
> + rcu_read_unlock();
> +
> + pc = kmalloc(sizeof(struct page_container), GFP_KERNEL);
> + if (pc == NULL)
> + goto out_nomem;
> +
> + while (res_counter_charge(&rss->res, 1)) {
> + if (container_try_to_free_pages(rss))
> + continue;
> +
The return codes of the functions is a bit confusing, ideally
container_try_to_free_pages() should return 0 on success. Also
res_counter_charge() has a WARN_ON(1) if the limit is exceeded.
The system administrator can figure out the details from failcnt,
I suspect when the container is running close to it's limit,
dmesg will have too many WARNING messages.
How much memory do you try to reclaim in container_try_to_free_pages()?
With my patches, I was planning to export this knob to userspace with
a default value. This will help the administrator decide how much
of the working set/container LRU should be freed on reaching the limit.
I cannot find the definition of container_try_to_free_pages() in
this patch.
> + container_out_of_memory(rss);
> + if (test_thread_flag(TIF_MEMDIE))
> + goto out_charge;
> + }
> +
> + pc->page = page;
> + pc->cnt = rss;
> + *ppc = pc;
> + return 0;
> +
> +out_charge:
> + kfree(pc);
> +out_nomem:
> + css_put(&rss->css);
> + return -ENOMEM;
> +}
> +
> +void container_rss_release(struct page_container *pc)
> +{
> + struct rss_container *rss;
> +
> + rss = pc->cnt;
> + res_counter_uncharge(&rss->res, 1);
> + css_put(&rss->css);
> + kfree(pc);
> +}
> +
> +void container_rss_add(struct page_container *pc)
> +{
> + struct page *pg;
> + struct rss_container *rss;
> +
> + pg = pc->page;
> + rss = pc->cnt;
> +
> + spin_lock(&rss->res.lock);
> + list_add(&pc->list, &rss->page_list);
This is not good, it won't give us LRU behaviour which is
useful for determining which pages to free.
> + spin_unlock(&rss->res.lock);
> +
> + page_container(pg) = pc;
> +}
> +
> +void container_rss_del(struct page_container *pc)
> +{
> + struct page *page;
> + struct rss_container *rss;
> +
> + page = pc->page;
> + rss = pc->cnt;
> +
> + spin_lock(&rss->res.lock);
> + list_del(&pc->list);
> + res_counter_uncharge_locked(&rss->res, 1);
> + spin_unlock(&rss->res.lock);
> +
> + css_put(&rss->css);
> + kfree(pc);
> +}
> +
> +unsigned long container_isolate_pages(unsigned long nr_to_scan,
> + struct rss_container *rss, struct list_head *dst,
> + int active, unsigned long *scanned)
> +{
> + unsigned long nr_taken = 0;
> + struct page *page;
> + struct page_container *pc;
> + unsigned long scan;
> + struct list_head *src;
> + LIST_HEAD(pc_list);
> + struct zone *z;
> +
> + spin_lock_irq(&rss->res.lock);
> + src = &rss->page_list;
> +
Which part of the working set are we pushing out, this looks like
we are using FIFO to determine which pages to reclaim. This needs
to be FIXED.
> + for (scan = 0; scan < nr_to_scan && !list_empty(src); scan++) {
> + pc = list_entry(src->prev, struct page_container, list);
> + page = pc->page;
> + z = page_zone(page);
> +
> + list_move(&pc->list, &pc_list);
> +
> + spin_lock(&z->lru_lock);
> + if (PageLRU(page)) {
> + if ((active && PageActive(page)) ||
> + (!active && !PageActive(page))) {
> + if (likely(get_page_un
...
|
|
|
|
|
[RFC][PATCH 0/7] Resource controllers based on process containers
By: xemul on Tue, 06 March 2007 14:42
|
|
|
[RFC][PATCH 1/7] Resource counters
By: xemul on Tue, 06 March 2007 14:47
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
By: xemul on Wed, 07 March 2007 07:17
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
By: xemul on Sun, 11 March 2007 09:01
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
By: ebiederm on Sun, 11 March 2007 19:00
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
By: ebiederm on Tue, 13 March 2007 09:09
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
By: xemul on Tue, 13 March 2007 09:27
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
By: xemul on Tue, 13 March 2007 15:41
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
By: xemul on Wed, 14 March 2007 07:12
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
By: ebiederm on Thu, 15 March 2007 16:51
|
|
|
Re: Re: [RFC][PATCH 1/7] Resource counters
By: dev on Tue, 13 March 2007 09:36
|
|
|
Re: [RFC][PATCH 1/7] Resource counters
|
|
|
[RFC][PATCH 2/7] RSS controller core
By: xemul on Tue, 06 March 2007 14:53
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: dev on Sun, 11 March 2007 12:13
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: ebiederm on Sun, 11 March 2007 19:34
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: xemul on Mon, 12 March 2007 09:02
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: xemul on Tue, 13 March 2007 07:17
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: xemul on Tue, 13 March 2007 15:32
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: dev on Tue, 13 March 2007 15:10
|
|
|
Re: Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: Re: [RFC][PATCH 2/7] RSS controller core
By: ebiederm on Tue, 13 March 2007 09:26
|
|
|
Re: Re: [RFC][PATCH 2/7] RSS controller core
By: dev on Tue, 13 March 2007 15:30
|
|
|
Re: Re: [RFC][PATCH 2/7] RSS controller core
By: dev on Tue, 13 March 2007 10:06
|
|
|
Re: Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: mel on Wed, 14 March 2007 15:38
|
|
|
Re: Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: Re: [RFC][PATCH 2/7] RSS controller core
By: ebiederm on Mon, 19 March 2007 17:41
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: xemul on Sun, 11 March 2007 09:08
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: xemul on Sun, 11 March 2007 15:04
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: xemul on Mon, 12 March 2007 08:31
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: xemul on Wed, 07 March 2007 07:25
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: ebiederm on Sun, 18 March 2007 16:58
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: akpm on Tue, 13 March 2007 06:04
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: Alan Cox on Tue, 13 March 2007 19:09
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: ebiederm on Fri, 16 March 2007 00:55
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: ebiederm on Fri, 16 March 2007 18:54
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: mel on Wed, 14 March 2007 16:47
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: dev on Tue, 13 March 2007 15:54
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: mel on Tue, 20 March 2007 18:57
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
By: ebiederm on Sun, 18 March 2007 17:42
|
|
|
Re: [RFC][PATCH 2/7] RSS controller core
|
|
|
controlling mmap()'d vs read/write() pages
|
|
|
Re: controlling mmap()'d vs read/write() pages
By: ebiederm on Tue, 20 March 2007 21:19
|
|
|
Re: controlling mmap()'d vs read/write() pages
|
|
|
Re: controlling mmap()'d vs read/write() pages
|
|
|
Re: controlling mmap()'d vs read/write() pages
By: ebiederm on Fri, 23 March 2007 10:12
|
|
|
Re: controlling mmap()'d vs read/write() pages
|
|
|
Re: controlling mmap()'d vs read/write() pages
|
|
|
Re: controlling mmap()'d vs read/write() pages
|
|
|
Re: controlling mmap()'d vs read/write() pages
|
|
|
Re: controlling mmap()'d vs read/write() pages
By: ebiederm on Fri, 23 March 2007 12:21
|
|
|
Re: controlling mmap()'d vs read/write() pages
|
|
|
[RFC][PATCH 3/7] Data structures changes for RSS accounting
By: xemul on Tue, 06 March 2007 14:55
|
|
|
Re: [RFC][PATCH 3/7] Data structures changes for RSS accounting
By: ebiederm on Sun, 11 March 2007 19:13
|
|
|
Re: [RFC][PATCH 3/7] Data structures changes for RSS accounting
By: dev on Mon, 12 March 2007 16:16
|
|
|
Re: [RFC][PATCH 3/7] Data structures changes for RSS accounting
|
|
|
Re: [RFC][PATCH 3/7] Data structures changes for RSS accounting
By: xemul on Mon, 12 March 2007 17:19
|
|
|
Re: [RFC][PATCH 3/7] Data structures changes for RSS accounting
|
|
|
Re: [RFC][PATCH 3/7] Data structures changes for RSS accounting
|
|
|
Re: [RFC][PATCH 3/7] Data structures changes for RSS accounting
By: xemul on Tue, 13 March 2007 07:10
|
|
|
[RFC][PATCH 4/7] RSS accounting hooks over the code
By: xemul on Tue, 06 March 2007 14:57
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
By: xemul on Wed, 14 March 2007 15:43
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
By: ebiederm on Sun, 11 March 2007 19:14
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
By: dev on Mon, 12 March 2007 16:23
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
By: dev on Mon, 12 March 2007 17:07
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
By: ebiederm on Tue, 13 March 2007 09:58
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
By: ebiederm on Tue, 13 March 2007 09:43
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
By: ebiederm on Tue, 13 March 2007 16:01
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
By: dev on Wed, 14 March 2007 16:16
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
Re: [RFC][PATCH 4/7] RSS accounting hooks over the code
|
|
|
[RFC][PATCH 5/7] Per-container OOM killer and page reclamation
By: xemul on Tue, 06 March 2007 15:01
|
|
|
Re: [RFC][PATCH 5/7] Per-container OOM killer and page reclamation
|
|
|
Re: [RFC][PATCH 5/7] Per-container OOM killer and page reclamation
By: xemul on Sun, 11 March 2007 08:39
|
|
|
[RFC][PATCH 6/7] Account for the number of tasks within container
By: xemul on Tue, 06 March 2007 15:02
|
|
|
Re: [RFC][PATCH 6/7] Account for the number of tasks within container
|
|
|
Re: [RFC][PATCH 6/7] Account for the number of tasks within container
By: xemul on Wed, 07 March 2007 07:10
|
|
|
Re: [RFC][PATCH 6/7] Account for the number of tasks within container
|
|
|
Re: [RFC][PATCH 6/7] Account for the number of tasks within container
By: xemul on Sun, 11 March 2007 08:34
|
|
|
[RFC][PATCH 7/7] Account for the number of files opened within container
By: xemul on Tue, 06 March 2007 15:05
|
|
|
Re: [RFC][PATCH 0/7] Resource controllers based on process containers
|
|
|
Re: [RFC][PATCH 0/7] Resource controllers based on process containers
By: xemul on Wed, 07 March 2007 07:27
|
|
|
Re: [RFC][PATCH 0/7] Resource controllers based on process containers
|
|
|
Re: [RFC][PATCH 0/7] Resource controllers based on process containers
By: xemul on Wed, 07 March 2007 07:30
|
|
|
Re: [RFC][PATCH 0/7] Resource controllers based on process containers
By: dev on Wed, 07 March 2007 09:30
|
Goto Forum:
Current Time: Sun Dec 08 09:16:45 GMT 2024
Total time taken to generate the page: 0.02854 seconds
|