[patch 8/8] cpusets v4 - One more hook, for /proc/<pid>/cpuset.

From: Paul Jackson
Date: Fri Jul 02 2004 - 06:11:37 EST


Add cpuset links to /proc, from each task to its cpuset.

Index: 2.6.7-mm5/fs/proc/base.c
===================================================================
--- 2.6.7-mm5.orig/fs/proc/base.c 2004-07-01 19:30:10.000000000 -0700
+++ 2.6.7-mm5/fs/proc/base.c 2004-07-01 19:30:24.000000000 -0700
@@ -32,6 +32,7 @@
#include <linux/mount.h>
#include <linux/security.h>
#include <linux/ptrace.h>
+#include <linux/cpuset.h>

/*
* For hysterical raisins we keep the same inumbers as in the old procfs.
@@ -60,6 +61,9 @@ enum pid_directory_inos {
PROC_TGID_MAPS,
PROC_TGID_MOUNTS,
PROC_TGID_WCHAN,
+#ifdef CONFIG_CPUSETS
+ PROC_TGID_CPUSET,
+#endif
#ifdef CONFIG_SECURITY
PROC_TGID_ATTR,
PROC_TGID_ATTR_CURRENT,
@@ -83,6 +87,9 @@ enum pid_directory_inos {
PROC_TID_MAPS,
PROC_TID_MOUNTS,
PROC_TID_WCHAN,
+#ifdef CONFIG_CPUSETS
+ PROC_TID_CPUSET,
+#endif
#ifdef CONFIG_SECURITY
PROC_TID_ATTR,
PROC_TID_ATTR_CURRENT,
@@ -123,6 +130,9 @@ static struct pid_entry tgid_base_stuff[
#ifdef CONFIG_KALLSYMS
E(PROC_TGID_WCHAN, "wchan", S_IFREG|S_IRUGO),
#endif
+#ifdef CONFIG_CPUSETS
+ E(PROC_TGID_CPUSET, "cpuset", S_IFREG|S_IRUGO),
+#endif
{0,0,NULL,0}
};
static struct pid_entry tid_base_stuff[] = {
@@ -145,6 +155,9 @@ static struct pid_entry tid_base_stuff[]
#ifdef CONFIG_KALLSYMS
E(PROC_TID_WCHAN, "wchan", S_IFREG|S_IRUGO),
#endif
+#ifdef CONFIG_CPUSETS
+ E(PROC_TID_CPUSET, "cpuset", S_IFREG|S_IRUGO),
+#endif
{0,0,NULL,0}
};

@@ -767,6 +780,14 @@ static struct inode_operations proc_pid_
.follow_link = proc_pid_follow_link
};

+
+#ifdef CONFIG_CPUSETS
+static int proc_pid_cpuset(struct task_struct *task, char *buffer)
+{
+ return proc_pid_cspath(task, buffer, PAGE_SIZE);
+}
+#endif /* CONFIG_CPUSETS */
+
static int pid_alive(struct task_struct *p)
{
BUG_ON(p->pids[PIDTYPE_PID].pidptr != &p->pids[PIDTYPE_PID].pid);
@@ -1375,6 +1396,13 @@ static struct dentry *proc_pident_lookup
ei->op.proc_read = proc_pid_wchan;
break;
#endif
+#ifdef CONFIG_CPUSETS
+ case PROC_TID_CPUSET:
+ case PROC_TGID_CPUSET:
+ inode->i_fop = &proc_info_file_operations;
+ ei->op.proc_read = proc_pid_cpuset;
+ break;
+#endif
default:
printk("procfs: impossible type (%d)",p->type);
iput(inode);
Index: 2.6.7-mm5/fs/proc/root.c
===================================================================
--- 2.6.7-mm5.orig/fs/proc/root.c 2004-07-01 19:30:10.000000000 -0700
+++ 2.6.7-mm5/fs/proc/root.c 2004-07-01 19:30:24.000000000 -0700
@@ -75,6 +75,9 @@ void __init proc_root_init(void)
proc_device_tree_init();
#endif
proc_bus = proc_mkdir("bus", 0);
+#ifdef CONFIG_CPUSETS
+ proc_mkdir("cpusets", 0);
+#endif
}

static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentry, struct nameidata *nd)

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@xxxxxxx> 1.650.933.1373
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/