OpenVZ Forum - RDF feed
type: channel
items: [PATCH 00/29] Rename Containers to Control Groups
items: [PATCH 01/29] task containersv11 basic task container framework
items: [PATCH 02/29] task containersv11 basic task container framework fix
items: [PATCH 03/29] task containersv11 add tasks file interface
items: [PATCH 04/29] task containersv11 add fork exit hooks
items: [PATCH 05/29] task containersv11 add container_clone interface
items: [PATCH 06/29] task containersv11 add procfs interface
items: [PATCH 07/29] task containersv11 shared container subsystem group arrays
items: [PATCH 08/29] task containersv11 shared container subsystem group arrays avoid lockdep warning
items: [PATCH 09/29] task containersv11 shared container subsystem group arrays include fix
items: [PATCH 10/29] task containersv11 automatic userspace notification of idle containers
items: [PATCH 11/29] task containersv11 make cpusets a client of containers
items: [PATCH 12/29] task containersv11 example cpu accounting subsystem
items: [PATCH 13/29] task containersv11 simple task container debug info subsystem
items: [PATCH 14/29] add containerstats v3
items: [PATCH 15/29] add containerstats v3 fix
items: [PATCH 16/29] containers implement namespace tracking subsystem
items: [PATCH 17/29] containers implement namespace tracking subsystem fix order of container subsystems in
items: [PATCH 18/29] memory controller add documentation
items: [PATCH 19/29] memory controller resource counters v7
items: [PATCH 20/29] memory controller resource counters v7 fix
items: [PATCH 21/29] memory controller containers setup v7
items: [PATCH 22/29] memory controller accounting setup v7
items: [PATCH 23/29] memory controller memory accounting v7
items: [PATCH 24/29] memory controller task migration v7
items: [PATCH 25/29] memory controller add per container lru and reclaim v7
items: [PATCH 26/29] memory controller add per container lru and reclaim v7 fix
items: [PATCH 27/29] memory controller oom handling v7
items: [PATCH 28/29] memory controller add switch to control what type of pages to limit v7
items: [PATCH 29/29] memory controller make page_referenced container aware v7
items: Re: [PATCH 23/29] memory controller memory accounting v7
items: Re: [PATCH 01/29] task containersv11 basic task container framework
items: Re: [PATCH 11/29] task containersv11 make cpusets a client of containers

[PATCH 00/29] Rename Containers to Control Groups
type: item
description: [ Sending to containers@lists.osdl.org for review before sending on to linux-kernel and akpm ] This patchset renames "Task Containers" to "Control Groups", in line with recent discussions. These patches are drop-in replacements for those of the same names in the current -mm tree: task-containersv11-basic-task-container-framework.patch task-containersv11-basic-task-container-framework-fix.patch task-containersv11-add-tasks-file-interface.patch task-containersv11-add-fork-exit-hooks.patch task-containersv11-add-container_clone-interface.patch task-containersv11-add-procfs-interface.patch task-containersv11-shared-container-subsystem-group-arrays.patch task-containersv11-shared-container-subsystem-group-arrays-avoid-lockdep-warning.patch task-containersv11-shared-container-subsystem-group-arrays-include-fix.patch task-containersv11-automatic-userspace-notification-of-idle-containers.patch task-containersv11-make-cpusets-a-client-of-containers.patch task-containersv11-example-cpu-accounting-subsystem.patch task-containersv11-simple-task-container-debug-info-subsystem.patch add-containerstats-v3.patch add-containerstats-v3-fix.patch containers-implement-namespace-tracking-subsystem.patch containers-implement-namespace-tracking-subsystem-fix-order-of-container-subsystems-in-init-kconfig.patch memory-controller-add-documentation.patch memory-controller-resource-counters-v7.patch memory-controller-resource-counters-v7-fix.patch memory-controller-containers-setup-v7.patch memory-controller-accounting-setup-v7.patch memory-controller-memory-accounting-v7.patch memory-controller-task-migration-v7.patch memory-controller-add-per-container-lru-and-reclaim-v7.patch memory-controller-add-per-container-lru-and-reclaim-v7-fix.patch memory-controller-oom-handling-v7.patch memory-controller-add-switch-to-control-what-type-of-pages-to-limit-v7.patch memory-controller-make-page_referenced-container-aware-v7.patch They are constructed by running the following perl script over the origina…
creator: Paul Menage
date: 2007-09-11T19:52:39-00:00

[PATCH 01/29] task containersv11 basic task container framework
type: item
description: From: Paul Menage <menage@google.com> Generic Process Control Groups -------------------------- There have recently been various proposals floating around for resource management/accounting and other task grouping subsystems in the kernel, including ResGroups, User BeanCounters, NSProxy cgroups, and others. These all need the basic abstraction of being able to group together multiple processes in an aggregate, in order to track/limit the resources permitted to those processes, or control other behaviour of the processes, and all implement this grouping in different ways. This patchset provides a framework for tracking and grouping processes into arbitrary "cgroups" and assigning arbitrary state to those groupings, in order to control the behaviour of the cgroup as an aggregate. The intention is that the various resource management and virtualization/cgroup efforts can also become task cgroup clients, with the result that: - the userspace APIs are (somewhat) normalised - it's easier to test e.g. the ResGroups CPU controller in conjunction with the BeanCounters memory controller, or use either of them as the resource-control portion of a virtual server system. - the additional kernel footprint of any of the competing resource management systems is substantially reduced, since it doesn't need to provide process grouping/containment, hence improving their chances of getting into the kernel This patch: Add the main task cgroups framework - the cgroup filesystem, and the basic structures for tracking membership and associating subsystem state objects to tasks. Signed-off-by: Paul Menage <menage@google.com> Cc: Serge E. Hallyn <serue@us.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Paul Jackson <pj@sgi.com> Cc: Kirill Korotaev <dev@openvz.org> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Andrew…
creator: Paul Menage
date: 2007-09-11T19:52:40-00:00

