diff options
author | Yury Norov <yury.norov@gmail.com> | 2023-08-19 17:12:33 +0300 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2023-09-15 14:48:09 +0300 |
commit | b1f099b1cf51d553c510c6c8141c27d9ba7ea1fe (patch) | |
tree | e126ab3ac7fd278ee7fb1dbd353f91d09f7d7950 /include/linux/numa.h | |
parent | 4de7b17fd05d03fa919e8c47fc66122bd24d7b6c (diff) | |
download | linux-b1f099b1cf51d553c510c6c8141c27d9ba7ea1fe.tar.xz |
numa: Generalize numa_map_to_online_node()
The function in fact searches the nearest node for a given one,
based on a N_ONLINE state. This is a common pattern to search
for a nearest node.
This patch converts numa_map_to_online_node() to numa_nearest_node()
so that others won't need to opencode the logic.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Mel Gorman <mgorman@suse.de>
Link: https://lore.kernel.org/r/20230819141239.287290-2-yury.norov@gmail.com
Diffstat (limited to 'include/linux/numa.h')
-rw-r--r-- | include/linux/numa.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/include/linux/numa.h b/include/linux/numa.h index 59df211d051f..fb30a42f0700 100644 --- a/include/linux/numa.h +++ b/include/linux/numa.h @@ -25,7 +25,7 @@ #include <asm/sparsemem.h> /* Generic implementation available */ -int numa_map_to_online_node(int node); +int numa_nearest_node(int node, unsigned int state); #ifndef memory_add_physaddr_to_nid static inline int memory_add_physaddr_to_nid(u64 start) @@ -44,10 +44,11 @@ static inline int phys_to_target_node(u64 start) } #endif #else /* !CONFIG_NUMA */ -static inline int numa_map_to_online_node(int node) +static inline int numa_nearest_node(int node, unsigned int state) { return NUMA_NO_NODE; } + static inline int memory_add_physaddr_to_nid(u64 start) { return 0; @@ -58,6 +59,8 @@ static inline int phys_to_target_node(u64 start) } #endif +#define numa_map_to_online_node(node) numa_nearest_node(node, N_ONLINE) + #ifdef CONFIG_HAVE_ARCH_NODE_DEV_GROUP extern const struct attribute_group arch_node_dev_group; #endif |