mirror of
https://github.com/fail0verflow/switch-linux.git
synced 2025-05-04 02:34:21 -04:00
cpumask: x86: Introduce cpumask_of_{node,pcibus} to replace {node,pcibus}_to_cpumask
Impact: New APIs The old node_to_cpumask/node_to_pcibus returned a cpumask_t: these return a pointer to a struct cpumask. Part of removing cpumasks from the stack. Also makes __pcibus_to_node take a const pointer. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Acked-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
d62720ade8
commit
393d68fb99
3 changed files with 35 additions and 18 deletions
|
@ -98,9 +98,9 @@ static inline void early_quirks(void) { }
|
||||||
|
|
||||||
#ifdef CONFIG_NUMA
|
#ifdef CONFIG_NUMA
|
||||||
/* Returns the node based on pci bus */
|
/* Returns the node based on pci bus */
|
||||||
static inline int __pcibus_to_node(struct pci_bus *bus)
|
static inline int __pcibus_to_node(const struct pci_bus *bus)
|
||||||
{
|
{
|
||||||
struct pci_sysdata *sd = bus->sysdata;
|
const struct pci_sysdata *sd = bus->sysdata;
|
||||||
|
|
||||||
return sd->node;
|
return sd->node;
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,12 @@ static inline cpumask_t __pcibus_to_cpumask(struct pci_bus *bus)
|
||||||
{
|
{
|
||||||
return node_to_cpumask(__pcibus_to_node(bus));
|
return node_to_cpumask(__pcibus_to_node(bus));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline const struct cpumask *
|
||||||
|
cpumask_of_pcibus(const struct pci_bus *bus)
|
||||||
|
{
|
||||||
|
return cpumask_of_node(__pcibus_to_node(bus));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _ASM_X86_PCI_H */
|
#endif /* _ASM_X86_PCI_H */
|
||||||
|
|
|
@ -61,13 +61,19 @@ static inline int cpu_to_node(int cpu)
|
||||||
*
|
*
|
||||||
* Side note: this function creates the returned cpumask on the stack
|
* Side note: this function creates the returned cpumask on the stack
|
||||||
* so with a high NR_CPUS count, excessive stack space is used. The
|
* so with a high NR_CPUS count, excessive stack space is used. The
|
||||||
* node_to_cpumask_ptr function should be used whenever possible.
|
* cpumask_of_node function should be used whenever possible.
|
||||||
*/
|
*/
|
||||||
static inline cpumask_t node_to_cpumask(int node)
|
static inline cpumask_t node_to_cpumask(int node)
|
||||||
{
|
{
|
||||||
return node_to_cpumask_map[node];
|
return node_to_cpumask_map[node];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns a bitmask of CPUs on Node 'node'. */
|
||||||
|
static inline const struct cpumask *cpumask_of_node(int node)
|
||||||
|
{
|
||||||
|
return &node_to_cpumask_map[node];
|
||||||
|
}
|
||||||
|
|
||||||
#else /* CONFIG_X86_64 */
|
#else /* CONFIG_X86_64 */
|
||||||
|
|
||||||
/* Mappings between node number and cpus on that node. */
|
/* Mappings between node number and cpus on that node. */
|
||||||
|
@ -82,7 +88,7 @@ DECLARE_EARLY_PER_CPU(int, x86_cpu_to_node_map);
|
||||||
#ifdef CONFIG_DEBUG_PER_CPU_MAPS
|
#ifdef CONFIG_DEBUG_PER_CPU_MAPS
|
||||||
extern int cpu_to_node(int cpu);
|
extern int cpu_to_node(int cpu);
|
||||||
extern int early_cpu_to_node(int cpu);
|
extern int early_cpu_to_node(int cpu);
|
||||||
extern const cpumask_t *_node_to_cpumask_ptr(int node);
|
extern const cpumask_t *cpumask_of_node(int node);
|
||||||
extern cpumask_t node_to_cpumask(int node);
|
extern cpumask_t node_to_cpumask(int node);
|
||||||
|
|
||||||
#else /* !CONFIG_DEBUG_PER_CPU_MAPS */
|
#else /* !CONFIG_DEBUG_PER_CPU_MAPS */
|
||||||
|
@ -103,7 +109,7 @@ static inline int early_cpu_to_node(int cpu)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns a pointer to the cpumask of CPUs on Node 'node'. */
|
/* Returns a pointer to the cpumask of CPUs on Node 'node'. */
|
||||||
static inline const cpumask_t *_node_to_cpumask_ptr(int node)
|
static inline const cpumask_t *cpumask_of_node(int node)
|
||||||
{
|
{
|
||||||
return &node_to_cpumask_map[node];
|
return &node_to_cpumask_map[node];
|
||||||
}
|
}
|
||||||
|
@ -116,12 +122,15 @@ static inline cpumask_t node_to_cpumask(int node)
|
||||||
|
|
||||||
#endif /* !CONFIG_DEBUG_PER_CPU_MAPS */
|
#endif /* !CONFIG_DEBUG_PER_CPU_MAPS */
|
||||||
|
|
||||||
/* Replace default node_to_cpumask_ptr with optimized version */
|
/*
|
||||||
|
* Replace default node_to_cpumask_ptr with optimized version
|
||||||
|
* Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)"
|
||||||
|
*/
|
||||||
#define node_to_cpumask_ptr(v, node) \
|
#define node_to_cpumask_ptr(v, node) \
|
||||||
const cpumask_t *v = _node_to_cpumask_ptr(node)
|
const cpumask_t *v = cpumask_of_node(node)
|
||||||
|
|
||||||
#define node_to_cpumask_ptr_next(v, node) \
|
#define node_to_cpumask_ptr_next(v, node) \
|
||||||
v = _node_to_cpumask_ptr(node)
|
v = cpumask_of_node(node)
|
||||||
|
|
||||||
#endif /* CONFIG_X86_64 */
|
#endif /* CONFIG_X86_64 */
|
||||||
|
|
||||||
|
@ -187,7 +196,7 @@ extern int __node_distance(int, int);
|
||||||
#define cpu_to_node(cpu) 0
|
#define cpu_to_node(cpu) 0
|
||||||
#define early_cpu_to_node(cpu) 0
|
#define early_cpu_to_node(cpu) 0
|
||||||
|
|
||||||
static inline const cpumask_t *_node_to_cpumask_ptr(int node)
|
static inline const cpumask_t *cpumask_of_node(int node)
|
||||||
{
|
{
|
||||||
return &cpu_online_map;
|
return &cpu_online_map;
|
||||||
}
|
}
|
||||||
|
@ -200,12 +209,15 @@ static inline int node_to_first_cpu(int node)
|
||||||
return first_cpu(cpu_online_map);
|
return first_cpu(cpu_online_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Replace default node_to_cpumask_ptr with optimized version */
|
/*
|
||||||
|
* Replace default node_to_cpumask_ptr with optimized version
|
||||||
|
* Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)"
|
||||||
|
*/
|
||||||
#define node_to_cpumask_ptr(v, node) \
|
#define node_to_cpumask_ptr(v, node) \
|
||||||
const cpumask_t *v = _node_to_cpumask_ptr(node)
|
const cpumask_t *v = cpumask_of_node(node)
|
||||||
|
|
||||||
#define node_to_cpumask_ptr_next(v, node) \
|
#define node_to_cpumask_ptr_next(v, node) \
|
||||||
v = _node_to_cpumask_ptr(node)
|
v = cpumask_of_node(node)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <asm-generic/topology.h>
|
#include <asm-generic/topology.h>
|
||||||
|
@ -214,8 +226,7 @@ static inline int node_to_first_cpu(int node)
|
||||||
/* Returns the number of the first CPU on Node 'node'. */
|
/* Returns the number of the first CPU on Node 'node'. */
|
||||||
static inline int node_to_first_cpu(int node)
|
static inline int node_to_first_cpu(int node)
|
||||||
{
|
{
|
||||||
node_to_cpumask_ptr(mask, node);
|
return cpumask_first(cpumask_of_node(node));
|
||||||
return first_cpu(*mask);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -334,25 +334,25 @@ static const cpumask_t cpu_mask_none;
|
||||||
/*
|
/*
|
||||||
* Returns a pointer to the bitmask of CPUs on Node 'node'.
|
* Returns a pointer to the bitmask of CPUs on Node 'node'.
|
||||||
*/
|
*/
|
||||||
const cpumask_t *_node_to_cpumask_ptr(int node)
|
const cpumask_t *cpumask_of_node(int node)
|
||||||
{
|
{
|
||||||
if (node_to_cpumask_map == NULL) {
|
if (node_to_cpumask_map == NULL) {
|
||||||
printk(KERN_WARNING
|
printk(KERN_WARNING
|
||||||
"_node_to_cpumask_ptr(%d): no node_to_cpumask_map!\n",
|
"cpumask_of_node(%d): no node_to_cpumask_map!\n",
|
||||||
node);
|
node);
|
||||||
dump_stack();
|
dump_stack();
|
||||||
return (const cpumask_t *)&cpu_online_map;
|
return (const cpumask_t *)&cpu_online_map;
|
||||||
}
|
}
|
||||||
if (node >= nr_node_ids) {
|
if (node >= nr_node_ids) {
|
||||||
printk(KERN_WARNING
|
printk(KERN_WARNING
|
||||||
"_node_to_cpumask_ptr(%d): node > nr_node_ids(%d)\n",
|
"cpumask_of_node(%d): node > nr_node_ids(%d)\n",
|
||||||
node, nr_node_ids);
|
node, nr_node_ids);
|
||||||
dump_stack();
|
dump_stack();
|
||||||
return &cpu_mask_none;
|
return &cpu_mask_none;
|
||||||
}
|
}
|
||||||
return &node_to_cpumask_map[node];
|
return &node_to_cpumask_map[node];
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(_node_to_cpumask_ptr);
|
EXPORT_SYMBOL(cpumask_of_node);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns a bitmask of CPUs on Node 'node'.
|
* Returns a bitmask of CPUs on Node 'node'.
|
||||||
|
|
Loading…
Add table
Reference in a new issue