Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1457119 > unrolled thread

[PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid unnecessary loop.

Started byzhongjiang <zhongjiang@huawei.com>
First post2016-08-05 16:10 +0200
Last post2016-08-10 04:40 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid unnecessary loop. zhongjiang <zhongjiang@huawei.com> - 2016-08-05 16:10 +0200
    Re: [PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid  unnecessary loop. zhong jiang <zhongjiang@huawei.com> - 2016-08-09 14:30 +0200
    Re: [PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid  unnecessary loop. Andrew Morton <akpm@linux-foundation.org> - 2016-08-10 01:30 +0200
      Re: [PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid  unnecessary loop. zhong jiang <zhongjiang@huawei.com> - 2016-08-10 04:40 +0200

#1457119 — [PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid unnecessary loop.

Fromzhongjiang <zhongjiang@huawei.com>
Date2016-08-05 16:10 +0200
Subject[PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid unnecessary loop.
Message-ID<s2NZ0-7N-11@gated-at.bofh.it>
From: zhong jiang <zhongjiang@huawei.com>

when required_kernelcore decrease to zero, we should exit the loop in time.
because It will waste time to scan the remainder node.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 mm/page_alloc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ea759b9..be7df17 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6093,7 +6093,7 @@ static unsigned long __init early_calculate_totalpages(void)
 		unsigned long pages = end_pfn - start_pfn;
 
 		totalpages += pages;
-		if (pages)
+		if (!node_isset(nid, node_states[N_MEMORY]) && pages)
 			node_set_state(nid, N_MEMORY);
 	}
 	return totalpages;
@@ -6115,6 +6115,7 @@ static void __init find_zone_movable_pfns_for_nodes(void)
 	unsigned long totalpages = early_calculate_totalpages();
 	int usable_nodes = nodes_weight(node_states[N_MEMORY]);
 	struct memblock_region *r;
+	bool avoid_loop = false;
 
 	/* Need to find movable_zone earlier when movable_node is specified. */
 	find_usable_zone_for_movable();
@@ -6275,6 +6276,8 @@ restart:
 			required_kernelcore -= min(required_kernelcore,
 								size_pages);
 			kernelcore_remaining -= size_pages;
+			if (!required_kernelcore && avoid_loop)
+				goto out2;
 			if (!kernelcore_remaining)
 				break;
 		}
@@ -6287,9 +6290,10 @@ restart:
 	 * satisfied
 	 */
 	usable_nodes--;
-	if (usable_nodes && required_kernelcore > usable_nodes)
+	if (usable_nodes && required_kernelcore > usable_nodes) {
+		avoid_loop = true;
 		goto restart;
-
+	}
 out2:
 	/* Align start of ZONE_MOVABLE on all nids to MAX_ORDER_NR_PAGES */
 	for (nid = 0; nid < MAX_NUMNODES; nid++)
-- 
1.8.3.1

[toc] | [next] | [standalone]


#1458665 — Re: [PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid unnecessary loop.

Fromzhong jiang <zhongjiang@huawei.com>
Date2016-08-09 14:30 +0200
SubjectRe: [PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid unnecessary loop.
Message-ID<s4ekq-7uJ-7@gated-at.bofh.it>
In reply to#1457119
On 2016/8/5 22:04, zhongjiang wrote:
> From: zhong jiang <zhongjiang@huawei.com>
>
> when required_kernelcore decrease to zero, we should exit the loop in time.
> because It will waste time to scan the remainder node.
>
> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> ---
>  mm/page_alloc.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index ea759b9..be7df17 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -6093,7 +6093,7 @@ static unsigned long __init early_calculate_totalpages(void)
>  		unsigned long pages = end_pfn - start_pfn;
>  
>  		totalpages += pages;
> -		if (pages)
> +		if (!node_isset(nid, node_states[N_MEMORY]) && pages)
>  			node_set_state(nid, N_MEMORY);
>  	}
>  	return totalpages;
> @@ -6115,6 +6115,7 @@ static void __init find_zone_movable_pfns_for_nodes(void)
>  	unsigned long totalpages = early_calculate_totalpages();
>  	int usable_nodes = nodes_weight(node_states[N_MEMORY]);
>  	struct memblock_region *r;
> +	bool avoid_loop = false;
>  
>  	/* Need to find movable_zone earlier when movable_node is specified. */
>  	find_usable_zone_for_movable();
> @@ -6275,6 +6276,8 @@ restart:
>  			required_kernelcore -= min(required_kernelcore,
>  								size_pages);
>  			kernelcore_remaining -= size_pages;
> +			if (!required_kernelcore && avoid_loop)
> +				goto out2;
>  			if (!kernelcore_remaining)
>  				break;
>  		}
> @@ -6287,9 +6290,10 @@ restart:
>  	 * satisfied
>  	 */
>  	usable_nodes--;
> -	if (usable_nodes && required_kernelcore > usable_nodes)
> +	if (usable_nodes && required_kernelcore > usable_nodes) {
> +		avoid_loop = true;
>  		goto restart;
> -
> +	}
>  out2:
>  	/* Align start of ZONE_MOVABLE on all nids to MAX_ORDER_NR_PAGES */
>  	for (nid = 0; nid < MAX_NUMNODES; nid++)
  Any one have any objection about above patch ? please let me know.
 
 

[toc] | [prev] | [next] | [standalone]


#1459181 — Re: [PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid unnecessary loop.

FromAndrew Morton <akpm@linux-foundation.org>
Date2016-08-10 01:30 +0200
SubjectRe: [PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid unnecessary loop.
Message-ID<s4oD8-5EB-31@gated-at.bofh.it>
In reply to#1457119
On Fri, 5 Aug 2016 22:04:07 +0800 zhongjiang <zhongjiang@huawei.com> wrote:

> when required_kernelcore decrease to zero, we should exit the loop in time.
> because It will waste time to scan the remainder node.

The patch is rather ugly and it only affects __init code, so the only
benefit will be to boot time.

Do we have any timing measurements which would justify changing this code?

[toc] | [prev] | [next] | [standalone]


#1459246 — Re: [PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid unnecessary loop.

Fromzhong jiang <zhongjiang@huawei.com>
Date2016-08-10 04:40 +0200
SubjectRe: [PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid unnecessary loop.
Message-ID<s4rB0-7Dj-3@gated-at.bofh.it>
In reply to#1459181
On 2016/8/10 7:29, Andrew Morton wrote:
> On Fri, 5 Aug 2016 22:04:07 +0800 zhongjiang <zhongjiang@huawei.com> wrote:
>
>> when required_kernelcore decrease to zero, we should exit the loop in time.
>> because It will waste time to scan the remainder node.
> The patch is rather ugly and it only affects __init code, so the only
> benefit will be to boot time.
   yes
> Do we have any timing measurements which would justify changing this code?
  I am sorry for that.  That is a only theoretical analysis.
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web