High memory limit is currently recorded directly in struct mem_cgroup. We are about to add a high limit for swap, move the field to struct page_counter and add some helpers.
Showing the changes to include/linux (2 of 3 files). Show all
Unified · Split
| @@ -215,9 +215,6 @@ struct mem_cgroup { · 214 unmodified lines | |||
| 215 | struct page_counter kmem; | 215 | struct page_counter kmem; |
| 216 | struct page_counter tcpmem; | 216 | struct page_counter tcpmem; |
| 217 | 217 | ||
| 218 | /* Upper bound of normal memory consumption range */ | ||
| 219 | unsigned long high; | ||
| 220 | |||
| 221 | /* Range enforcement for interrupt charges */ | 218 | /* Range enforcement for interrupt charges */ |
| 222 | struct work_struct high_work; | 219 | struct work_struct high_work; |
| 223 | 220 | ||
| @@ -10,6 +10,7 @@ struct page_counter { · 9 unmodified lines | |||
| 10 | atomic_long_t usage; | 10 | atomic_long_t usage; |
| 11 | unsigned long min; | 11 | unsigned long min; |
| 12 | unsigned long low; | 12 | unsigned long low; |
| 13 | unsigned long high; | ||
| 13 | unsigned long max; | 14 | unsigned long max; |
| 14 | struct page_counter *parent; | 15 | struct page_counter *parent; |
| 15 | 16 | ||
| @@ -55,6 +56,13 @@ bool page_counter_try_charge(struct page_counter *counter, · 39 unmodified lines | |||
| 55 | void page_counter_uncharge(struct page_counter *counter, unsigned long nr_pages); | 56 | void page_counter_uncharge(struct page_counter *counter, unsigned long nr_pages); |
| 56 | void page_counter_set_min(struct page_counter *counter, unsigned long nr_pages); | 57 | void page_counter_set_min(struct page_counter *counter, unsigned long nr_pages); |
| 57 | void page_counter_set_low(struct page_counter *counter, unsigned long nr_pages); | 58 | void page_counter_set_low(struct page_counter *counter, unsigned long nr_pages); |
| 59 | |||
| 60 | static inline void page_counter_set_high(struct page_counter *counter, | ||
| 61 | unsigned long nr_pages) | ||
| 62 | { | ||
| 63 | WRITE_ONCE(counter->high, nr_pages); | ||
| 64 | } | ||
| 65 | |||
| 58 | int page_counter_set_max(struct page_counter *counter, unsigned long nr_pages); | 66 | int page_counter_set_max(struct page_counter *counter, unsigned long nr_pages); |
| 59 | int page_counter_memparse(const char *buf, const char *max, | 67 | int page_counter_memparse(const char *buf, const char *max, |
| 60 | unsigned long *nr_pages); | 68 | unsigned long *nr_pages); |