1 |
On Sat, Feb 29, 2020 at 9:49 AM Dale <rdalek1967@×××××.com> wrote: |
2 |
> |
3 |
> I have noticed the OOM killing the wrong thing as well. In a way, how |
4 |
> does it know what it should kill really??? After all, the process using |
5 |
> the most memory may not be the problem but another one, or more, could. |
6 |
> I guess in most cases the one using the most is the bad one but it may |
7 |
> not always be the case. I'm not sure how OOM could determine that tho. |
8 |
> Maybe having some setting like you mentions would help. It's a thought. |
9 |
|
10 |
Oh, plenty of people have given thought to it. |
11 |
|
12 |
The algorithm is actually not as well-documented as I thought it was. |
13 |
Lots of documents, but they're fragmented. Behavior is also |
14 |
configurable. For example, you can just tell Linux to panic on OOM, |
15 |
or just have it kill the process that triggered OOM even if it isn't |
16 |
using much memory. |
17 |
|
18 |
Best docs I could find are at (among other places): |
19 |
https://github.com/torvalds/linux/blob/master/Documentation/filesystems/proc.txt#L1520 |
20 |
|
21 |
Aside from setting limits on services so that they die/restart before |
22 |
overall system memory is threatened, adjusting oom_score_adj lets you |
23 |
tweak overall priorities for any process. |
24 |
|
25 |
By default it mostly comes down to what process is hogging the most |
26 |
RAM, with slight preference for root-owned processes. |
27 |
|
28 |
Really though setting resource limits is your best bet. Then you can |
29 |
set a threshold above normal use, and if something misbehaves it is |
30 |
going to get restarted before most of RAM is taken. User session |
31 |
cgroups can of course be limited as well so that interactive processes |
32 |
can't just go nuts and use all your RAM. |
33 |
|
34 |
-- |
35 |
Rich |