summaryrefslogtreecommitdiff
path: root/src/core/load-fragment.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-05-22 11:53:12 +0900
committerLennart Poettering <lennart@poettering.net>2014-05-22 11:53:12 +0900
commit9a0549093332880df47c4218209ce126b8586835 (patch)
tree3f929d8ef12b580f5c6ed91b7316bbbac4d4a299 /src/core/load-fragment.c
parent609e002e78e79ef2bf9d6a6ea22bda215abbbb14 (diff)
cgroups: simplify CPUQuota= logic
Only accept cpu quota values in percentages, get rid of period definition. It's not clear whether the CFS period controllable per-cgroup even has a future in the kernel, hence let's simplify all this, hardcode the period to 100ms and only accept percentage based quota values.
Diffstat (limited to 'src/core/load-fragment.c')
-rw-r--r--src/core/load-fragment.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 7c5b49c85b..6403e41113 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -2465,7 +2465,7 @@ int config_parse_cpu_quota(
void *userdata) {
CGroupContext *c = data;
- int r;
+ double percent;
assert(filename);
assert(lvalue);
@@ -2473,30 +2473,22 @@ int config_parse_cpu_quota(
if (isempty(rvalue)) {
c->cpu_quota_per_sec_usec = (usec_t) -1;
- c->cpu_quota_usec = (usec_t) -1;
return 0;
}
- if (endswith(rvalue, "%")) {
- double percent;
-
- if (sscanf(rvalue, "%lf%%", &percent) != 1 || percent <= 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' invalid. Ignoring.", rvalue);
- return 0;
- }
+ if (!endswith(rvalue, "%")) {
- c->cpu_quota_per_sec_usec = (usec_t) (percent * USEC_PER_SEC / 100);
- c->cpu_quota_usec = (usec_t) -1;
- } else {
- r = parse_sec(rvalue, &c->cpu_quota_usec);
- if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' invalid. Ignoring.", rvalue);
- return 0;
- }
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' not ending in '%%'. Ignoring.", rvalue);
+ return 0;
+ }
- c->cpu_quota_per_sec_usec = (usec_t) -1;
+ if (sscanf(rvalue, "%lf%%", &percent) != 1 || percent <= 0) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' invalid. Ignoring.", rvalue);
+ return 0;
}
+ c->cpu_quota_per_sec_usec = (usec_t) (percent * USEC_PER_SEC / 100);
+
return 0;
}