equal
deleted
inserted
replaced
7 * |
7 * |
8 * Copyright 2007 OpenVZ SWsoft Inc |
8 * Copyright 2007 OpenVZ SWsoft Inc |
9 * |
9 * |
10 * Author: Pavel Emelianov <xemul@openvz.org> |
10 * Author: Pavel Emelianov <xemul@openvz.org> |
11 * |
11 * |
12 * See Documentation/controllers/resource_counter.txt for more |
12 * See Documentation/cgroups/resource_counter.txt for more |
13 * info about what this counter is. |
13 * info about what this counter is. |
14 */ |
14 */ |
15 |
15 |
16 #include <linux/cgroup.h> |
16 #include <linux/cgroup.h> |
17 |
17 |
41 /* |
41 /* |
42 * the lock to protect all of the above. |
42 * the lock to protect all of the above. |
43 * the routines below consider this to be IRQ-safe |
43 * the routines below consider this to be IRQ-safe |
44 */ |
44 */ |
45 spinlock_t lock; |
45 spinlock_t lock; |
|
46 /* |
|
47 * Parent counter, used for hierarchial resource accounting |
|
48 */ |
|
49 struct res_counter *parent; |
46 }; |
50 }; |
47 |
51 |
48 /** |
52 /** |
49 * Helpers to interact with userspace |
53 * Helpers to interact with userspace |
50 * res_counter_read_u64() - returns the value of the specified member. |
54 * res_counter_read_u64() - returns the value of the specified member. |
85 |
89 |
86 /* |
90 /* |
87 * helpers for accounting |
91 * helpers for accounting |
88 */ |
92 */ |
89 |
93 |
90 void res_counter_init(struct res_counter *counter); |
94 void res_counter_init(struct res_counter *counter, struct res_counter *parent); |
91 |
95 |
92 /* |
96 /* |
93 * charge - try to consume more resource. |
97 * charge - try to consume more resource. |
94 * |
98 * |
95 * @counter: the counter |
99 * @counter: the counter |
101 */ |
105 */ |
102 |
106 |
103 int __must_check res_counter_charge_locked(struct res_counter *counter, |
107 int __must_check res_counter_charge_locked(struct res_counter *counter, |
104 unsigned long val); |
108 unsigned long val); |
105 int __must_check res_counter_charge(struct res_counter *counter, |
109 int __must_check res_counter_charge(struct res_counter *counter, |
106 unsigned long val); |
110 unsigned long val, struct res_counter **limit_fail_at); |
107 |
111 |
108 /* |
112 /* |
109 * uncharge - tell that some portion of the resource is released |
113 * uncharge - tell that some portion of the resource is released |
110 * |
114 * |
111 * @counter: the counter |
115 * @counter: the counter |