Re: s6 options

From: Oliver Schad <oliver.schad_at_automatic-server.com>
Date: Wed, 4 Nov 2020 11:47:14 +0100

Hi Chaitanya

s6 is not build to mirror all kernel interfaces for process management.
This stuff is heavily system dependent and it makes to real sense to
just copy a kernel interface to a s6 option, which just works on Linux.

So the right way is to put that into the run script of your service -
it's just an echo to the /proc hierarchy, in
concrete /proc/self/oom_score_adj. It's that easy.

Look at the Linux kernel documentation, how to handle that in detail
(https://www.kernel.org/doc/Documentation/filesystems/proc.txt):

=================== snip ====================

-----------------------------------------------------------------------------
CHAPTER 3: PER-PROCESS PARAMETERS
------------------------------------------------------------------------------

3.1 /proc/<pid>/oom_adj & /proc/<pid>/oom_score_adj- Adjust the oom-killer score
--------------------------------------------------------------------------------

These file can be used to adjust the badness heuristic used to select which
process gets killed in out of memory conditions.

The badness heuristic assigns a value to each candidate task ranging from 0
(never kill) to 1000 (always kill) to determine which process is targeted. The
units are roughly a proportion along that range of allowed memory the process
may allocate from based on an estimation of its current memory and swap use.
For example, if a task is using all allowed memory, its badness score will be
1000. If it is using half of its allowed memory, its score will be 500.

There is an additional factor included in the badness score: the current memory
and swap usage is discounted by 3% for root processes.

The amount of "allowed" memory depends on the context in which the oom killer
was called. If it is due to the memory assigned to the allocating task's cpuset
being exhausted, the allowed memory represents the set of mems assigned to that
cpuset. If it is due to a mempolicy's node(s) being exhausted, the allowed
memory represents the set of mempolicy nodes. If it is due to a memory
limit (or swap limit) being reached, the allowed memory is that configured
limit. Finally, if it is due to the entire system being out of memory, the
allowed memory represents all allocatable resources.

The value of /proc/<pid>/oom_score_adj is added to the badness score before it
is used to determine which task to kill. Acceptable values range from -1000
(OOM_SCORE_ADJ_MIN) to +1000 (OOM_SCORE_ADJ_MAX). This allows userspace to
polarize the preference for oom killing either by always preferring a certain
task or completely disabling it. The lowest possible value, -1000, is
equivalent to disabling oom killing entirely for that task since it will always
report a badness score of 0.

========================== snap ====================================

On Wed, 4 Nov 2020 15:45:19 +0530
billa chaitanya <billachaitanya_at_gmail.com> wrote:

> Hi Team,
> Is there any option available in s6 (like oom-kill-protect )
> equivalent to "OOMScoreAdjust" of systemd ?
>
>
> Thanks,
> Chaitanya



-- 
Automatic-Server AG •••••
Oliver Schad
Geschäftsführer
Turnerstrasse 2
9000 St. Gallen | Schweiz
www.automatic-server.com | oliver.schad_at_automatic-server.com
Tel: +41 71 511 31 11 | Mobile: +41 76 330 03 47



Received on Wed Nov 04 2020 - 10:47:14 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:44:19 UTC