Blame view
include/linux/page_counter.h
2.1 KB
b24413180 License cleanup: ... |
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
3e32cb2e0 mm: memcontrol: l... |
2 3 4 5 6 7 8 9 |
#ifndef _LINUX_PAGE_COUNTER_H #define _LINUX_PAGE_COUNTER_H #include <linux/atomic.h> #include <linux/kernel.h> #include <asm/page.h> struct page_counter { |
bbec2e151 mm: rename page_c... |
10 |
atomic_long_t usage; |
bf8d5d52f memcg: introduce ... |
11 |
unsigned long min; |
230671533 mm: memory.low hi... |
12 |
unsigned long low; |
d1663a907 mm/memcg: move cg... |
13 |
unsigned long high; |
bf8d5d52f memcg: introduce ... |
14 |
unsigned long max; |
3e32cb2e0 mm: memcontrol: l... |
15 |
struct page_counter *parent; |
bf8d5d52f memcg: introduce ... |
16 17 18 19 |
/* effective memory.min and memory.min usage tracking */ unsigned long emin; atomic_long_t min_usage; atomic_long_t children_min_usage; |
230671533 mm: memory.low hi... |
20 21 22 23 |
/* effective memory.low and memory.low usage tracking */ unsigned long elow; atomic_long_t low_usage; atomic_long_t children_low_usage; |
3e32cb2e0 mm: memcontrol: l... |
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
/* legacy */ unsigned long watermark; unsigned long failcnt; }; #if BITS_PER_LONG == 32 #define PAGE_COUNTER_MAX LONG_MAX #else #define PAGE_COUNTER_MAX (LONG_MAX / PAGE_SIZE) #endif static inline void page_counter_init(struct page_counter *counter, struct page_counter *parent) { |
bbec2e151 mm: rename page_c... |
38 39 |
atomic_long_set(&counter->usage, 0); counter->max = PAGE_COUNTER_MAX; |
3e32cb2e0 mm: memcontrol: l... |
40 41 42 43 44 |
counter->parent = parent; } static inline unsigned long page_counter_read(struct page_counter *counter) { |
bbec2e151 mm: rename page_c... |
45 |
return atomic_long_read(&counter->usage); |
3e32cb2e0 mm: memcontrol: l... |
46 |
} |
64f219938 mm: memcontrol: r... |
47 |
void page_counter_cancel(struct page_counter *counter, unsigned long nr_pages); |
3e32cb2e0 mm: memcontrol: l... |
48 |
void page_counter_charge(struct page_counter *counter, unsigned long nr_pages); |
6071ca520 mm: page_counter:... |
49 50 51 |
bool page_counter_try_charge(struct page_counter *counter, unsigned long nr_pages, struct page_counter **fail); |
64f219938 mm: memcontrol: r... |
52 |
void page_counter_uncharge(struct page_counter *counter, unsigned long nr_pages); |
bf8d5d52f memcg: introduce ... |
53 |
void page_counter_set_min(struct page_counter *counter, unsigned long nr_pages); |
230671533 mm: memory.low hi... |
54 |
void page_counter_set_low(struct page_counter *counter, unsigned long nr_pages); |
d1663a907 mm/memcg: move cg... |
55 56 57 58 59 60 |
static inline void page_counter_set_high(struct page_counter *counter, unsigned long nr_pages) { WRITE_ONCE(counter->high, nr_pages); } |
bf8d5d52f memcg: introduce ... |
61 |
int page_counter_set_max(struct page_counter *counter, unsigned long nr_pages); |
650c5e565 mm: page_counter:... |
62 63 |
int page_counter_memparse(const char *buf, const char *max, unsigned long *nr_pages); |
3e32cb2e0 mm: memcontrol: l... |
64 65 66 67 68 69 70 |
static inline void page_counter_reset_watermark(struct page_counter *counter) { counter->watermark = page_counter_read(counter); } #endif /* _LINUX_PAGE_COUNTER_H */ |