[PATCH 02/29] task containersv11 basic task container framework fix
type: item
description: From: "Paul Menage" <menage@google.com> On 7/28/07, Andrew Morton <akpm@linux-foundation.org> wrote: > > [<c0154ad2>] proc_cpuset_show+0x5e/0xb9 > > [<c01976b1>] seq_read+0xef/0x266 > > [<c0181398>] vfs_read+0x8e/0x117 > > [<c01817c9>] sys_read+0x3d/0x61 > > [<c010401e>] sysenter_past_esp+0x5f/0x99 > > ======================= > > INFO: lockdep is turned off. > > Code: 00 89 d8 83 c4 0c 5b 5e 5f 5d c3 55 89 e5 57 56 53 83 ec 08 89 > > 45 f0 89 55 ec 89 d3 01 cb 8d 43 ff c6 43 ff 00 8b 55 f0 8b 72 1c <8b> > > 56 3c 29 d0 3b 45 ec 72 45 89 d1 c1 e9 02 8b 76 40 89 c7 f3 > > EIP: [<c01536a7>] cgroup_path+0x20/0x7b SS:ESP 0068:c5ccff00 > Oops, this is a case of trying to read /proc/self/cpuset when cpusets are completely unmounted. It works fine when cpusets is mounted as part of any hierarchy, or part of an active but unmounted hierarchy. Attached patch fixes it, and should be rolled in to the first patch of the series. (basic framework patch). Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- kernel/cgroup.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff -puN kernel/cgroup.c~task-cgroupsv11-basic-task-cgroup-framework-fix kernel/cgroup.c --- a/kernel/cgroup.c~task-cgroupsv11-basic-task-cgroup-framework-fix +++ a/kernel/cgroup.c @@ -683,6 +683,15 @@ int cgroup_path(const struct containe { char *start; + if (cont == dummytop) { + /* + * Inactive subsystems have no dentry for their root + * cgroup + */ + strcpy(buf, "/"); + return 0; + } + start = buf + buflen; *--start = '\0'; _ -- _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Paul Menage
date: 2007-09-11T19:52:41-00:00

[PATCH 03/29] task containersv11 add tasks file interface
type: item
description: From: Paul Menage <menage@google.com> Add the per-directory "tasks" file for cgroupfs mounts; this allows the user to determine which tasks are members of a cgroup by reading a cgroup's "tasks", and to move a task into a cgroup by writing its pid to its "tasks". Signed-off-by: Paul Menage <menage@google.com> Cc: Serge E. Hallyn <serue@us.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Paul Jackson <pj@sgi.com> Cc: Kirill Korotaev <dev@openvz.org> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/cgroup.h | 10 + kernel/cgroup.c | 359 +++++++++++++++++++++++++++++++++++- 2 files changed, 368 insertions(+), 1 deletion(-) diff -puN include/linux/cgroup.h~task-cgroupsv11-add-tasks-file-interface include/linux/cgroup.h --- a/include/linux/cgroup.h~task-cgroupsv11-add-tasks-file-interface +++ a/include/linux/cgroup.h @@ -144,6 +144,16 @@ int cgroup_is_removed(const struct co int cgroup_path(const struct cgroup *cont, char *buf, int buflen); +int __cgroup_task_count(const struct cgroup *cont); +static inline int cgroup_task_count(const struct cgroup *cont) +{ + int task_count; + rcu_read_lock(); + task_count = __cgroup_task_count(cont); + rcu_read_unlock(); + return task_count; +} + /* Return true if the cgroup is a descendant of the current cgroup */ int cgroup_is_descendant(const struct cgroup *cont); diff -puN kernel/cgroup.c~task-cgroupsv11-add-tasks-file-interface kernel/cgroup.c --- a/kernel/cgroup.c~task-cgroupsv11-add-tasks-file-interface +++ a/kernel/cgroup.c @@ -40,7 +40,7 @@ #include <linux/magic.h> #include <linux/spinlock.h> #include <linux/string.h> - +#include <linux/sort.h> #include <asm/atomic.h> /* Generate an array of cgroup subsystem pointers */ @@ -713,6 +713,127 @@ int cgroup_path(const struct containe return 0; } +/* + *…
creator: Paul Menage
date: 2007-09-11T19:52:42-00:00

[PATCH 04/29] task containersv11 add fork exit hooks
type: item
description: From: Paul Menage <menage@google.com> tAdd adds the necessary hooks to the fork() and exit() paths to ensure that new children inherit their parent's cgroup assignments, and that exiting processes release reference counts on their cgroups. Signed-off-by: Paul Menage <menage@google.com> Cc: Serge E. Hallyn <serue@us.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Paul Jackson <pj@sgi.com> Cc: Kirill Korotaev <dev@openvz.org> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/cgroup.h | 6 + kernel/cgroup.c | 121 ++++++++++++++++++++++++++++++++++++ kernel/exit.c | 2 kernel/fork.c | 14 +++- 4 files changed, 141 insertions(+), 2 deletions(-) diff -puN include/linux/cgroup.h~task-cgroupsv11-add-fork-exit-hooks include/linux/cgroup.h --- a/include/linux/cgroup.h~task-cgroupsv11-add-fork-exit-hooks +++ a/include/linux/cgroup.h @@ -25,6 +25,9 @@ extern int cgroup_init(void); extern void cgroup_init_smp(void); extern void cgroup_lock(void); extern void cgroup_unlock(void); +extern void cgroup_fork(struct task_struct *p); +extern void cgroup_fork_callbacks(struct task_struct *p); +extern void cgroup_exit(struct task_struct *p, int run_callbacks); /* Per-subsystem/per-cgroup state maintained by the system. */ struct cgroup_subsys_state { @@ -215,6 +218,9 @@ int cgroup_path(const struct containe static inline int cgroup_init_early(void) { return 0; } static inline int cgroup_init(void) { return 0; } static inline void cgroup_init_smp(void) {} +static inline void cgroup_fork(struct task_struct *p) {} +static inline void cgroup_fork_callbacks(struct task_struct *p) {} +static inline void cgroup_exit(struct task_struct *p, int callbacks) {} static inline void cgroup_lock(void) {} static inline void cgroup_unlock(void) {} diff -puN kernel/cgroup.c~task…
creator: Paul Menage
date: 2007-09-11T19:52:43-00:00

[PATCH 05/29] task containersv11 add container_clone interface
type: item
description: From: Paul Menage <menage@google.com> Add support for cgroup_clone(), a way to create new cgroups intended to be used for systems such as namespace unsharing. A new subsystem callback, post_clone(), is added to allow subsystems to automatically configure cloned cgroups. Signed-off-by: Paul Menage <menage@google.com> Cc: Serge E. Hallyn <serue@us.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Paul Jackson <pj@sgi.com> Cc: Kirill Korotaev <dev@openvz.org> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- Documentation/cgroups.txt | 7 + include/linux/cgroup.h | 3 kernel/cgroup.c | 135 +++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+) diff -puN Documentation/cgroups.txt~task-cgroupsv11-add-cgroup_clone-interface Documentation/cgroups.txt --- a/Documentation/cgroups.txt~task-cgroupsv11-add-cgroup_clone-interface +++ a/Documentation/cgroups.txt @@ -504,6 +504,13 @@ include/linux/cgroup.h for details). method can return an error code, the error code is currently not always handled well. +void post_clone(struct cgroup_subsys *ss, struct cgroup *cont) + +Called at the end of cgroup_clone() to do any paramater +initialization which might be required before a task could attach. For +example in cpusets, no task may attach before 'cpus' and 'mems' are set +up. + void bind(struct cgroup_subsys *ss, struct cgroup *root) LL=callback_mutex diff -puN include/linux/cgroup.h~task-cgroupsv11-add-cgroup_clone-interface include/linux/cgroup.h --- a/include/linux/cgroup.h~task-cgroupsv11-add-cgroup_clone-interface +++ a/include/linux/cgroup.h @@ -174,6 +174,7 @@ struct cgroup_subsys { void (*exit)(struct cgroup_subsys *ss, struct task_struct *task); int (*populate)(struct cgroup_subsys *ss, struct cgroup *cont); + void (*post_clone)(struct cgroup_subsys…
creator: Paul Menage
date: 2007-09-11T19:52:44-00:00

[PATCH 06/29] task containersv11 add procfs interface
type: item
description: From: Paul Menage <menage@google.com> Add: /proc/cgroups - general system info /proc/*/cgroup - per-task cgroup membership info Signed-off-by: Paul Menage <menage@google.com> Cc: Serge E. Hallyn <serue@us.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Paul Jackson <pj@sgi.com> Cc: Kirill Korotaev <dev@openvz.org> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- fs/proc/base.c | 7 + include/linux/cgroup.h | 2 kernel/cgroup.c | 132 ++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) diff -puN fs/proc/base.c~task-cgroupsv11-add-procfs-interface fs/proc/base.c --- a/fs/proc/base.c~task-cgroupsv11-add-procfs-interface +++ a/fs/proc/base.c @@ -67,6 +67,7 @@ #include <linux/mount.h> #include <linux/security.h> #include <linux/ptrace.h> +#include <linux/cgroup.h> #include <linux/cpuset.h> #include <linux/audit.h> #include <linux/poll.h> @@ -2051,6 +2052,9 @@ static const struct pid_entry tgid_base_ #ifdef CONFIG_CPUSETS REG("cpuset", S_IRUGO, cpuset), #endif +#ifdef CONFIG_CGROUPS + REG("cgroup", S_IRUGO, cgroup), +#endif INF("oom_score", S_IRUGO, oom_score), REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust), #ifdef CONFIG_AUDITSYSCALL @@ -2340,6 +2344,9 @@ static const struct pid_entry tid_base_s #ifdef CONFIG_CPUSETS REG("cpuset", S_IRUGO, cpuset), #endif +#ifdef CONFIG_CGROUPS + REG("cgroup", S_IRUGO, cgroup), +#endif INF("oom_score", S_IRUGO, oom_score), REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust), #ifdef CONFIG_AUDITSYSCALL diff -puN include/linux/cgroup.h~task-cgroupsv11-add-procfs-interface include/linux/cgroup.h --- a/include/linux/cgroup.h~task-cgroupsv11-add-procfs-interface +++ a/include/linux/cgroup.h @@ -29,6 +29,8 @@ extern void cgroup_fork(struct task_s extern void cgroup_fork_callbacks(struct task_struct *p); extern void cgro…
creator: Paul Menage
date: 2007-09-11T19:52:45-00:00

[PATCH 07/29] task containersv11 shared container subsystem group arrays
type: item
description: From: Paul Menage <menage@google.com> Replace the struct css_set embedded in task_struct with a pointer; all tasks that have the same set of memberships across all hierarchies will share a css_set object, and will be linked via their css_sets field to the "tasks" list_head in the css_set. Assuming that many tasks share the same cgroup assignments, this reduces overall space usage and keeps the size of the task_struct down (three pointers added to task_struct compared to a non-cgroups kernel, no matter how many subsystems are registered). Signed-off-by: Paul Menage <menage@google.com> Cc: Serge E. Hallyn <serue@us.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Paul Jackson <pj@sgi.com> Cc: Kirill Korotaev <dev@openvz.org> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- Documentation/cgroups.txt | 14 include/linux/cgroup.h | 89 ++++ include/linux/sched.h | 33 - kernel/cgroup.c | 606 ++++++++++++++++++++++++++++----- kernel/fork.c | 1 5 files changed, 620 insertions(+), 123 deletions(-) diff -puN Documentation/cgroups.txt~task-cgroupsv11-shared-cgroup-subsystem-group-arrays Documentation/cgroups.txt --- a/Documentation/cgroups.txt~task-cgroupsv11-shared-cgroup-subsystem-group-arrays +++ a/Documentation/cgroups.txt @@ -176,7 +176,9 @@ Control Groups extends the kernel as follows subsystem state is something that's expected to happen frequently and in performance-critical code, whereas operations that require a task's actual cgroup assignments (in particular, moving between - cgroups) are less common. + cgroups) are less common. A linked list runs through the cg_list + field of each task_struct using the css_set, anchored at + css_set->tasks. - A cgroup hierarchy filesystem can be mounted for browsing and manipulation from user space. @@ -252,6 +254,1…
creator: Paul Menage
date: 2007-09-11T19:52:46-00:00

[PATCH 08/29] task containersv11 shared container subsystem group arrays avoid lockdep warning
type: item
description: From: Paul Menage <menage@google.com> I think this is the right way to handle the lockdep false-positive in the current cgroups patches, but I'm not that familiar with lockdep so any suggestions for a better approach are welcomed. In order to avoid a false-positive lockdep warning, we lock the root inode of a new filesystem mount prior to taking cgroup_mutex, to preserve the invariant that cgroup_mutex nests inside inode->i_mutex. In order to prevent a lockdep false positive when locking i_mutex on a newly-created cgroup directory inode we use mutex_lock_nested(), with a nesting level of I_MUTEX_CHILD since the new inode will ultimately be a child directory of the parent whose i_mutex is nested outside of cgroup_mutex. Signed-off-by: Paul Menage <menage@google.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- kernel/cgroup.c | 17 +++++++---------- 1 files changed, 7 insertions(+), 10 deletions(-) diff -puN kernel/cgroup.c~task-cgroupsv11-shared-cgroup-subsystem-group-arrays-avoid-lockdep-warning kernel/cgroup.c --- a/kernel/cgroup.c~task-cgroupsv11-shared-cgroup-subsystem-group-arrays-avoid-lockdep-warning +++ a/kernel/cgroup.c @@ -867,13 +867,16 @@ static int cgroup_get_sb(struct file_ } else { /* New superblock */ struct cgroup *cont = &root->top_cgroup; + struct inode *inode; BUG_ON(sb->s_root != NULL); ret = cgroup_get_rootdir(sb); if (ret) goto drop_new_super; + inode = sb->s_root->d_inode; + mutex_lock(&inode->i_mutex); mutex_lock(&cgroup_mutex); /* @@ -886,12 +889,14 @@ static int cgroup_get_sb(struct file_ ret = allocate_cg_links(css_set_count, &tmp_cg_links); if (ret) { mutex_unlock(&cgroup_mutex); + mutex_unlock(&inode->i_mutex); goto drop_new_super; } ret = rebind_subsystems(root, root->subsys_bits); if (ret == -EBUSY) { mutex_unlock(&cgroup_mutex); + mutex_unlock(&inode->i_mutex); goto drop_new_super; } @@ -931,16 +936,8 @@ static int cgroup_get_sb(struct file_ BUG_ON(!list_empty(&cont->ch…
creator: Paul Menage
date: 2007-09-11T19:52:47-00:00

[PATCH 09/29] task containersv11 shared container subsystem group arrays include fix
type: item
description: From: Andrew Morton <akpm@linux-foundation.org> kernel/cgroup.c: In function 'cgroup_new_inode': kernel/cgroup.c:573: error: variable 'cgroup_backing_dev_info' has initializer but incomplete type kernel/cgroup.c:574: error: unknown field 'capabilities' specified in initializer kernel/cgroup.c:574: error: 'BDI_CAP_NO_ACCT_DIRTY' undeclared (first use in this function) kernel/cgroup.c:574: error: (Each undeclared identifier is reported only once) Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- kernel/cgroup.c | 1 + 1 file changed, 1 insertion(+) diff -puN kernel/cgroup.c~task-cgroupsv11-shared-cgroup-subsystem-group-arrays-include-fix kernel/cgroup.c --- a/kernel/cgroup.c~task-cgroupsv11-shared-cgroup-subsystem-group-arrays-include-fix +++ a/kernel/cgroup.c @@ -36,6 +36,7 @@ #include <linux/proc_fs.h> #include <linux/rcupdate.h> #include <linux/sched.h> +#include <linux/backing-dev.h> #include <linux/seq_file.h> #include <linux/slab.h> #include <linux/magic.h> _ -- _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Paul Menage
date: 2007-09-11T19:52:48-00:00

[PATCH 10/29] task containersv11 automatic userspace notification of idle containers
type: item
description: From: Paul Menage <menage@google.com> Add the following files to the cgroup filesystem: notify_on_release - configures/reports whether the cgroup subsystem should attempt to run a release script when this cgroup becomes unused release_agent - configures/reports the release agent to be used for this hierarchy (top level in each hierarchy only) releasable - reports whether this cgroup would have been auto-released if notify_on_release was true and a release agent was configured (mainly useful for debugging) To avoid locking issues, invoking the userspace release agent is done via a workqueue task; cgroups that need to have their release agents invoked by the workqueue task are linked on to a list. Signed-off-by: Paul Menage <menage@google.com> Cc: Serge E. Hallyn <serue@us.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Paul Jackson <pj@sgi.com> Cc: Kirill Korotaev <dev@openvz.org> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/cgroup.h | 11 kernel/cgroup.c | 425 ++++++++++++++++++++++++++++++++---- 2 files changed, 393 insertions(+), 43 deletions(-) diff -puN include/linux/cgroup.h~task-cgroupsv11-automatic-userspace-notification-of-idle-cgroups include/linux/cgroup.h --- a/include/linux/cgroup.h~task-cgroupsv11-automatic-userspace-notification-of-idle-cgroups +++ a/include/linux/cgroup.h @@ -77,10 +77,11 @@ static inline void css_get(struct contai * css_get() */ +extern void __css_put(struct cgroup_subsys_state *css); static inline void css_put(struct cgroup_subsys_state *css) { if (!test_bit(CSS_ROOT, &css->flags)) - atomic_dec(&css->refcnt); + __css_put(css); } struct cgroup { @@ -112,6 +113,13 @@ struct cgroup { * tasks in this cgroup. Protected by css_set_lock */ struct list_head css_sets; + + /* + * Linked list running through …
creator: Paul Menage
date: 2007-09-11T19:52:49-00:00

[PATCH 11/29] task containersv11 make cpusets a client of containers
type: item
description: From: Paul Menage <menage@google.com> Remove the filesystem support logic from the cpusets system and makes cpusets a cgroup subsystem The "cpuset" filesystem becomes a dummy filesystem; attempts to mount it get passed through to the cgroup filesystem with the appropriate options to emulate the old cpuset filesystem behaviour. Signed-off-by: Paul Menage <menage@google.com> Cc: Serge E. Hallyn <serue@us.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Paul Jackson <pj@sgi.com> Cc: Kirill Korotaev <dev@openvz.org> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- Documentation/cpusets.txt | 91 +- fs/proc/base.c | 4 include/linux/cgroup_subsys.h | 6 include/linux/cpuset.h | 12 include/linux/mempolicy.h | 12 include/linux/sched.h | 3 init/Kconfig | 7 kernel/cpuset.c | 1192 +++++------------------------ kernel/exit.c | 2 kernel/fork.c | 3 mm/mempolicy.c | 2 11 files changed, 278 insertions(+), 1056 deletions(-) diff -puN Documentation/cpusets.txt~task-cgroupsv11-make-cpusets-a-client-of-cgroups Documentation/cpusets.txt --- a/Documentation/cpusets.txt~task-cgroupsv11-make-cpusets-a-client-of-cgroups +++ a/Documentation/cpusets.txt @@ -7,6 +7,7 @@ Written by Simon.Derr@bull.net Portions Copyright (c) 2004-2006 Silicon Graphics, Inc. Modified by Paul Jackson <pj@sgi.com> Modified by Christoph Lameter <clameter@sgi.com> +Modified by Paul Menage <menage@google.com> CONTENTS: ========= @@ -16,10 +17,9 @@ CONTENTS: 1.2 Why are cpusets needed ? 1.3 How are cpusets implemented ? 1.4 What are exclusive cpusets ? - 1.5 What does notify_on_release do ? - 1.6 What is memory_pressure ? - 1.7 What is memory spread ? - 1.8 How do I use cpusets ? + 1.5 What is memory_pressure ? + 1.6 What is memory spread ? + 1.7 How do I use cpusets ? 2. Usage Examples and Syntax 2.1 Ba…
creator: Paul Menage
date: 2007-09-11T19:52:50-00:00

[PATCH 12/29] task containersv11 example cpu accounting subsystem
type: item
description: From: Paul Menage <menage@google.com> This example demonstrates how to use the generic cgroup subsystem for a simple resource tracker that counts, for the processes in a cgroup, the total CPU time used and the %CPU used in the last complete 10 second interval. Portions contributed by Balbir Singh <balbir@in.ibm.com> Signed-off-by: Paul Menage <menage@google.com> Cc: Serge E. Hallyn <serue@us.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Paul Jackson <pj@sgi.com> Cc: Kirill Korotaev <dev@openvz.org> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/cgroup_subsys.h | 6 include/linux/cpu_acct.h | 14 ++ init/Kconfig | 7 + kernel/Makefile | 1 kernel/cpu_acct.c | 186 +++++++++++++++++++++++++++++ kernel/sched.c | 14 +- 6 files changed, 225 insertions(+), 3 deletions(-) diff -puN include/linux/cgroup_subsys.h~task-cgroupsv11-example-cpu-accounting-subsystem include/linux/cgroup_subsys.h --- a/include/linux/cgroup_subsys.h~task-cgroupsv11-example-cpu-accounting-subsystem +++ a/include/linux/cgroup_subsys.h @@ -13,4 +13,10 @@ SUBSYS(cpuset) /* */ +#ifdef CONFIG_CGROUP_CPUACCT +SUBSYS(cpuacct) +#endif + +/* */ + /* */ diff -puN /dev/null include/linux/cpu_acct.h --- /dev/null +++ a/include/linux/cpu_acct.h @@ -0,0 +1,14 @@ + +#ifndef _LINUX_CPU_ACCT_H +#define _LINUX_CPU_ACCT_H + +#include <linux/cgroup.h> +#include <asm/cputime.h> + +#ifdef CONFIG_CGROUP_CPUACCT +extern void cpuacct_charge(struct task_struct *, cputime_t cputime); +#else +static void inline cpuacct_charge(struct task_struct *p, cputime_t cputime) {} +#endif + +#endif diff -puN init/Kconfig~task-cgroupsv11-example-cpu-accounting-subsystem init/Kconfig --- a/init/Kconfig~task-cgroupsv11-example-cpu-accounting-subsystem +++ a/init/Kconfig @@ -318,6 +318,13 @@ config PROC_PID_CPU…
creator: Paul Menage
date: 2007-09-11T19:52:51-00:00

[PATCH 13/29] task containersv11 simple task container debug info subsystem
type: item
description: From: Paul Menage <menage@google.com> This example subsystem exports debugging information as an aid to diagnosing refcount leaks, etc, in the cgroup framework. Signed-off-by: Paul Menage <menage@google.com> Cc: Serge E. Hallyn <serue@us.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Paul Jackson <pj@sgi.com> Cc: Kirill Korotaev <dev@openvz.org> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/cgroup_subsys.h | 4 + init/Kconfig | 10 ++ kernel/Makefile | 1 kernel/cgroup_debug.c | 97 +++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+) diff -puN include/linux/cgroup_subsys.h~task-cgroupsv11-simple-task-cgroup-debug-info-subsystem include/linux/cgroup_subsys.h --- a/include/linux/cgroup_subsys.h~task-cgroupsv11-simple-task-cgroup-debug-info-subsystem +++ a/include/linux/cgroup_subsys.h @@ -19,4 +19,8 @@ SUBSYS(cpuacct) /* */ +#ifdef CONFIG_CGROUP_DEBUG +SUBSYS(debug) +#endif + /* */ diff -puN init/Kconfig~task-cgroupsv11-simple-task-cgroup-debug-info-subsystem init/Kconfig --- a/init/Kconfig~task-cgroupsv11-simple-task-cgroup-debug-info-subsystem +++ a/init/Kconfig @@ -282,6 +282,16 @@ config CGROUPS Say N if unsure. +config CGROUP_DEBUG + bool "Example debug cgroup subsystem" + depends on CGROUPS + help + This option enables a simple cgroup subsystem that + exports useful debugging information about the cgroups + framework + + Say N if unsure + config CPUSETS bool "Cpuset support" depends on SMP && CGROUPS diff -puN kernel/Makefile~task-cgroupsv11-simple-task-cgroup-debug-info-subsystem kernel/Makefile --- a/kernel/Makefile~task-cgroupsv11-simple-task-cgroup-debug-info-subsystem +++ a/kernel/Makefile @@ -39,6 +39,7 @@ obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o obj-$(CONFIG_KEXEC) += kexec.o obj-$(CONFIG_COMPAT) += compat.o ob…
creator: Paul Menage
date: 2007-09-11T19:52:52-00:00

[PATCH 14/29] add containerstats v3
type: item
description: From: Balbir Singh <balbir@linux.vnet.ibm.com> This patch is inspired by the discussion at http://lkml.org/lkml/2007/4/11/187 and implements per cgroup statistics as suggested by Andrew Morton in http://lkml.org/lkml/2007/4/11/263. The patch is on top of 2.6.21-mm1 with Paul's cgroups v9 patches (forward ported) This patch implements per cgroup statistics infrastructure and re-uses code from the taskstats interface. A new set of cgroup operations are registered with commands and attributes. It should be very easy to *extend* per cgroup statistics, by adding members to the cgroupstats structure. The current model for cgroupstats is a pull, a push model (to post statistics on interesting events), should be very easy to add. Currently user space requests for statistics by passing the cgroup file descriptor. Statistics about the state of all the tasks in the cgroup is returned to user space. TODO's/NOTE: This patch provides an infrastructure for implementing cgroup statistics. Based on the needs of each controller, we can incrementally add more statistics, event based support for notification of statistics, accumulation of taskstats into cgroup statistics in the future. Sample output # ./cgroupstats -C /cgroup/a sleeping 2, blocked 0, running 1, stopped 0, uninterruptible 0 # ./cgroupstats -C /cgroup/ sleeping 154, blocked 0, running 0, stopped 0, uninterruptible 0 If the approach looks good, I'll enhance and post the user space utility for the same Feedback, comments, test results are always welcome! Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Paul Menage <menage@google.com> Cc: Jay Lan <jlan@engr.sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- Documentation/accounting/cgroupstats.txt | 27 ++++++ include/linux/Kbuild | 1 include/linux/cgroup.h | 8 ++ include/linux/cgroupstats.h | 70 ++++++++++++++++++ include/linux/delayacct.h | 13 +++ kernel/cgroup.c | 55 ++++++++++++++ kernel/taskstats.c | 66 ++++++++++++++++ 7 files changed, 240…
creator: Paul Menage
date: 2007-09-11T19:52:53-00:00

[PATCH 15/29] add containerstats v3 fix
type: item
description: From: Andrew Morton <akpm@linux-foundation.org> kernel/taskstats.c: In function 'cgroupstats_user_cmd': kernel/taskstats.c:414: error: dereferencing pointer to incomplete type Cc: Paul Menage <menage@google.com> Cc: Jay Lan <jlan@engr.sgi.com> Cc: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- kernel/taskstats.c | 1 + 1 file changed, 1 insertion(+) diff -puN kernel/taskstats.c~add-cgroupstats-v3-fix kernel/taskstats.c --- a/kernel/taskstats.c~add-cgroupstats-v3-fix +++ a/kernel/taskstats.c @@ -24,6 +24,7 @@ #include <linux/percpu.h> #include <linux/cgroupstats.h> #include <linux/cgroup.h> +#include <linux/fs.h> #include <linux/file.h> #include <net/genetlink.h> #include <asm/atomic.h> _ -- _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Paul Menage
date: 2007-09-11T19:52:54-00:00

[PATCH 16/29] containers implement namespace tracking subsystem
type: item
description: From: "Serge E. Hallyn" <serue@us.ibm.com> When a task enters a new namespace via a clone() or unshare(), a new cgroup is created and the task moves into it. This version names cgroups which are automatically created using cgroup_clone() as "node_<pid>" where pid is the pid of the unsharing or cloned process. (Thanks Pavel for the idea) This is safe because if the process unshares again, it will create /cgroups/(...)/node_<pid>/node_<pid> The only possibilities (AFAICT) for a -EEXIST on unshare are 1. pid wraparound 2. a process fails an unshare, then tries again. Case 1 is unlikely enough that I ignore it (at least for now). In case 2, the node_<pid> will be empty and can be rmdir'ed to make the subsequent unshare() succeed. Changelog: Name cloned cgroups as "node_<pid>". Signed-off-by: Serge E. Hallyn <serue@us.ibm.com> Cc: Paul Menage <menage@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/cgroup_subsys.h | 6 + include/linux/nsproxy.h | 7 ++ init/Kconfig | 9 ++ kernel/Makefile | 1 kernel/ns_cgroup.c | 100 +++++++++++++++++++++++++++++ kernel/nsproxy.c | 17 ++++ 6 files changed, 139 insertions(+), 1 deletion(-) diff -puN include/linux/cgroup_subsys.h~cgroups-implement-namespace-tracking-subsystem include/linux/cgroup_subsys.h --- a/include/linux/cgroup_subsys.h~cgroups-implement-namespace-tracking-subsystem +++ a/include/linux/cgroup_subsys.h @@ -24,3 +24,9 @@ SUBSYS(debug) #endif /* */ + +#ifdef CONFIG_CGROUP_NS +SUBSYS(ns) +#endif + +/* */ diff -puN include/linux/nsproxy.h~cgroups-implement-namespace-tracking-subsystem include/linux/nsproxy.h --- a/include/linux/nsproxy.h~cgroups-implement-namespace-tracking-subsystem +++ a/include/linux/nsproxy.h @@ -55,4 +55,11 @@ static inline void exit_task_namespaces( put_nsproxy(ns); } } + +#ifdef CONFIG_CGROUP_NS +int ns_cgroup_clone(struct task_struct *tsk); +#else +static inline int ns_cgroup_clone(struct task_struct *tsk) { return 0; } +#endif + #endif diff -puN init/Kconfig~cgrou…
creator: Paul Menage
date: 2007-09-11T19:52:55-00:00

[PATCH 17/29] containers implement namespace tracking subsystem fix order of container subsystems in
type: item
description: From: Cedric Le Goater <clg@fr.ibm.com> some cosmetic changes to init/Kconfig to make the subsystem list under cgroups look nicer when CONFIG_CGROUPS=y. also changed the 'select' to 'depends on' for the namespace subsystem. Signed-off-by: Cedric Le Goater <clg@fr.ibm.com> Acked-by: Paul Menage <menage@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- init/Kconfig | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff -puN init/Kconfig~cgroups-implement-namespace-tracking-subsystem-fix-order-of-cgroup-subsystems-in-init-kconfig init/Kconfig --- a/init/Kconfig~cgroups-implement-namespace-tracking-subsystem-fix-order-of-cgroup-subsystems-in-init-kconfig +++ a/init/Kconfig @@ -292,6 +292,22 @@ config CGROUP_DEBUG Say N if unsure +config CGROUP_NS + bool "Namespace cgroup subsystem" + depends on CGROUPS + help + Provides a simple namespace cgroup subsystem to + provide hierarchical naming of sets of namespaces, + for instance virtual servers and checkpoint/restart + jobs. + +config CGROUP_CPUACCT + bool "Simple CPU accounting cgroup subsystem" + depends on CGROUPS + help + Provides a simple Resource Controller for monitoring the + total CPU consumed by the tasks in a cgroup + config CPUSETS bool "Cpuset support" depends on SMP && CGROUPS @@ -323,27 +339,11 @@ config SYSFS_DEPRECATED If you are using a distro that was released in 2006 or later, it should be safe to say N here. -config CGROUP_NS - bool "Namespace cgroup subsystem" - select CGROUPS - help - Provides a simple namespace cgroup subsystem to - provide hierarchical naming of sets of namespaces, - for instance virtual servers and checkpoint/restart - jobs. - config PROC_PID_CPUSET bool "Include legacy /proc/<pid>/cpuset file" depends on CPUSETS default y -config CGROUP_CPUACCT - bool "Simple CPU accounting cgroup subsystem" - depends on CGROUPS - help - Provides a simple Resource Controller for monitoring the - total CPU consumed by the tasks in a cgrou…
creator: Paul Menage
date: 2007-09-11T19:52:56-00:00

[PATCH 18/29] memory controller add documentation
type: item
description: From: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Pavel Emelianov <xemul@openvz.org> Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Kirill Korotaev <dev@sw.ru> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: David Rientjes <rientjes@google.com> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- Documentation/controllers/memory.txt | 259 +++++++++++++++++++++++++ 1 files changed, 259 insertions(+) diff -puN /dev/null Documentation/controllers/memory.txt --- /dev/null +++ a/Documentation/controllers/memory.txt @@ -0,0 +1,259 @@ +Memory Controller + +Salient features + +a. Enable control of both RSS (mapped) and Page Cache (unmapped) pages +b. The infrastructure allows easy addition of other types of memory to control +c. Provides *zero overhead* for non memory controller users +d. Provides a double LRU: global memory pressure causes reclaim from the + global LRU; a cgroup on hitting a limit, reclaims from the per + cgroup LRU + +NOTE: Page Cache (unmapped) also includes Swap Cache pages as a subset +and will not be referred to explicitly in the rest of the documentation. + +Benefits and Purpose of the memory controller + +The memory controller isolates the memory behaviour of a group of tasks +from the rest of the system. The article on LWN [12] mentions some probable +uses of the memory controller. The memory controller can be used to + +a. Isolate an application or a group of applications + Memory hungry applications can be isolated and limited to a smaller + amount of memory. +b. Create a cgroup with limited amount of memory, this can be used + as a good alternative to booting with mem=XXXX. +c. Virtualization solutions can control the amount of memory they want + to assign to a virtual machine instance. +d. A CD/DVD burn…
creator: Paul Menage
date: 2007-09-11T19:52:57-00:00

[PATCH 19/29] memory controller resource counters v7
type: item
description: From: Pavel Emelianov <xemul@openvz.org> Introduce generic structures and routines for resource accounting. Each resource accounting cgroup is supposed to aggregate it, cgroup_subsystem_state and its resource-specific members within. Signed-off-by: Pavel Emelianov <xemul@openvz.org> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Kirill Korotaev <dev@sw.ru> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: David Rientjes <rientjes@google.com> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/res_counter.h | 102 ++++++++++++++++++++++++++++ init/Kconfig | 7 + kernel/Makefile | 1 kernel/res_counter.c | 120 ++++++++++++++++++++++++++++++++++ 4 files changed, 230 insertions(+) diff -puN /dev/null include/linux/res_counter.h --- /dev/null +++ a/include/linux/res_counter.h @@ -0,0 +1,102 @@ +#ifndef __RES_COUNTER_H__ +#define __RES_COUNTER_H__ + +/* + * Resource Counters + * Contain common data types and routines for resource accounting + * + * Copyright 2007 OpenVZ SWsoft Inc + * + * Author: Pavel Emelianov <xemul@openvz.org> + * + */ + +#include <linux/cgroup.h> + +/* + * The core object. the cgroup that wishes to account for some + * resource may include this counter into its structures and use + * the helpers described beyond + */ + +struct res_counter { + /* + * the current resource consumption level + */ + unsigned long usage; + /* + * the limit that usage cannot exceed + */ + unsigned long limit; + /* + * the number of unsuccessful attempts to consume the resource + */ + unsigned long failcnt; + /* + * the lock to protect all of the above. + * the routines below consider this to be IRQ-safe + */ + spinlock_t lock; +}; + +/* + * Helpers to interact with userspace + * res_counter_read/_write - put/get the specifi…
creator: Paul Menage
date: 2007-09-11T19:52:58-00:00

[PATCH 20/29] memory controller resource counters v7 fix
type: item
description: From: David Rientjes <rientjes@google.com> There's a gotcha in res_counter_charge_locked() because of C99 6.3.1.8(1) since both counter->limit and 'val' are of unsigned long type, the result of the subtraction will be the same; no promotion is required. So if 'val' is greater than counter->limit, it will always be larger than counter->usage and the conditional will fail. Simply casting this to signed doesn't work since counter->usage is also unsigned and thus the result of the subtraction will be promoted to unsigned since the ranks are the same. Even though the only (current) use of res_counter_charge() is with a 'val' actual of 1, this still fails if you set counter->limit to 0. No chance of overflow unless you're running on a machine with 4KB pages and 16TB of memory. Signed-off-by: David Rientjes <rientjes@google.com> Cc: Pavel Emelianov <xemul@openvz.org> Cc: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- kernel/res_counter.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) diff -puN kernel/res_counter.c~memory-controller-resource-counters-v7-fix kernel/res_counter.c --- a/kernel/res_counter.c~memory-controller-resource-counters-v7-fix +++ a/kernel/res_counter.c @@ -21,7 +21,7 @@ void res_counter_init(struct res_counter int res_counter_charge_locked(struct res_counter *counter, unsigned long val) { - if (counter->usage > (counter->limit - val)) { + if (counter->usage + val > counter->limit) { counter->failcnt++; return -ENOMEM; } _ -- _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Paul Menage
date: 2007-09-11T19:52:59-00:00

[PATCH 21/29] memory controller containers setup v7
type: item
description: From: Balbir Singh <balbir@linux.vnet.ibm.com> Setup the memory cgroup and add basic hooks and controls to integrate and work with the cgroup. Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Pavel Emelianov <xemul@openvz.org> Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Kirill Korotaev <dev@sw.ru> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: David Rientjes <rientjes@google.com> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/cgroup_subsys.h | 6 + include/linux/memcontrol.h | 21 ++++ init/Kconfig | 7 + mm/Makefile | 1 mm/memcontrol.c | 127 +++++++++++++++++++++++++++++ 5 files changed, 162 insertions(+) diff -puN include/linux/cgroup_subsys.h~memory-controller-cgroups-setup-v7 include/linux/cgroup_subsys.h --- a/include/linux/cgroup_subsys.h~memory-controller-cgroups-setup-v7 +++ a/include/linux/cgroup_subsys.h @@ -30,3 +30,9 @@ SUBSYS(ns) #endif /* */ + +#ifdef CONFIG_CGROUP_MEM_CONT +SUBSYS(mem_cgroup) +#endif + +/* */ diff -puN /dev/null include/linux/memcontrol.h --- /dev/null +++ a/include/linux/memcontrol.h @@ -0,0 +1,21 @@ +/* memcontrol.h - Memory Controller + * + * Copyright IBM Corporation, 2007 + * Author Balbir Singh <balbir@linux.vnet.ibm.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef _LINUX_MEMCONTROL_H +#define _LINUX_MEMCONTROL_H + +#endif /* _LINUX_MEM…
creator: Paul Menage
date: 2007-09-11T19:53:00-00:00

[PATCH 22/29] memory controller accounting setup v7
type: item
description: From: Pavel Emelianov <xemul@openvz.org> Basic setup routines, the mm_struct has a pointer to the cgroup that it belongs to and the the page has a page_cgroup associated with it. Signed-off-by: Pavel Emelianov <xemul@openvz.org> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Kirill Korotaev <dev@sw.ru> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/memcontrol.h | 36 ++++++++++++++++++++++ include/linux/mm_types.h | 6 +++ include/linux/sched.h | 1 kernel/fork.c | 11 ++++-- mm/memcontrol.c | 57 ++++++++++++++++++++++++++++++++--- 5 files changed, 104 insertions(+), 7 deletions(-) diff -puN include/linux/memcontrol.h~memory-controller-accounting-setup-v7 include/linux/memcontrol.h --- a/include/linux/memcontrol.h~memory-controller-accounting-setup-v7 +++ a/include/linux/memcontrol.h @@ -3,6 +3,9 @@ * Copyright IBM Corporation, 2007 * Author Balbir Singh <balbir@linux.vnet.ibm.com> * + * Copyright 2007 OpenVZ SWsoft Inc + * Author: Pavel Emelianov <xemul@openvz.org> + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -17,5 +20,38 @@ #ifndef _LINUX_MEMCONTROL_H #define _LINUX_MEMCONTROL_H +struct mem_cgroup; +struct page_cgroup; + +#ifdef CONFIG_CGROUP_MEM_CONT + +extern void mm_init_cgroup(struct mm_struct *mm, struct task_struct *p); +extern void mm_free_cgroup(struct mm_struct *mm); +extern void page_assign_page_cgroup(struct page *page, + struct page_cgroup *pc); +extern struct page_cgroup *page_get_page_cgroup(struct page *page); + +#else /* CONFIG_CGROUP_MEM_CONT */ +static inline void mm_init_cgroup(struct mm_stru…
creator: Paul Menage
date: 2007-09-11T19:53:01-00:00

[PATCH 23/29] memory controller memory accounting v7
type: item
description: From: Balbir Singh <balbir@linux.vnet.ibm.com> Add the accounting hooks. The accounting is carried out for RSS and Page Cache (unmapped) pages. There is now a common limit and accounting for both. The RSS accounting is accounted at page_add_*_rmap() and page_remove_rmap() time. Page cache is accounted at add_to_page_cache(), __delete_from_page_cache(). Swap cache is also accounted for. Each page's page_cgroup is protected with the last bit of the page_cgroup pointer, this makes handling of race conditions involving simultaneous mappings of a page easier. A reference count is kept in the page_cgroup to deal with cases where a page might be unmapped from the RSS of all tasks, but still lives in the page cache. Credits go to Vaidyanathan Srinivasan for helping with reference counting work of the page cgroup. Almost all of the page cache accounting code has help from Vaidyanathan Srinivasan. Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Pavel Emelianov <xemul@openvz.org> Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Kirill Korotaev <dev@sw.ru> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/memcontrol.h | 20 ++++ mm/filemap.c | 12 ++ mm/memcontrol.c | 166 ++++++++++++++++++++++++++++++++++- mm/memory.c | 43 ++++++++- mm/migrate.c | 6 + mm/page_alloc.c | 3 mm/rmap.c | 17 +++ mm/swap_state.c | 12 ++ mm/swapfile.c | 41 +++++--- 9 files changed, 293 insertions(+), 27 deletions(-) diff -puN include/linux/memcontrol.h~memory-controller-memory-accounting-v7 include/linux/memcontrol.h --- a/include/linux/memcontrol.h~memory-controller-memory-accounting-v7 +++ a/include/linux/memcontrol.h @@ -30,6 +30,13 @@ extern void mm_free_cgroup(struct mm_ extern void page_assi…
creator: Paul Menage
date: 2007-09-11T19:53:02-00:00

[PATCH 24/29] memory controller task migration v7
type: item
description: From: Balbir Singh <balbir@linux.vnet.ibm.com> Allow tasks to migrate from one cgroup to the other. We migrate mm_struct's mem_cgroup only when the thread group id migrates. Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Pavel Emelianov <xemul@openvz.org> Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Kirill Korotaev <dev@sw.ru> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: David Rientjes <rientjes@google.com> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- mm/memcontrol.c | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+) diff -puN mm/memcontrol.c~memory-controller-task-migration-v7 mm/memcontrol.c --- a/mm/memcontrol.c~memory-controller-task-migration-v7 +++ a/mm/memcontrol.c @@ -326,11 +326,46 @@ static int mem_cgroup_populate(struct ARRAY_SIZE(mem_cgroup_files)); } +static void mem_cgroup_move_task(struct cgroup_subsys *ss, + struct cgroup *cont, + struct cgroup *old_cont, + struct task_struct *p) +{ + struct mm_struct *mm; + struct mem_cgroup *mem, *old_mem; + + mm = get_task_mm(p); + if (mm == NULL) + return; + + mem = mem_cgroup_from_cont(cont); + old_mem = mem_cgroup_from_cont(old_cont); + + if (mem == old_mem) + goto out; + + /* + * Only thread group leaders are allowed to migrate, the mm_struct is + * in effect owned by the leader + */ + if (p->tgid != p->pid) + goto out; + + css_get(&mem->css); + rcu_assign_pointer(mm->mem_cgroup, mem); + css_put(&old_mem->css); + +out: + mmput(mm); + return; +} + struct cgroup_subsys mem_cgroup_subsys = { .name = "memory", .subsys_id = mem_cgroup_subsys_id, .create = mem_cgroup_create, .destroy = mem_cgroup_destroy, .populate = mem_cgroup_populate, + .attach = mem_cgroup_move_task, .early_init = 1, }; _ -- _______________________________________________ Containers mailing list Containers@list…
creator: Paul Menage
date: 2007-09-11T19:53:03-00:00

[PATCH 25/29] memory controller add per container lru and reclaim v7
type: item
description: From: Balbir Singh <balbir@linux.vnet.ibm.com> Add the page_cgroup to the per cgroup LRU. The reclaim algorithm has been modified to make the isolate_lru_pages() as a pluggable component. The scan_control data structure now accepts the cgroup on behalf of which reclaims are carried out. try_to_free_pages() has been extended to become cgroup aware. Signed-off-by: Pavel Emelianov <xemul@openvz.org> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Kirill Korotaev <dev@sw.ru> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: David Rientjes <rientjes@google.com> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/memcontrol.h | 12 +++ include/linux/res_counter.h | 23 +++++ include/linux/swap.h | 3 mm/memcontrol.c | 135 +++++++++++++++++++++++++++++++++- mm/swap.c | 2 mm/vmscan.c | 126 +++++++++++++++++++++++++------ 6 files changed, 275 insertions(+), 26 deletions(-) diff -puN include/linux/memcontrol.h~memory-controller-add-per-cgroup-lru-and-reclaim-v7 include/linux/memcontrol.h --- a/include/linux/memcontrol.h~memory-controller-add-per-cgroup-lru-and-reclaim-v7 +++ a/include/linux/memcontrol.h @@ -32,6 +32,13 @@ extern void page_assign_page_cgroup(s extern struct page_cgroup *page_get_page_cgroup(struct page *page); extern int mem_cgroup_charge(struct page *page, struct mm_struct *mm); extern void mem_cgroup_uncharge(struct page_cgroup *pc); +extern void mem_cgroup_move_lists(struct page_cgroup *pc, bool active); +extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, + struct list_head *dst, + unsigned long *scanned, int order, + int mode, struct zone *z, + struct mem_cgroup *mem_cont, + int active); static inline void mem_cgroup_uncharge_page(struct page *page) { @@ -71,6 +78,11 @@ static inline vo…
creator: Paul Menage
date: 2007-09-11T19:53:04-00:00

[PATCH 26/29] memory controller add per container lru and reclaim v7 fix
type: item
description: From: Andrew Morton <akpm@linux-foundation.org> mm/memcontrol.c: In function 'mem_cgroup_charge': mm/memcontrol.c:337: error: implicit declaration of function 'congestion_wait' Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: David Rientjes <rientjes@google.com> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Kirill Korotaev <dev@sw.ru> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Paul Menage <menage@google.com> Cc: Pavel Emelianov <xemul@openvz.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- mm/memcontrol.c | 1 + 1 file changed, 1 insertion(+) diff -puN mm/memcontrol.c~memory-controller-add-per-cgroup-lru-and-reclaim-v7-fix mm/memcontrol.c --- a/mm/memcontrol.c~memory-controller-add-per-cgroup-lru-and-reclaim-v7-fix +++ a/mm/memcontrol.c @@ -22,6 +22,7 @@ #include <linux/cgroup.h> #include <linux/mm.h> #include <linux/page-flags.h> +#include <linux/backing-dev.h> #include <linux/bit_spinlock.h> #include <linux/rcupdate.h> #include <linux/swap.h> _ -- _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Paul Menage
date: 2007-09-11T19:53:05-00:00

[PATCH 27/29] memory controller oom handling v7
type: item
description: From: Pavel Emelianov <xemul@openvz.org> Out of memory handling for cgroups over their limit. A task from the cgroup over limit is chosen using the existing OOM logic and killed. TODO: 1. As discussed in the OLS BOF session, consider implementing a user space policy for OOM handling. Signed-off-by: Pavel Emelianov <xemul@openvz.org> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Kirill Korotaev <dev@sw.ru> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: David Rientjes <rientjes@google.com> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/memcontrol.h | 1 mm/memcontrol.c | 1 mm/oom_kill.c | 42 +++++++++++++++++++++++++++++++---- 3 files changed, 40 insertions(+), 4 deletions(-) diff -puN include/linux/memcontrol.h~memory-controller-oom-handling-v7 include/linux/memcontrol.h --- a/include/linux/memcontrol.h~memory-controller-oom-handling-v7 +++ a/include/linux/memcontrol.h @@ -39,6 +39,7 @@ extern unsigned long mem_cgroup_isola int mode, struct zone *z, struct mem_cgroup *mem_cont, int active); +extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem); static inline void mem_cgroup_uncharge_page(struct page *page) { diff -puN mm/memcontrol.c~memory-controller-oom-handling-v7 mm/memcontrol.c --- a/mm/memcontrol.c~memory-controller-oom-handling-v7 +++ a/mm/memcontrol.c @@ -322,6 +322,7 @@ int mem_cgroup_charge(struct page *pa } css_put(&mem->css); + mem_cgroup_out_of_memory(mem); goto free_pc; } diff -puN mm/oom_kill.c~memory-controller-oom-handling-v7 mm/oom_kill.c --- a/mm/oom_kill.c~memory-controller-oom-handling-v7 +++ a/mm/oom_kill.c @@ -25,6 +25,7 @@ #include <linux/cpuset.h> #include <linux/module.h> #include <linux/notifier.h> +#include <linux/memcontrol.h> int sysctl_panic_on_oom; /* #define DEBUG *…
creator: Paul Menage
date: 2007-09-11T19:53:06-00:00

[PATCH 28/29] memory controller add switch to control what type of pages to limit v7
type: item
description: From: Balbir Singh <balbir@linux.vnet.ibm.com> Choose if we want cached pages to be accounted or not. By default both are accounted for. A new set of tunables are added. echo -n 1 > mem_control_type switches the accounting to account for only mapped pages echo -n 3 > mem_control_type switches the behaviour back Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Pavel Emelianov <xemul@openvz.org> Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Kirill Korotaev <dev@sw.ru> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: David Rientjes <rientjes@google.com> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/memcontrol.h | 9 +++ mm/filemap.c | 2 mm/memcontrol.c | 92 +++++++++++++++++++++++++++++++++++ mm/swap_state.c | 2 4 files changed, 103 insertions(+), 2 deletions(-) diff -puN include/linux/memcontrol.h~memory-controller-add-switch-to-control-what-type-of-pages-to-limit-v7 include/linux/memcontrol.h --- a/include/linux/memcontrol.h~memory-controller-add-switch-to-control-what-type-of-pages-to-limit-v7 +++ a/include/linux/memcontrol.h @@ -20,6 +20,8 @@ #ifndef _LINUX_MEMCONTROL_H #define _LINUX_MEMCONTROL_H +#include <linux/mm.h> + struct mem_cgroup; struct page_cgroup; @@ -40,6 +42,7 @@ extern unsigned long mem_cgroup_isola struct mem_cgroup *mem_cont, int active); extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem); +extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm); static inline void mem_cgroup_uncharge_page(struct page *page) { @@ -84,6 +87,12 @@ static inline void mem_cgroup_move_li { } +static inline int mem_cgroup_cache_charge(struct page *page, + struct mm_struct *mm) +{ + return 0; +} + #endif /* CONFIG_CGROUP_MEM_CONT */ #endif /* _LINUX_MEMCONTROL_H */ diff -puN mm/filemap.c~memory-controller-add-switch-to-contro…
creator: Paul Menage
date: 2007-09-11T19:53:07-00:00

[PATCH 29/29] memory controller make page_referenced container aware v7
type: item
description: From: Balbir Singh <balbir@linux.vnet.ibm.com> Make page_referenced() cgroup aware. Without this patch, page_referenced() can cause a page to be skipped while reclaiming pages. This patch ensures that other cgroups do not hold pages in a particular cgroup hostage. It is required to ensure that shared pages are freed from a cgroup when they are not actively referenced from the cgroup that brought them in Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Pavel Emelianov <xemul@openvz.org> Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Kirill Korotaev <dev@sw.ru> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: David Rientjes <rientjes@google.com> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/memcontrol.h | 6 ++++++ include/linux/rmap.h | 5 +++-- mm/memcontrol.c | 5 +++++ mm/rmap.c | 30 ++++++++++++++++++++++++------ mm/vmscan.c | 4 ++-- 5 files changed, 40 insertions(+), 10 deletions(-) diff -puN include/linux/memcontrol.h~memory-controller-make-page_referenced-cgroup-aware-v7 include/linux/memcontrol.h --- a/include/linux/memcontrol.h~memory-controller-make-page_referenced-cgroup-aware-v7 +++ a/include/linux/memcontrol.h @@ -43,6 +43,7 @@ extern unsigned long mem_cgroup_isola int active); extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem); extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm); +extern struct mem_cgroup *mm_cgroup(struct mm_struct *mm); static inline void mem_cgroup_uncharge_page(struct page *page) { @@ -93,6 +94,11 @@ static inline int mem_cgroup_cache_ch return 0; } +static inline struct mem_cgroup *mm_cgroup(struct mm_struct *mm) +{ + return NULL; +} + #endif /* CONFIG_CGROUP_MEM_CONT */ #endif /* _LINUX_MEMCONTROL_H */ diff -puN include/linux/rmap.h~memory-controller-make-page_referenced-cgroup-aware-…
creator: Paul Menage
date: 2007-09-11T19:53:08-00:00

