diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-10-25 12:30:53 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-25 12:30:53 -0400 |
commit | 0b9e31e9264f1bad89856afb96da1688292f13b4 (patch) | |
tree | 7a9e9b6456dce993efeed8734de0a15a1f16ae94 /fs/proc/base.c | |
parent | cf82ff7ea7695b0e82ba07bc5e9f1bd03a74e1aa (diff) | |
parent | 964fe080d94db82a3268443e9b9ece4c60246414 (diff) |
Merge branch 'linus' into sched/core
Conflicts:
fs/proc/array.c
Merge reason: resolve conflict and queue up dependent patch.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r-- | fs/proc/base.c | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 6f742f6658a9..837469a96598 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -447,7 +447,7 @@ static int proc_oom_score(struct task_struct *task, char *buffer) | |||
447 | 447 | ||
448 | do_posix_clock_monotonic_gettime(&uptime); | 448 | do_posix_clock_monotonic_gettime(&uptime); |
449 | read_lock(&tasklist_lock); | 449 | read_lock(&tasklist_lock); |
450 | points = badness(task, uptime.tv_sec); | 450 | points = badness(task->group_leader, uptime.tv_sec); |
451 | read_unlock(&tasklist_lock); | 451 | read_unlock(&tasklist_lock); |
452 | return sprintf(buffer, "%lu\n", points); | 452 | return sprintf(buffer, "%lu\n", points); |
453 | } | 453 | } |
@@ -458,7 +458,7 @@ struct limit_names { | |||
458 | }; | 458 | }; |
459 | 459 | ||
460 | static const struct limit_names lnames[RLIM_NLIMITS] = { | 460 | static const struct limit_names lnames[RLIM_NLIMITS] = { |
461 | [RLIMIT_CPU] = {"Max cpu time", "ms"}, | 461 | [RLIMIT_CPU] = {"Max cpu time", "seconds"}, |
462 | [RLIMIT_FSIZE] = {"Max file size", "bytes"}, | 462 | [RLIMIT_FSIZE] = {"Max file size", "bytes"}, |
463 | [RLIMIT_DATA] = {"Max data size", "bytes"}, | 463 | [RLIMIT_DATA] = {"Max data size", "bytes"}, |
464 | [RLIMIT_STACK] = {"Max stack size", "bytes"}, | 464 | [RLIMIT_STACK] = {"Max stack size", "bytes"}, |
@@ -999,11 +999,17 @@ static ssize_t oom_adjust_read(struct file *file, char __user *buf, | |||
999 | struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); | 999 | struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); |
1000 | char buffer[PROC_NUMBUF]; | 1000 | char buffer[PROC_NUMBUF]; |
1001 | size_t len; | 1001 | size_t len; |
1002 | int oom_adjust; | 1002 | int oom_adjust = OOM_DISABLE; |
1003 | unsigned long flags; | ||
1003 | 1004 | ||
1004 | if (!task) | 1005 | if (!task) |
1005 | return -ESRCH; | 1006 | return -ESRCH; |
1006 | oom_adjust = task->oomkilladj; | 1007 | |
1008 | if (lock_task_sighand(task, &flags)) { | ||
1009 | oom_adjust = task->signal->oom_adj; | ||
1010 | unlock_task_sighand(task, &flags); | ||
1011 | } | ||
1012 | |||
1007 | put_task_struct(task); | 1013 | put_task_struct(task); |
1008 | 1014 | ||
1009 | len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust); | 1015 | len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust); |
@@ -1015,32 +1021,44 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf, | |||
1015 | size_t count, loff_t *ppos) | 1021 | size_t count, loff_t *ppos) |
1016 | { | 1022 | { |
1017 | struct task_struct *task; | 1023 | struct task_struct *task; |
1018 | char buffer[PROC_NUMBUF], *end; | 1024 | char buffer[PROC_NUMBUF]; |
1019 | int oom_adjust; | 1025 | long oom_adjust; |
1026 | unsigned long flags; | ||
1027 | int err; | ||
1020 | 1028 | ||
1021 | memset(buffer, 0, sizeof(buffer)); | 1029 | memset(buffer, 0, sizeof(buffer)); |
1022 | if (count > sizeof(buffer) - 1) | 1030 | if (count > sizeof(buffer) - 1) |
1023 | count = sizeof(buffer) - 1; | 1031 | count = sizeof(buffer) - 1; |
1024 | if (copy_from_user(buffer, buf, count)) | 1032 | if (copy_from_user(buffer, buf, count)) |
1025 | return -EFAULT; | 1033 | return -EFAULT; |
1026 | oom_adjust = simple_strtol(buffer, &end, 0); | 1034 | |
1035 | err = strict_strtol(strstrip(buffer), 0, &oom_adjust); | ||
1036 | if (err) | ||
1037 | return -EINVAL; | ||
1027 | if ((oom_adjust < OOM_ADJUST_MIN || oom_adjust > OOM_ADJUST_MAX) && | 1038 | if ((oom_adjust < OOM_ADJUST_MIN || oom_adjust > OOM_ADJUST_MAX) && |
1028 | oom_adjust != OOM_DISABLE) | 1039 | oom_adjust != OOM_DISABLE) |
1029 | return -EINVAL; | 1040 | return -EINVAL; |
1030 | if (*end == '\n') | 1041 | |
1031 | end++; | ||
1032 | task = get_proc_task(file->f_path.dentry->d_inode); | 1042 | task = get_proc_task(file->f_path.dentry->d_inode); |
1033 | if (!task) | 1043 | if (!task) |
1034 | return -ESRCH; | 1044 | return -ESRCH; |
1035 | if (oom_adjust < task->oomkilladj && !capable(CAP_SYS_RESOURCE)) { | 1045 | if (!lock_task_sighand(task, &flags)) { |
1046 | put_task_struct(task); | ||
1047 | return -ESRCH; | ||
1048 | } | ||
1049 | |||
1050 | if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) { | ||
1051 | unlock_task_sighand(task, &flags); | ||
1036 | put_task_struct(task); | 1052 | put_task_struct(task); |
1037 | return -EACCES; | 1053 | return -EACCES; |
1038 | } | 1054 | } |
1039 | task->oomkilladj = oom_adjust; | 1055 | |
1056 | task->signal->oom_adj = oom_adjust; | ||
1057 | |||
1058 | unlock_task_sighand(task, &flags); | ||
1040 | put_task_struct(task); | 1059 | put_task_struct(task); |
1041 | if (end - buffer == 0) | 1060 | |
1042 | return -EIO; | 1061 | return count; |
1043 | return end - buffer; | ||
1044 | } | 1062 | } |
1045 | 1063 | ||
1046 | static const struct file_operations proc_oom_adjust_operations = { | 1064 | static const struct file_operations proc_oom_adjust_operations = { |
@@ -1169,17 +1187,16 @@ static ssize_t proc_fault_inject_write(struct file * file, | |||
1169 | count = sizeof(buffer) - 1; | 1187 | count = sizeof(buffer) - 1; |
1170 | if (copy_from_user(buffer, buf, count)) | 1188 | if (copy_from_user(buffer, buf, count)) |
1171 | return -EFAULT; | 1189 | return -EFAULT; |
1172 | make_it_fail = simple_strtol(buffer, &end, 0); | 1190 | make_it_fail = simple_strtol(strstrip(buffer), &end, 0); |
1173 | if (*end == '\n') | 1191 | if (*end) |
1174 | end++; | 1192 | return -EINVAL; |
1175 | task = get_proc_task(file->f_dentry->d_inode); | 1193 | task = get_proc_task(file->f_dentry->d_inode); |
1176 | if (!task) | 1194 | if (!task) |
1177 | return -ESRCH; | 1195 | return -ESRCH; |
1178 | task->make_it_fail = make_it_fail; | 1196 | task->make_it_fail = make_it_fail; |
1179 | put_task_struct(task); | 1197 | put_task_struct(task); |
1180 | if (end - buffer == 0) | 1198 | |
1181 | return -EIO; | 1199 | return count; |
1182 | return end - buffer; | ||
1183 | } | 1200 | } |
1184 | 1201 | ||
1185 | static const struct file_operations proc_fault_inject_operations = { | 1202 | static const struct file_operations proc_fault_inject_operations = { |
@@ -2586,9 +2603,6 @@ static void proc_flush_task_mnt(struct vfsmount *mnt, pid_t pid, pid_t tgid) | |||
2586 | dput(dentry); | 2603 | dput(dentry); |
2587 | } | 2604 | } |
2588 | 2605 | ||
2589 | if (tgid == 0) | ||
2590 | goto out; | ||
2591 | |||
2592 | name.name = buf; | 2606 | name.name = buf; |
2593 | name.len = snprintf(buf, sizeof(buf), "%d", tgid); | 2607 | name.len = snprintf(buf, sizeof(buf), "%d", tgid); |
2594 | leader = d_hash_and_lookup(mnt->mnt_root, &name); | 2608 | leader = d_hash_and_lookup(mnt->mnt_root, &name); |
@@ -2645,17 +2659,16 @@ out: | |||
2645 | void proc_flush_task(struct task_struct *task) | 2659 | void proc_flush_task(struct task_struct *task) |
2646 | { | 2660 | { |
2647 | int i; | 2661 | int i; |
2648 | struct pid *pid, *tgid = NULL; | 2662 | struct pid *pid, *tgid; |
2649 | struct upid *upid; | 2663 | struct upid *upid; |
2650 | 2664 | ||
2651 | pid = task_pid(task); | 2665 | pid = task_pid(task); |
2652 | if (thread_group_leader(task)) | 2666 | tgid = task_tgid(task); |
2653 | tgid = task_tgid(task); | ||
2654 | 2667 | ||
2655 | for (i = 0; i <= pid->level; i++) { | 2668 | for (i = 0; i <= pid->level; i++) { |
2656 | upid = &pid->numbers[i]; | 2669 | upid = &pid->numbers[i]; |
2657 | proc_flush_task_mnt(upid->ns->proc_mnt, upid->nr, | 2670 | proc_flush_task_mnt(upid->ns->proc_mnt, upid->nr, |
2658 | tgid ? tgid->numbers[i].nr : 0); | 2671 | tgid->numbers[i].nr); |
2659 | } | 2672 | } |
2660 | 2673 | ||
2661 | upid = &pid->numbers[pid->level]; | 2674 | upid = &pid->numbers[pid->level]; |