Comment 20 for bug 2008157

Revision history for this message
James Dingwall (a-james-launchpad) wrote :

I've had a look at the x86 code where this error comes from:

/* Returns a pointer to the cpumask of CPUs on Node 'node'. */
static inline const struct cpumask *cpumask_of_node(int node)
{
 return node_to_cpumask_map[node];
}

So it seems the error arises because it is asked for a negative index from the node_to_cpumask_map array. Interestingly the same name for sparc has handling for the case the argument is -1:

#define cpumask_of_node(node) ((node) == -1 ? \
                               cpu_all_mask : \
                               &numa_cpumask_lookup_table[node])

and so does powerpc:

#define cpumask_of_node(node) ((node) == -1 ? \
                               cpu_all_mask : \
                               node_to_cpumask_map[node])

in drivers/base/arch_numa.c there is a debug version for this name which returns cpu_all_mask as sparc and powerpc for NUMA_NO_NODE (include/linux/numa.h:#define NUMA_NO_NODE (-1)):

#ifdef CONFIG_DEBUG_PER_CPU_MAPS

/*
 * Returns a pointer to the bitmask of CPUs on Node 'node'.
 */
const struct cpumask *cpumask_of_node(int node)
{

        if (node == NUMA_NO_NODE)
                return cpu_all_mask;

        if (WARN_ON(node < 0 || node >= nr_node_ids))
                return cpu_none_mask;

        if (WARN_ON(node_to_cpumask_map[node] == NULL))
                return cpu_online_mask;

        return node_to_cpumask_map[node];
}
EXPORT_SYMBOL(cpumask_of_node);

#endif

Based on these alternative implementations it seems as though cpumask_of_node for x86 should be something like:

/* Returns a pointer to the cpumask of CPUs on Node 'node'. */
static inline const struct cpumask *cpumask_of_node(int node)
{
 return node == -1 ? cpu_all_mask : node_to_cpumask_map[node];
}

I have insufficient knowledge about this stuff to say that is definitely the case though.