diff options
author | Mike Rapoport (IBM) <rppt@kernel.org> | 2024-06-14 11:05:43 +0300 |
---|---|---|
committer | Mike Rapoport (IBM) <rppt@kernel.org> | 2024-06-16 10:17:57 +0300 |
commit | 8043832e2a123fd9372007a29192f2f3ba328cd6 (patch) | |
tree | 91eead9aeec744a0c76e4da790894a9a35617185 /include/linux | |
parent | 3ac36aa7307363b7247ccb6f6a804e11496b2b36 (diff) | |
download | linux-8043832e2a123fd9372007a29192f2f3ba328cd6.tar.xz |
memblock: use numa_valid_node() helper to check for invalid node ID
Introduce numa_valid_node(nid) that verifies that nid is a valid node ID
and use that instead of comparing nid parameter with either NUMA_NO_NODE
or MAX_NUMNODES.
This makes the checks for valid node IDs consistent and more robust and
allows to get rid of multiple WARNings.
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/numa.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/numa.h b/include/linux/numa.h index 1d43371fafd2..eb19503604fe 100644 --- a/include/linux/numa.h +++ b/include/linux/numa.h @@ -15,6 +15,11 @@ #define NUMA_NO_NODE (-1) #define NUMA_NO_MEMBLK (-1) +static inline bool numa_valid_node(int nid) +{ + return nid >= 0 && nid < MAX_NUMNODES; +} + /* optionally keep NUMA memory info available post init */ #ifdef CONFIG_NUMA_KEEP_MEMINFO #define __initdata_or_meminfo |