aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/obsolete/proc-pid-oom_adj22
-rw-r--r--Documentation/filesystems/proc.txt22
-rw-r--r--fs/proc/base.c117
-rw-r--r--include/linux/oom.h11
-rw-r--r--include/linux/sched.h1
-rw-r--r--kernel/fork.c1
-rw-r--r--mm/oom_kill.c4
7 files changed, 7 insertions, 171 deletions
diff --git a/Documentation/ABI/obsolete/proc-pid-oom_adj b/Documentation/ABI/obsolete/proc-pid-oom_adj
deleted file mode 100644
index 9a3cb88ade47..000000000000
--- a/Documentation/ABI/obsolete/proc-pid-oom_adj
+++ /dev/null
@@ -1,22 +0,0 @@
1What: /proc/<pid>/oom_adj
2When: August 2012
3Why: /proc/<pid>/oom_adj allows userspace to influence the oom killer's
4 badness heuristic used to determine which task to kill when the kernel
5 is out of memory.
6
7 The badness heuristic has since been rewritten since the introduction of
8 this tunable such that its meaning is deprecated. The value was
9 implemented as a bitshift on a score generated by the badness()
10 function that did not have any precise units of measure. With the
11 rewrite, the score is given as a proportion of available memory to the
12 task allocating pages, so using a bitshift which grows the score
13 exponentially is, thus, impossible to tune with fine granularity.
14
15 A much more powerful interface, /proc/<pid>/oom_score_adj, was
16 introduced with the oom killer rewrite that allows users to increase or
17 decrease the badness score linearly. This interface will replace
18 /proc/<pid>/oom_adj.
19
20 A warning will be emitted to the kernel log if an application uses this
21 deprecated interface. After it is printed once, future warnings will be
22 suppressed until the kernel is rebooted.
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index fb0a6aeb936c..a1793d670cd0 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -33,7 +33,7 @@ Table of Contents
33 2 Modifying System Parameters 33 2 Modifying System Parameters
34 34
35 3 Per-Process Parameters 35 3 Per-Process Parameters
36 3.1 /proc/<pid>/oom_adj & /proc/<pid>/oom_score_adj - Adjust the oom-killer 36 3.1 /proc/<pid>/oom_score_adj - Adjust the oom-killer
37 score 37 score
38 3.2 /proc/<pid>/oom_score - Display current oom-killer score 38 3.2 /proc/<pid>/oom_score - Display current oom-killer score
39 3.3 /proc/<pid>/io - Display the IO accounting fields 39 3.3 /proc/<pid>/io - Display the IO accounting fields
@@ -1320,10 +1320,10 @@ of the kernel.
1320CHAPTER 3: PER-PROCESS PARAMETERS 1320CHAPTER 3: PER-PROCESS PARAMETERS
1321------------------------------------------------------------------------------ 1321------------------------------------------------------------------------------
1322 1322
13233.1 /proc/<pid>/oom_adj & /proc/<pid>/oom_score_adj- Adjust the oom-killer score 13233.1 /proc/<pid>/oom_score_adj- Adjust the oom-killer score
1324-------------------------------------------------------------------------------- 1324--------------------------------------------------------------------------------
1325 1325
1326These file can be used to adjust the badness heuristic used to select which 1326This file can be used to adjust the badness heuristic used to select which
1327process gets killed in out of memory conditions. 1327process gets killed in out of memory conditions.
1328 1328
1329The badness heuristic assigns a value to each candidate task ranging from 0 1329The badness heuristic assigns a value to each candidate task ranging from 0
@@ -1361,22 +1361,10 @@ same system, cpuset, mempolicy, or memory controller resources to use at least
1361equivalent to discounting 50% of the task's allowed memory from being considered 1361equivalent to discounting 50% of the task's allowed memory from being considered
1362as scoring against the task. 1362as scoring against the task.
1363 1363
1364For backwards compatibility with previous kernels, /proc/<pid>/oom_adj may also
1365be used to tune the badness score. Its acceptable values range from -16
1366(OOM_ADJUST_MIN) to +15 (OOM_ADJUST_MAX) and a special value of -17
1367(OOM_DISABLE) to disable oom killing entirely for that task. Its value is
1368scaled linearly with /proc/<pid>/oom_score_adj.
1369
1370Writing to /proc/<pid>/oom_score_adj or /proc/<pid>/oom_adj will change the
1371other with its scaled value.
1372
1373The value of /proc/<pid>/oom_score_adj may be reduced no lower than the last 1364The value of /proc/<pid>/oom_score_adj may be reduced no lower than the last
1374value set by a CAP_SYS_RESOURCE process. To reduce the value any lower 1365value set by a CAP_SYS_RESOURCE process. To reduce the value any lower
1375requires CAP_SYS_RESOURCE. 1366requires CAP_SYS_RESOURCE.
1376 1367
1377NOTICE: /proc/<pid>/oom_adj is deprecated and will be removed, please see
1378Documentation/feature-removal-schedule.txt.
1379
1380Caveat: when a parent task is selected, the oom killer will sacrifice any first 1368Caveat: when a parent task is selected, the oom killer will sacrifice any first
1381generation children with separate address spaces instead, if possible. This 1369generation children with separate address spaces instead, if possible. This
1382avoids servers and important system daemons from being killed and loses the 1370avoids servers and important system daemons from being killed and loses the
@@ -1387,9 +1375,7 @@ minimal amount of work.
1387------------------------------------------------------------- 1375-------------------------------------------------------------
1388 1376
1389This file can be used to check the current score used by the oom-killer is for 1377This file can be used to check the current score used by the oom-killer is for
1390any given <pid>. Use it together with /proc/<pid>/oom_adj to tune which 1378any given <pid>.
1391process should be killed in an out-of-memory situation.
1392
1393 1379
13943.3 /proc/<pid>/io - Display the IO accounting fields 13803.3 /proc/<pid>/io - Display the IO accounting fields
1395------------------------------------------------------- 1381-------------------------------------------------------
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
876static 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
900static 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);
966err_sighand:
967 unlock_task_sighand(task, &flags);
968err_task_lock:
969 task_unlock(task);
970 put_task_struct(task);
971out:
972 return err < 0 ? err : count;
973}
974
975static 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
981static ssize_t oom_score_adj_read(struct file *file, char __user *buf, 876static 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;
1063err_sighand: 950err_sighand:
1064 unlock_task_sighand(task, &flags); 951 unlock_task_sighand(task, &flags);
1065err_task_lock: 952err_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),
diff --git a/include/linux/oom.h b/include/linux/oom.h
index 49a3031fda50..d36a8221f58b 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -2,17 +2,6 @@
2#define __INCLUDE_LINUX_OOM_H 2#define __INCLUDE_LINUX_OOM_H
3 3
4/* 4/*
5 * /proc/<pid>/oom_adj is deprecated, see
6 * Documentation/feature-removal-schedule.txt.
7 *
8 * /proc/<pid>/oom_adj set to -17 protects from the oom-killer
9 */
10#define OOM_DISABLE (-17)
11/* inclusive */
12#define OOM_ADJUST_MIN (-16)
13#define OOM_ADJUST_MAX 15
14
15/*
16 * /proc/<pid>/oom_score_adj set to OOM_SCORE_ADJ_MIN disables oom killing for 5 * /proc/<pid>/oom_score_adj set to OOM_SCORE_ADJ_MIN disables oom killing for
17 * pid. 6 * pid.
18 */ 7 */
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 9c5612f0374b..c2070e92a9d6 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -671,7 +671,6 @@ struct signal_struct {
671 struct rw_semaphore group_rwsem; 671 struct rw_semaphore group_rwsem;
672#endif 672#endif
673 673
674 int oom_adj; /* OOM kill score adjustment (bit shift) */
675 int oom_score_adj; /* OOM kill score adjustment */ 674 int oom_score_adj; /* OOM kill score adjustment */
676 int oom_score_adj_min; /* OOM kill score adjustment minimum value. 675 int oom_score_adj_min; /* OOM kill score adjustment minimum value.
677 * Only settable by CAP_SYS_RESOURCE. */ 676 * Only settable by CAP_SYS_RESOURCE. */
diff --git a/kernel/fork.c b/kernel/fork.c
index ec667f797af3..972762e01024 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1056,7 +1056,6 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
1056 init_rwsem(&sig->group_rwsem); 1056 init_rwsem(&sig->group_rwsem);
1057#endif 1057#endif
1058 1058
1059 sig->oom_adj = current->signal->oom_adj;
1060 sig->oom_score_adj = current->signal->oom_score_adj; 1059 sig->oom_score_adj = current->signal->oom_score_adj;
1061 sig->oom_score_adj_min = current->signal->oom_score_adj_min; 1060 sig->oom_score_adj_min = current->signal->oom_score_adj_min;
1062 1061
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 198600861638..79e0f3e24831 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -428,8 +428,8 @@ static void dump_header(struct task_struct *p, gfp_t gfp_mask, int order,
428{ 428{
429 task_lock(current); 429 task_lock(current);
430 pr_warning("%s invoked oom-killer: gfp_mask=0x%x, order=%d, " 430 pr_warning("%s invoked oom-killer: gfp_mask=0x%x, order=%d, "
431 "oom_adj=%d, oom_score_adj=%d\n", 431 "oom_score_adj=%d\n",
432 current->comm, gfp_mask, order, current->signal->oom_adj, 432 current->comm, gfp_mask, order,
433 current->signal->oom_score_adj); 433 current->signal->oom_score_adj);
434 cpuset_print_task_mems_allowed(current); 434 cpuset_print_task_mems_allowed(current);
435 task_unlock(current); 435 task_unlock(current);