[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1310393706-321-3-git-send-email-fweisbec@gmail.com>
Date: Mon, 11 Jul 2011 16:15:01 +0200
From: Frederic Weisbecker <fweisbec@...il.com>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Frederic Weisbecker <fweisbec@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Paul Menage <menage@...gle.com>,
Li Zefan <lizf@...fujitsu.com>,
Johannes Weiner <hannes@...xchg.org>,
Aditya Kali <adityakali@...gle.com>
Subject: [PATCH 2/7] cgroups: New resource counter inheritance API
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@...il.com>
Cc: Paul Menage <menage@...gle.com>
Cc: Li Zefan <lizf@...fujitsu.com>
Cc: Johannes Weiner <hannes@...xchg.org>
Cc: Aditya Kali <adityakali@...gle.com>
---
include/linux/res_counter.h | 2 ++
kernel/res_counter.c | 25 +++++++++++++++++++++++++
2 files changed, 27 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 806d041..8cb0362 100644
--- a/kernel/res_counter.c
+++ b/kernel/res_counter.c
@@ -198,3 +198,28 @@ 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 *pval, val;
+ unsigned long flags;
+
+ parent = counter->parent;
+ if (!parent)
+ return;
+
+ local_irq_save(flags);
+
+ spin_lock(&counter->lock);
+ pval = res_counter_member(counter, member);
+ val = *pval;
+ spin_unlock(&counter->lock);
+
+ spin_lock(&parent->lock);
+ pval = res_counter_member(parent, member);
+ *pval = val;
+ spin_unlock(&parent->lock);
+
+ local_irq_restore(flags);
+}
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists