Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 308918
b: refs/heads/master
c: 2bb2ba9
h: refs/heads/master
v: v3
  • Loading branch information
Frederic Weisbecker authored and Linus Torvalds committed May 29, 2012
1 parent 8fc4dfd commit b7ba881
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f9be23d6da035241b7687b25e64401171986dcef
refs/heads/master: 2bb2ba9d51a8044a71a29608d2c4ef8f5b2d57a2
8 changes: 8 additions & 0 deletions trunk/Documentation/cgroups/resource_counter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ to work with it.

The _locked routines imply that the res_counter->lock is taken.

f. void res_counter_uncharge_until
(struct res_counter *rc, struct res_counter *top,
unsinged long val)

Almost same as res_cunter_uncharge() but propagation of uncharge
stops when rc == top. This is useful when kill a res_coutner in
child cgroup.

2.1 Other accounting routines

There are more routines that may help you with common needs, like
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/res_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ int __must_check res_counter_charge_nofail(struct res_counter *counter,
void res_counter_uncharge_locked(struct res_counter *counter, unsigned long val);
void res_counter_uncharge(struct res_counter *counter, unsigned long val);

void res_counter_uncharge_until(struct res_counter *counter,
struct res_counter *top,
unsigned long val);
/**
* res_counter_margin - calculate chargeable space of a counter
* @cnt: the counter
Expand Down
10 changes: 8 additions & 2 deletions trunk/kernel/res_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,26 @@ void res_counter_uncharge_locked(struct res_counter *counter, unsigned long val)
counter->usage -= val;
}

void res_counter_uncharge(struct res_counter *counter, unsigned long val)
void res_counter_uncharge_until(struct res_counter *counter,
struct res_counter *top,
unsigned long val)
{
unsigned long flags;
struct res_counter *c;

local_irq_save(flags);
for (c = counter; c != NULL; c = c->parent) {
for (c = counter; c != top; c = c->parent) {
spin_lock(&c->lock);
res_counter_uncharge_locked(c, val);
spin_unlock(&c->lock);
}
local_irq_restore(flags);
}

void res_counter_uncharge(struct res_counter *counter, unsigned long val)
{
res_counter_uncharge_until(counter, NULL, val);
}

static inline unsigned long long *
res_counter_member(struct res_counter *counter, int member)
Expand Down

0 comments on commit b7ba881

Please sign in to comment.