summaryrefslogtreecommitdiff
path: root/src/core/load-fragment.c
diff options
context:
space:
mode:
authorWaLyong Cho <walyong.cho@samsung.com>2014-05-16 00:09:34 +0900
committerLennart Poettering <lennart@poettering.net>2014-05-22 07:13:56 +0900
commit95ae05c0e79868c22b3e8e6fbc53432786876730 (patch)
tree874e9eb9902db34ded1e65ef88bbaf29d2f5aa4e /src/core/load-fragment.c
parent7e4f9431caf4be39f39b64634f7708d7ca217d41 (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/load-fragment.c')
-rw-r--r--src/core/load-fragment.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 25a3905591..da1ab2f912 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -2451,6 +2451,47 @@ int config_parse_cpu_shares(
}
c->cpu_shares = lu;
+ if (!c->startup_cpu_shares_set)
+ c->startup_cpu_shares = lu;
+
+ return 0;
+}
+
+int config_parse_startup_cpu_shares(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ CGroupContext *c = data;
+ unsigned long lu;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+
+ if (isempty(rvalue)) {
+ c->startup_cpu_shares = 1024;
+ return 0;
+ }
+
+ r = safe_atolu(rvalue, &lu);
+ if (r < 0 || lu <= 0) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Startup CPU shares '%s' invalid. Ignoring.", rvalue);
+ return 0;
+ }
+
+ c->startup_cpu_shares = lu;
+ c->startup_cpu_shares_set = true;
+
return 0;
}
@@ -2628,6 +2669,46 @@ int config_parse_blockio_weight(
}
c->blockio_weight = lu;
+ if (!c->startup_blockio_weight_set)
+ c->startup_blockio_weight = lu;
+
+ return 0;
+}
+
+int config_parse_startup_blockio_weight(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ CGroupContext *c = data;
+ unsigned long lu;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+
+ if (isempty(rvalue)) {
+ c->startup_blockio_weight = 1000;
+ return 0;
+ }
+
+ r = safe_atolu(rvalue, &lu);
+ if (r < 0 || lu < 10 || lu > 1000) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Startup Block IO weight '%s' invalid. Ignoring.", rvalue);
+ return 0;
+ }
+
+ c->startup_blockio_weight = lu;
+ c->startup_blockio_weight_set = true;
return 0;
}
@@ -3445,11 +3526,13 @@ void unit_dump_config_items(FILE *f) {
{ config_parse_address_families, "FAMILIES" },
#endif
{ config_parse_cpu_shares, "SHARES" },
+ { config_parse_startup_cpu_shares, "STARTUPSHARES" },
{ config_parse_memory_limit, "LIMIT" },
{ config_parse_device_allow, "DEVICE" },
{ config_parse_device_policy, "POLICY" },
{ config_parse_blockio_bandwidth, "BANDWIDTH" },
{ config_parse_blockio_weight, "WEIGHT" },
+ { config_parse_startup_blockio_weight, "STARTUPWEIGHT" },
{ config_parse_blockio_device_weight, "DEVICEWEIGHT" },
{ config_parse_long, "LONG" },
{ config_parse_socket_service, "SERVICE" },