Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4cf808eb authored by Linus Torvalds's avatar Linus Torvalds Committed by Linus Torvalds
Browse files

[PATCH] Handle holes in node mask in node fallback list setup



Change the find_next_best_node algorithm to correctly skip
over holes in the node online mask. Previously it would not handle
missing nodes correctly and cause crashes at boot.

[Written by Linus, tested by AK]

Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent cfe91f9c
Loading
Loading
Loading
Loading
+11 −11
Original line number Original line Diff line number Diff line
@@ -1541,29 +1541,29 @@ static int __initdata node_load[MAX_NUMNODES];
 */
 */
static int __init find_next_best_node(int node, nodemask_t *used_node_mask)
static int __init find_next_best_node(int node, nodemask_t *used_node_mask)
{
{
	int i, n, val;
	int n, val;
	int min_val = INT_MAX;
	int min_val = INT_MAX;
	int best_node = -1;
	int best_node = -1;


	for_each_online_node(i) {
	/* Use the local node if we haven't already */
		cpumask_t tmp;
	if (!node_isset(node, *used_node_mask)) {
		node_set(node, *used_node_mask);
		return node;
	}


		/* Start from local node */
	for_each_online_node(n) {
		n = (node+i) % num_online_nodes();
		cpumask_t tmp;


		/* Don't want a node to appear more than once */
		/* Don't want a node to appear more than once */
		if (node_isset(n, *used_node_mask))
		if (node_isset(n, *used_node_mask))
			continue;
			continue;


		/* Use the local node if we haven't already */
		if (!node_isset(node, *used_node_mask)) {
			best_node = node;
			break;
		}

		/* Use the distance array to find the distance */
		/* Use the distance array to find the distance */
		val = node_distance(node, n);
		val = node_distance(node, n);


		/* Penalize nodes under us ("prefer the next node") */
		val += (n < node);

		/* Give preference to headless and unused nodes */
		/* Give preference to headless and unused nodes */
		tmp = node_to_cpumask(n);
		tmp = node_to_cpumask(n);
		if (!cpus_empty(tmp))
		if (!cpus_empty(tmp))