Commit 338c843108bf5030d6765f4405126e70f8b77845

Authored by Li Zefan
Committed by Linus Torvalds
1 parent 302362c5ab

memcg: remove some redundant checks

We don't need to check do_swap_account in the case that the function which
checks do_swap_account will never get called if do_swap_account == 0.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 4 additions and 15 deletions Side-by-side Diff

... ... @@ -45,7 +45,7 @@
45 45 #define MEM_CGROUP_RECLAIM_RETRIES 5
46 46  
47 47 #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
48   -/* Turned on only when memory cgroup is enabled && really_do_swap_account = 0 */
  48 +/* Turned on only when memory cgroup is enabled && really_do_swap_account = 1 */
49 49 int do_swap_account __read_mostly;
50 50 static int really_do_swap_account __initdata = 1; /* for remember boot option*/
51 51 #else
52 52  
... ... @@ -1763,16 +1763,14 @@
1763 1763 return ret;
1764 1764 }
1765 1765  
1766   -int mem_cgroup_resize_memsw_limit(struct mem_cgroup *memcg,
1767   - unsigned long long val)
  1766 +static int mem_cgroup_resize_memsw_limit(struct mem_cgroup *memcg,
  1767 + unsigned long long val)
1768 1768 {
1769 1769 int retry_count;
1770 1770 u64 memlimit, oldusage, curusage;
1771 1771 int children = mem_cgroup_count_children(memcg);
1772 1772 int ret = -EBUSY;
1773 1773  
1774   - if (!do_swap_account)
1775   - return -EINVAL;
1776 1774 /* see mem_cgroup_resize_res_limit */
1777 1775 retry_count = children * MEM_CGROUP_RECLAIM_RETRIES;
1778 1776 oldusage = res_counter_read_u64(&memcg->memsw, RES_USAGE);
... ... @@ -2007,8 +2005,7 @@
2007 2005 val = res_counter_read_u64(&mem->res, name);
2008 2006 break;
2009 2007 case _MEMSWAP:
2010   - if (do_swap_account)
2011   - val = res_counter_read_u64(&mem->memsw, name);
  2008 + val = res_counter_read_u64(&mem->memsw, name);
2012 2009 break;
2013 2010 default:
2014 2011 BUG();
... ... @@ -311,8 +311,6 @@
311 311 struct swap_cgroup_ctrl *ctrl;
312 312 unsigned long idx, max;
313 313  
314   - if (!do_swap_account)
315   - return 0;
316 314 ctrl = &swap_cgroup_ctrl[type];
317 315  
318 316 for (idx = 0; idx < ctrl->length; idx++) {
... ... @@ -349,9 +347,6 @@
349 347 struct swap_cgroup *sc;
350 348 unsigned short old;
351 349  
352   - if (!do_swap_account)
353   - return 0;
354   -
355 350 ctrl = &swap_cgroup_ctrl[type];
356 351  
357 352 mappage = ctrl->map[idx];
... ... @@ -379,9 +374,6 @@
379 374 struct page *mappage;
380 375 struct swap_cgroup *sc;
381 376 unsigned short ret;
382   -
383   - if (!do_swap_account)
384   - return 0;
385 377  
386 378 ctrl = &swap_cgroup_ctrl[type];
387 379 mappage = ctrl->map[idx];