[systemd-devel] [PATCH 1/1] RFC: Set the Default OOM Score from configuration file

Lennart Poettering lennart at poettering.net
Fri May 3 07:49:09 PDT 2013


On Sat, 27.04.13 07:49, Sangjung Woo (again4you at gmail.com) wrote:

> If 'OOMScoreAdjust' option is ommited from unit file, this patch makes
> the executed process's oom_score_adj as default OOM score in case of
> explicitly 'DefaultOOMScore' is declared in configuration file.
> (i.e. system.conf and user.conf)

This definitely sounds like a useful addition!

> If the unit file has 'OOMScoreAdjust' option, set the its oom_score_adj
> as declared value as before.

I'd prefer to call this option OOMScoreAdjust= too, i.e. not with the
"Default" prefix, and use the same nomenclature as the per-service
option.

Generally, the entries in system.conf that are not prefixed with
"Default" apply to PID 1 itself, while those prefixed with "Default" are
defaults for units, and are not applied to PID 1. Since this option
would apply to PID 1 it hence should not carry the "Default" prefix.

> +static char *arg_default_oom_score = NULL;

This should probably be an "int", i.e. the same way as we store this in
struct ExecContext, see src/core/execute.h for details. Also, since this
value can validly be negative, postive and 0, we'd need an additional
bool to indicate whether the value is set at all.

We should also validate all settings we read immediately and refuse
invalid settings. See config_parse_exec_oom_score_adjust() in
src/core/load-fragment.c for inspiration.

Also, this patch would need a matching man page update.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list