diff -NurpP --minimal linux-2.6.20-rc6/fs/namespace.c linux-2.6.20-rc6-x/fs/namespace.c --- linux-2.6.20-rc6/fs/namespace.c 2007-01-30 05:09:27 +0100 +++ linux-2.6.20-rc6-x/fs/namespace.c 2007-01-30 05:21:16 +0100 @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include "pnode.h" @@ -1499,6 +1500,7 @@ struct mnt_namespace *dup_mnt_ns(struct q = next_mnt(q, new_ns->root); } up_write(&namespace_sem); + atomic_inc(&vs_global_mnt_ns); if (rootmnt) mntput(rootmnt); @@ -1876,5 +1878,6 @@ void __put_mnt_ns(struct mnt_namespace * spin_unlock(&vfsmount_lock); up_write(&namespace_sem); release_mounts(&umount_list); + atomic_dec(&vs_global_mnt_ns); kfree(ns); } diff -NurpP --minimal linux-2.6.20-rc6/fs/proc/proc_misc.c linux-2.6.20-rc6-x/fs/proc/proc_misc.c --- linux-2.6.20-rc6/fs/proc/proc_misc.c 2007-01-30 05:09:27 +0100 +++ linux-2.6.20-rc6-x/fs/proc/proc_misc.c 2007-01-30 05:29:03 +0100 @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -260,6 +261,26 @@ static int version_read_proc(char *page, return proc_calc_metrics(page, start, off, count, eof, len); } +static int global_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len; + + len = snprintf(page, PAGE_SIZE, + "nsproxy:\t%d\n" + "fs:\t%d\n" + "mnt_ns:\t%d\n" + "uts_ns:\t%d\n" + "ipc_ns:\t%d\n" + ,atomic_read(&vs_global_nsproxy) + ,atomic_read(&vs_global_fs) + ,atomic_read(&vs_global_mnt_ns) + ,atomic_read(&vs_global_uts_ns) + ,atomic_read(&vs_global_ipc_ns) + ); + return proc_calc_metrics(page, start, off, count, eof, len); +} + extern struct seq_operations cpuinfo_op; static int cpuinfo_open(struct inode *inode, struct file *file) { @@ -681,6 +702,7 @@ void __init proc_misc_init(void) {"uptime", uptime_read_proc}, {"meminfo", meminfo_read_proc}, {"version", version_read_proc}, + {"global", global_read_proc}, #ifdef CONFIG_PROC_HARDWARE {"hardware", hardware_read_proc}, #endif diff -NurpP --minimal linux-2.6.20-rc6/include/linux/vserver/global.h linux-2.6.20-rc6-x/include/linux/vserver/global.h --- linux-2.6.20-rc6/include/linux/vserver/global.h 1970-01-01 01:00:00 +0100 +++ linux-2.6.20-rc6-x/include/linux/vserver/global.h 2007-01-30 05:21:16 +0100 @@ -0,0 +1,5 @@ +extern atomic_t vs_global_nsproxy; +extern atomic_t vs_global_fs; +extern atomic_t vs_global_mnt_ns; +extern atomic_t vs_global_uts_ns; +extern atomic_t vs_global_ipc_ns; diff -NurpP --minimal linux-2.6.20-rc6/ipc/util.c linux-2.6.20-rc6-x/ipc/util.c --- linux-2.6.20-rc6/ipc/util.c 2007-01-30 05:09:33 +0100 +++ linux-2.6.20-rc6-x/ipc/util.c 2007-01-30 05:21:16 +0100 @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -73,6 +74,7 @@ static struct ipc_namespace *clone_ipc_n goto err_shm; kref_init(&ns->kref); + atomic_inc(&vs_global_ipc_ns); return ns; err_shm: @@ -142,6 +144,7 @@ void free_ipc_ns(struct kref *kref) sem_exit_ns(ns); msg_exit_ns(ns); shm_exit_ns(ns); + atomic_dec(&vs_global_ipc_ns); kfree(ns); } #endif diff -NurpP --minimal linux-2.6.20-rc6/kernel/exit.c linux-2.6.20-rc6-x/kernel/exit.c --- linux-2.6.20-rc6/kernel/exit.c 2007-01-30 05:09:33 +0100 +++ linux-2.6.20-rc6-x/kernel/exit.c 2007-01-30 05:21:16 +0100 @@ -42,6 +42,7 @@ #include /* for audit_free() */ #include #include +#include #include #include @@ -515,6 +516,7 @@ static inline void __put_fs_struct(struc dput(fs->altroot); mntput(fs->altrootmnt); } + atomic_dec(&vs_global_fs); kmem_cache_free(fs_cachep, fs); } } diff -NurpP --minimal linux-2.6.20-rc6/kernel/fork.c linux-2.6.20-rc6-x/kernel/fork.c --- linux-2.6.20-rc6/kernel/fork.c 2007-01-30 05:09:33 +0100 +++ linux-2.6.20-rc6-x/kernel/fork.c 2007-01-30 05:21:16 +0100 @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -57,6 +58,12 @@ #include #include +atomic_t vs_global_nsproxy = ATOMIC_INIT(0); +atomic_t vs_global_fs = ATOMIC_INIT(0); +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0); +atomic_t vs_global_uts_ns = ATOMIC_INIT(0); +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0); + /* * Protected counters by write_lock_irq(&tasklist_lock) */ @@ -589,6 +596,7 @@ static inline struct fs_struct *__copy_f fs->altroot = NULL; } read_unlock(&old->lock); + atomic_inc(&vs_global_fs); } return fs; } diff -NurpP --minimal linux-2.6.20-rc6/kernel/nsproxy.c linux-2.6.20-rc6-x/kernel/nsproxy.c --- linux-2.6.20-rc6/kernel/nsproxy.c 2007-01-30 05:09:33 +0100 +++ linux-2.6.20-rc6-x/kernel/nsproxy.c 2007-01-30 05:21:16 +0100 @@ -20,6 +20,7 @@ #include #include #include +#include struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); @@ -48,6 +49,7 @@ static inline struct nsproxy *clone_name ns = kmemdup(orig, sizeof(struct nsproxy), GFP_KERNEL); if (ns) atomic_set(&ns->count, 1); + atomic_inc(&vs_global_nsproxy); return ns; } @@ -146,4 +148,5 @@ void free_nsproxy(struct nsproxy *ns) if (ns->pid_ns) put_pid_ns(ns->pid_ns); kfree(ns); + atomic_dec(&vs_global_nsproxy); } diff -NurpP --minimal linux-2.6.20-rc6/kernel/utsname.c linux-2.6.20-rc6-x/kernel/utsname.c --- linux-2.6.20-rc6/kernel/utsname.c 2006-11-30 21:19:44 +0100 +++ linux-2.6.20-rc6-x/kernel/utsname.c 2007-01-30 05:21:16 +0100 @@ -13,6 +13,7 @@ #include #include #include +#include /* * Clone a new ns copying an original utsname, setting refcount to 1 @@ -27,6 +28,7 @@ static struct uts_namespace *clone_uts_n if (ns) { memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); kref_init(&ns->kref); + atomic_inc(&vs_global_uts_ns); } return ns; } @@ -91,5 +93,6 @@ void free_uts_ns(struct kref *kref) struct uts_namespace *ns; ns = container_of(kref, struct uts_namespace, kref); + atomic_dec(&vs_global_uts_ns); kfree(ns); }