diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h index 1a9ef3e627d1..5dce5c21822c 100644 --- a/include/linux/nodemask.h +++ b/include/linux/nodemask.h @@ -352,6 +352,7 @@ extern nodemask_t node_possible_map; #define node_possible(node) node_isset((node), node_possible_map) #define first_online_node first_node(node_online_map) #define next_online_node(nid) next_node((nid), node_online_map) +int highest_possible_node_id(void); #else #define num_online_nodes() 1 #define num_possible_nodes() 1 @@ -359,6 +360,7 @@ extern nodemask_t node_possible_map; #define node_possible(node) ((node) == 0) #define first_online_node 0 #define next_online_node(nid) (MAX_NUMNODES) +#define highest_possible_node_id() 0 #endif #define any_online_node(mask) \ diff --git a/lib/cpumask.c b/lib/cpumask.c index 3a67dc5ada7d..7a2a73f88d59 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -43,3 +43,19 @@ int __any_online_cpu(const cpumask_t *mask) return cpu; } EXPORT_SYMBOL(__any_online_cpu); + +#if MAX_NUMNODES > 1 +/* + * Find the highest possible node id. + */ +int highest_possible_node_id(void) +{ + unsigned int node; + unsigned int highest = 0; + + for_each_node_mask(node, node_possible_map) + highest = node; + return highest; +} +EXPORT_SYMBOL(highest_possible_node_id); +#endif