Home » Mailing lists » Devel » [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy! [message #17625 is a reply to message #17605] |
Thu, 08 March 2007 18:13   |
Srivatsa Vaddagiri
Messages: 241 Registered: August 2006
|
Senior Member |
|
|
On Wed, Mar 07, 2007 at 11:00:31PM +0530, Srivatsa Vaddagiri wrote:
> > I'd like to see that. I suspect it will be a bit more fiddly than the
> > simple cpu_acct subsystem.
>
> I am almost done with the conversion. And yes cpuset is a beast to
> convert over! Will test and send the patches out tomorrow.
Ok ..I am not in a state yet where I can post the patches to lkml in the
usual conventions (breaking down neatly/good documentation etc). But I
do have something which seems to work! I could mount cpuset as:
mount -t rcfs -ocpuset none cpuset
cd cpuset
mkdir a
cd a
cat tasks # shows nothing
echo 7 > cpus
echo 0 > mems
echo 1 > cpu_exclusive
echo some_pid > tasks
cat tasks # shows some_pid
top now shows some_pid running on CPU7, as expected :)
Instead of the usual convention of inlining patches and sending them in
separate mails, I am sending all of them as attachments (beware, bugs around!).
But this gives you an idea on which direction this is proceeding ..
Todo:
- Introduce refcounting of resource objects (get/put_res_ns)
- rmdir needs to check resource object refcount rather than
nsproxy's
- Trace couple of other lockdep warnings I have hit
Patches attached.
--
Regards,
vatsa
---
linux-2.6.20-vatsa/include/linux/init_task.h | 11
linux-2.6.20-vatsa/include/linux/nsproxy.h | 11
linux-2.6.20-vatsa/init/Kconfig | 22
linux-2.6.20-vatsa/init/main.c | 3
linux-2.6.20-vatsa/kernel/Makefile | 1
---
linux-2.6.20.1-vatsa/include/linux/init_task.h | 11
linux-2.6.20.1-vatsa/include/linux/nsproxy.h | 11
linux-2.6.20.1-vatsa/include/linux/rcfs.h | 76 +
linux-2.6.20.1-vatsa/init/Kconfig | 22
linux-2.6.20.1-vatsa/init/main.c | 3
linux-2.6.20.1-vatsa/kernel/Makefile | 1
linux-2.6.20.1-vatsa/kernel/nsproxy.c | 65 +
linux-2.6.20.1-vatsa/kernel/rcfs.c | 1202 +++++++++++++++++++++++++
8 files changed, 1391 insertions(+)
diff -puN include/linux/init_task.h~rcfs include/linux/init_task.h
--- linux-2.6.20.1/include/linux/init_task.h~rcfs 2007-03-08 21:21:33.000000000 +0530
+++ linux-2.6.20.1-vatsa/include/linux/init_task.h 2007-03-08 21:21:34.000000000 +0530
@@ -71,6 +71,16 @@
}
extern struct nsproxy init_nsproxy;
+
+#ifdef CONFIG_RCFS
+#define INIT_RCFS(nsproxy) \
+ .list = LIST_HEAD_INIT(nsproxy.list), \
+ .ctlr_data = {[ 0 ... CONFIG_MAX_RC_SUBSYS-1 ] = NULL },
+#else
+#define INIT_RCFS(nsproxy)
+#endif
+
+
#define INIT_NSPROXY(nsproxy) { \
.pid_ns = &init_pid_ns, \
.count = ATOMIC_INIT(1), \
@@ -78,6 +88,7 @@ extern struct nsproxy init_nsproxy;
.uts_ns = &init_uts_ns, \
.mnt_ns = NULL, \
INIT_IPC_NS(ipc_ns) \
+ INIT_RCFS(nsproxy) \
}
#define INIT_SIGHAND(sighand) { \
diff -puN include/linux/nsproxy.h~rcfs include/linux/nsproxy.h
--- linux-2.6.20.1/include/linux/nsproxy.h~rcfs 2007-03-08 21:21:33.000000000 +0530
+++ linux-2.6.20.1-vatsa/include/linux/nsproxy.h 2007-03-08 21:21:34.000000000 +0530
@@ -28,6 +28,10 @@ struct nsproxy {
struct ipc_namespace *ipc_ns;
struct mnt_namespace *mnt_ns;
struct pid_namespace *pid_ns;
+#ifdef CONFIG_RCFS
+ struct list_head list;
+ void *ctlr_data[CONFIG_MAX_RC_SUBSYS];
+#endif
};
extern struct nsproxy init_nsproxy;
@@ -35,6 +39,13 @@ struct nsproxy *dup_namespaces(struct ns
int copy_namespaces(int flags, struct task_struct *tsk);
void get_task_namespaces(struct task_struct *tsk);
void free_nsproxy(struct nsproxy *ns);
+#ifdef CONFIG_RCFS
+struct nsproxy *find_nsproxy(struct nsproxy *ns);
+int namespaces_init(void);
+int nsproxy_task_count(void *data, int idx);
+#else
+static inline int namespaces_init(void) { return 0;}
+#endif
static inline void put_nsproxy(struct nsproxy *ns)
{
diff -puN /dev/null include/linux/rcfs.h
--- /dev/null 2007-03-08 22:46:54.325490448 +0530
+++ linux-2.6.20.1-vatsa/include/linux/rcfs.h 2007-03-08 21:21:34.000000000 +0530
@@ -0,0 +1,76 @@
+#ifndef _LINUX_RCFS_H
+#define _LINUX_RCFS_H
+
+#ifdef CONFIG_RCFS
+
+/* struct cftype:
+ *
+ * The files in the container filesystem mostly have a very simple read/write
+ * handling, some common function will take care of it. Nevertheless some cases
+ * (read tasks) are special and therefore I define this structure for every
+ * kind of file.
+ *
+ *
+ * When reading/writing to a file:
+ * - the container to use in file->f_dentry->d_parent->d_fsdata
+ * - the 'cftype' of the file is file->f_dentry->d_fsdata
+ */
+
+struct inode;
+#define MAX_CFTYPE_NAME 64
+struct cftype {
+ /* By convention, the name should begin with the name of the
+ * subsystem, followed by a period */
+ char name[MAX_CFTYPE_NAME];
+ int private;
+ int (*open) (struct inode *inode, struct file *file);
+ ssize_t (*read) (struct nsproxy *ns, struct cftype *cft,
+ struct file *file,
+ char __user *buf, size_t nbytes, loff_t *ppos);
+ ssize_t (*write) (struct nsproxy *ns, struct cftype *cft,
+ struct file *file,
+ const char __user *buf, size_t nbytes, loff_t *ppos);
+ int (*release) (struct inode *inode, struct file *file);
+};
+
+/* resource control subsystem type. See Documentation/rcfs.txt for details */
+
+struct rc_subsys {
+ int (*create)(struct rc_subsys *ss, struct nsproxy *ns,
+ struct nsproxy *parent);
+ void (*destroy)(struct rc_subsys *ss, struct nsproxy *ns);
+ int (*can_attach)(struct rc_subsys *ss, struct nsproxy *ns,
+ struct task_struct *tsk);
+ void (*attach)(struct rc_subsys *ss, struct nsproxy *new,
+ struct nsproxy *old, struct task_struct *tsk);
+ int (*populate)(struct rc_subsys *ss, struct dentry *d);
+ int subsys_id;
+ int active;
+
+#define MAX_CONTAINER_TYPE_NAMELEN 32
+ const char *name;
+
+ /* Protected by RCU */
+ int hierarchy;
+
+ struct list_head sibling;
+};
+
+int rc_register_subsys(struct rc_subsys *subsys);
+/* Add a new file to the given container directory. Should only be
+ * called by subsystems from within a populate() method */
+int rcfs_add_file(struct dentry *d, const struct cftype *cft);
+extern int rcfs_init(void);
+extern void rcfs_manage_lock(void);
+extern void rcfs_manage_unlock(void);
+extern int rcfs_dir_removed(struct dentry *d);
+extern int rcfs_path(struct dentry *d, char *buf, int len);
+
+#else
+
+static inline int rcfs_init(void) { return 0; }
+
+#endif
+
+
+#endif
diff -puN init/Kconfig~rcfs init/Kconfig
--- linux-2.6.20.1/init/Kconfig~rcfs 2007-03-08 21:21:33.000000000 +0530
+++ linux-2.6.20.1-vatsa/init/Kconfig 2007-03-08 22:47:50.000000000 +0530
@@ -238,6 +238,28 @@ config IKCONFIG_PROC
This option enables access to the kernel configuration file
through /proc/config.gz.
+config RCFS
+ bool "Resource control file system support"
+ default n
+ help
+ This option will let you create and manage resource containers,
+ which can be used to aggregate multiple processes, e.g. for
+ the purposes of resource tracking.
+
+ Say N if unsure
+
+config MAX_RC_SUBSYS
+ int "Number of resource control subsystems to support"
+ depends on RCFS
+ range 1 255
+ default 8
+
+config MAX_RC_HIERARCHIES
+ int "Number of rcfs hierarchies to support"
+ depends on RCFS
+ range 2 255
+ default 4
+
config CPUSETS
bool "Cpuset support"
depends on SMP
diff -puN init/main.c~rcfs init/main.c
--- linux-2.6.20.1/init/main.c~rcfs 2007-03-08 21:21:33.000000000 +0530
+++ linux-2.6.20.1-vatsa/init/main.c 2007-03-08 21:21:34.000000000 +0530
@@ -52,6 +52,7 @@
#include <linux/lockdep.h>
#include <linux/pid_namespace.h>
#include <linux/device.h>
+#include <linux/rcfs.h>
#include <asm/io.h>
#include <asm/bugs.h>
@@ -512,6 +513,7 @@ asmlinkage void __init start_kernel(void
setup_per_cpu_areas();
smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
+ namespaces_init();
/*
* Set up the scheduler prior starting any interrupts (such as the
* timer interrupt). Full topology setup happens at smp_init()
@@ -578,6 +580,7 @@ asmlinkage void __init start_kernel(void
}
#endif
vfs_caches_init_early();
+ rcfs_init();
cpuset_init_early();
mem_init();
kmem_cache_init();
diff -puN kernel/Makefile~rcfs kernel/Makefile
--- linux-2.6.20.1/kernel/Makefile~rcfs 2007-03-08 21:21:34.000000000 +0530
+++ linux-2.6.20.1-vatsa/kernel/Makefile 2007-03-08 22:47:50.000000000 +0530
@@ -50,6 +50,7 @@ obj-$(CONFIG_RELAY) += relay.o
obj-$(CONFIG_UTS_NS) += utsname.o
obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
+obj-$(CONFIG_RCFS) += rcfs.o
ifneq ($(CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER),y)
# According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
diff -puN kernel/nsproxy.c~rcfs kernel/nsproxy.c
--- linux-2.6.20.1/kernel/nsproxy.c~rcfs 2007-03-08 21:21:34.000000000 +0530
+++ linux-2.6.20.1-vatsa/kernel/nsproxy.c 2007-03-08 22:54:04.000000000 +0530
@@ -23,6 +23,11 @@
struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
+#ifdef CONFIG_RCFS
+static LIST_HEAD(nslisthead);
+static DEFINE_SPINLOCK(nslistlock);
+#endif
+
static inline void get_nsproxy(struct nsproxy *ns)
{
atomic_inc(&ns->count);
@@ -71,6 +76,12 @@ struct nsproxy *dup_namespaces(struct ns
get_pid_ns(ns->pid_ns);
}
+#ifdef CONFIG_RCFS
+ spin_lock_irq(&nslistlock);
+ list_add(&ns->list, &nslisthead);
+ spin_unlock_irq(&nslistlock);
+#endif
+
return ns;
}
@@ -145,5 +156,59 @@ void free_nsproxy(struct nsproxy *ns)
put_ipc_ns(ns->ipc_ns);
if (ns->pid_ns)
put_pid_ns(ns->pid_ns);
+#ifdef CONFIG_RCFS
+ spin_lock_irq(&nslistlock);
+ list_del(&ns->list);
+ spin_unlock_irq(&nslistlock);
+#endif
kfree(ns);
}
+
+#ifdef CONFIG_RCFS
+struct nsproxy *find_nsproxy(struct nsproxy *target)
+{
+ struct nsproxy *ns;
+ int i =
...
|
|
|
 |
|
[PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
[PATCH 1/2] rcfs core patch
|
 |
|
Re: [ckrm-tech] [PATCH 1/2] rcfs core patch
|
 |
|
Re: [ckrm-tech] [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
By: ebiederm on Thu, 08 March 2007 03:12
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
By: dev on Fri, 09 March 2007 09:07
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
By: serue on Sun, 11 March 2007 16:36
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
By: dev on Fri, 09 March 2007 09:23
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
By: dev on Sun, 11 March 2007 17:09
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
By: dev on Tue, 13 March 2007 08:28
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [ckrm-tech] [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
By: serue on Fri, 09 March 2007 16:16
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
Re: [PATCH 1/2] rcfs core patch
|
 |
|
[PATCH 2/2] cpu_accounting controller
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
By: akpm on Fri, 02 March 2007 16:52
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
By: dev on Fri, 02 March 2007 17:25
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [ckrm-tech] [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
By: ebiederm on Wed, 07 March 2007 23:16
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
By: serue on Wed, 07 March 2007 17:43
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
By: ebiederm on Wed, 07 March 2007 22:32
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
By: serue on Wed, 07 March 2007 21:59
|
 |
|
Re: [ckrm-tech] [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [ckrm-tech] [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
By: ebiederm on Wed, 07 March 2007 23:13
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
By: serue on Wed, 07 March 2007 20:58
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [ckrm-tech] [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [ckrm-tech] [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
 |
|
Re: [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
|
Goto Forum:
Current Time: Thu Aug 21 20:10:29 GMT 2025
Total time taken to generate the page: 0.06235 seconds
|