[systemd-devel] [PATCH] cgroup: propagate cgroup mask only for proportional properties
WaLyong Cho
walyong.cho at samsung.com
Thu Mar 26 23:10:04 PDT 2015
Some of cgroup properties does not affect to sibling
cgroups. CPUShares and BlockIOWeight are only needed to be propagated.
---
src/core/cgroup.c | 29 ++++++++++++++++++++++++++++-
src/core/cgroup.h | 2 ++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 6b8abb4..b4b9678 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -458,6 +458,23 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha
}
}
+CGroupControllerMask cgroup_context_get_proportional_mask(CGroupContext *c) {
+ CGroupControllerMask mask = 0;
+
+ /* Get only proportional mask */
+
+ if (c->cpu_shares != (unsigned long) -1 ||
+ c->startup_cpu_shares != (unsigned long) -1)
+ mask |= CGROUP_CPU;
+
+ if (c->blockio_weight != (unsigned long) -1 ||
+ c->startup_blockio_weight != (unsigned long) -1 ||
+ c->blockio_device_weights)
+ mask |= CGROUP_BLKIO;
+
+ return mask;
+}
+
CGroupControllerMask cgroup_context_get_mask(CGroupContext *c) {
CGroupControllerMask mask = 0;
@@ -487,6 +504,16 @@ CGroupControllerMask cgroup_context_get_mask(CGroupContext *c) {
return mask;
}
+CGroupControllerMask unit_get_cgroup_proportional_mask(Unit *u) {
+ CGroupContext *c;
+
+ c = unit_get_cgroup_context(u);
+ if (!c)
+ return 0;
+
+ return cgroup_context_get_proportional_mask(c);
+}
+
CGroupControllerMask unit_get_cgroup_mask(Unit *u) {
CGroupContext *c;
@@ -531,7 +558,7 @@ CGroupControllerMask unit_get_members_mask(Unit *u) {
continue;
u->cgroup_members_mask |=
- unit_get_cgroup_mask(member) |
+ unit_get_cgroup_proportional_mask(member) |
unit_get_members_mask(member);
}
}
diff --git a/src/core/cgroup.h b/src/core/cgroup.h
index 869ddae..2371158 100644
--- a/src/core/cgroup.h
+++ b/src/core/cgroup.h
@@ -98,12 +98,14 @@ void cgroup_context_done(CGroupContext *c);
void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix);
void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const char *path, ManagerState state);
+CGroupControllerMask cgroup_context_get_proportional_mask(CGroupContext *c);
CGroupControllerMask cgroup_context_get_mask(CGroupContext *c);
void cgroup_context_free_device_allow(CGroupContext *c, CGroupDeviceAllow *a);
void cgroup_context_free_blockio_device_weight(CGroupContext *c, CGroupBlockIODeviceWeight *w);
void cgroup_context_free_blockio_device_bandwidth(CGroupContext *c, CGroupBlockIODeviceBandwidth *b);
+CGroupControllerMask unit_get_cgroup_proportional_mask(Unit *u);
CGroupControllerMask unit_get_cgroup_mask(Unit *u);
CGroupControllerMask unit_get_siblings_mask(Unit *u);
CGroupControllerMask unit_get_members_mask(Unit *u);
--
1.9.3
More information about the systemd-devel
mailing list