res_counter: Merge some common code
cover res_counter: Merge some common code
Just a small code factorizing. I hope Glauber can have a look at the second patch to confirm this is what we want for the net memcg controller (that is the only user of the nofail version AFAICS).
Thanks.
Frederic Weisbecker (2):
res_counter: Merge res_counter_charge and res_counter_charge_nofail
res_counter: Account max_usage when calling
res_counter_charge_nofail()
Documentation/cgroups/resource_counter.txt | 4 +- include/linux/res_counter.h | 2 +- kernel/res_counter.c | 71 +++++++++++++--------------- 3 files changed, 36 insertions(+), 41 deletions(-)
Signature · 1 line
1.7.5.4
PATCH 1/2 res_counter: Merge res_counter_charge and res_counter_charge_nofail
These two functions do almost the same thing and duplicate some code. Merge their implementation into a single common function. res_counter_charge_locked() takes one more parameter but it doesn't seem to be used outside res_counter.c yet anyway.
There is no (intended) change in the behaviour.
--- Documentation/cgroups/resource_counter.txt | 4 +- include/linux/res_counter.h | 2 +- kernel/res_counter.c | 73 +++++++++++++--------------- 3 files changed, 37 insertions(+), 42 deletions(-)
Documentation/cgroups/resource_counter.txt +2 -2
@@ -77,11 +77,11 @@ to work with it. where the charging failed. d. int res_counter_charge_locked - (struct res_counter *rc, unsigned long val) + (struct res_counter *rc, unsigned long val, bool force) The same as res_counter_charge(), but it must not acquire/release the res_counter->lock internally (it must be called with res_counter->lock - held). + held). The force parameter indicates whether we can bypass the limit. e. void res_counter_uncharge[_locked] (struct res_counter *rc, unsigned long val)
include/linux/res_counter.h +1 -1
@@ -116,7 +116,7 @@ void res_counter_init(struct res_counter *counter, struct res_counter *parent);*/ int __must_check res_counter_charge_locked (struct res_counter *counter, -unsigned long val); +unsigned long val,bool force);int __must_check res_counter_charge (struct res_counter *counter,unsigned long val,struct res_counter **limit_fail_at); int __must_check res_counter_charge_nofail(struct res_counter *counter,
kernel/res_counter.c +34 -39
109 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 2/2 res_counter: Account max_usage when calling res_counter_charge_nofail()
In reply to Frederic WeisbeckerUpdating max_usage is something one would expect when we reach a new maximum usage value even when we do this by forcing through the limit with res_counter_charge_nofail().
(Whether we want to account failcnt when we force through the limit is another debate).
--- kernel/res_counter.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/res_counter.c +1 -1
@@ -35,7 +35,7 @@ int res_counter_charge_locked(struct res_counter *counter, unsigned long val, } counter->usage += val; -if (!force && counter->usage > counter->max_usage) +if (counter->usage > counter->max_usage) counter->max_usage = counter->usage;return ret; }
Signature · 1 line
1.7.5.4
Re: [PATCH 1/2] res_counter: Merge res_counter_charge and res_counter_charge_nofail
In reply to Frederic WeisbeckerQuoted 5 lines · Frederic Weisbecker
These two functions do almost the same thing and duplicate some code. Merge their implementation into a single common function.
res_counter_charge_locked()takes one more parameter but it doesn't seem to be used outsideres_counter.cyet anyway.
Quoted 8 lines
There is no (intended) change in the behaviour.
Signed-off-by Frederic Weisbecker <[email protected]>Cc Tejun Heo <[email protected]>Cc Li Zefan <[email protected]>Cc KAMEZAWA Hiroyuki <[email protected]>Cc Glauber Costa <[email protected]>Cc Kirill A. Shutemov <[email protected]>
Re: [PATCH 2/2] res_counter: Account max_usage when calling res_counter_charge_nofail()
In reply to Frederic WeisbeckerQuoted 7 lines · Frederic Weisbecker
Updating
max_usageis something one would expect when we reach a new maximum usage value even when we do this by forcing through the limit withres_counter_charge_nofail().(Whether we want to account failcnt when we force through the limit is another debate).
Quoted 6 lines
Signed-off-by Frederic Weisbecker <[email protected]>Cc Tejun Heo <[email protected]>Cc Li Zefan <[email protected]>Cc KAMEZAWA Hiroyuki <[email protected]>Cc Glauber Costa <[email protected]>Cc Kirill A. Shutemov <[email protected]>
Quoted 11 lines · Frederic Weisbecker
Just a small code factorizing. I hope Glauber can have a look at the second patch to confirm this is what we want for the net memcg controller (that is the only user of the nofail version AFAICS).
Thanks.
Frederic Weisbecker (2):
res_counter: Mergeres_counter_chargeandres_counter_charge_nofail
res_counter: Accountmax_usagewhen calling
res_counter_charge_nofail()
Quoted 4 lines
Documentation/cgroups/resource_counter.txt | 4 +- include/linux/res_counter.h | 2 +- kernel/res_counter.c | 71 +++++++++++++--------------- 3 files changed, 36 insertions(+), 41 deletions(-)
Signature · 1 line
Kirill A. Shutemov
Glauber Costa
Acked-byRe: [PATCH 1/2] res_counter: Merge res_counter_charge and res_counter_charge_nofail
In reply to KAMEZAWA HiroyukiQuoted 17 lines · KAMEZAWA Hiroyuki
Quoted 5 lines · Frederic Weisbecker
These two functions do almost the same thing and duplicate some code. Merge their implementation into a single common function.
res_counter_charge_locked()takes one more parameter but it doesn't seem to be used outsideres_counter.cyet anyway.Quoted 8 lines
There is no (intended) change in the behaviour.
Signed-off-by Frederic Weisbecker<[email protected]>Cc Tejun Heo<[email protected]>Cc Li Zefan<[email protected]>Cc KAMEZAWA Hiroyuki<[email protected]>Cc Glauber Costa<[email protected]>Cc Kirill A. Shutemov<[email protected]>
Quoted 2 lines
Acked-by KAMEZAWA Hiroyuki<[email protected]>
Glauber Costa
Acked-byRe: [PATCH 2/2] res_counter: Account max_usage when calling res_counter_charge_nofail()
In reply to KAMEZAWA HiroyukiQuoted 17 lines · KAMEZAWA Hiroyuki
Quoted 7 lines · Frederic Weisbecker
Updating
max_usageis something one would expect when we reach a new maximum usage value even when we do this by forcing through the limit withres_counter_charge_nofail().(Whether we want to account failcnt when we force through the limit is another debate).
Quoted 6 lines
Signed-off-by Frederic Weisbecker<[email protected]>Cc Tejun Heo<[email protected]>Cc Li Zefan<[email protected]>Cc KAMEZAWA Hiroyuki<[email protected]>Cc Glauber Costa<[email protected]>Cc Kirill A. Shutemov<[email protected]>
Quoted 2 lines
Acked-by KAMEZAWA Hiroyuki<[email protected]>
Tejun Heo
AppliedRe: [PATCH 1/2] res_counter: Merge res_counter_charge and res_counter_charge_nofail
In reply to Frederic WeisbeckerQuoted 5 lines · Frederic Weisbecker
These two functions do almost the same thing and duplicate some code. Merge their implementation into a single common function.
res_counter_charge_locked()takes one more parameter but it doesn't seem to be used outsideres_counter.cyet anyway.
Quoted 8 lines
There is no (intended) change in the behaviour.
Signed-off-by Frederic Weisbecker <[email protected]>Cc Tejun Heo <[email protected]>Cc Li Zefan <[email protected]>Cc KAMEZAWA Hiroyuki <[email protected]>Cc Glauber Costa <[email protected]>Cc Kirill A. Shutemov <[email protected]>
Applied to cgroup/for-3.5. Thanks.
Signature · 1 line
tejun
Tejun Heo
AppliedRe: [PATCH 2/2] res_counter: Account max_usage when calling res_counter_charge_nofail()
In reply to Frederic WeisbeckerQuoted 7 lines · Frederic Weisbecker
Updating
max_usageis something one would expect when we reach a new maximum usage value even when we do this by forcing through the limit withres_counter_charge_nofail().(Whether we want to account failcnt when we force through the limit is another debate).
Quoted 6 lines
Signed-off-by Frederic Weisbecker <[email protected]>Cc Tejun Heo <[email protected]>Cc Li Zefan <[email protected]>Cc KAMEZAWA Hiroyuki <[email protected]>Cc Glauber Costa <[email protected]>Cc Kirill A. Shutemov <[email protected]>
Applied to cgroup/for-3.5. Thanks.
Signature · 1 line
tejun