linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mm/vmscan: make inactive_anon_is_low_global return directly
@ 2015-09-16 11:59 Yaowei Bai
  2015-09-16 11:59 ` [PATCH 2/3] mm/oom_kill: introduce is_sysrq_oom helper Yaowei Bai
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Yaowei Bai @ 2015-09-16 11:59 UTC (permalink / raw)
  To: akpm, mgorman, mhocko, rientjes, hannes, vdavydov, oleg, vbabka,
	iamjoonsoo.kim, zhangyanfei
  Cc: linux-mm, linux-kernel

Delete unnecessary if to let inactive_anon_is_low_global return
directly.

No functional changes.

Signed-off-by: Yaowei Bai <bywxiaobai@163.com>
---
 mm/vmscan.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 2d978b2..2785d8e 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1866,10 +1866,7 @@ static int inactive_anon_is_low_global(struct zone *zone)
 	active = zone_page_state(zone, NR_ACTIVE_ANON);
 	inactive = zone_page_state(zone, NR_INACTIVE_ANON);
 
-	if (inactive * zone->inactive_ratio < active)
-		return 1;
-
-	return 0;
+	return inactive * zone->inactive_ratio < active;
 }
 
 /**
-- 
1.9.1


--
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] 11+ messages in thread

* [PATCH 2/3] mm/oom_kill: introduce is_sysrq_oom helper
  2015-09-16 11:59 [PATCH 1/3] mm/vmscan: make inactive_anon_is_low_global return directly Yaowei Bai
@ 2015-09-16 11:59 ` Yaowei Bai
  2015-09-21 16:18   ` Michal Hocko
  2015-09-21 23:02   ` David Rientjes
  2015-09-16 12:00 ` [PATCH 3/3] mm/compaction: add an is_via_compact_memory helper function Yaowei Bai
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: Yaowei Bai @ 2015-09-16 11:59 UTC (permalink / raw)
  To: akpm, mgorman, mhocko, rientjes, hannes, vdavydov, oleg, vbabka,
	iamjoonsoo.kim, zhangyanfei
  Cc: linux-mm, linux-kernel

Introduce is_sysrq_oom helper function indicating oom kill triggered
by sysrq to improve readability.

No functional changes.

Signed-off-by: Yaowei Bai <bywxiaobai@163.com>
---
 mm/oom_kill.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 1ecc0bc..7b6228e 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -118,6 +118,15 @@ found:
 	return t;
 }
 
+/*
+ * order == -1 means the oom kill is required by sysrq, otherwise only
+ * for display purposes.
+ */
+static inline bool is_sysrq_oom(struct oom_control *oc)
+{
+	return oc->order == -1;
+}
+
 /* return true if the task is not adequate as candidate victim task. */
 static bool oom_unkillable_task(struct task_struct *p,
 		struct mem_cgroup *memcg, const nodemask_t *nodemask)
@@ -265,7 +274,7 @@ enum oom_scan_t oom_scan_process_thread(struct oom_control *oc,
 	 * Don't allow any other task to have access to the reserves.
 	 */
 	if (test_tsk_thread_flag(task, TIF_MEMDIE)) {
-		if (oc->order != -1)
+		if (!is_sysrq_oom(oc))
 			return OOM_SCAN_ABORT;
 	}
 	if (!task->mm)
@@ -278,7 +287,7 @@ enum oom_scan_t oom_scan_process_thread(struct oom_control *oc,
 	if (oom_task_origin(task))
 		return OOM_SCAN_SELECT;
 
-	if (task_will_free_mem(task) && oc->order != -1)
+	if (task_will_free_mem(task) && !is_sysrq_oom(oc))
 		return OOM_SCAN_ABORT;
 
 	return OOM_SCAN_OK;
@@ -608,7 +617,7 @@ void check_panic_on_oom(struct oom_control *oc, enum oom_constraint constraint,
 			return;
 	}
 	/* Do not panic for oom kills triggered by sysrq */
-	if (oc->order == -1)
+	if (is_sysrq_oom(oc))
 		return;
 	dump_header(oc, NULL, memcg);
 	panic("Out of memory: %s panic_on_oom is enabled\n",
@@ -688,7 +697,7 @@ bool out_of_memory(struct oom_control *oc)
 
 	p = select_bad_process(oc, &points, totalpages);
 	/* Found nothing?!?! Either we hang forever, or we panic. */
-	if (!p && oc->order != -1) {
+	if (!p && !is_sysrq_oom(oc)) {
 		dump_header(oc, NULL, NULL);
 		panic("Out of memory and no killable processes...\n");
 	}
-- 
1.9.1


--
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] 11+ messages in thread

* [PATCH 3/3] mm/compaction: add an is_via_compact_memory helper function
  2015-09-16 11:59 [PATCH 1/3] mm/vmscan: make inactive_anon_is_low_global return directly Yaowei Bai
  2015-09-16 11:59 ` [PATCH 2/3] mm/oom_kill: introduce is_sysrq_oom helper Yaowei Bai
