diff options
| author | Davidlohr Bueso <dave@gnu.org> | 2012-10-08 19:29:30 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-09 03:22:24 -0400 |
| commit | 01dc52ebdf472f77cca623ca693ca24cfc0f1bbe (patch) | |
| tree | 2d0f35f2aff418d52a84fb50974ad3bacf68d4bd /fs/proc/base.c | |
| parent | d5dc0ad928fb9e972001e552597fd0b794863f34 (diff) | |
oom: remove deprecated oom_adj
The deprecated /proc/<pid>/oom_adj is scheduled for removal this month.
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Acked-by: David Rientjes <rientjes@google.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/base.c')
| -rw-r--r-- | fs/proc/base.c | 117 |
1 files changed, 1 insertions, 116 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index d295af993677..ef5c84be66f9 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
| @@ -873,111 +873,6 @@ static const struct file_operations proc_environ_operations = { | |||
| 873 | .release = mem_release, | 873 | .release = mem_release, |
| 874 | }; | 874 | }; |
| 875 | 875 | ||
| 876 | static ssize_t oom_adjust_read(struct file *file, char __user *buf, | ||
| 877 | size_t count, loff_t *ppos) | ||
| 878 | { | ||
| 879 | struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); | ||
| 880 | char buffer[PROC_NUMBUF]; | ||
| 881 | size_t len; | ||
| 882 | int oom_adjust = OOM_DISABLE; | ||
| 883 | unsigned long flags; | ||
| 884 | |||
| 885 | if (!task) | ||
| 886 | return -ESRCH; | ||
| 887 | |||
| 888 | if (lock_task_sighand(task, &flags)) { | ||
| 889 | oom_adjust = task->signal->oom_adj; | ||
| 890 | unlock_task_sighand(task, &flags); | ||
| 891 | } | ||
| 892 | |||
| 893 | put_task_struct(task); | ||
| 894 | |||
| 895 | len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust); | ||
| 896 | |||
| 897 | return simple_read_from_buffer(buf, count, ppos, buffer, len); | ||
| 898 | } | ||
| 899 | |||
| 900 | static ssize_t oom_adjust_write(struct file *file, const char __user *buf, | ||
| 901 | size_t count, loff_t *ppos) | ||
| 902 | { | ||
| 903 | struct task_struct *task; | ||
| 904 | char buffer[PROC_NUMBUF]; | ||
| 905 | int oom_adjust; | ||
| 906 | unsigned long flags; | ||
| 907 | int err; | ||
| 908 | |||
| 909 | memset(buffer, 0, sizeof(buffer)); | ||
| 910 | if (count > sizeof(buffer) - 1) | ||
| 911 | count = sizeof(buffer) - 1; | ||
| 912 | if (copy_from_user(buffer, buf, count)) { | ||
| 913 | err = -EFAULT; | ||
| 914 | goto out; | ||
| 915 | } | ||
| 916 | |||
| 917 | err = kstrtoint(strstrip(buffer), 0, &oom_adjust); | ||
| 918 | if (err) | ||
| 919 | goto out; | ||
| 920 | if ((oom_adjust < OOM_ADJUST_MIN || oom_adjust > OOM_ADJUST_MAX) && | ||
| 921 | oom_adjust != OOM_DISABLE) { | ||
| 922 | err = -EINVAL; | ||
| 923 | goto out; | ||
| 924 | } | ||
| 925 | |||
| 926 | task = get_proc_task(file->f_path.dentry->d_inode); | ||
| 927 | if (!task) { | ||
| 928 | err = -ESRCH; | ||
| 929 | goto out; | ||
| 930 | } | ||
| 931 | |||
| 932 | task_lock(task); | ||
| 933 | if (!task->mm) { | ||
| 934 | err = -EINVAL; | ||
| 935 | goto err_task_lock; | ||
| 936 | } | ||
| 937 | |||
| 938 | if (!lock_task_sighand(task, &flags)) { | ||
| 939 | err = -ESRCH; | ||
| 940 | goto err_task_lock; | ||
| 941 | } | ||
| 942 | |||
| 943 | if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) { | ||
| 944 | err = -EACCES; | ||
| 945 | goto err_sighand; | ||
| 946 | } | ||
| 947 | |||
| 948 | /* | ||
| 949 | * Warn that /proc/pid/oom_adj is deprecated, see | ||
| 950 | * Documentation/feature-removal-schedule.txt. | ||
| 951 | */ | ||
| 952 | printk_once(KERN_WARNING "%s (%d): /proc/%d/oom_adj is deprecated, please use /proc/%d/oom_score_adj instead.\n", | ||
| 953 | current->comm, task_pid_nr(current), task_pid_nr(task), | ||
| 954 | task_pid_nr(task)); | ||
| 955 | task->signal->oom_adj = oom_adjust; | ||
| 956 | /* | ||
| 957 | * Scale /proc/pid/oom_score_adj appropriately ensuring that a maximum | ||
| 958 | * value is always attainable. | ||
| 959 | */ | ||
| 960 | if (task->signal->oom_adj == OOM_ADJUST_MAX) | ||
| 961 | task->signal->oom_score_adj = OOM_SCORE_ADJ_MAX; | ||
| 962 | else | ||
| 963 | task->signal->oom_score_adj = (oom_adjust * OOM_SCORE_ADJ_MAX) / | ||
| 964 | -OOM_DISABLE; | ||
| 965 | trace_oom_score_adj_update(task); | ||
| 966 | err_sighand: | ||
| 967 | unlock_task_sighand(task, &flags); | ||
| 968 | err_task_lock: | ||
| 969 | task_unlock(task); | ||
| 970 | put_task_struct(task); | ||
| 971 | out: | ||
| 972 | return err < 0 ? err : count; | ||
| 973 | } | ||
| 974 | |||
| 975 | static const struct file_operations proc_oom_adjust_operations = { | ||
| 976 | .read = oom_adjust_read, | ||
| 977 | .write = oom_adjust_write, | ||
| 978 | .llseek = generic_file_llseek, | ||
| 979 | }; | ||
| 980 | |||
| 981 | static ssize_t oom_score_adj_read(struct file *file, char __user *buf, | 876 | static ssize_t oom_score_adj_read(struct file *file, char __user *buf, |
| 982 | size_t count, loff_t *ppos) | 877 | size_t count, loff_t *ppos) |
| 983 | { | 878 | { |
| @@ -1051,15 +946,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf, | |||
| 1051 | if (has_capability_noaudit(current, CAP_SYS_RESOURCE)) | 946 | if (has_capability_noaudit(current, CAP_SYS_RESOURCE)) |
| 1052 | task->signal->oom_score_adj_min = oom_score_adj; | 947 | task->signal->oom_score_adj_min = oom_score_adj; |
| 1053 | trace_oom_score_adj_update(task); | 948 | trace_oom_score_adj_update(task); |
| 1054 | /* | 949 | |
| 1055 | * Scale /proc/pid/oom_adj appropriately ensuring that OOM_DISABLE is | ||
| 1056 | * always attainable. | ||
| 1057 | */ | ||
| 1058 | if (task->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) | ||
| 1059 | task->signal->oom_adj = OOM_DISABLE; | ||
| 1060 | else | ||
| 1061 | task->signal->oom_adj = (oom_score_adj * OOM_ADJUST_MAX) / | ||
| 1062 | OOM_SCORE_ADJ_MAX; | ||
| 1063 | err_sighand: | 950 | err_sighand: |
| 1064 | unlock_task_sighand(task, &flags); | 951 | unlock_task_sighand(task, &flags); |
| 1065 | err_task_lock: | 952 | err_task_lock: |
| @@ -2710,7 +2597,6 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
| 2710 | REG("cgroup", S_IRUGO, proc_cgroup_operations), | 2597 | REG("cgroup", S_IRUGO, proc_cgroup_operations), |
| 2711 | #endif | 2598 | #endif |
| 2712 | INF("oom_score", S_IRUGO, proc_oom_score), | 2599 | INF("oom_score", S_IRUGO, proc_oom_score), |
| 2713 | REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations), | ||
| 2714 | REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), | 2600 | REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), |
| 2715 | #ifdef CONFIG_AUDITSYSCALL | 2601 | #ifdef CONFIG_AUDITSYSCALL |
| 2716 | REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), | 2602 | REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), |
| @@ -3077,7 +2963,6 @@ static const struct pid_entry tid_base_stuff[] = { | |||
| 3077 | REG("cgroup", S_IRUGO, proc_cgroup_operations), | 2963 | REG("cgroup", S_IRUGO, proc_cgroup_operations), |
| 3078 | #endif | 2964 | #endif |
| 3079 | INF("oom_score", S_IRUGO, proc_oom_score), | 2965 | INF("oom_score", S_IRUGO, proc_oom_score), |
| 3080 | REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations), | ||
| 3081 | REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), | 2966 | REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), |
| 3082 | #ifdef CONFIG_AUDITSYSCALL | 2967 | #ifdef CONFIG_AUDITSYSCALL |
| 3083 | REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), | 2968 | REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), |
