Skip to contentSkip to conversation

mm/memblock.c: hardcode the end_pfn being -1

PATCH In review [email protected] 2 participants 2 messages Mar 9, 2018 – Mar 10, 2018

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 5/8 mm/memblock.c: hardcode the end_pfn being -1

From: Daniel Vacek <[email protected]>
Subject: mm/memblock.c: hardcode the end_pfn being -1

This is just a cleanup. It aids handling the special end case in the next commit.

[[email protected]: make it work against current -linus, not against -mm]
[[email protected]: make it work against current -linus, not against -mm some more]
Cc Michal Hocko <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Pavel Tatashin <[email protected]>
Cc Paul Burton <[email protected]>

---

 mm/memblock.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
mm/memblock.c renamed from mm/memblock.c~mm-memblock-hardcode-the-end_pfn-being-1 +5 -5
diff -puN mm/memblock.c~mm-memblock-hardcode-the-end_pfn-being-1 mm/memblock.c
@@ -1107,7 +1107,7 @@ unsigned long __init_memblock memblock_n
 	struct memblock_type *type = &memblock.memory;
 	unsigned int right = type->cnt;
 	unsigned int mid, left = 0;
-	phys_addr_t addr = PFN_PHYS(pfn + 1);
+	phys_addr_t addr = PFN_PHYS(++pfn);
 
 	do {
 		mid = (right + left) / 2;
@@ -1118,15 +1118,15 @@ unsigned long __init_memblock memblock_n
 				  type->regions[mid].size))
 			left = mid + 1;
 		else {
-			/* addr is within the region, so pfn + 1 is valid */
-			return min(pfn + 1, max_pfn);
+			/* addr is within the region, so pfn is valid */
+			return pfn;
 		}
 	} while (left < right);
 
 	if (right == type->cnt)
-		return max_pfn;
+		return -1UL;
 	else
-		return min(PHYS_PFN(type->regions[right].base), max_pfn);
+		return PHYS_PFN(type->regions[right].base);
 }
 
 /**

_

#1 lore raw
Quoted 8 lines · On Sat, Mar 10, 2018 at 12:51 AM, <[email protected]> wrote:

From: Daniel Vacek <[email protected]>
Subject: mm/memblock.c: hardcode the end_pfn being -1

This is just a cleanup. It aids handling the special end case in the next commit.

[[email protected]: make it work against current -linus, not against -mm] [[email protected]: make it work against current -linus, not against -mm some more]

Bad and bad some more. I believe you broke it and then you had to fix it...

--nX

Quoted 47 lines

---

 mm/memblock.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff -puN mm/memblock.c~mm-memblock-hardcode-the-end_pfn-being-1 mm/memblock.c

mm/memblock.c renamed from mm/memblock.c~mm-memblock-hardcode-the-end_pfn-being-1 +5 -5
@@ -1107,7 +1107,7 @@ unsigned long __init_memblock memblock_n
        struct memblock_type *type = &memblock.memory;
        unsigned int right = type->cnt;
        unsigned int mid, left = 0;
-       phys_addr_t addr = PFN_PHYS(pfn + 1);
+       phys_addr_t addr = PFN_PHYS(++pfn);
 
        do {
                mid = (right + left) / 2;
@@ -1118,15 +1118,15 @@ unsigned long __init_memblock memblock_n
                                  type->regions[mid].size))
                        left = mid + 1;
                else {
-                       /* addr is within the region, so pfn + 1 is valid */
-                       return min(pfn + 1, max_pfn);
+                       /* addr is within the region, so pfn is valid */
+                       return pfn;
                }
        } while (left < right);
 
        if (right == type->cnt)
-               return max_pfn;
+               return -1UL;
        else
-               return min(PHYS_PFN(type->regions[right].base), max_pfn);
+               return PHYS_PFN(type->regions[right].base);
 }
 
 /**

_