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