summaryrefslogtreecommitdiff
path: root/src/core/dbus-cgroup.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/dbus-cgroup.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/dbus-cgroup.c')
-rw-r--r--src/core/dbus-cgroup.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index e9bdabf93..a7c8ca6c2 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -173,11 +173,13 @@ const sd_bus_vtable bus_cgroup_vtable[] = {
SD_BUS_VTABLE_START(0),
SD_BUS_PROPERTY("CPUAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, cpu_accounting), 0),
SD_BUS_PROPERTY("CPUShares", "t", bus_property_get_ulong, offsetof(CGroupContext, cpu_shares), 0),
+ SD_BUS_PROPERTY("StartupCPUShares", "t", bus_property_get_ulong, offsetof(CGroupContext, startup_cpu_shares), 0),
SD_BUS_PROPERTY("CPUQuotaPerSecUSec", "t", property_get_cpu_quota_per_sec_usec, 0, 0),
SD_BUS_PROPERTY("CPUQuotaUSec", "t", property_get_cpu_quota_usec, 0, 0),
SD_BUS_PROPERTY("CPUQuotaPeriodUSec", "t", bus_property_get_usec, offsetof(CGroupContext, cpu_quota_period_usec), 0),
SD_BUS_PROPERTY("BlockIOAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, blockio_accounting), 0),
SD_BUS_PROPERTY("BlockIOWeight", "t", bus_property_get_ulong, offsetof(CGroupContext, blockio_weight), 0),
+ SD_BUS_PROPERTY("StartupBlockIOWeight", "t", bus_property_get_ulong, offsetof(CGroupContext, startup_blockio_weight), 0),
SD_BUS_PROPERTY("BlockIODeviceWeight", "a(st)", property_get_blockio_device_weight, 0, 0),
SD_BUS_PROPERTY("BlockIOReadBandwidth", "a(st)", property_get_blockio_device_bandwidths, 0, 0),
SD_BUS_PROPERTY("BlockIOWriteBandwidth", "a(st)", property_get_blockio_device_bandwidths, 0, 0),
@@ -238,6 +240,26 @@ int bus_cgroup_set_property(
return 1;
+ } else if (streq(name, "StartupCPUShares")) {
+ uint64_t u64;
+ unsigned long ul;
+
+ r = sd_bus_message_read(message, "t", &u64);
+ if (r < 0)
+ return r;
+
+ ul = (unsigned long) u64;
+ if (ul <= 0 || (uint64_t) ul != u64)
+ return sd_bus_error_set_errnof(error, EINVAL, "StartupCPUShares value out of range");
+
+ if (mode != UNIT_CHECK) {
+ c->startup_cpu_shares = ul;
+ c->startup_cpu_shares_set = true;
+ unit_write_drop_in_private_format(u, mode, name, "StartupCPUShares=%lu", ul);
+ }
+
+ return 1;
+
} else if (streq(name, "CPUQuotaPerSecUSec")) {
uint64_t u64;
@@ -330,6 +352,26 @@ int bus_cgroup_set_property(
return 1;
+ } else if (streq(name, "StartupBlockIOWeight")) {
+ uint64_t u64;
+ unsigned long ul;
+
+ r = sd_bus_message_read(message, "t", &u64);
+ if (r < 0)
+ return r;
+
+ ul = (unsigned long) u64;
+ if (ul < 10 || ul > 1000)
+ return sd_bus_error_set_errnof(error, EINVAL, "StartupBlockIOWeight value out of range");
+
+ if (mode != UNIT_CHECK) {
+ c->startup_blockio_weight = ul;
+ c->startup_blockio_weight_set = true;
+ unit_write_drop_in_private_format(u, mode, name, "StartupBlockIOWeight=%lu", ul);
+ }
+
+ return 1;
+
} else if (streq(name, "BlockIOReadBandwidth") || streq(name, "BlockIOWriteBandwidth")) {
const char *path;
bool read = true;