From: Frederic Weisbecker <fweisbec@xxxxxxxxx> 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@xxxxxxxxxxxxx: Separate 32 bits and 64 bits versions] Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx> Acked-by: Paul Menage <paul@xxxxxxxxxxxxxx> Cc: Li Zefan <lizf@xxxxxxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Aditya Kali <adityakali@xxxxxxxxxx> Cc: Oleg Nesterov <oleg@xxxxxxxxxx> Cc: Tim Hockin <thockin@xxxxxxxxxx> Cc: Tejun Heo <htejun@xxxxxxxxx> Cc: Containers <containers@xxxxxxxxxxxxxxxxxxxxxxxxxx> Cc: Glauber Costa <glommer@xxxxxxxxx> Cc: Cgroups <cgroups@xxxxxxxxxxxxxxx> Cc: Daniel J Walsh <dwalsh@xxxxxxxxxx> Cc: "Daniel P. Berrange" <berrange@xxxxxxxxxx> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> Cc: Max Kellermann <mk@xxxxxxxxxx> Cc: Mandeep Singh Baines <msb@xxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Kirill A. Shutemov <kirill@xxxxxxxxxxxxx> --- 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 _______________________________________________ Containers mailing list Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/containers