diff options
author | WaLyong Cho <walyong.cho@samsung.com> | 2014-05-16 00:09:34 +0900 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-05-22 07:13:56 +0900 |
commit | 95ae05c0e79868c22b3e8e6fbc53432786876730 (patch) | |
tree | 874e9eb9902db34ded1e65ef88bbaf29d2f5aa4e /src/core/unit.c | |
parent | 7e4f9431caf4be39f39b64634f7708d7ca217d41 (diff) |
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.
Diffstat (limited to 'src/core/unit.c')
-rw-r--r-- | src/core/unit.c | 18 |
1 files changed, 18 insertions, 0 deletions
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; |