diff options
| author | Mike Rapoport (IBM) <rppt@kernel.org> | 2024-06-14 11:05:43 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-01-17 15:36:09 +0300 |
| commit | fdebee5c5c2bdba49dc225331548e42b79e44204 (patch) | |
| tree | c1cfd11c947b5ba68eb067e5b3ab660ff3840cdc /include/linux | |
| parent | 4ddb7f966f3d06fcf1ba5ee298af6714b593584b (diff) | |
| download | linux-fdebee5c5c2bdba49dc225331548e42b79e44204.tar.xz | |
memblock: use numa_valid_node() helper to check for invalid node ID
commit 8043832e2a123fd9372007a29192f2f3ba328cd6 upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.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 |
