[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1328067470-5980-2-git-send-email-fweisbec@gmail.com>
Date: Wed, 1 Feb 2012 04:37:41 +0100
From: Frederic Weisbecker <fweisbec@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Tejun Heo <tj@...nel.org>, Li Zefan <lizf@...fujitsu.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
Frederic Weisbecker <fweisbec@...il.com>,
Johannes Weiner <hannes@...xchg.org>,
Aditya Kali <adityakali@...gle.com>,
Oleg Nesterov <oleg@...hat.com>,
Tim Hockin <thockin@...kin.org>, Tejun Heo <htejun@...il.com>,
Containers <containers@...ts.linux-foundation.org>,
Glauber Costa <glommer@...il.com>,
Cgroups <cgroups@...r.kernel.org>,
Daniel J Walsh <dwalsh@...hat.com>,
"Daniel P. Berrange" <berrange@...hat.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
Max Kellermann <mk@...all.com>,
Mandeep Singh Baines <msb@...omium.org>,
"Kirill A. Shutemov" <kirill@...temov.name>
Subject: [PATCH 01/10] cgroups: add res_counter_write_u64() API
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@...temov.name: Separate 32 bits and 64 bits versions]
Signed-off-by: Frederic Weisbecker <fweisbec@...il.com>
Acked-by: Paul Menage <paul@...lmenage.org>
Cc: Li Zefan <lizf@...fujitsu.com>
Cc: Johannes Weiner <hannes@...xchg.org>
Cc: Aditya Kali <adityakali@...gle.com>
Cc: Oleg Nesterov <oleg@...hat.com>
Cc: Tim Hockin <thockin@...kin.org>
Cc: Tejun Heo <htejun@...il.com>
Cc: Containers <containers@...ts.linux-foundation.org>
Cc: Glauber Costa <glommer@...il.com>
Cc: Cgroups <cgroups@...r.kernel.org>
Cc: Daniel J Walsh <dwalsh@...hat.com>
Cc: "Daniel P. Berrange" <berrange@...hat.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc: Max Kellermann <mk@...all.com>
Cc: Mandeep Singh Baines <msb@...omium.org>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Kirill A. Shutemov <kirill@...temov.name>
---
include/linux/res_counter.h | 2 ++
kernel/res_counter.c | 31 +++++++++++++++++++++++++------
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
index c9d625c..1b3fe05 100644
--- a/include/linux/res_counter.h
+++ b/include/linux/res_counter.h
@@ -82,6 +82,8 @@ int res_counter_memparse_write_strategy(const char *buf,
int res_counter_write(struct res_counter *counter, int member,
const char *buffer, write_strategy_fn write_strategy);
+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 6d269cc..c46465c 100644
--- a/kernel/res_counter.c
+++ b/kernel/res_counter.c
@@ -167,12 +167,32 @@ int res_counter_memparse_write_strategy(const char *buf,
return 0;
}
+#if BITS_PER_LONG == 32
+void res_counter_write_u64(struct res_counter *counter, int member, u64 val)
+{
+ unsigned long long *target;
+ unsigned long flags;
+
+ spin_lock_irqsave(&counter->lock, flags);
+ target = res_counter_member(counter, member);
+ *target = val;
+ spin_unlock_irqrestore(&counter->lock, flags);
+}
+#else
+void res_counter_write_u64(struct res_counter *counter, int member, u64 val)
+{
+ unsigned long long *target;
+
+ target = res_counter_member(counter, member);
+ *target = val;
+}
+#endif
+
int res_counter_write(struct res_counter *counter, int member,
const char *buf, write_strategy_fn write_strategy)
{
char *end;
- unsigned long flags;
- unsigned long long tmp, *val;
+ unsigned long long tmp;
if (write_strategy) {
if (write_strategy(buf, &tmp))
@@ -182,9 +202,8 @@ int res_counter_write(struct res_counter *counter, int member,
if (*end != '\0')
return -EINVAL;
}
- spin_lock_irqsave(&counter->lock, flags);
- val = res_counter_member(counter, member);
- *val = tmp;
- spin_unlock_irqrestore(&counter->lock, flags);
+
+ res_counter_write_u64(counter, member, tmp);
+
return 0;
}
--
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