Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

res_counter: limit change support ebusy

Add an interface to set limit. This is necessary to memory resource
controller because it shrinks usage at set limit.

Other controllers may not need this interface to shrink usage because
shrinking is not necessary or impossible.

Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Paul Menage <menage@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

KAMEZAWA Hiroyuki and committed by
Linus Torvalds
12b98044 cede86ac

+16
+16
include/linux/res_counter.h
··· 158 158 cnt->failcnt = 0; 159 159 spin_unlock_irqrestore(&cnt->lock, flags); 160 160 } 161 + 162 + static inline int res_counter_set_limit(struct res_counter *cnt, 163 + unsigned long long limit) 164 + { 165 + unsigned long flags; 166 + int ret = -EBUSY; 167 + 168 + spin_lock_irqsave(&cnt->lock, flags); 169 + if (cnt->usage < limit) { 170 + cnt->limit = limit; 171 + ret = 0; 172 + } 173 + spin_unlock_irqrestore(&cnt->lock, flags); 174 + return ret; 175 + } 176 + 161 177 #endif