summaryrefslogtreecommitdiff
path: root/src/core/load-fragment.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-07-19 15:58:49 +0200
committerLennart Poettering <lennart@poettering.net>2016-07-22 15:33:12 +0200
commit83f8e80857090f63cf6a02c54d381dad3c0fad55 (patch)
treee224c1dd3d5a139acfb0eb7a0d42dfd5cd31f3aa /src/core/load-fragment.c
parentbf3dd08a81f7500973d8a4add8c73a0856ae5f7d (diff)
core: support percentage specifications on TasksMax=
This adds support for a TasksMax=40% syntax for specifying values relative to the system's configured maximum number of processes. This is useful in order to neatly subdivide the available room for tasks within containers.
Diffstat (limited to 'src/core/load-fragment.c')
-rw-r--r--src/core/load-fragment.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 782e420e4c..cd7bf9c707 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -2861,9 +2861,18 @@ int config_parse_tasks_max(
return 0;
}
- r = safe_atou64(rvalue, &u);
- if (r < 0 || u < 1) {
- log_syntax(unit, LOG_ERR, filename, line, r, "Maximum tasks value '%s' invalid. Ignoring.", rvalue);
+ r = parse_percent(rvalue);
+ if (r < 0) {
+ r = safe_atou64(rvalue, &u);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r, "Maximum tasks value '%s' invalid. Ignoring.", rvalue);
+ return 0;
+ }
+ } else
+ u = system_tasks_max_scale(r, 100U);
+
+ if (u <= 0 || u >= UINT64_MAX) {
+ log_syntax(unit, LOG_ERR, filename, line, 0, "Maximum tasks value '%s' out of range. Ignoring.", rvalue);
return 0;
}