Skip to contentSkip to conversation

res_counter: Merge some common code

PATCH Applied Frederic Weisbecker 5 participants 10 messages Apr 24, 2012 – Apr 27, 2012 Documentation

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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.

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]>
---
 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
index 95b24d7..f3c4ec3 100644
@@ -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
index da81af0..fb20189 100644
@@ -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
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] res_counter: Merge res_counter_charge and res_counter_charge_nofail

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 outside res_counter.c yet anyway.

Quoted 8 lines

There is no (intended) change in the behaviour.

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]>
Acked-by
#3 lore raw

Re: [PATCH 1/2] res_counter: Merge res_counter_charge and res_counter_charge_nofail

Quoted 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 outside res_counter.c yet anyway.

Quoted 8 lines

There is no (intended) change in the behaviour.

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
Applied
#4 lore raw

Re: [PATCH 1/2] res_counter: Merge res_counter_charge and res_counter_charge_nofail

In reply to Frederic Weisbecker
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 outside res_counter.c yet anyway.

Quoted 8 lines

There is no (intended) change in the behaviour.

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
#5 lore raw

PATCH 2/2 res_counter: Account max_usage when calling res_counter_charge_nofail()

In reply to Frederic Weisbecker

Updating 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).

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]>
---
 kernel/res_counter.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/res_counter.c +1 -1
index 07a2992..bebe2b1 100644
@@ -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
Acked-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] res_counter: Account max_usage when calling res_counter_charge_nofail()

Quoted 7 lines · Frederic Weisbecker

Updating 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).

Quoted 6 lines
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]>
Acked-by
#7 lore raw

Re: [PATCH 2/2] res_counter: Account max_usage when calling res_counter_charge_nofail()

Quoted 17 lines · KAMEZAWA Hiroyuki
Quoted 7 lines · Frederic Weisbecker

Updating 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).

Quoted 6 lines
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
Applied
#8 lore raw

Re: [PATCH 2/2] res_counter: Account max_usage when calling res_counter_charge_nofail()

In reply to Frederic Weisbecker
Quoted 7 lines · Frederic Weisbecker

Updating 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).

Quoted 6 lines
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
Acked-by on the v1 series
#9 lore raw
In reply to Frederic Weisbecker
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: Merge res_counter_charge and res_counter_charge_nofail
res_counter: Account max_usage when 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