Re: [PATCH 23/29] memory controller memory accounting v7
type: item
description: > From: Balbir Singh <balbir@linux.vnet.ibm.com> > void page_assign_page_cgroup(struct page *page, struct page_cgroup *pc) > { > - page->page_cgroup = (unsigned long)pc; > + int locked; > + > + /* > + * While resetting the page_cgroup we might not hold the > + * page_cgroup lock. free_hot_cold_page() is an example > + * of such a scenario > + */ > + if (pc) > + VM_BUG_ON(!page_cgroup_locked(page)); > + locked = (page->page_cgroup & PAGE_CGROUP_LOCK); > + page->page_cgroup = ((unsigned long)pc | locked); > } This looks a bit odd, why not write: locked = page_cgroup_locked(page); if (pc) VM_BUG_ON(!locked) > +/* > + * Charge the memory controller for page usage. > + * Return > + * 0 if the charge was successful > + * < 0 if the cgroup is over its limit > + */ > +int mem_cgroup_charge(struct page *page, struct mm_struct *mm) > +{ > + struct mem_cgroup *mem; > + struct page_cgroup *pc, *race_pc; > + > + /* > + * Should page_cgroup's go to their own slab? > + * One could optimize the performance of the charging routine > + * by saving a bit in the page_flags and using it as a lock > + * to see if the cgroup page already has a page_cgroup associated > + * with it > + */ > + lock_page_cgroup(page); > + pc = page_get_page_cgroup(page); > + /* > + * The page_cgroup exists and the page has already been accounted > + */ > + if (pc) { > + atomic_inc(&pc->ref_cnt); > + goto done; > + } > + > + unlock_page_cgroup(page); > + > + pc = kzalloc(sizeof(struct page_cgroup), GFP_KERNEL); > + if (pc == NULL) > + goto err; > + > + rcu_read_lock(); > + /* > + * We always charge the cgroup the mm_struct belongs to > + * the mm_struct's mem_cgroup changes on task migration if the > + * thread group leader migrates. It's possible that mm is not > + * set, if so charge the init_mm (happens for pagecache usage). > + */ > + if (!mm) > + mm = &init_mm; > + > + mem = rcu_dereference(mm->mem_cgroup); > + /* > + * For every charge from the cgroup, increment reference > + * count > + */ > + css_get(&…
creator: Peter Zijlstra
date: 2007-09-12T20:56:50-00:00

Re: [PATCH 23/29] memory controller memory accounting v7
type: item
description: Peter Zijlstra wrote: >> From: Balbir Singh <balbir@linux.vnet.ibm.com> > >> void page_assign_page_cgroup(struct page *page, struct page_cgroup *pc) >> { >> - page->page_cgroup = (unsigned long)pc; >> + int locked; >> + >> + /* >> + * While resetting the page_cgroup we might not hold the >> + * page_cgroup lock. free_hot_cold_page() is an example >> + * of such a scenario >> + */ >> + if (pc) >> + VM_BUG_ON(!page_cgroup_locked(page)); >> + locked = (page->page_cgroup & PAGE_CGROUP_LOCK); >> + page->page_cgroup = ((unsigned long)pc | locked); >> } > > This looks a bit odd, why not write: > > locked = page_cgroup_locked(page); > if (pc) > VM_BUG_ON(!locked) > Sure, we could write it this way or VM_BUG_ON(pc && !locked) >> +/* >> + * Charge the memory controller for page usage. >> + * Return >> + * 0 if the charge was successful >> + * < 0 if the cgroup is over its limit >> + */ >> +int mem_cgroup_charge(struct page *page, struct mm_struct *mm) >> +{ >> + struct mem_cgroup *mem; >> + struct page_cgroup *pc, *race_pc; >> + >> + /* >> + * Should page_cgroup's go to their own slab? >> + * One could optimize the performance of the charging routine >> + * by saving a bit in the page_flags and using it as a lock >> + * to see if the cgroup page already has a page_cgroup associated >> + * with it >> + */ >> + lock_page_cgroup(page); >> + pc = page_get_page_cgroup(page); >> + /* >> + * The page_cgroup exists and the page has already been accounted >> + */ >> + if (pc) { >> + atomic_inc(&pc->ref_cnt); >> + goto done; >> + } >> + >> + unlock_page_cgroup(page); >> + >> + pc = kzalloc(sizeof(struct page_cgroup), GFP_KERNEL); >> + if (pc == NULL) >> + goto err; >> + >> + rcu_read_lock(); >> + /* >> + * We always charge the cgroup the mm_struct belongs to >> + * the mm_struct's mem_cgroup changes on task migration if the >> + * thread group leader migrates. It's possible that mm is not >> + * set, if so charge the init_mm (happens for pagecache usage). >> + */ >> + if (!mm) >> + mm …
creator: Balbir Singh
date: 2007-09-13T09:49:01-00:00

Re: [PATCH 23/29] memory controller memory accounting v7
type: item
description: On Thu, 2007-09-13 at 15:19 +0530, Balbir Singh wrote: > VM_BUG_ON(pc && !locked) Even better :-) > >> +/* > >> + * Charge the memory controller for page usage. > >> + * Return > >> + * 0 if the charge was successful > >> + * < 0 if the cgroup is over its limit > >> + */ > >> +int mem_cgroup_charge(struct page *page, struct mm_struct *mm) > >> +{ > >> + struct mem_cgroup *mem; > >> + struct page_cgroup *pc, *race_pc; > >> + > >> + /* > >> + * Should page_cgroup's go to their own slab? > >> + * One could optimize the performance of the charging routine > >> + * by saving a bit in the page_flags and using it as a lock > >> + * to see if the cgroup page already has a page_cgroup associated > >> + * with it > >> + */ > >> + lock_page_cgroup(page); > >> + pc = page_get_page_cgroup(page); > >> + /* > >> + * The page_cgroup exists and the page has already been accounted > >> + */ > >> + if (pc) { > >> + atomic_inc(&pc->ref_cnt); > >> + goto done; > >> + } > >> + > >> + unlock_page_cgroup(page); > >> + > >> + pc = kzalloc(sizeof(struct page_cgroup), GFP_KERNEL); > >> + if (pc == NULL) > >> + goto err; > >> + > >> + rcu_read_lock(); > >> + /* > >> + * We always charge the cgroup the mm_struct belongs to > >> + * the mm_struct's mem_cgroup changes on task migration if the > >> + * thread group leader migrates. It's possible that mm is not > >> + * set, if so charge the init_mm (happens for pagecache usage). > >> + */ > >> + if (!mm) > >> + mm = &init_mm; > >> + > >> + mem = rcu_dereference(mm->mem_cgroup); > >> + /* > >> + * For every charge from the cgroup, increment reference > >> + * count > >> + */ > >> + css_get(&mem->css); > >> + rcu_read_unlock(); > >> + > >> + /* > >> + * If we created the page_cgroup, we should free it on exceeding > >> + * the cgroup limit. > >> + */ > >> + if (res_counter_charge(&mem->res, 1)) { > >> + css_put(&mem->css); > >> + goto free_pc; > >> + } > >> + > >> + lock_page_cgroup(page); > >> + /* > >> + * Check if somebody else beat us to allocat…
creator: Peter Zijlstra
date: 2007-09-13T10:18:01-00:00

Re: [PATCH 23/29] memory controller memory accounting v7
type: item
description: Peter Zijlstra wrote: > On Thu, 2007-09-13 at 15:19 +0530, Balbir Singh wrote: > >> VM_BUG_ON(pc && !locked) > > Even better :-) > Good, I'll change it. >> I am not sure I understand this comment. > > Is that inc needed? the pc is already associated with the page and > should thus already have a reference, so this inc would do 1->2, but we > then set it to 1 again. seems like a superfluous operation. That is something I need to look into. I'll try and get to it soon. -- 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-09-13T10:29:08-00:00

Re: [PATCH 01/29] task containersv11 basic task container framework
type: item
description: Paul M: This patch doesn't build for me in the following case. If I apply the rest of the containersv11 patches, it builds, but if I happen to bisect into this set of patches having applied only: task-containersv11-basic-task-container-framework.patch while using sn2_defconfig (with CONFIG_CGROUPS=y), then a build for arch ia64 fails with: $ make kernel/cgroup.o CHK include/linux/version.h CHK include/linux/utsrelease.h CALL scripts/checksyscalls.sh <stdin>:1389:2: warning: #warning syscall revokeat not implemented <stdin>:1393:2: warning: #warning syscall frevoke not implemented CC kernel/cgroup.o kernel/cgroup.c: In function 'cgroup_new_inode': kernel/cgroup.c:227: error: variable 'cgroup_backing_dev_info' has initializer but incomplete type kernel/cgroup.c:228: error: unknown field 'capabilities' specified in initializer kernel/cgroup.c:228: error: 'BDI_CAP_NO_ACCT_DIRTY' undeclared (first use in this function) kernel/cgroup.c:228: error: (Each undeclared identifier is reported only once kernel/cgroup.c:228: error: for each function it appears in.) kernel/cgroup.c:228: error: 'BDI_CAP_NO_WRITEBACK' undeclared (first use in this function) kernel/cgroup.c:228: warning: excess elements in struct initializer kernel/cgroup.c:228: warning: (near initialization for 'cgroup_backing_dev_info') kernel/cgroup.c:227: error: storage size of 'cgroup_backing_dev_info' isn't known kernel/cgroup.c:227: warning: unused variable 'cgroup_backing_dev_info' make[1]: *** [kernel/cgroup.o] Error 1 make: *** [kernel/cgroup.o] Error 2 I haven't tested building other partial applications of the containersv11 patch set; any initial sequence of them should build. ... also ... too bad the names of these patches all have 'container' in them, not 'cgroup'. I realize how this came to be, due to changing container to cgroup after these patches were named, but it sure would be nice if the final patch set record that gets layed down in Linus's history showed the correct name of 'cgroup' in these pa…
creator: Paul Jackson
date: 2007-09-30T04:40:43-00:00

Re: [PATCH 01/29] task containersv11 basic task container framework
type: item
description: I had to push down all of the following patches, before I could get it to build: task-containersv11-basic-task-container-framework.patch task-containersv11-basic-task-container-framework-fix.patch task-containersv11-basic-task-container-framework-containers-fix-refcount-bug.patch task-containersv11-add-tasks-file-interface.patch task-containersv11-add-fork-exit-hooks.patch task-containersv11-add-container_clone-interface.patch task-containersv11-add-container_clone-interface-containers-fix-refcount-bug.patch task-containersv11-add-procfs-interface.patch task-containersv11-add-procfs-interface-containers-bdi-init-hooks.patch task-containersv11-shared-container-subsystem-group-arrays.patch task-containersv11-shared-container-subsystem-group-arrays-avoid-lockdep-warning.patch task-containersv11-shared-container-subsystem-group-arrays-include-fix.patch That's a big stretch of forbidden territory for innocent bisecters. -- I won't rest till it's the best ... Programmer, Linux Scalability Paul Jackson <pj@sgi.com> 1.925.600.0401 _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Paul Jackson
date: 2007-09-30T05:10:30-00:00

Re: [PATCH 01/29] task containersv11 basic task container framework
type: item
description: And then I pushed just one more patch: task-containersv11-automatic-userspace-notification-of-idle-containers.patch and the build died again: $ make kernel/cgroup.o CHK include/linux/version.h CHK include/linux/utsrelease.h CALL scripts/checksyscalls.sh <stdin>:1389:2: warning: #warning syscall revokeat not implemented <stdin>:1393:2: warning: #warning syscall frevoke not implemented CC kernel/cgroup.o kernel/cgroup.c: In function 'cgroup_release_agent': kernel/cgroup.c:2725: error: implicit declaration of function 'call_usermodehelper' kernel/cgroup.c:2725: error: 'UMH_WAIT_EXEC' undeclared (first use in this function) kernel/cgroup.c:2725: error: (Each undeclared identifier is reported only once kernel/cgroup.c:2725: error: for each function it appears in.) make[1]: *** [kernel/cgroup.o] Error 1 make: *** [kernel/cgroup.o] Error 2 -- I won't rest till it's the best ... Programmer, Linux Scalability Paul Jackson <pj@sgi.com> 1.925.600.0401 _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Paul Jackson
date: 2007-09-30T05:14:25-00:00

Re: [PATCH 11/29] task containersv11 make cpusets a client of containers
type: item
description: There are some 21 mentions of 'manage_mutex' in the comments of kernel/cpuset.c remaining after this patch is applied, but no such mutex exists anymore. Could you update kernel/cpuset.c comments, Paul M., for this and whatever other changes apply ? -- I won't rest till it's the best ... Programmer, Linux Scalability Paul Jackson <pj@sgi.com> 1.925.600.0401 _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Paul Jackson
date: 2007-09-30T06:25:13-00:00

Re: [PATCH 01/29] task containersv11 basic task container framework
type: item
description: On 9/29/07, Paul Jackson <pj@sgi.com> wrote: > Paul M: > > This patch doesn't build for me in the following case. If I apply the > rest of the containersv11 patches, it builds, but if I happen to bisect > into this set of patches having applied only: These patches weren't the normal style of incremental patchset - they were direct substitutions of the previous patches in Andrew's -mm tree. Andrew's approach when encountering patches that are, e.g. missing includes on some architectures, is to add a *-fix.patch to the series; in this case it looks as though the fix for the missing ia64 include was added towards the end of the series rather than directly after the patch that needed it. Hence the fact that you couldn't compile until that later patch had been pushed. Andrew, is it practical for you to collapse any *-fix.patch files for cgroups into the appropriate patches that they fix? That would simplify the patch set a bit. > > task-containersv11-basic-task-container-framework.patch > > while using sn2_defconfig (with CONFIG_CGROUPS=y), then a build for > arch ia64 fails with: > > > $ make kernel/cgroup.o > CHK include/linux/version.h > CHK include/linux/utsrelease.h > CALL scripts/checksyscalls.sh > <stdin>:1389:2: warning: #warning syscall revokeat not implemented > <stdin>:1393:2: warning: #warning syscall frevoke not implemented > CC kernel/cgroup.o > kernel/cgroup.c: In function 'cgroup_new_inode': > kernel/cgroup.c:227: error: variable 'cgroup_backing_dev_info' has initializer but incomplete type > kernel/cgroup.c:228: error: unknown field 'capabilities' specified in initializer > kernel/cgroup.c:228: error: 'BDI_CAP_NO_ACCT_DIRTY' undeclared (first use in this function) > kernel/cgroup.c:228: error: (Each undeclared identifier is reported only once > kernel/cgroup.c:228: error: for each function it appears in.) > kernel/cgroup.c:228: error: 'BDI_CAP_NO_WRITEBACK' undeclared (first use in this function) > kernel/cgroup.c:228: warning: excess elements in struct …
creator: Paul Menage
date: 2007-09-30T07:10:18-00:00

Re: [PATCH 11/29] task containersv11 make cpusets a client of containers
type: item
description: On 9/29/07, Paul Jackson <pj@sgi.com> wrote: > There are some 21 mentions of 'manage_mutex' in the comments of > kernel/cpuset.c remaining after this patch is applied, but no such > mutex exists anymore. > Oops, sorry - fixing this is on my todo list. Paul _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Paul Menage
date: 2007-09-30T07:11:18-00:00

Re: [PATCH 11/29] task containersv11 make cpusets a client of containers
type: item
description: > fixing this is on my todo list. thanks! -- I won't rest till it's the best ... Programmer, Linux Scalability Paul Jackson <pj@sgi.com> 1.925.600.0401 _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Paul Jackson
date: 2007-09-30T07:19:15-00:00

Re: [PATCH 01/29] task containersv11 basic task container framework
type: item
description: On Sun, 30 Sep 2007 00:10:18 -0700 "Paul Menage" <menage@google.com> wrote: > On 9/29/07, Paul Jackson <pj@sgi.com> wrote: > > Paul M: > > > > This patch doesn't build for me in the following case. If I apply the > > rest of the containersv11 patches, it builds, but if I happen to bisect > > into this set of patches having applied only: > > These patches weren't the normal style of incremental patchset - they > were direct substitutions of the previous patches in Andrew's -mm > tree. > > Andrew's approach when encountering patches that are, e.g. missing > includes on some architectures, is to add a *-fix.patch to the series; > in this case it looks as though the fix for the missing ia64 include > was added towards the end of the series rather than directly after the > patch that needed it. It makes my poor little life heaps easier if people can refer to patches via their original Subject: or, better, their filename in the -mm patch series. I have vague memories that one of the container/cgroup fixup patches was a bit of a jumbo patch which intersected multiple preceding patches. Often I will refactor such a patch into several little *-fix.patch patches so that everything lands nicely, but this time it was all too much effort and I just jammmed <whichever patch it was> onto the tail of the queue. And I think that's OK, because we don't care about git bisectability with CONFIG_CGROUPS=y (I think?) Anyone who is bisecting through the middle of the containers patch series is not searching for a containers problem, so they can just configure it all off. If we broke the build when CONFIG_CGROUPS=n then yeah, that's a problem. wrt Paul's observation: > ... also ... too bad the names of these patches all have 'container' in > them, not 'cgroup'. I realize how this came to be, due to changing > container to cgroup after these patches were named, but it sure would > be nice if the final patch set record that gets layed down in Linus's > history showed the correct name of 'cgr…
creator: akpm
date: 2007-09-30T09:03:30-00:00

Re: [PATCH 01/29] task containersv11 basic task container framework
type: item
description: Andrew wrote: > And I think that's OK, because we don't care about git bisectability with > CONFIG_CGROUPS=y (I think?) Anyone who is bisecting through the middle of > the containers patch series is not searching for a containers problem, so > they can just configure it all off. Ok - I guess. In *-mm, this seems fine. I'd have figured that in Linus's tree, a wider variety of people will be bisecting, some of them with CONFIG_CGROUPS=y who don't even know what a CGROUP is, and so we'd want bisect to work for them. But you (Andrew) would know better than I. > that'll be OK. The "task-containers" text appears only in the filenmaes in > the -mm patch series. Those filenames don't make an appearance in the git > tree at all, so I didn't bother renaming all the files. Ah - ok - good. -- I won't rest till it's the best ... Programmer, Linux Scalability Paul Jackson <pj@sgi.com> 1.925.600.0401 _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Paul Jackson
date: 2007-09-30T09:15:36-00:00

Re: [PATCH 01/29] task containersv11 basic task container framework
type: item
description: On Sun, 30 Sep 2007 02:15:36 -0700 Paul Jackson <pj@sgi.com> wrote: > Andrew wrote: > > And I think that's OK, because we don't care about git bisectability with > > CONFIG_CGROUPS=y (I think?) Anyone who is bisecting through the middle of > > the containers patch series is not searching for a containers problem, so > > they can just configure it all off. > > Ok - I guess. > > In *-mm, this seems fine. I'd have figured that in Linus's tree, a wider > variety of people will be bisecting, some of them with CONFIG_CGROUPS=y > who don't even know what a CGROUP is, and so we'd want bisect to work > for them. Well obviously the situation is less than ideal, but it's livable with. If one of their bisection points precedes the crgroups patch series, their `make oldconfig' will knock out cgroups for them anyway, so when their bisection cursor moves within or after the cgroups patches, they'll still have CONFIG_CGROUPS=n. Serendipity. _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: akpm
date: 2007-09-30T09:29:42-00:00

Re: [PATCH 01/29] task containersv11 basic task container framework
type: item
description: Andrew wrote: > so when > their bisection cursor moves within or after the cgroups patches, they'll > still have CONFIG_CGROUPS=n. Serendipity. Unless it's one of the configs that enables cgroups by default, thanks to the patch: task-containers-enable-containers-by-default-in-some-configs.patch namely configs: arch/ia64/configs/sn2_defconfig | 1 + arch/mips/configs/ip27_defconfig | 1 + arch/mips/configs/sb1250-swarm_defconfig | 1 + arch/powerpc/configs/cell_defconfig | 1 + arch/powerpc/configs/ppc64_defconfig | 1 + arch/powerpc/configs/pseries_defconfig | 1 + But these are not commonly used configs, so that's not a big deal. So ... yeah ... good enough. -- I won't rest till it's the best ... Programmer, Linux Scalability Paul Jackson <pj@sgi.com> 1.925.600.0401 _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Paul Jackson
date: 2007-09-30T09:36:03-00:00