@@ -1034,13 +1034,13 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *memcg)
10341034 unsigned long limit ;
10351035
10361036 count = page_counter_read (& memcg -> memory );
1037- limit = READ_ONCE (memcg -> memory .limit );
1037+ limit = READ_ONCE (memcg -> memory .max );
10381038 if (count < limit )
10391039 margin = limit - count ;
10401040
10411041 if (do_memsw_account ()) {
10421042 count = page_counter_read (& memcg -> memsw );
1043- limit = READ_ONCE (memcg -> memsw .limit );
1043+ limit = READ_ONCE (memcg -> memsw .max );
10441044 if (count <= limit )
10451045 margin = min (margin , limit - count );
10461046 else
@@ -1148,13 +1148,13 @@ void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
11481148
11491149 pr_info ("memory: usage %llukB, limit %llukB, failcnt %lu\n" ,
11501150 K ((u64 )page_counter_read (& memcg -> memory )),
1151- K ((u64 )memcg -> memory .limit ), memcg -> memory .failcnt );
1151+ K ((u64 )memcg -> memory .max ), memcg -> memory .failcnt );
11521152 pr_info ("memory+swap: usage %llukB, limit %llukB, failcnt %lu\n" ,
11531153 K ((u64 )page_counter_read (& memcg -> memsw )),
1154- K ((u64 )memcg -> memsw .limit ), memcg -> memsw .failcnt );
1154+ K ((u64 )memcg -> memsw .max ), memcg -> memsw .failcnt );
11551155 pr_info ("kmem: usage %llukB, limit %llukB, failcnt %lu\n" ,
11561156 K ((u64 )page_counter_read (& memcg -> kmem )),
1157- K ((u64 )memcg -> kmem .limit ), memcg -> kmem .failcnt );
1157+ K ((u64 )memcg -> kmem .max ), memcg -> kmem .failcnt );
11581158
11591159 for_each_mem_cgroup_tree (iter , memcg ) {
11601160 pr_info ("Memory cgroup stats for " );
@@ -1179,21 +1179,21 @@ void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
11791179/*
11801180 * Return the memory (and swap, if configured) limit for a memcg.
11811181 */
1182- unsigned long mem_cgroup_get_limit (struct mem_cgroup * memcg )
1182+ unsigned long mem_cgroup_get_max (struct mem_cgroup * memcg )
11831183{
1184- unsigned long limit ;
1184+ unsigned long max ;
11851185
1186- limit = memcg -> memory .limit ;
1186+ max = memcg -> memory .max ;
11871187 if (mem_cgroup_swappiness (memcg )) {
1188- unsigned long memsw_limit ;
1189- unsigned long swap_limit ;
1188+ unsigned long memsw_max ;
1189+ unsigned long swap_max ;
11901190
1191- memsw_limit = memcg -> memsw .limit ;
1192- swap_limit = memcg -> swap .limit ;
1193- swap_limit = min (swap_limit , (unsigned long )total_swap_pages );
1194- limit = min (limit + swap_limit , memsw_limit );
1191+ memsw_max = memcg -> memsw .max ;
1192+ swap_max = memcg -> swap .max ;
1193+ swap_max = min (swap_max , (unsigned long )total_swap_pages );
1194+ max = min (max + swap_max , memsw_max );
11951195 }
1196- return limit ;
1196+ return max ;
11971197}
11981198
11991199static bool mem_cgroup_out_of_memory (struct mem_cgroup * memcg , gfp_t gfp_mask ,
@@ -2444,10 +2444,10 @@ static inline int mem_cgroup_move_swap_account(swp_entry_t entry,
24442444}
24452445#endif
24462446
2447- static DEFINE_MUTEX (memcg_limit_mutex );
2447+ static DEFINE_MUTEX (memcg_max_mutex );
24482448
2449- static int mem_cgroup_resize_limit (struct mem_cgroup * memcg ,
2450- unsigned long limit , bool memsw )
2449+ static int mem_cgroup_resize_max (struct mem_cgroup * memcg ,
2450+ unsigned long max , bool memsw )
24512451{
24522452 bool enlarge = false;
24532453 int ret ;
@@ -2460,22 +2460,22 @@ static int mem_cgroup_resize_limit(struct mem_cgroup *memcg,
24602460 break ;
24612461 }
24622462
2463- mutex_lock (& memcg_limit_mutex );
2463+ mutex_lock (& memcg_max_mutex );
24642464 /*
24652465 * Make sure that the new limit (memsw or memory limit) doesn't
2466- * break our basic invariant rule memory.limit <= memsw.limit .
2466+ * break our basic invariant rule memory.max <= memsw.max .
24672467 */
2468- limits_invariant = memsw ? limit >= memcg -> memory .limit :
2469- limit <= memcg -> memsw .limit ;
2468+ limits_invariant = memsw ? max >= memcg -> memory .max :
2469+ max <= memcg -> memsw .max ;
24702470 if (!limits_invariant ) {
2471- mutex_unlock (& memcg_limit_mutex );
2471+ mutex_unlock (& memcg_max_mutex );
24722472 ret = - EINVAL ;
24732473 break ;
24742474 }
2475- if (limit > counter -> limit )
2475+ if (max > counter -> max )
24762476 enlarge = true;
2477- ret = page_counter_limit (counter , limit );
2478- mutex_unlock (& memcg_limit_mutex );
2477+ ret = page_counter_set_max (counter , max );
2478+ mutex_unlock (& memcg_max_mutex );
24792479
24802480 if (!ret )
24812481 break ;
@@ -2757,7 +2757,7 @@ static u64 mem_cgroup_read_u64(struct cgroup_subsys_state *css,
27572757 return (u64 )mem_cgroup_usage (memcg , true) * PAGE_SIZE ;
27582758 return (u64 )page_counter_read (counter ) * PAGE_SIZE ;
27592759 case RES_LIMIT :
2760- return (u64 )counter -> limit * PAGE_SIZE ;
2760+ return (u64 )counter -> max * PAGE_SIZE ;
27612761 case RES_MAX_USAGE :
27622762 return (u64 )counter -> watermark * PAGE_SIZE ;
27632763 case RES_FAILCNT :
@@ -2871,24 +2871,24 @@ static void memcg_free_kmem(struct mem_cgroup *memcg)
28712871}
28722872#endif /* !CONFIG_SLOB */
28732873
2874- static int memcg_update_kmem_limit (struct mem_cgroup * memcg ,
2875- unsigned long limit )
2874+ static int memcg_update_kmem_max (struct mem_cgroup * memcg ,
2875+ unsigned long max )
28762876{
28772877 int ret ;
28782878
2879- mutex_lock (& memcg_limit_mutex );
2880- ret = page_counter_limit (& memcg -> kmem , limit );
2881- mutex_unlock (& memcg_limit_mutex );
2879+ mutex_lock (& memcg_max_mutex );
2880+ ret = page_counter_set_max (& memcg -> kmem , max );
2881+ mutex_unlock (& memcg_max_mutex );
28822882 return ret ;
28832883}
28842884
2885- static int memcg_update_tcp_limit (struct mem_cgroup * memcg , unsigned long limit )
2885+ static int memcg_update_tcp_max (struct mem_cgroup * memcg , unsigned long max )
28862886{
28872887 int ret ;
28882888
2889- mutex_lock (& memcg_limit_mutex );
2889+ mutex_lock (& memcg_max_mutex );
28902890
2891- ret = page_counter_limit (& memcg -> tcpmem , limit );
2891+ ret = page_counter_set_max (& memcg -> tcpmem , max );
28922892 if (ret )
28932893 goto out ;
28942894
@@ -2913,7 +2913,7 @@ static int memcg_update_tcp_limit(struct mem_cgroup *memcg, unsigned long limit)
29132913 memcg -> tcpmem_active = true;
29142914 }
29152915out :
2916- mutex_unlock (& memcg_limit_mutex );
2916+ mutex_unlock (& memcg_max_mutex );
29172917 return ret ;
29182918}
29192919
@@ -2941,16 +2941,16 @@ static ssize_t mem_cgroup_write(struct kernfs_open_file *of,
29412941 }
29422942 switch (MEMFILE_TYPE (of_cft (of )-> private )) {
29432943 case _MEM :
2944- ret = mem_cgroup_resize_limit (memcg , nr_pages , false);
2944+ ret = mem_cgroup_resize_max (memcg , nr_pages , false);
29452945 break ;
29462946 case _MEMSWAP :
2947- ret = mem_cgroup_resize_limit (memcg , nr_pages , true);
2947+ ret = mem_cgroup_resize_max (memcg , nr_pages , true);
29482948 break ;
29492949 case _KMEM :
2950- ret = memcg_update_kmem_limit (memcg , nr_pages );
2950+ ret = memcg_update_kmem_max (memcg , nr_pages );
29512951 break ;
29522952 case _TCP :
2953- ret = memcg_update_tcp_limit (memcg , nr_pages );
2953+ ret = memcg_update_tcp_max (memcg , nr_pages );
29542954 break ;
29552955 }
29562956 break ;
@@ -3126,8 +3126,8 @@ static int memcg_stat_show(struct seq_file *m, void *v)
31263126 /* Hierarchical information */
31273127 memory = memsw = PAGE_COUNTER_MAX ;
31283128 for (mi = memcg ; mi ; mi = parent_mem_cgroup (mi )) {
3129- memory = min (memory , mi -> memory .limit );
3130- memsw = min (memsw , mi -> memsw .limit );
3129+ memory = min (memory , mi -> memory .max );
3130+ memsw = min (memsw , mi -> memsw .max );
31313131 }
31323132 seq_printf (m , "hierarchical_memory_limit %llu\n" ,
31333133 (u64 )memory * PAGE_SIZE );
@@ -3626,7 +3626,7 @@ void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
36263626 * pheadroom = PAGE_COUNTER_MAX ;
36273627
36283628 while ((parent = parent_mem_cgroup (memcg ))) {
3629- unsigned long ceiling = min (memcg -> memory .limit , memcg -> high );
3629+ unsigned long ceiling = min (memcg -> memory .max , memcg -> high );
36303630 unsigned long used = page_counter_read (& memcg -> memory );
36313631
36323632 * pheadroom = min (* pheadroom , ceiling - min (ceiling , used ));
@@ -4319,12 +4319,12 @@ static void mem_cgroup_css_reset(struct cgroup_subsys_state *css)
43194319{
43204320 struct mem_cgroup * memcg = mem_cgroup_from_css (css );
43214321
4322- page_counter_limit (& memcg -> memory , PAGE_COUNTER_MAX );
4323- page_counter_limit (& memcg -> swap , PAGE_COUNTER_MAX );
4324- page_counter_limit (& memcg -> memsw , PAGE_COUNTER_MAX );
4325- page_counter_limit (& memcg -> kmem , PAGE_COUNTER_MAX );
4326- page_counter_limit (& memcg -> tcpmem , PAGE_COUNTER_MAX );
43274322 memcg -> low = 0 ;
4323+ page_counter_set_max (& memcg -> memory , PAGE_COUNTER_MAX );
4324+ page_counter_set_max (& memcg -> swap , PAGE_COUNTER_MAX );
4325+ page_counter_set_max (& memcg -> memsw , PAGE_COUNTER_MAX );
4326+ page_counter_set_max (& memcg -> kmem , PAGE_COUNTER_MAX );
4327+ page_counter_set_max (& memcg -> tcpmem , PAGE_COUNTER_MAX );
43284328 memcg -> high = PAGE_COUNTER_MAX ;
43294329 memcg -> soft_limit = PAGE_COUNTER_MAX ;
43304330 memcg_wb_domain_size_changed (memcg );
@@ -5131,7 +5131,7 @@ static ssize_t memory_high_write(struct kernfs_open_file *of,
51315131static int memory_max_show (struct seq_file * m , void * v )
51325132{
51335133 struct mem_cgroup * memcg = mem_cgroup_from_css (seq_css (m ));
5134- unsigned long max = READ_ONCE (memcg -> memory .limit );
5134+ unsigned long max = READ_ONCE (memcg -> memory .max );
51355135
51365136 if (max == PAGE_COUNTER_MAX )
51375137 seq_puts (m , "max\n" );
@@ -5155,7 +5155,7 @@ static ssize_t memory_max_write(struct kernfs_open_file *of,
51555155 if (err )
51565156 return err ;
51575157
5158- xchg (& memcg -> memory .limit , max );
5158+ xchg (& memcg -> memory .max , max );
51595159
51605160 for (;;) {
51615161 unsigned long nr_pages = page_counter_read (& memcg -> memory );
@@ -6074,7 +6074,7 @@ long mem_cgroup_get_nr_swap_pages(struct mem_cgroup *memcg)
60746074 return nr_swap_pages ;
60756075 for (; memcg != root_mem_cgroup ; memcg = parent_mem_cgroup (memcg ))
60766076 nr_swap_pages = min_t (long , nr_swap_pages ,
6077- READ_ONCE (memcg -> swap .limit ) -
6077+ READ_ONCE (memcg -> swap .max ) -
60786078 page_counter_read (& memcg -> swap ));
60796079 return nr_swap_pages ;
60806080}
@@ -6095,7 +6095,7 @@ bool mem_cgroup_swap_full(struct page *page)
60956095 return false;
60966096
60976097 for (; memcg != root_mem_cgroup ; memcg = parent_mem_cgroup (memcg ))
6098- if (page_counter_read (& memcg -> swap ) * 2 >= memcg -> swap .limit )
6098+ if (page_counter_read (& memcg -> swap ) * 2 >= memcg -> swap .max )
60996099 return true;
61006100
61016101 return false;
@@ -6129,7 +6129,7 @@ static u64 swap_current_read(struct cgroup_subsys_state *css,
61296129static int swap_max_show (struct seq_file * m , void * v )
61306130{
61316131 struct mem_cgroup * memcg = mem_cgroup_from_css (seq_css (m ));
6132- unsigned long max = READ_ONCE (memcg -> swap .limit );
6132+ unsigned long max = READ_ONCE (memcg -> swap .max );
61336133
61346134 if (max == PAGE_COUNTER_MAX )
61356135 seq_puts (m , "max\n" );
@@ -6151,9 +6151,9 @@ static ssize_t swap_max_write(struct kernfs_open_file *of,
61516151 if (err )
61526152 return err ;
61536153
6154- mutex_lock (& memcg_limit_mutex );
6155- err = page_counter_limit (& memcg -> swap , max );
6156- mutex_unlock (& memcg_limit_mutex );
6154+ mutex_lock (& memcg_max_mutex );
6155+ err = page_counter_set_max (& memcg -> swap , max );
6156+ mutex_unlock (& memcg_max_mutex );
61576157 if (err )
61586158 return err ;
61596159
0 commit comments