mm/vmscan : use vmcan_swappiness( ) basing on MEMCG config to elimiate unnecessary runtime cost
Subsystems (4)
PATCH RESEND 1/1 mm/vmscan : use vmcan_swappiness( ) basing on MEMCG config to elimiate unnecessary runtime cost
Currently, we get the vm_swappiness via vmscan_swappiness(), which calls global_reclaim() to check if this is a global reclaim.
Besides, the current implementation of global_reclaim() always returns true for the !CONFIG_MEGCG case, and judges the other case by checking whether scan_control->target_mem_cgroup is null or not.
Thus, we could just use two versions of vmscan_swappiness() based on MEMCG Kconfig , to eliminate the unnecessary run-time cost for the !CONFIG_MEMCG at all, and to squash all memcg-related checking into the CONFIG_MEMCG version.
---
mm/memcontrol.c | 6 +++++- mm/vmscan.c | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-)
mm/memcontrol.c +5 -1
@@ -1525,9 +1525,13 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *memcg)int mem_cgroup_swappiness (struct mem_cgroup *memcg) { -struct cgroup *cgrp = memcg->css.cgroup; +struct cgroup *cgrp; + +if (!memcg) +return vm_swappiness;/* root ? */ + cgrp = memcg->css.cgroup;if (cgrp->parent ==NULL )return vm_swappiness;
mm/vmscan.c +7 -2
@@ -1742,12 +1742,17 @@ static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,return shrink_inactive_list (nr_to_scan, lruvec, sc, lru); } +#ifdef CONFIG_MEMCG static int vmscan_swappiness (struct scan_control *sc) { -if (global_reclaim (sc)) -return vm_swappiness;return mem_cgroup_swappiness (sc->target_mem_cgroup); } +#else +static int vmscan_swappiness (struct scan_control *sc) +{ +return vm_swappiness; +} +#endif enum scan_balance {SCAN_EQUAL ,
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Please fix a typo in subject line (which affects how easy we can access paticular patches later with grepping subject lines.)
Quoted 64 lines · larmbr
Currently, we get the
vm_swappinessviavmscan_swappiness(), which callsglobal_reclaim()to check if this is a global reclaim.Besides, the current implementation of
global_reclaim()always returns true for the !CONFIG_MEGCG case, and judges the other case by checking whetherscan_control->target_mem_cgroupis null or not.Thus, we could just use two versions of
vmscan_swappiness()based on MEMCGKconfig, to eliminate the unnecessary run-time cost for the !CONFIG_MEMCG at all, and to squash all memcg-related checking into theCONFIG_MEMCGversion.Signed-off-by Zhan Jianyu <[email protected]>---
mm/memcontrol.c | 6 +++++- mm/vmscan.c | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-)mm/memcontrol.c +5
-1@@ -1525,9 +1525,13 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *memcg)int mem_cgroup_swappiness (struct mem_cgroup *memcg) { -struct cgroup *cgrp = memcg->css.cgroup; +struct cgroup *cgrp; + +if (!memcg) +return vm_swappiness;/* root ? */ + cgrp = memcg->css.cgroup;if (cgrp->parent ==NULL )return vm_swappiness;mm/vmscan.c +7
-3@@ -1742,12 +1742,17 @@ static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,return shrink_inactive_list (nr_to_scan, lruvec, sc, lru); } +#ifdef CONFIG_MEMCG static int vmscan_swappiness (struct scan_control *sc) { -if (global_reclaim (sc)) -return vm_swappiness;return mem_cgroup_swappiness (sc->target_mem_cgroup); } +#else +static int vmscan_swappiness (struct scan_control *sc) +{ +return vm_swappiness; +} +#endif enum scan_balance {SCAN_EQUAL , --
Quoted 5 lines
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerQuoted 11 lines · larmbr
Currently, we get the
vm_swappinessviavmscan_swappiness(), which callsglobal_reclaim()to check if this is a global reclaim.Besides, the current implementation of
global_reclaim()always returns true for the !CONFIG_MEGCG case, and judges the other case by checking whetherscan_control->target_mem_cgroupis null or not.Thus, we could just use two versions of
vmscan_swappiness()based on MEMCGKconfig, to eliminate the unnecessary run-time cost for the !CONFIG_MEMCG at all, and to squash all memcg-related checking into theCONFIG_MEMCGversion.
The compiler can easily detect that global_reclaim() always returns true for !CONFIG_MEMCG during compile time and not even generate a branch for this.
Quoted 1 line
2 files changed, 12 insertions(+), 3 deletions(-)
You're adding more code for now gain.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · Johannes Weiner
Quoted 7 lines · larmbr
Currently, we get the
vm_swappinessviavmscan_swappiness(), which callsglobal_reclaim()to check if this is a global reclaim.Besides, the current implementation of
global_reclaim()always returns true for the !CONFIG_MEGCG case, and judges the other case by checking whetherscan_control->target_mem_cgroupis null or not.
Quoted 9 lines
Quoted 4 lines
Thus, we could just use two versions of
vmscan_swappiness()based on MEMCGKconfig, to eliminate the unnecessary run-time cost for the !CONFIG_MEMCG at all, and to squash all memcg-related checking into theCONFIG_MEMCGversion.The compiler can easily detect that
global_reclaim()always returns true for !CONFIG_MEMCG during compile time and not even generate a branch for this.
Hi, Johannes Weiner,
Thanks for your comment ;)
Andrew has pointed this out and this patch is abandoned.
--
Regards,
Zhan Jianyu
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>