linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/page_alloc: break on the first hit of mem range
@ 2018-03-27  3:57 Wei Yang
  2018-03-27 10:58 ` Michal Hocko
  2018-03-27 22:47 ` Andrew Morton
  0 siblings, 2 replies; 13+ messages in thread
From: Wei Yang @ 2018-03-27  3:57 UTC (permalink / raw)
  To: akpm, mhocko, tj; +Cc: linux-mm, Wei Yang

find_min_pfn_for_node() iterate on pfn range to find the minimum pfn for a
node. The memblock_region in memblock_type are already ordered, which means
the first hit in iteration is the minimum pfn.

This patch returns the fist hit instead of iterating the whole regions.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 mm/page_alloc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 635d7dd29d7f..a65de1ec4b91 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6365,14 +6365,14 @@ unsigned long __init node_map_pfn_alignment(void)
 /* Find the lowest pfn for a node */
 static unsigned long __init find_min_pfn_for_node(int nid)
 {
-	unsigned long min_pfn = ULONG_MAX;
-	unsigned long start_pfn;
+	unsigned long min_pfn;
 	int i;
 
-	for_each_mem_pfn_range(i, nid, &start_pfn, NULL, NULL)
-		min_pfn = min(min_pfn, start_pfn);
+	for_each_mem_pfn_range(i, nid, &min_pfn, NULL, NULL) {
+		break;
+	}
 
-	if (min_pfn == ULONG_MAX) {
+	if (i == -1) {
 		pr_warn("Could not find start_pfn for node %d\n", nid);
 		return 0;
 	}
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-03-28 14:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-27  3:57 [PATCH] mm/page_alloc: break on the first hit of mem range Wei Yang
2018-03-27 10:58 ` Michal Hocko
2018-03-28  0:39   ` Wei Yang
2018-03-28  7:02     ` Michal Hocko
2018-03-28 13:17       ` Wei Yang
2018-03-27 22:47 ` Andrew Morton
2018-03-28  0:51   ` Wei Yang
2018-03-28  1:37     ` Andrew Morton
2018-03-28  3:44       ` Wei Yang
2018-03-28  3:47       ` [PATCH] mm/page_alloc: optimize find_min_pfn_for_node() by geting the minimal pfn directly Wei Yang
2018-03-28 11:58         ` Michal Hocko
2018-03-28 13:34           ` Wei Yang
2018-03-28 14:02             ` Michal Hocko

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