diff options
author | Ingo Molnar <mingo@elte.hu> | 2007-07-09 12:52:00 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2007-07-09 12:52:00 -0400 |
commit | 43ae34cb4cd650d1eb4460a8253a8e747ba052ac (patch) | |
tree | 51f1b6a8331dea95d8d560c2c27f4abdad1d759c /fs/proc/base.c | |
parent | 77e54a1f88a1cb0746c7694fa40052bd02df1123 (diff) |
sched: scheduler debugging, core
scheduler debugging core: implement /proc/sched_debug and
/proc/<PID>/sched files for scheduler debugging.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r-- | fs/proc/base.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 0f40e820c7fd..46ea5d56e1bb 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -929,6 +929,69 @@ static const struct file_operations proc_fault_inject_operations = { | |||
929 | }; | 929 | }; |
930 | #endif | 930 | #endif |
931 | 931 | ||
932 | #ifdef CONFIG_SCHED_DEBUG | ||
933 | /* | ||
934 | * Print out various scheduling related per-task fields: | ||
935 | */ | ||
936 | static int sched_show(struct seq_file *m, void *v) | ||
937 | { | ||
938 | struct inode *inode = m->private; | ||
939 | struct task_struct *p; | ||
940 | |||
941 | WARN_ON(!inode); | ||
942 | |||
943 | p = get_proc_task(inode); | ||
944 | if (!p) | ||
945 | return -ESRCH; | ||
946 | proc_sched_show_task(p, m); | ||
947 | |||
948 | put_task_struct(p); | ||
949 | |||
950 | return 0; | ||
951 | } | ||
952 | |||
953 | static ssize_t | ||
954 | sched_write(struct file *file, const char __user *buf, | ||
955 | size_t count, loff_t *offset) | ||
956 | { | ||
957 | struct inode *inode = file->f_path.dentry->d_inode; | ||
958 | struct task_struct *p; | ||
959 | |||
960 | WARN_ON(!inode); | ||
961 | |||
962 | p = get_proc_task(inode); | ||
963 | if (!p) | ||
964 | return -ESRCH; | ||
965 | proc_sched_set_task(p); | ||
966 | |||
967 | put_task_struct(p); | ||
968 | |||
969 | return count; | ||
970 | } | ||
971 | |||
972 | static int sched_open(struct inode *inode, struct file *filp) | ||
973 | { | ||
974 | int ret; | ||
975 | |||
976 | ret = single_open(filp, sched_show, NULL); | ||
977 | if (!ret) { | ||
978 | struct seq_file *m = filp->private_data; | ||
979 | |||
980 | m->private = inode; | ||
981 | } | ||
982 | return ret; | ||
983 | } | ||
984 | |||
985 | static const struct file_operations proc_pid_sched_operations = { | ||
986 | .open = sched_open, | ||
987 | .read = seq_read, | ||
988 | .write = sched_write, | ||
989 | .llseek = seq_lseek, | ||
990 | .release = seq_release, | ||
991 | }; | ||
992 | |||
993 | #endif | ||
994 | |||
932 | static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd) | 995 | static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd) |
933 | { | 996 | { |
934 | struct inode *inode = dentry->d_inode; | 997 | struct inode *inode = dentry->d_inode; |
@@ -1963,6 +2026,9 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
1963 | INF("environ", S_IRUSR, pid_environ), | 2026 | INF("environ", S_IRUSR, pid_environ), |
1964 | INF("auxv", S_IRUSR, pid_auxv), | 2027 | INF("auxv", S_IRUSR, pid_auxv), |
1965 | INF("status", S_IRUGO, pid_status), | 2028 | INF("status", S_IRUGO, pid_status), |
2029 | #ifdef CONFIG_SCHED_DEBUG | ||
2030 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), | ||
2031 | #endif | ||
1966 | INF("cmdline", S_IRUGO, pid_cmdline), | 2032 | INF("cmdline", S_IRUGO, pid_cmdline), |
1967 | INF("stat", S_IRUGO, tgid_stat), | 2033 | INF("stat", S_IRUGO, tgid_stat), |
1968 | INF("statm", S_IRUGO, pid_statm), | 2034 | INF("statm", S_IRUGO, pid_statm), |
@@ -2247,6 +2313,9 @@ static const struct pid_entry tid_base_stuff[] = { | |||
2247 | INF("environ", S_IRUSR, pid_environ), | 2313 | INF("environ", S_IRUSR, pid_environ), |
2248 | INF("auxv", S_IRUSR, pid_auxv), | 2314 | INF("auxv", S_IRUSR, pid_auxv), |
2249 | INF("status", S_IRUGO, pid_status), | 2315 | INF("status", S_IRUGO, pid_status), |
2316 | #ifdef CONFIG_SCHED_DEBUG | ||
2317 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), | ||
2318 | #endif | ||
2250 | INF("cmdline", S_IRUGO, pid_cmdline), | 2319 | INF("cmdline", S_IRUGO, pid_cmdline), |
2251 | INF("stat", S_IRUGO, tid_stat), | 2320 | INF("stat", S_IRUGO, tid_stat), |
2252 | INF("statm", S_IRUGO, pid_statm), | 2321 | INF("statm", S_IRUGO, pid_statm), |