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

Leesoo Ahn posted 1 patch 1 year, 8 months ago
mm/sparse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] mm/sparse: use MEMBLOCK_ALLOC_ACCESSIBLE enum instead of 0
Posted by Leesoo Ahn 1 year, 8 months ago
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.

Signed-off-by: Leesoo Ahn <lsahn@ooseel.net>
---
v1 -> v2: do not rename 'limit' to 'limit_or_flag'
---
 mm/sparse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/sparse.c b/mm/sparse.c
index de40b2c73406..cf93abc542ca 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -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;
-- 
2.34.1
Re: [PATCH v2] mm/sparse: use MEMBLOCK_ALLOC_ACCESSIBLE enum instead of 0
Posted by Mike Rapoport 1 year, 8 months ago
On Tue, Jun 11, 2024 at 12:15:28AM +0900, Leesoo Ahn wrote:
> 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.
> 
> Signed-off-by: Leesoo Ahn <lsahn@ooseel.net>

Acked-by: Mike Rapoport (IBM) <rppt@kernel.org>

> ---
> v1 -> v2: do not rename 'limit' to 'limit_or_flag'
> ---
>  mm/sparse.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/sparse.c b/mm/sparse.c
> index de40b2c73406..cf93abc542ca 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -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;
> -- 
> 2.34.1
> 

-- 
Sincerely yours,
Mike.
Re: [PATCH v2] mm/sparse: use MEMBLOCK_ALLOC_ACCESSIBLE enum instead of 0
Posted by Wei Yang 1 year, 8 months ago
On Tue, Jun 11, 2024 at 12:15:28AM +0900, Leesoo Ahn wrote:
>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.
>
>Signed-off-by: Leesoo Ahn <lsahn@ooseel.net>

Reviewed-by: Wei Yang <richard.weiyang@gmail.com>

>---
>v1 -> v2: do not rename 'limit' to 'limit_or_flag'
>---
> mm/sparse.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/mm/sparse.c b/mm/sparse.c
>index de40b2c73406..cf93abc542ca 100644
>--- a/mm/sparse.c
>+++ b/mm/sparse.c
>@@ -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;
>-- 
>2.34.1
>

-- 
Wei Yang
Help you, Help me