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

Umut Tezduyar umut at tezduyar.com
Sun Apr 28 11:37:15 PDT 2013


Hi,

Should DefaultOOMScore= and DefaultLimit***= be really under [Manager]?
Wouldn't it be better to have an [Exec] section. Or even have [Service],
[Mount],.. sections that can give separate configuration per exec unit.

Other idea would be having both [Manager] and [Service], [Mount], .. where
configuration directives in [Service] overrides [Manager]. This way, one
can specify a top level configuration under [Manager] and overwrite it per
exec unit.

Also, there are many configuration options per exec units that are not in
the system.conf. Are we open taking patches on completing missing
configuration options?

Thanks


On Sat, Apr 27, 2013 at 4:49 PM, 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)
>
> If the unit file has 'OOMScoreAdjust' option, set the its oom_score_adj
> as declared value as before.
>
> Signed-off-by: Sangjung Woo <again4you at gmail.com>
> ---
>  src/core/main.c      |    8 ++++++++
>  src/core/system.conf |    1 +
>  src/core/user.conf   |    1 +
>  3 files changed, 10 insertions(+)
>
> diff --git a/src/core/main.c b/src/core/main.c
> index 22cec4e..e8bb015 100644
> --- a/src/core/main.c
> +++ b/src/core/main.c
> @@ -90,6 +90,7 @@ static bool arg_confirm_spawn = false;
>  static bool arg_show_status = true;
>  static bool arg_switched_root = false;
>  static char **arg_default_controllers = NULL;
> +static char *arg_default_oom_score = NULL;
>  static char ***arg_join_controllers = NULL;
>  static ExecOutput arg_default_std_output = EXEC_OUTPUT_JOURNAL;
>  static ExecOutput arg_default_std_error = EXEC_OUTPUT_INHERIT;
> @@ -641,6 +642,7 @@ static int parse_config_file(void) {
>                  { "Manager", "DefaultStandardOutput",
> config_parse_output,       0, &arg_default_std_output  },
>                  { "Manager", "DefaultStandardError",
>  config_parse_output,       0, &arg_default_std_error   },
>                  { "Manager", "JoinControllers",
> config_parse_join_controllers, 0, &arg_join_controllers },
> +                { "Manager", "DefaultOOMScore",
> config_parse_string,       0, &arg_default_oom_score   },
>                  { "Manager", "RuntimeWatchdogSec",    config_parse_sec,
>        0, &arg_runtime_watchdog    },
>                  { "Manager", "ShutdownWatchdogSec",   config_parse_sec,
>        0, &arg_shutdown_watchdog   },
>                  { "Manager", "CapabilityBoundingSet",
> config_parse_bounding_set, 0, &arg_capability_bounding_set_drop },
> @@ -1414,6 +1416,12 @@ int main(int argc, char *argv[]) {
>          if (parse_config_file() < 0)
>                  goto finish;
>
> +        if (arg_default_oom_score)
> +                if (write_string_file("/proc/self/oom_score_adj",
> arg_default_oom_score) < 0){
> +                        log_error("Fail to set default oom_score_adj:
> %s", arg_default_oom_score);
> +                        goto finish;
> +                }
> +
>          if (arg_running_as == SYSTEMD_SYSTEM)
>                  if (parse_proc_cmdline() < 0)
>                          goto finish;
> diff --git a/src/core/system.conf b/src/core/system.conf
> index 508e0f5..7c0e12e 100644
> --- a/src/core/system.conf
> +++ b/src/core/system.conf
> @@ -41,3 +41,4 @@
>  #DefaultLimitNICE=
>  #DefaultLimitRTPRIO=
>  #DefaultLimitRTTIME=
> +#DefaultOOMScore=
> diff --git a/src/core/user.conf b/src/core/user.conf
> index 4252451..f101e99 100644
> --- a/src/core/user.conf
> +++ b/src/core/user.conf
> @@ -15,3 +15,4 @@
>  #DefaultControllers=cpu
>  #DefaultStandardOutput=inherit
>  #DefaultStandardError=inherit
> +#DefaultOOMScore=
> --
> 1.7.10.4
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130428/e96f1d45/attachment.html>


More information about the systemd-devel mailing list