Re: [systemd-devel] [PATCH 1/5] cgroup: add the setting memory.use_hierarchy support for systemd

2013-09-17 Thread Lennart Poettering
On Mon, 16.09.13 09:57, Gao feng (gaof...@cn.fujitsu.com) wrote:

 
 On 09/13/2013 08:26 PM, Lennart Poettering wrote:
  On Fri, 13.09.13 17:49, Gao feng (gaof...@cn.fujitsu.com) wrote:
  
  Some programs need to set the memory.use_hierarchy(such as libvirt),
  Add this feature.
  
  Hmm, should this really be an option? Shouldn't we much rather turn this
  on unconditionally if the memory controller is used for a unit?
  
  This appears like an option that would go a way in Tejun's new sane
  cgroup tree logic anyway, no?
  
 
 So, systemd has no job to deal with memory hierarchy? the kernel will
 support memory hierarchy unconditionally? right?

Hmm? What I was suggesting is that memory.use_hierarchy should be the
default for systemd, and not configurable by the user, under the
assumption that with Tejun's sane_behaviour thing this would become the
default anyway?

Tejun?

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/5] cgroup: add the setting memory.use_hierarchy support for systemd

2013-09-15 Thread Gao feng
On 09/13/2013 08:26 PM, Lennart Poettering wrote:
 On Fri, 13.09.13 17:49, Gao feng (gaof...@cn.fujitsu.com) wrote:
 
 Some programs need to set the memory.use_hierarchy(such as libvirt),
 Add this feature.
 
 Hmm, should this really be an option? Shouldn't we much rather turn this
 on unconditionally if the memory controller is used for a unit?
 
 This appears like an option that would go a way in Tejun's new sane
 cgroup tree logic anyway, no?
 

So, systemd has no job to deal with memory hierarchy? the kernel will
support memory hierarchy unconditionally? right?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/5] cgroup: add the setting memory.use_hierarchy support for systemd

2013-09-13 Thread Gao feng
Some programs need to set the memory.use_hierarchy(such as libvirt),
Add this feature.
---
 src/core/cgroup.c |  9 +
 src/core/cgroup.h |  1 +
 src/core/dbus-cgroup.c| 16 
 src/core/load-fragment-gperf.gperf.m4 |  1 +
 4 files changed, 27 insertions(+)

diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 244baff..336d394 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -274,6 +274,14 @@ void cgroup_context_apply(CGroupContext *c, 
CGroupControllerMask mask, const cha
 
 if (r  0)
 log_error(Failed to set memory.soft_limit_in_bytes on 
%s: %s, path, strerror(-r));
+
+if (c-memory_hierarchy)
+r = cg_set_attribute(memory, path, 
memory.use_hierarchy, 1);
+else
+r = cg_set_attribute(memory, path, 
memory.use_hierarchy, 0);
+
+if (r  0)
+log_error(Failed to set memory.use_hierarchy on %s: 
%s, path, strerror(-r));
 }
 
 if (mask  CGROUP_DEVICE) {
@@ -336,6 +344,7 @@ CGroupControllerMask cgroup_context_get_mask(CGroupContext 
*c) {
 mask |= CGROUP_BLKIO;
 
 if (c-memory_accounting ||
+c-memory_hierarchy ||
 c-memory_limit != (uint64_t) -1 ||
 c-memory_soft_limit != (uint64_t) -1)
 mask |= CGROUP_MEMORY;
diff --git a/src/core/cgroup.h b/src/core/cgroup.h
index 786bd71..c35eea5 100644
--- a/src/core/cgroup.h
+++ b/src/core/cgroup.h
@@ -69,6 +69,7 @@ struct CGroupContext {
 bool cpu_accounting;
 bool blockio_accounting;
 bool memory_accounting;
+bool memory_hierarchy;
 
 unsigned long cpu_shares;
 
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index 1f2a396..20a913c 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -132,6 +132,7 @@ const BusProperty bus_cgroup_context_properties[] = {
 { BlockIOReadBandwidth,bus_cgroup_append_device_bandwidths, 
a(st), 0   },
 { BlockIOWriteBandwidth,   bus_cgroup_append_device_bandwidths, 
a(st), 0   },
 { MemoryAccounting,bus_property_append_bool,b, 
offsetof(CGroupContext, memory_accounting)  },
+{ MemoryHierarchy, bus_property_append_bool,b, 
offsetof(CGroupContext, memory_hierarchy)   },
 { MemoryLimit, bus_property_append_uint64,  t, 
offsetof(CGroupContext, memory_limit)   },
 { MemorySoftLimit, bus_property_append_uint64,  t, 
offsetof(CGroupContext, memory_soft_limit)  },
 { DevicePolicy,bus_cgroup_append_device_policy, s, 
offsetof(CGroupContext, device_policy)  },
@@ -438,6 +439,21 @@ int bus_cgroup_set_property(
 
 return 1;
 
+} else if (streq(name, MemoryHierarchy)) {
+
+if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_BOOLEAN)
+return -EINVAL;
+
+if (mode != UNIT_CHECK) {
+dbus_bool_t b;
+dbus_message_iter_get_basic(i, b);
+
+c-memory_hierarchy = b;
+unit_write_drop_in_private(u, mode, name, b ? 
MemoryHierarchy=yes : MemoryHierarchy=no);
+}
+
+return 1;
+
 } else if (streq(name, DevicePolicy)) {
 const char *policy;
 CGroupDevicePolicy p;
diff --git a/src/core/load-fragment-gperf.gperf.m4 
b/src/core/load-fragment-gperf.gperf.m4
index 33c6880..bc57780 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -88,6 +88,7 @@ m4_define(`CGROUP_CONTEXT_CONFIG_ITEMS',
 $1.CPUAccounting,config_parse_bool,  0,
 offsetof($1, cgroup_context.cpu_accounting)
 $1.CPUShares,config_parse_cpu_shares,0,
 offsetof($1, cgroup_context)
 $1.MemoryAccounting, config_parse_bool,  0,
 offsetof($1, cgroup_context.memory_accounting)
+$1.MemoryHierarchy,  config_parse_bool,  0,
 offsetof($1, cgroup_context.memory_hierarchy)
 $1.MemoryLimit,  config_parse_memory_limit,  0,
 offsetof($1, cgroup_context)
 $1.MemorySoftLimit,  config_parse_memory_limit,  0,
 offsetof($1, cgroup_context)
 $1.DeviceAllow,  config_parse_device_allow,  0,
 offsetof($1, cgroup_context)
-- 
1.8.3.1

___
systemd-devel mailing list

Re: [systemd-devel] [PATCH 1/5] cgroup: add the setting memory.use_hierarchy support for systemd

2013-09-13 Thread Lennart Poettering
On Fri, 13.09.13 17:49, Gao feng (gaof...@cn.fujitsu.com) wrote:

 Some programs need to set the memory.use_hierarchy(such as libvirt),
 Add this feature.

Hmm, should this really be an option? Shouldn't we much rather turn this
on unconditionally if the memory controller is used for a unit?

This appears like an option that would go a way in Tejun's new sane
cgroup tree logic anyway, no?

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel