06/12: ckrm_tasksupport_procsupport
Adds an interface in /proc to get the class name of a task.
--
Signed-Off-By: Chandra Seetharaman <[EMAIL PROTECTED]>
Signed-off-by: MAEDA Naoaki <[EMAIL PROTECTED]>
fs/proc/base.c | 19 +++++++++++++++++++
include/linux/ckrm.h | 1 +
kernel/ckrm/ckrm_task.c | 33 ++++++++++++++++++++++++++++++++-
3 files changed, 52 insertions(+), 1 deletion(-)
Index: linux-2.6.16/fs/proc/base.c
===================================================================
--- linux-2.6.16.orig/fs/proc/base.c
+++ linux-2.6.16/fs/proc/base.c
@@ -70,6 +70,7 @@
#include <linux/ptrace.h>
#include <linux/seccomp.h>
#include <linux/cpuset.h>
+#include <linux/ckrm.h>
#include <linux/audit.h>
#include <linux/poll.h>
#include "internal.h"
@@ -114,6 +115,9 @@ enum pid_directory_inos {
#ifdef CONFIG_CPUSETS
PROC_TGID_CPUSET,
#endif
+#ifdef CONFIG_CKRM
+ PROC_TGID_CKRM_CLASS,
+#endif
#ifdef CONFIG_SECURITY
PROC_TGID_ATTR,
PROC_TGID_ATTR_CURRENT,
@@ -154,6 +158,9 @@ enum pid_directory_inos {
#ifdef CONFIG_CPUSETS
PROC_TID_CPUSET,
#endif
+#ifdef CONFIG_CKRM
+ PROC_TID_CKRM_CLASS,
+#endif
#ifdef CONFIG_SECURITY
PROC_TID_ATTR,
PROC_TID_ATTR_CURRENT,
@@ -216,6 +223,9 @@ static struct pid_entry tgid_base_stuff[
#ifdef CONFIG_CPUSETS
E(PROC_TGID_CPUSET, "cpuset", S_IFREG|S_IRUGO),
#endif
+#ifdef CONFIG_CKRM
+ E(PROC_TGID_CKRM_CLASS,"ckrm_class",S_IFREG|S_IRUGO),
+#endif
E(PROC_TGID_OOM_SCORE, "oom_score",S_IFREG|S_IRUGO),
E(PROC_TGID_OOM_ADJUST,"oom_adj", S_IFREG|S_IRUGO|S_IWUSR),
#ifdef CONFIG_AUDITSYSCALL
@@ -258,6 +268,9 @@ static struct pid_entry tid_base_stuff[]
#ifdef CONFIG_CPUSETS
E(PROC_TID_CPUSET, "cpuset", S_IFREG|S_IRUGO),
#endif
+#ifdef CONFIG_CKRM
+ E(PROC_TID_CKRM_CLASS, "ckrm_class",S_IFREG|S_IRUGO),
+#endif
E(PROC_TID_OOM_SCORE, "oom_score",S_IFREG|S_IRUGO),
E(PROC_TID_OOM_ADJUST, "oom_adj", S_IFREG|S_IRUGO|S_IWUSR),
#ifdef CONFIG_AUDITSYSCALL
@@ -1772,6 +1785,12 @@ static struct dentry *proc_pident_lookup
inode->i_fop = &proc_cpuset_operations;
break;
#endif
+#ifdef CONFIG_CKRM
+ case PROC_TID_CKRM_CLASS:
+ case PROC_TGID_CKRM_CLASS:
+ inode->i_fop = &proc_ckrm_class_operations;
+ break;
+#endif
case PROC_TID_OOM_SCORE:
case PROC_TGID_OOM_SCORE:
inode->i_fop = &proc_info_file_operations;
Index: linux-2.6.16/kernel/ckrm/ckrm_task.c
===================================================================
--- linux-2.6.16.orig/kernel/ckrm/ckrm_task.c
+++ linux-2.6.16/kernel/ckrm/ckrm_task.c
@@ -13,7 +13,8 @@
* (at your option) any later version.
*
*/
-#include <linux/sched.h>
+#include <linux/seq_file.h>
+#include <linux/proc_fs.h>
#include <linux/ckrm_rc.h>
static inline struct ckrm_class *remove_from_old_class(struct task_struct *tsk)
@@ -160,3 +161,33 @@ next_task:
spin_unlock(&class->class_lock);
kref_put(&class->ref, ckrm_release_class);
}
+
+static int proc_ckrm_class_show(struct seq_file *m, void *v)
+{
+ struct task_struct *tsk = m->private;
+ struct ckrm_class *class = tsk->class;
+
+ if (!class)
+ return -EINVAL;
+
+ kref_get(&class->ref);
+ seq_puts(m, "/");
+ if (!ckrm_is_class_root(class))
+ seq_puts(m, class->name);
+ seq_putc(m, '\n');
+ kref_put(&class->ref, ckrm_release_class);
+ return 0;
+}
+
+static int ckrm_class_open(struct inode *inode, struct file *file)
+{
+ struct task_struct *tsk = PROC_I(inode)->task;
+ return single_open(file, proc_ckrm_class_show, tsk);
+}
+
+struct file_operations proc_ckrm_class_operations = {
+ .open = ckrm_class_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
Index: linux-2.6.16/include/linux/ckrm.h
===================================================================
--- linux-2.6.16.orig/include/linux/ckrm.h
+++ linux-2.6.16/include/linux/ckrm.h
@@ -98,6 +98,7 @@ extern struct ckrm_controller *ckrm_get_
extern struct ckrm_controller *ckrm_get_controller_by_id(unsigned int);
extern void ckrm_put_controller(struct ckrm_controller *);
+extern struct file_operations proc_ckrm_class_operations;
extern struct ckrm_class ckrm_default_class;
static inline int ckrm_is_class_root(const struct ckrm_class* class)
{
--
----------------------------------------------------------------------
Chandra Seetharaman | Be careful what you choose....
- [EMAIL PROTECTED] | .......you may get it.
----------------------------------------------------------------------
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
ckrm-tech mailing list
https://lists.sourceforge.net/lists/listinfo/ckrm-tech