[PATCH 1/9] cgroups: add res_counter_write_u64() API
Dwight Engen
dwight.engen at oracle.com
Thu Dec 12 21:35:10 UTC 2013
From: Frederic Weisbecker <fweisbec at gmail.com>
Extend the resource counter API with a mirror of res_counter_read_u64() to
make it handy to update a resource counter value from a cgroup subsystem
u64 value file.
[kirill at shutemov.name: Separate 32 bits and 64 bits versions]
Signed-off-by: Frederic Weisbecker <fweisbec at gmail.com>
Acked-by: Paul Menage <paul at paulmenage.org>
Cc: Li Zefan <lizf at cn.fujitsu.com>
Cc: Johannes Weiner <hannes at cmpxchg.org>
Cc: Aditya Kali <adityakali at google.com>
Cc: Oleg Nesterov <oleg at redhat.com>
Cc: Tim Hockin <thockin at hockin.org>
Cc: Tejun Heo <htejun at gmail.com>
Cc: Containers <containers at lists.linux-foundation.org>
Cc: Glauber Costa <glommer at gmail.com>
Cc: Cgroups <cgroups at vger.kernel.org>
Cc: Daniel J Walsh <dwalsh at redhat.com>
Cc: "Daniel P. Berrange" <berrange at redhat.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu at jp.fujitsu.com>
Cc: Max Kellermann <mk at cm4all.com>
Cc: Mandeep Singh Baines <msb at chromium.org>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Kirill A. Shutemov <kirill at shutemov.name>
---
include/linux/res_counter.h | 2 ++
kernel/res_counter.c | 14 ++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
index 201a697..eb78440 100644
--- a/include/linux/res_counter.h
+++ b/include/linux/res_counter.h
@@ -78,6 +78,8 @@ ssize_t res_counter_read(struct res_counter *counter, int member,
int res_counter_memparse_write_strategy(const char *buf,
unsigned long long *res);
+void res_counter_write_u64(struct res_counter *counter, int member, u64 val);
+
/*
* the field descriptors. one for each member of res_counter
*/
diff --git a/kernel/res_counter.c b/kernel/res_counter.c
index 4aa8a30..673a7a6 100644
--- a/kernel/res_counter.c
+++ b/kernel/res_counter.c
@@ -170,11 +170,25 @@ u64 res_counter_read_u64(struct res_counter *counter, int member)
return ret;
}
+
+void res_counter_write_u64(struct res_counter *counter, int member, u64 val)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&counter->lock, flags);
+ *res_counter_member(counter, member) = val;
+ spin_unlock_irqrestore(&counter->lock, flags);
+}
#else
u64 res_counter_read_u64(struct res_counter *counter, int member)
{
return *res_counter_member(counter, member);
}
+
+void res_counter_write_u64(struct res_counter *counter, int member, u64 val)
+{
+ *res_counter_member(counter, member) = val;
+}
#endif
int res_counter_memparse_write_strategy(const char *buf,
--
1.8.3.1
More information about the Containers
mailing list