@ 2015-09-16 12:00 ` Yaowei Bai
  2015-09-21 16:19   ` Michal Hocko
                     ` (2 more replies)
  2015-09-21 16:18 ` [PATCH 1/3] mm/vmscan: make inactive_anon_is_low_global return directly Michal Hocko
  2015-09-21 23:01 ` David Rientjes
  3 siblings, 3 replies; 11+ messages in thread
From: Yaowei Bai @ 2015-09-16 12:00 UTC (permalink / raw)
  To: akpm, mgorman, mhocko, rientjes, hannes, vdavydov, oleg, vbabka,
	iamjoonsoo.kim, zhangyanfei
  Cc: linux-mm, linux-kernel

Introduce is_via_compact_memory helper function indicating compacting
via /proc/sys/vm/compact_memory to improve readability.

To catch this situation in __compaction_suitable, use order as parameter
directly instead of using struct compact_control.

This patch has no functional changes.

Signed-off-by: Yaowei Bai <bywxiaobai@163.com>
---
 mm/compaction.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index c5c627a..a8e6593 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1197,6 +1197,15 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
 	return cc->nr_migratepages ? ISOLATE_SUCCESS : ISOLATE_NONE;
 }
 
+/*
+ * order == -1 is expected when compacting via
+ * /proc/sys/vm/compact_memory
+ */
+static inline bool is_via_compact_memory(int order)
+{
+	return order == -1;
+}
+
 static int __compact_finished(struct zone *zone, struct compact_control *cc,
 			    const int migratetype)
 {
@@ -1223,11 +1232,7 @@ static int __compact_finished(struct zone *zone, struct compact_control *cc,
 		return COMPACT_COMPLETE;
 	}
 
-	/*
-	 * order == -1 is expected when compacting via
-	 * /proc/sys/vm/compact_memory
-	 */
-	if (cc->order == -1)
+	if (is_via_compact_memory(cc->order))
 		return COMPACT_CONTINUE;
 
 	/* Compaction run is not finished if the watermark is not met */
@@ -1290,11 +1295,7 @@ static unsigned long __compaction_suitable(struct zone *zone, int order,
 	int fragindex;
 	unsigned long watermark;
 
-	/*
-	 * order == -1 is expected when compacting via
-	 * /proc/sys/vm/compact_memory
-	 */
-	if (order == -1)
+	if (is_via_compact_memory(order))
 		return COMPACT_CONTINUE;
 
 	watermark = low_wmark_pages(zone);
@@ -1658,10 +1659,11 @@ static void __compact_pgdat(pg_data_t *pgdat, struct compact_control *cc)
 		 * this makes sure we compact the whole zone regardless of
 		 * cached scanner positions.
 		 */
-		if (cc->order == -1)
+		if (is_via_compact_memory(cc->order))
 			__reset_isolation_suitable(zone);
 
-		if (cc->order == -1 || !compaction_deferred(zone, cc->order))
+		if (is_via_compact_memory(cc->order) ||
+				!compaction_deferred(zone, cc->order))
 			compact_zone(zone, cc);
 
 		if (cc->order > 0) {
-- 
1.9.1


--
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] 11+ messages in thread

* Re: [PATCH 1/3] mm/vmscan: make inactive_anon_is_low_global return directly
  2015-09-16 11:59 [PATCH 1/3] mm/vmscan: make inactive_anon_is_low_global return directly Yaowei Bai
  2015-09-16 11:59 ` [PATCH 2/3] mm/oom_kill: introduce is_sysrq_oom helper Yaowei Bai
  2015-09-16 12:00 ` [PATCH 3/3] mm/compaction: add an is_via_compact_memory helper function Yaowei Bai
@ 2015-09-21 16:18 ` Michal Hocko
  2015-09-22 13:15   ` Yaowei Bai
  2015-09-21 23:01 ` David Rientjes
  3 siblings, 1 reply; 11+ messages in thread
