Lines Matching full:counter
50 * page_counter_cancel - take pages out of the local counter
51 * @counter: counter
54 void page_counter_cancel(struct page_counter *counter, unsigned long nr_pages) in page_counter_cancel() argument
58 new = atomic_long_sub_return(nr_pages, &counter->usage); in page_counter_cancel()
63 atomic_long_set(&counter->usage, new); in page_counter_cancel()
65 if (track_protection(counter)) in page_counter_cancel()
66 propagate_protected_usage(counter, new); in page_counter_cancel()
71 * @counter: counter
74 * NOTE: This does not consider any configured counter limits.
76 void page_counter_charge(struct page_counter *counter, unsigned long nr_pages) in page_counter_charge() argument
79 bool protection = track_protection(counter); in page_counter_charge()
81 for (c = counter; c; c = c->parent) { in page_counter_charge()
111 * @counter: counter
113 * @fail: points first counter to hit its limit, if any
115 * Returns %true on success, or %false and @fail if the counter or one
118 bool page_counter_try_charge(struct page_counter *counter, in page_counter_try_charge() argument
123 bool protection = track_protection(counter); in page_counter_try_charge()
124 bool track_failcnt = counter->track_failcnt; in page_counter_try_charge()
126 for (c = counter; c; c = c->parent) { in page_counter_try_charge()
140 * counter has changed and retries. in page_counter_try_charge()
168 for (c = counter; c != *fail; c = c->parent) in page_counter_try_charge()
176 * @counter: counter
179 void page_counter_uncharge(struct page_counter *counter, unsigned long nr_pages) in page_counter_uncharge() argument
183 for (c = counter; c; c = c->parent) in page_counter_uncharge()
189 * @counter: counter
193 * counter already exceeds the specified limit.
195 * The caller must serialize invocations on the same counter.
197 int page_counter_set_max(struct page_counter *counter, unsigned long nr_pages) in page_counter_set_max() argument
205 * below the concurrently-changing counter value. in page_counter_set_max()
212 * modified counter and retry. in page_counter_set_max()
214 usage = page_counter_read(counter); in page_counter_set_max()
219 old = xchg(&counter->max, nr_pages); in page_counter_set_max()
221 if (page_counter_read(counter) <= usage || nr_pages >= old) in page_counter_set_max()
224 counter->max = old; in page_counter_set_max()
231 * @counter: counter
234 * The caller must serialize invocations on the same counter.
236 void page_counter_set_min(struct page_counter *counter, unsigned long nr_pages) in page_counter_set_min() argument
240 WRITE_ONCE(counter->min, nr_pages); in page_counter_set_min()
242 for (c = counter; c; c = c->parent) in page_counter_set_min()
248 * @counter: counter
251 * The caller must serialize invocations on the same counter.
253 void page_counter_set_low(struct page_counter *counter, unsigned long nr_pages) in page_counter_set_low() argument
257 WRITE_ONCE(counter->low, nr_pages); in page_counter_set_low()
259 for (c = counter; c; c = c->parent) in page_counter_set_low()
264 * page_counter_memparse - memparse() for page counter limits
295 * This function calculates an individual page counter's effective
316 * if one counter claims much more protection than it uses memory,
321 * budget is NOT proportional. A counter's protection from a sibling
325 * without having to declare each individual counter's fixed share
328 * proportion to each counter's *usage*. This makes the protection
416 * @counter: the page_counter the counter to update
425 struct page_counter *counter, in page_counter_calculate_protection() argument
429 struct page_counter *parent = counter->parent; in page_counter_calculate_protection()
438 if (root == counter) in page_counter_calculate_protection()
441 usage = page_counter_read(counter); in page_counter_calculate_protection()
446 counter->emin = READ_ONCE(counter->min); in page_counter_calculate_protection()
447 counter->elow = READ_ONCE(counter->low); in page_counter_calculate_protection()
453 WRITE_ONCE(counter->emin, effective_protection(usage, parent_usage, in page_counter_calculate_protection()
454 READ_ONCE(counter->min), in page_counter_calculate_protection()
459 WRITE_ONCE(counter->elow, effective_protection(usage, parent_usage, in page_counter_calculate_protection()
460 READ_ONCE(counter->low), in page_counter_calculate_protection()