diff mbox series

rt-numa: Fix the value to check in numa_initialize()

Message ID TYCP286MB1913E08DE65A54E19F3286F3A17D9@TYCP286MB1913.JPNP286.PROD.OUTLOOK.COM
State New
Headers show
Series rt-numa: Fix the value to check in numa_initialize() | expand

Commit Message

Oscar Shiang Dec. 22, 2021, 6:28 a.m. UTC
According to numa(3) [1], all numa functions are undefined if
numa_available() returns -1.

Thus numa_initialize() should not return 0, which indicates
libnuma is available, if numa_available() returns -1. It should
return 1 instead.

[1]: https://man7.org/linux/man-pages/man3/numa.3.html

Signed-off-by: Oscar Shiang <oscar0225@livemail.tw>
---
 src/lib/rt-numa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

John Kacur Dec. 22, 2021, 3:45 p.m. UTC | #1
On Wed, 22 Dec 2021, Oscar Shiang wrote:

> According to numa(3) [1], all numa functions are undefined if
> numa_available() returns -1.
> 
> Thus numa_initialize() should not return 0, which indicates
> libnuma is available, if numa_available() returns -1. It should
> return 1 instead.
> 
> [1]: https://man7.org/linux/man-pages/man3/numa.3.html
> 
> Signed-off-by: Oscar Shiang <oscar0225@livemail.tw>
> ---
>  src/lib/rt-numa.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c
> index bb0121a..47a643e 100644
> --- a/src/lib/rt-numa.c
> +++ b/src/lib/rt-numa.c
> @@ -25,7 +25,7 @@ int numa_initialize(void)
>  	if (is_initialized == 1)
>  		return numa;
>  
> -	if (numa_available() != -1)
> +	if (numa_available() == -1)
>  		numa = 1;
>  
>  	is_initialized = 1;
> -- 
> 2.25.1
> 
> 

No, it looks to me like the code is correct but the comment is incorrect.
If you submit a patch fixing the comment, I'll apply it.

Thanks

John
Oscar Shiang Dec. 23, 2021, 6:29 a.m. UTC | #2
> On Dec 22, 2021, at 11:45 PM, John Kacur <jkacur@redhat.com> wrote:
> 
> No, it looks to me like the code is correct but the comment is incorrect.
> If you submit a patch fixing the comment, I'll apply it.
> 

I agree. I will send another patch to fix the comment.

Thanks

Oscar
diff mbox series

Patch

diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c
index bb0121a..47a643e 100644
--- a/src/lib/rt-numa.c
+++ b/src/lib/rt-numa.c
@@ -25,7 +25,7 @@  int numa_initialize(void)
 	if (is_initialized == 1)
 		return numa;
 
-	if (numa_available() != -1)
+	if (numa_available() == -1)
 		numa = 1;
 
 	is_initialized = 1;