* [PATCH RESEND] mm/vmscan : use vmcan_swappiness( ) basing on MEMCG config to elimiate unnecessary runtime cost
@ 2013-08-26 13:36 larmbr
2013-08-27 0:13 ` Naoya Horiguchi
2013-09-03 22:47 ` Johannes Weiner
0 siblings, 2 replies; 4+ messages in thread
From: larmbr @ 2013-08-26 13:36 UTC (permalink / raw)
To: linux-mm
Cc: hannes, mhocko, bsingharora, kamezawa.hiroyu, akpm, mgorman, riel,
nasa4836, linux-kernel
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.
Signed-off-by: Zhan Jianyu <nasa4836@gmail.com>
---
mm/memcontrol.c | 6 +++++-
mm/vmscan.c | 9 +++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c5792a5..1290320 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 2cff0d4..1de652d 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -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 majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH RESEND] mm/vmscan : use vmcan_swappiness( ) basing on MEMCG config to elimiate unnecessary runtime cost
2013-08-26 13:36 [PATCH RESEND] mm/vmscan : use vmcan_swappiness( ) basing on MEMCG config to elimiate unnecessary runtime cost larmbr
@ 2013-08-27 0:13 ` Naoya Horiguchi
2013-09-03 22:47 ` Johannes Weiner
1 sibling, 0 replies; 4+ messages in thread
From: Naoya Horiguchi @ 2013-08-27 0:13 UTC (permalink / raw)
To: larmbr
Cc: linux-mm, hannes, mhocko, bsingharora, kamezawa.hiroyu, akpm,
mgorman, riel, linux-kernel
Please fix a typo in subject line (which affects how easy we can access
paticular patches later with grepping subject lines.)
Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
On Mon, Aug 26, 2013 at 09:36:58PM +0800, larmbr wrote:
> 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.
>
> Signed-off-by: Zhan Jianyu <nasa4836@gmail.com>
> ---
> mm/memcontrol.c | 6 +++++-
> mm/vmscan.c | 9 +++++++--
> 2 files changed, 12 insertions(+), 3 deletions(-)
>
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index c5792a5..1290320 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -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;
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 2cff0d4..1de652d 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -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 majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH RESEND] mm/vmscan : use vmcan_swappiness( ) basing on MEMCG config to elimiate unnecessary runtime cost
2013-08-26 13:36 [PATCH RESEND] mm/vmscan : use vmcan_swappiness( ) basing on MEMCG config to elimiate unnecessary runtime cost larmbr
2013-08-27 0:13 ` Naoya Horiguchi
@ 2013-09-03 22:47 ` Johannes Weiner
2013-09-04 8:58 ` Zhan Jianyu
1 sibling, 1 reply; 4+ messages in thread
From: Johannes Weiner @ 2013-09-03 22:47 UTC (permalink / raw)
To: larmbr
Cc: linux-mm, mhocko, bsingharora, kamezawa.hiroyu, akpm, mgorman,
riel, linux-kernel
On Mon, Aug 26, 2013 at 09:36:58PM +0800, larmbr wrote:
> 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.
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.
> 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 majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] mm/vmscan : use vmcan_swappiness( ) basing on MEMCG config to elimiate unnecessary runtime cost
2013-09-03 22:47 ` Johannes Weiner
@ 2013-09-04 8:58 ` Zhan Jianyu
0 siblings, 0 replies; 4+ messages in thread
From: Zhan Jianyu @ 2013-09-04 8:58 UTC (permalink / raw)
To: Johannes Weiner
Cc: linux-mm, mhocko, Balbir Singh, kamezawa.hiroyu, Andrew Morton,
Mel Gorman, riel, linux-kernel
On Wed, Sep 4, 2013 at 6:47 AM, Johannes Weiner <hannes@cmpxchg.org> wrote:
> On Mon, Aug 26, 2013 at 09:36:58PM +0800, larmbr wrote:
>> 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.
>
> 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 majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-09-04 8:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-26 13:36 [PATCH RESEND] mm/vmscan : use vmcan_swappiness( ) basing on MEMCG config to elimiate unnecessary runtime cost larmbr
2013-08-27 0:13 ` Naoya Horiguchi
2013-09-03 22:47 ` Johannes Weiner
2013-09-04 8:58 ` Zhan Jianyu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).