mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 11:46:19 +00:00
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>
This commit is contained in:
parent
302362c5ab
commit
338c843108
2 changed files with 4 additions and 15 deletions
|
@ -45,7 +45,7 @@ struct cgroup_subsys mem_cgroup_subsys __read_mostly;
|
||||||
#define MEM_CGROUP_RECLAIM_RETRIES 5
|
#define MEM_CGROUP_RECLAIM_RETRIES 5
|
||||||
|
|
||||||
#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
|
#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
|
||||||
/* Turned on only when memory cgroup is enabled && really_do_swap_account = 0 */
|
/* Turned on only when memory cgroup is enabled && really_do_swap_account = 1 */
|
||||||
int do_swap_account __read_mostly;
|
int do_swap_account __read_mostly;
|
||||||
static int really_do_swap_account __initdata = 1; /* for remember boot option*/
|
static int really_do_swap_account __initdata = 1; /* for remember boot option*/
|
||||||
#else
|
#else
|
||||||
|
@ -1763,16 +1763,14 @@ static int mem_cgroup_resize_limit(struct mem_cgroup *memcg,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mem_cgroup_resize_memsw_limit(struct mem_cgroup *memcg,
|
static int mem_cgroup_resize_memsw_limit(struct mem_cgroup *memcg,
|
||||||
unsigned long long val)
|
unsigned long long val)
|
||||||
{
|
{
|
||||||
int retry_count;
|
int retry_count;
|
||||||
u64 memlimit, oldusage, curusage;
|
u64 memlimit, oldusage, curusage;
|
||||||
int children = mem_cgroup_count_children(memcg);
|
int children = mem_cgroup_count_children(memcg);
|
||||||
int ret = -EBUSY;
|
int ret = -EBUSY;
|
||||||
|
|
||||||
if (!do_swap_account)
|
|
||||||
return -EINVAL;
|
|
||||||
/* see mem_cgroup_resize_res_limit */
|
/* see mem_cgroup_resize_res_limit */
|
||||||
retry_count = children * MEM_CGROUP_RECLAIM_RETRIES;
|
retry_count = children * MEM_CGROUP_RECLAIM_RETRIES;
|
||||||
oldusage = res_counter_read_u64(&memcg->memsw, RES_USAGE);
|
oldusage = res_counter_read_u64(&memcg->memsw, RES_USAGE);
|
||||||
|
@ -2007,8 +2005,7 @@ static u64 mem_cgroup_read(struct cgroup *cont, struct cftype *cft)
|
||||||
val = res_counter_read_u64(&mem->res, name);
|
val = res_counter_read_u64(&mem->res, name);
|
||||||
break;
|
break;
|
||||||
case _MEMSWAP:
|
case _MEMSWAP:
|
||||||
if (do_swap_account)
|
val = res_counter_read_u64(&mem->memsw, name);
|
||||||
val = res_counter_read_u64(&mem->memsw, name);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BUG();
|
BUG();
|
||||||
|
|
|
@ -311,8 +311,6 @@ static int swap_cgroup_prepare(int type)
|
||||||
struct swap_cgroup_ctrl *ctrl;
|
struct swap_cgroup_ctrl *ctrl;
|
||||||
unsigned long idx, max;
|
unsigned long idx, max;
|
||||||
|
|
||||||
if (!do_swap_account)
|
|
||||||
return 0;
|
|
||||||
ctrl = &swap_cgroup_ctrl[type];
|
ctrl = &swap_cgroup_ctrl[type];
|
||||||
|
|
||||||
for (idx = 0; idx < ctrl->length; idx++) {
|
for (idx = 0; idx < ctrl->length; idx++) {
|
||||||
|
@ -349,9 +347,6 @@ unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id)
|
||||||
struct swap_cgroup *sc;
|
struct swap_cgroup *sc;
|
||||||
unsigned short old;
|
unsigned short old;
|
||||||
|
|
||||||
if (!do_swap_account)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ctrl = &swap_cgroup_ctrl[type];
|
ctrl = &swap_cgroup_ctrl[type];
|
||||||
|
|
||||||
mappage = ctrl->map[idx];
|
mappage = ctrl->map[idx];
|
||||||
|
@ -380,9 +375,6 @@ unsigned short lookup_swap_cgroup(swp_entry_t ent)
|
||||||
struct swap_cgroup *sc;
|
struct swap_cgroup *sc;
|
||||||
unsigned short ret;
|
unsigned short ret;
|
||||||
|
|
||||||
if (!do_swap_account)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ctrl = &swap_cgroup_ctrl[type];
|
ctrl = &swap_cgroup_ctrl[type];
|
||||||
mappage = ctrl->map[idx];
|
mappage = ctrl->map[idx];
|
||||||
sc = page_address(mappage);
|
sc = page_address(mappage);
|
||||||
|
|
Loading…
Reference in a new issue