--- /usr/tmp/TmpDir.16435-0/linux/linux/arch/ia64/mm/discontig.c_1.25 Sat Feb 14 08:10:47 2004 +++ linux/linux/arch/ia64/mm/discontig.c Sat Feb 14 08:09:00 2004 @@ -399,6 +400,44 @@ } /** + * find_next_best_node - find the next node that should appear in a given + * node's fallback list + * @node: node whose fallback list we're appending + * + * We use a number of factors to determine which is the next node that should + * appear on a given node's fallback list. The node should not have appeared + * already in @node's fallback list, and it should be the next closest node + * according to the distance array (which contains arbitrary distance values + * from each node to each node in the system), and should also prefer nodes + * with no CPUs, since presumably they'll have very little allocation pressure + * on them otherwise. + */ +int find_next_best_node(int node) +{ + int i, val, min_val, best_node; + + for (i = 0; i < numnodes; i++) { + /* Don't want a node to appear more than once */ + if (node_present(node, i)) + continue; + + /* Use the distance array to find the distance */ + val = node_distance(node, i); + + /* Give preference to headless and unused nodes */ + val += nid_enabled_cpu_count[i] * 255; + val += node_load[i]; + + if (val < min_val) { + min_val = val; + best_node = i; + } + } + + return best_node; +} + +/** * build_zonelists - do a first pass sort of the zone fallback lists * @pgdat: pg_data_t corresponding to the node we're sorting for *