From 95ae05c0e79868c22b3e8e6fbc53432786876730 Mon Sep 17 00:00:00 2001 From: WaLyong Cho Date: Fri, 16 May 2014 00:09:34 +0900 Subject: core: add startup resource control option Similar to CPUShares= and BlockIOWeight= respectively. However only assign the specified weight during startup. Each control group attribute is re-assigned as weight by CPUShares=weight and BlockIOWeight=weight after startup. If not CPUShares= or BlockIOWeight= be specified, then the attribute is re-assigned to each default attribute value. (default cpu.shares=1024, blkio.weight=1000) If only CPUShares=weight or BlockIOWeight=weight be specified, then that implies StartupCPUShares=weight and StartupBlockIOWeight=weight. --- src/core/unit.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/core/unit.c') diff --git a/src/core/unit.c b/src/core/unit.c index 41651bab87..ea55c709b0 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1071,6 +1071,20 @@ static int unit_add_mount_dependencies(Unit *u) { return 0; } +static int unit_add_startup_units(Unit *u) { + CGroupContext *c; + int r = 0; + + c = unit_get_cgroup_context(u); + if (c != NULL && manager_state(u->manager) == MANAGER_STARTING && + (c->startup_cpu_shares_set || c->startup_blockio_weight_set)) { + r = set_put(u->manager->startup_units, u); + if (r == -EEXIST) + r = 0; + } + return r; +} + int unit_load(Unit *u) { int r; @@ -1112,6 +1126,10 @@ int unit_load(Unit *u) { if (r < 0) goto fail; + r = unit_add_startup_units(u); + if (r < 0) + goto fail; + if (u->on_failure_job_mode == JOB_ISOLATE && set_size(u->dependencies[UNIT_ON_FAILURE]) > 1) { log_error_unit(u->id, "More than one OnFailure= dependencies specified for %s but OnFailureJobMode=isolate set. Refusing.", u->id); r = -EINVAL; -- cgit v1.2.3-54-g00ecf