Skip to contentSkip to conversation

mm/sparse: use MEMBLOCK_ALLOC_ACCESSIBLE enum instead of 0

PATCH Applied Leesoo Ahn 3 participants 3 messages Jun 10, 2024 – Jun 11, 2024

Subsystems (2)
lore
Share & tools
lore

Leesoo Ahn

author
#0 lore raw

PATCH v2 1/1 mm/sparse: use MEMBLOCK_ALLOC_ACCESSIBLE enum instead of 0

Setting 'limit' variable to 0 might seem like it means "no limit". But in the memblock API, 0 actually means the 'MEMBLOCK_ALLOC_ACCESSIBLE' enum, which limits the physical address range end based on 'memblock.current_limit'. This could be confusing.

Use the enum instead of 0 to make it clear.

---
v1 -> v2: do not rename 'limit' to 'limit_or_flag'

---
 mm/sparse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/sparse.c +1 -1
index de40b2c73406..cf93abc542ca 100644
@@ -351,7 +351,7 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
 again:
 	usage = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, goal, limit, nid);
 	if (!usage && limit) {
-		limit = 0;
+		limit = MEMBLOCK_ALLOC_ACCESSIBLE;
 		goto again;
 	}
 	return usage;
Signature · 1 line
2.34.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Leesoo Ahn

Setting 'limit' variable to 0 might seem like it means "no limit". But in the memblock API, 0 actually means the 'MEMBLOCK_ALLOC_ACCESSIBLE' enum, which limits the physical address range end based on 'memblock.current_limit'. This could be confusing.

Use the enum instead of 0 to make it clear.

Quoted 22 lines

---
v1 -> v2: do not rename 'limit' to 'limit_or_flag'
---
mm/sparse.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
mm/sparse.c +0 -0
index de40b2c73406..cf93abc542ca 100644
@@ -351,7 +351,7 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,

again:

	usage = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, goal, limit, nid);
	if (!usage && limit) {
mm/sparse.c +1 -1
-		limit = 0;
+		limit = MEMBLOCK_ALLOC_ACCESSIBLE;
		goto again;
	}
	return usage;
Signature · 1 line
2.34.1
Signature · 2 lines
Wei Yang
Help you, Help me
reviewer Acked-by on v2 1/1
#2 lore raw
In reply to Leesoo Ahn
Quoted 8 lines · Leesoo Ahn

Setting 'limit' variable to 0 might seem like it means "no limit". But in the memblock API, 0 actually means the 'MEMBLOCK_ALLOC_ACCESSIBLE' enum, which limits the physical address range end based on 'memblock.current_limit'. This could be confusing.

Use the enum instead of 0 to make it clear.

Quoted 22 lines

---
v1 -> v2: do not rename 'limit' to 'limit_or_flag'

---
 mm/sparse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/sparse.c +1 -1
index de40b2c73406..cf93abc542ca 100644
@@ -351,7 +351,7 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
 again:
 	usage = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, goal, limit, nid);
 	if (!usage && limit) {
-		limit = 0;
+		limit = MEMBLOCK_ALLOC_ACCESSIBLE;
 		goto again;
 	}
 	return usage;
Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours,
Mike.