| 1 |
.\" Copyright 1994-1995, Daniel Quinlan <[email protected]> |
| 2 |
.\" Copyright 2002-2017, Michael Kerrisk <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: GPL-3.0-or-later |
| 6 |
.\" |
| 7 |
.TH proc_pid_oom_score_adj 5 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
/proc/pid/oom_score_adj \- OOM-killer score adjustment |
| 10 |
.SH DESCRIPTION |
| 11 |
.TP |
| 12 |
.IR /proc/ pid /oom_score_adj " (since Linux 2.6.36)" |
| 13 |
This file can be used to adjust the badness heuristic used to select which |
| 14 |
process gets killed in out-of-memory conditions. |
| 15 |
.IP |
| 16 |
The badness heuristic assigns a value to each candidate task ranging from 0 |
| 17 |
(never kill) to 1000 (always kill) to determine which process is targeted. |
| 18 |
The units are roughly a proportion along that range of |
| 19 |
allowed memory the process may allocate from, |
| 20 |
based on an estimation of its current memory and swap use. |
| 21 |
For example, if a task is using all allowed memory, |
| 22 |
its badness score will be 1000. |
| 23 |
If it is using half of its allowed memory, its score will be 500. |
| 24 |
.IP |
| 25 |
There is an additional factor included in the badness score: root |
| 26 |
processes are given 3% extra memory over other tasks. |
| 27 |
.IP |
| 28 |
The amount of "allowed" memory depends on the context |
| 29 |
in which the OOM-killer was called. |
| 30 |
If it is due to the memory assigned to the allocating task's cpuset |
| 31 |
being exhausted, |
| 32 |
the allowed memory represents the set of mems assigned to that |
| 33 |
cpuset (see |
| 34 |
.BR cpuset (7)). |
| 35 |
If it is due to a mempolicy's node(s) being exhausted, |
| 36 |
the allowed memory represents the set of mempolicy nodes. |
| 37 |
If it is due to a memory limit (or swap limit) being reached, |
| 38 |
the allowed memory is that configured limit. |
| 39 |
Finally, if it is due to the entire system being out of memory, the |
| 40 |
allowed memory represents all allocatable resources. |
| 41 |
.IP |
| 42 |
The value of |
| 43 |
.I oom_score_adj |
| 44 |
is added to the badness score before it |
| 45 |
is used to determine which task to kill. |
| 46 |
Acceptable values range from \-1000 |
| 47 |
(OOM_SCORE_ADJ_MIN) to +1000 (OOM_SCORE_ADJ_MAX). |
| 48 |
This allows user space to control the preference for OOM-killing, |
| 49 |
ranging from always preferring a certain |
| 50 |
task or completely disabling it from OOM-killing. |
| 51 |
The lowest possible value, \-1000, is |
| 52 |
equivalent to disabling OOM-killing entirely for that task, |
| 53 |
since it will always report a badness score of 0. |
| 54 |
.IP |
| 55 |
Consequently, it is very simple for user space to define |
| 56 |
the amount of memory to consider for each task. |
| 57 |
Setting an |
| 58 |
.I oom_score_adj |
| 59 |
value of +500, for example, |
| 60 |
is roughly equivalent to allowing the remainder of tasks sharing the |
| 61 |
same system, cpuset, mempolicy, or memory controller resources |
| 62 |
to use at least 50% more memory. |
| 63 |
A value of \-500, on the other hand, would be roughly |
| 64 |
equivalent to discounting 50% of the task's |
| 65 |
allowed memory from being considered as scoring against the task. |
| 66 |
.IP |
| 67 |
For backward compatibility with previous kernels, |
| 68 |
.IR /proc/ pid /oom_adj |
| 69 |
can still be used to tune the badness score. |
| 70 |
Its value is |
| 71 |
scaled linearly with |
| 72 |
.IR oom_score_adj . |
| 73 |
.IP |
| 74 |
Writing to |
| 75 |
.IR /proc/ pid /oom_score_adj |
| 76 |
or |
| 77 |
.IR /proc/ pid /oom_adj |
| 78 |
will change the other with its scaled value. |
| 79 |
.IP |
| 80 |
The |
| 81 |
.BR choom (1) |
| 82 |
program provides a command-line interface for adjusting the |
| 83 |
.I oom_score_adj |
| 84 |
value of a running process or a newly executed command. |
| 85 |
.SH HISTORY |
| 86 |
.TP |
| 87 |
.IR /proc/ pid /oom_adj " (since Linux 2.6.11)" |
| 88 |
This file can be used to adjust the score used to select which process |
| 89 |
should be killed in an out-of-memory (OOM) situation. |
| 90 |
The kernel uses this value for a bit-shift operation of the process's |
| 91 |
.I oom_score |
| 92 |
value: |
| 93 |
valid values are in the range \-16 to +15, |
| 94 |
plus the special value \-17, |
| 95 |
which disables OOM-killing altogether for this process. |
| 96 |
A positive score increases the likelihood of this |
| 97 |
process being killed by the OOM-killer; |
| 98 |
a negative score decreases the likelihood. |
| 99 |
.IP |
| 100 |
The default value for this file is 0; |
| 101 |
a new process inherits its parent's |
| 102 |
.I oom_adj |
| 103 |
setting. |
| 104 |
A process must be privileged |
| 105 |
.RB ( CAP_SYS_RESOURCE ) |
| 106 |
to update this file, |
| 107 |
although a process can always increase its own |
| 108 |
.I oom_adj |
| 109 |
setting (since Linux 2.6.20). |
| 110 |
.IP |
| 111 |
Since Linux 2.6.36, use of this file is deprecated in favor of |
| 112 |
.IR /proc/ pid /oom_score_adj , |
| 113 |
and finally removed in Linux 3.7. |
| 114 |
.SH SEE ALSO |
| 115 |
.BR proc (5), |
| 116 |
.BR proc_pid_oom_score (5) |