History

mm/memcg: move cgroup high memory limit setting into struct page_counter

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.

Jakub Kicinski committed 6 years ago

Commit d1663a91 parent ff144e63 files · +19 −11Browse files

Showing the changes to include/linux (2 of 3 files). Show all

Unified · Split

2 files
  1. include/linux/memcontrol.h +0 −3
  2. include/linux/page_counter.h +8 −0
include/linux/memcontrol.h+0−3
@@ -215,9 +215,6 @@ struct mem_cgroup { · 214 unmodified lines
215215 struct page_counter kmem;
216216 struct page_counter tcpmem;
217217
218− /* Upper bound of normal memory consumption range */
219− unsigned long high;
220−
221218 /* Range enforcement for interrupt charges */
222219 struct work_struct high_work;
223220
include/linux/page_counter.h+8−0
@@ -10,6 +10,7 @@ struct page_counter { · 9 unmodified lines
1010 atomic_long_t usage;
1111 unsigned long min;
1212 unsigned long low;
13+ unsigned long high;
1314 unsigned long max;
1415 struct page_counter *parent;
1516
@@ -55,6 +56,13 @@ bool page_counter_try_charge(struct page_counter *counter, · 39 unmodified lines
5556 void page_counter_uncharge(struct page_counter *counter, unsigned long nr_pages);
5657 void page_counter_set_min(struct page_counter *counter, unsigned long nr_pages);
5758 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+
5866 int page_counter_set_max(struct page_counter *counter, unsigned long nr_pages);
5967 int page_counter_memparse(const char *buf, const char *max,
6068 unsigned long *nr_pages);