lkml.org 
[lkml]   [2011]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 02/12] cgroups: New resource counter inheritance API
Date
Provide an API to inherit a counter value from a parent.
This can be useful to implement cgroup.clone_children on
a resource counter.

Still the resources of the children are limited by those
of the parent, so this is only to provide a default setting
behaviour when clone_children is set.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Menage <paul@paulmenage.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Aditya Kali <adityakali@google.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Tim Hockin <thockin@hockin.org>
Cc: Tejun Heo <tj@kernel.org>
---
include/linux/res_counter.h | 2 ++
kernel/res_counter.c | 12 ++++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
index 1b3fe05..109d118 100644
--- a/include/linux/res_counter.h
+++ b/include/linux/res_counter.h
@@ -84,6 +84,8 @@ int res_counter_write(struct res_counter *counter, int member,

void res_counter_write_u64(struct res_counter *counter, int member, u64 val);

+void res_counter_inherit(struct res_counter *counter, int member);
+
/*
* the field descriptors. one for each member of res_counter
*/
diff --git a/kernel/res_counter.c b/kernel/res_counter.c
index 0faafcc..1349115 100644
--- a/kernel/res_counter.c
+++ b/kernel/res_counter.c
@@ -202,3 +202,15 @@ int res_counter_write(struct res_counter *counter, int member,

return 0;
}
+
+void res_counter_inherit(struct res_counter *counter, int member)
+{
+ struct res_counter *parent;
+ unsigned long long val;
+
+ parent = counter->parent;
+ if (parent) {
+ val = res_counter_read_u64(parent, member);
+ res_counter_write_u64(counter, member, val);
+ }
+}
--
1.7.5.4


\
 
 \ /
  Last update: 2011-09-06 02:17    [W:0.137 / U:0.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site