From: Michal Hocko @ 2015-09-21 16:18 UTC (permalink / raw)
  To: Yaowei Bai
  Cc: akpm, mgorman, rientjes, hannes, vdavydov, oleg, vbabka,
	iamjoonsoo.kim, zhangyanfei, linux-mm, linux-kernel

On Wed 16-09-15 19:59:58, Yaowei Bai wrote:
> Delete unnecessary if to let inactive_anon_is_low_global return
> directly.
> 
> No functional changes.

Is this really an improvement? I am not so sure. If anything the
function has a bool return semantic...

> Signed-off-by: Yaowei Bai <bywxiaobai@163.com>
> ---
>  mm/vmscan.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 2d978b2..2785d8e 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1866,10 +1866,7 @@ static int inactive_anon_is_low_global(struct zone *zone)
>  	active = zone_page_state(zone, NR_ACTIVE_ANON);
>  	inactive = zone_page_state(zone, NR_INACTIVE_ANON);
>  
> -	if (inactive * zone->inactive_ratio < active)
> -		return 1;
> -
> -	return 0;
> +	return inactive * zone->inactive_ratio < active;
>  }
>  
>  /**
> -- 
> 1.9.1
> 
> 
> --
> 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>

-- 
Michal Hocko
SUSE Labs

--
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] 11+ messages in thread

* Re: [PATCH 2/3] mm/oom_kill: introduce is_sysrq_oom helper
  2015-09-16 11:59 ` [PATCH 2/3] mm/oom_kill: introduce is_sysrq_oom helper Yaowei Bai
@ 2015-09-21 16:18   ` Michal Hocko
  2015-09-21 23:02   ` David Rientjes
  1 sibling, 0 replies; 11+ messages in thread
From: Michal Hocko @ 2015-09-21 16:18 UTC (permalink / raw)
  To: Yaowei Bai
  Cc: akpm, mgorman, rientjes, hannes, vdavydov, oleg, vbabka,
	iamjoonsoo.kim, zhangyanfei, linux-mm, linux-kernel

On Wed 16-09-15 19:59:59, Yaowei Bai wrote:
> Introduce is_sysrq_oom helper function indicating oom kill triggered
> by sysrq to improve readability.
> 
> No functional changes.

I was complaining about a subtle semantic of order -1 when it was
introduced. This is easier to follow. At least for me.
 
> Signed-off-by: Yaowei Bai <bywxiaobai@163.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  mm/oom_kill.c | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 1ecc0bc..7b6228e 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -118,6 +118,15 @@ found:
>  	return t;
>  }
>  
> +/*
> + * order == -1 means the oom kill is required by sysrq, otherwise only
> + * for display purposes.
> + */
> +static inline bool is_sysrq_oom(struct oom_control *oc)
> +{
> +	return oc->order == -1;
> +}
> +
>  /* return true if the task is not adequate as candidate victim task. */
>  static bool oom_unkillable_task(struct task_struct *p,
>  		struct mem_cgroup *memcg, const nodemask_t *nodemask)
> @@ -265,7 +274,7 @@ enum oom_scan_t oom_scan_process_thread(struct oom_control *oc,
>  	 * Don't allow any other task to have access to the reserves.
>  	 */
>  	if (test_tsk_thread_flag(task, TIF_MEMDIE)) {
> -		if (oc->order != -1)
> +		if (!is_sysrq_oom(oc))
>  			return OOM_SCAN_ABORT;
>  	}
>  	if (!task->mm)
> @@ -278,7 +287,7 @@ enum oom_scan_t oom_scan_process_thread(struct oom_control *oc,
>  	if (oom_task_origin(task))
>  		return OOM_SCAN_SELECT;
>  
> -	if (task_will_free_mem(task) && oc->order != -1)
> +	if (task_will_free_mem(task) && !is_sysrq_oom(oc))
>  		return OOM_SCAN_ABORT;
>  
>  	return OOM_SCAN_OK;
> @@ -608,7 +617,7 @@ void check_panic_on_oom(struct oom_control *oc, enum oom_constraint constraint,
>  			return;
>  	}
>  	/* Do not panic for oom kills triggered by sysrq */
> -	if (oc->order == -1)
> +	if (is_sysrq_oom(oc))
>  		return;
>  	dump_header(oc, NULL, memcg);
>  	panic("Out of memory: %s panic_on_oom is enabled\n",
> @@ -688,7 +697,7 @@ bool out_of_memory(struct oom_control *oc)
>  
>  	p = select_bad_process(oc, &points, totalpages);
>  	/* Found nothing?!?! Either we hang forever, or we panic. */
> -	if (!p && oc->order != -1) {
> +	if (!p && !is_sysrq_oom(oc)) {
>  		dump_header(oc, NULL, NULL);
>  		panic("Out of memory and no killable processes...\n");
>  	}
> -- 
> 1.9.1
> 
> 
> --
> 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>

-- 
Michal Hocko
SUSE Labs

--
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] 11+ messages in thread

* Re: [PATCH 3/3] mm/compaction: add an is_via_compact_memory helper function
  2015-09-16 12:00 ` [PATCH 3/3] mm/compaction: add an is_via_compact_memory helper function Yaowei Bai
@ 2015-09-21 16:19   ` Michal Hocko
  2015-09-21 23:03   ` David Rientjes
  2015-09-23 16:42   ` Vlastimil Babka
  2 siblings, 0 replies; 11+ messages in thread
From: Michal Hocko @ 2015-09-21 16:19 UTC (permalink / raw)
  To: Yaowei Bai
  Cc: akpm, mgorman, rientjes, hannes, vdavydov, oleg, vbabka,
	iamjoonsoo.kim, zhangyanfei, linux-mm, linux-kernel

On Wed 16-09-15 20:00:00, Yaowei Bai wrote:
> Introduce is_via_compact_memory helper function indicating compacting
> via /proc/sys/vm/compact_memory to improve readability.
> 
> To catch this situation in __compaction_suitable, use order as parameter
> directly instead of using struct compact_control.
> 
> This patch has no functional changes.

This is a similar case as for the sysrq_oom. I do not like the name that
much though. I am not familiar with the compaction too much to help you
with a better name, unfortunatelly. Maybe is_global_compaction()...

> 
> Signed-off-by: Yaowei Bai <bywxiaobai@163.com>
> ---
>  mm/compaction.c | 26 ++++++++++++++------------
>  1 file changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index c5c627a..a8e6593 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -1197,6 +1197,15 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
>  	return cc->nr_migratepages ? ISOLATE_SUCCESS : ISOLATE_NONE;
>  }
>  
> +/*
> + * order == -1 is expected when compacting via
> + * /proc/sys/vm/compact_memory
> + */
> +static inline bool is_via_compact_memory(int order)
> +{
> +	return order == -1;
> +}
> +
>  static int __compact_finished(struct zone *zone, struct compact_control *cc,
>  			    const int migratetype)
>  {
> @@ -1223,11 +1232,7 @@ static int __compact_finished(struct zone *zone, struct compact_control *cc,
>  		return COMPACT_COMPLETE;
>  	}
>  
> -	/*
> -	 * order == -1 is expected when compacting via
> -	 * /proc/sys/vm/compact_memory
> -	 */
> -	if (cc->order == -1)
> +	if (is_via_compact_memory(cc->order))
>  		return COMPACT_CONTINUE;
>  
>  	/* Compaction run is not finished if the watermark is not met */
> @@ -1290,11 +1295,7 @@ static unsigned long __compaction_suitable(struct zone *zone, int order,
>  	int fragindex;
>  	unsigned long watermark;
>  
> -	/*
> -	 * order == -1 is expected when compacting via
> -	 * /proc/sys/vm/compact_memory
> -	 */
> -	if (order == -1)
> +	if (is_via_compact_memory(order))
>  		return COMPACT_CONTINUE;
>  
>  	watermark = low_wmark_pages(zone);
> @@ -1658,10 +1659,11 @@ static void __compact_pgdat(pg_data_t *pgdat, struct compact_control *cc)
>  		 * this makes sure we compact the whole zone regardless of
>  		 * cached scanner positions.
>  		 */
> -		if (cc->order == -1)
> +		if (is_via_compact_memory(cc->order))
>  			__reset_isolation_suitable(zone);
>  
> -		if (cc->order == -1 || !compaction_deferred(zone, cc->order))
> +		if (is_via_compact_memory(cc->order) ||
> +				!compaction_deferred(zone, cc->order))
>  			compact_zone(zone, cc);
>  
>  		if (cc->order > 0) {
> -- 
> 1.9.1
> 
> 
> --
> 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>

-- 
Michal Hocko
SUSE Labs

--
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] 11+ messages in thread

* Re: [PATCH 1/3] mm/vmscan: make inactive_anon_is_low_global return directly
  2015-09-16 11:59 [PATCH 1/3] mm/vmscan: make inactive_anon_is_low_global return directly Yaowei Bai
                   ` (2 preceding siblings ...)
  2015-09-21 16:18 ` [PATCH 1/3] mm/vmscan: make inactive_anon_is_low_global return directly Michal Hocko
@ 2015-09-21 23:01 ` David Rientjes
  3 siblings, 0 replies; 11+ messages in thread
From: David Rientjes @ 2015-09-21 23:01 UTC (permalink / raw)
  To: Yaowei Bai
  Cc: akpm, mgorman, mhocko, hannes, vdavydov, oleg, vbabka,
	iamjoonsoo.kim, zhangyanfei, linux-mm, linux-kernel

On Wed, 16 Sep 2015, Yaowei Bai wrote:

> Delete unnecessary if to let inactive_anon_is_low_global return
> directly.
> 
> No functional changes.
> 
> Signed-off-by: Yaowei Bai <bywxiaobai@163.com>

Acked-by: David Rientjes <rientjes@google.com>

--
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] 11+ messages in thread

* Re: [PATCH 2/3] mm/oom_kill: introduce is_sysrq_oom helper
  2015-09-16 11:59 ` [PATCH 2/3] mm/oom_kill: introduce is_sysrq_oom helper Yaowei Bai
  2015-09-21 16:18   ` Michal Hocko
@ 2015-09-21 23:02   ` David Rientjes
  1 sibling, 0 replies; 11+ messages in thread
From: David Rientjes @ 2015-09-21 23:02 UTC (permalink / raw)
  To: Yaowei Bai
  Cc: akpm, mgorman, mhocko, hannes, vdavydov, oleg, vbabka,
	iamjoonsoo.kim, zhangyanfei, linux-mm, linux-kernel

On Wed, 16 Sep 2015, Yaowei Bai wrote:

> Introduce is_sysrq_oom helper function indicating oom kill triggered
> by sysrq to improve readability.
> 
> No functional changes.
> 
> Signed-off-by: Yaowei Bai <bywxiaobai@163.com>

Acked-by: David Rientjes <rientjes@google.com>

--
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] 11+ messages in thread

* Re: [PATCH 3/3] mm/compaction: add an is_via_compact_memory helper function
  2015-09-16 12:00 ` [PATCH 3/3] mm/compaction: add an is_via_compact_memory helper function Yaowei Bai
  2015-09-21 16:19   ` Michal Hocko
@ 2015-09-21 23:03   ` David Rientjes
  2015-09-23 16:42   ` Vlastimil Babka
  2 siblings, 0 replies; 11+ messages in thread
From: David Rientjes @ 2015-09-21 23:03 UTC (permalink / raw)
  To: Yaowei Bai
  Cc: akpm, mgorman, mhocko, hannes, vdavydov, oleg, vbabka,
	iamjoonsoo.kim, zhangyanfei, linux-mm, linux-kernel

On Wed, 16 Sep 2015, Yaowei Bai wrote:

> Introduce is_via_compact_memory helper function indicating compacting
> via /proc/sys/vm/compact_memory to improve readability.
> 
> To catch this situation in __compaction_suitable, use order as parameter
> directly instead of using struct compact_control.
> 
> This patch has no functional changes.
> 
> Signed-off-by: Yaowei Bai <bywxiaobai@163.com>

Acked-by: David Rientjes <rientjes@google.com>

Thanks for doing these cleanups!

--
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] 11+ messages in thread

* Re: [PATCH 1/3] mm/vmscan: make inactive_anon_is_low_global return directly
  2015-09-21 16:18 ` [PATCH 1/3] mm/vmscan: make inactive_anon_is_low_global return directly Michal Hocko
@ 2015-09-22 13:15   ` Yaowei Bai
  0 siblings, 0 replies; 11+ messages in thread
From: Yaowei Bai @ 2015-09-22 13:15 UTC (permalink / raw)
  To: Michal Hocko
  Cc: akpm, mgorman, rientjes, hannes, vdavydov, oleg, vbabka,
	iamjoonsoo.kim, zhangyanfei, linux-mm, linux-kernel

On Mon, Sep 21, 2015 at 06:18:07PM +0200, Michal Hocko wrote:
> On Wed 16-09-15 19:59:58, Yaowei Bai wrote:
> > Delete unnecessary if to let inactive_anon_is_low_global return
> > directly.
> > 
> > No functional changes.
> 
> Is this really an improvement? I am not so sure. If anything the
> function has a bool return semantic...

Just FYI, I also sent a patch making inactive_anon_is_low_global return
bool and it has been added into Andrew's -mm tree.

> 

--
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] 11+ messages in thread

* Re: [PATCH 3/3] mm/compaction: add an is_via_compact_memory helper function
  2015-09-16 12:00 ` [PATCH 3/3] mm/compaction: add an is_via_compact_memory helper function Yaowei Bai
  2015-09-21 16:19   ` Michal Hocko
  2015-09-21 23:03   ` David Rientjes
@ 2015-09-23 16:42   ` Vlastimil Babka
  2 siblings, 0 replies; 11+ messages in thread
From: Vlastimil Babka @ 2015-09-23 16:42 UTC (permalink / raw)
  To: Yaowei Bai, akpm, mgorman, mhocko, rientjes, hannes, vdavydov,
	oleg, iamjoonsoo.kim, zhangyanfei
  Cc: linux-mm, linux-kernel

On 09/16/2015 02:00 PM, Yaowei Bai wrote:
> Introduce is_via_compact_memory helper function indicating compacting
> via /proc/sys/vm/compact_memory to improve readability.

Note that it can also be through single node, i.e.
/sys/devices/system/node/node0/compact

is_manual_compaction() would perhaps be better name

> To catch this situation in __compaction_suitable, use order as parameter
> directly instead of using struct compact_control.

That can be fixed as well. Remove the test from __compaction_suitable(),
and in compact_zone(), do something like:
   ret = is_manual_compaction() ? COMPACT_CONTINUE : compaction_suitable()

I think it's better since it's more explicit, but I understand others 
might feel differently.

> This patch has no functional changes.
>
> Signed-off-by: Yaowei Bai <bywxiaobai@163.com>
> ---
>   mm/compaction.c | 26 ++++++++++++++------------
>   1 file changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> index c5c627a..a8e6593 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -1197,6 +1197,15 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
>   	return cc->nr_migratepages ? ISOLATE_SUCCESS : ISOLATE_NONE;
>   }
>
> +/*
> + * order == -1 is expected when compacting via
> + * /proc/sys/vm/compact_memory
> + */
> +static inline bool is_via_compact_memory(int order)
> +{
> +	return order == -1;
> +}
> +
>   static int __compact_finished(struct zone *zone, struct compact_control *cc,
>   			    const int migratetype)
>   {
> @@ -1223,11 +1232,7 @@ static int __compact_finished(struct zone *zone, struct compact_control *cc,
>   		return COMPACT_COMPLETE;
>   	}
>
> -	/*
> -	 * order == -1 is expected when compacting via
> -	 * /proc/sys/vm/compact_memory
> -	 */
> -	if (cc->order == -1)
> +	if (is_via_compact_memory(cc->order))
>   		return COMPACT_CONTINUE;
>
>   	/* Compaction run is not finished if the watermark is not met */
> @@ -1290,11 +1295,7 @@ static unsigned long __compaction_suitable(struct zone *zone, int order,
>   	int fragindex;
>   	unsigned long watermark;
>
> -	/*
> -	 * order == -1 is expected when compacting via
> -	 * /proc/sys/vm/compact_memory
> -	 */
> -	if (order == -1)
> +	if (is_via_compact_memory(order))
>   		return COMPACT_CONTINUE;
>
>   	watermark = low_wmark_pages(zone);
> @@ -1658,10 +1659,11 @@ static void __compact_pgdat(pg_data_t *pgdat, struct compact_control *cc)
>   		 * this makes sure we compact the whole zone regardless of
>   		 * cached scanner positions.
>   		 */
> -		if (cc->order == -1)
> +		if (is_via_compact_memory(cc->order))
>   			__reset_isolation_suitable(zone);
>
> -		if (cc->order == -1 || !compaction_deferred(zone, cc->order))
> +		if (is_via_compact_memory(cc->order) ||
> +				!compaction_deferred(zone, cc->order))
>   			compact_zone(zone, cc);
>
>   		if (cc->order > 0) {
>

--
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] 11+ messages in thread

end of thread, other threads:[~2015-09-23 16:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-16 11:59 [PATCH 1/3] mm/vmscan: make inactive_anon_is_low_global return directly Yaowei Bai
2015-09-16 11:59 ` [PATCH 2/3] mm/oom_kill: introduce is_sysrq_oom helper Yaowei Bai
2015-09-21 16:18   ` Michal Hocko
2015-09-21 23:02   ` David Rientjes
2015-09-16 12:00 ` [PATCH 3/3] mm/compaction: add an is_via_compact_memory helper function Yaowei Bai
2015-09-21 16:19   ` Michal Hocko
2015-09-21 23:03   ` David Rientjes
2015-09-23 16:42   ` Vlastimil Babka
2015-09-21 16:18 ` [PATCH 1/3] mm/vmscan: make inactive_anon_is_low_global return directly Michal Hocko
2015-09-22 13:15   ` Yaowei Bai
2015-09-21 23:01 ` David Rientjes

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).