Skip to content

Commit 7cc3959

Browse files
glommerIngo Molnar
authored andcommitted
x86: move {un}map_cpu_to_logical_apicid to smpboot.c
Move map_cpu_to_logical_apicid() and unmap_cpu_to_logical_apicid() to smpboot.c. They take together all the bunch of static functions they rely upon Signed-off-by: Glauber Costa <gcosta@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent b9f9294 commit 7cc3959

2 files changed

Lines changed: 62 additions & 57 deletions

File tree

‎arch/x86/kernel/smpboot.c‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,66 @@ static cpumask_t cpu_sibling_setup_map;
5050
/* Set if we find a B stepping CPU */
5151
int __cpuinitdata smp_b_stepping;
5252

53+
#if defined(CONFIG_NUMA) && defined(CONFIG_X86_32)
54+
55+
/* which logical CPUs are on which nodes */
56+
cpumask_t node_to_cpumask_map[MAX_NUMNODES] __read_mostly =
57+
{ [0 ... MAX_NUMNODES-1] = CPU_MASK_NONE };
58+
EXPORT_SYMBOL(node_to_cpumask_map);
59+
/* which node each logical CPU is on */
60+
int cpu_to_node_map[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = 0 };
61+
EXPORT_SYMBOL(cpu_to_node_map);
62+
63+
/* set up a mapping between cpu and node. */
64+
static void map_cpu_to_node(int cpu, int node)
65+
{
66+
printk(KERN_INFO "Mapping cpu %d to node %d\n", cpu, node);
67+
cpu_set(cpu, node_to_cpumask_map[node]);
68+
cpu_to_node_map[cpu] = node;
69+
}
70+
71+
/* undo a mapping between cpu and node. */
72+
static void unmap_cpu_to_node(int cpu)
73+
{
74+
int node;
75+
76+
printk(KERN_INFO "Unmapping cpu %d from all nodes\n", cpu);
77+
for (node = 0; node < MAX_NUMNODES; node++)
78+
cpu_clear(cpu, node_to_cpumask_map[node]);
79+
cpu_to_node_map[cpu] = 0;
80+
}
81+
#else /* !(CONFIG_NUMA && CONFIG_X86_32) */
82+
#define map_cpu_to_node(cpu, node) ({})
83+
#define unmap_cpu_to_node(cpu) ({})
84+
#endif
85+
86+
#ifdef CONFIG_X86_32
87+
u8 cpu_2_logical_apicid[NR_CPUS] __read_mostly =
88+
{ [0 ... NR_CPUS-1] = BAD_APICID };
89+
90+
void map_cpu_to_logical_apicid(void)
91+
{
92+
int cpu = smp_processor_id();
93+
int apicid = logical_smp_processor_id();
94+
int node = apicid_to_node(apicid);
95+
96+
if (!node_online(node))
97+
node = first_online_node;
98+
99+
cpu_2_logical_apicid[cpu] = apicid;
100+
map_cpu_to_node(cpu, node);
101+
}
102+
103+
void unmap_cpu_to_logical_apicid(int cpu)
104+
{
105+
cpu_2_logical_apicid[cpu] = BAD_APICID;
106+
unmap_cpu_to_node(cpu);
107+
}
108+
#else
109+
#define unmap_cpu_to_logical_apicid(cpu) do {} while (0)
110+
#define map_cpu_to_logical_apicid() do {} while (0)
111+
#endif
112+
53113
static void __cpuinit smp_apply_quirks(struct cpuinfo_x86 *c)
54114
{
55115
#ifdef CONFIG_X86_32

‎arch/x86/kernel/smpboot_32.c‎

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ EXPORT_PER_CPU_SYMBOL(x86_bios_cpu_apicid);
7474

7575
u8 apicid_2_node[MAX_APICID];
7676

77-
static void map_cpu_to_logical_apicid(void);
77+
extern void map_cpu_to_logical_apicid(void);
78+
extern void unmap_cpu_to_logical_apicid(int cpu);
7879

7980
/* State of each CPU. */
8081
DEFINE_PER_CPU(int, cpu_state) = { 0 };
@@ -262,62 +263,6 @@ extern struct {
262263
unsigned short ss;
263264
} stack_start;
264265

265-
#ifdef CONFIG_NUMA
266-
267-
/* which logical CPUs are on which nodes */
268-
cpumask_t node_to_cpumask_map[MAX_NUMNODES] __read_mostly =
269-
{ [0 ... MAX_NUMNODES-1] = CPU_MASK_NONE };
270-
EXPORT_SYMBOL(node_to_cpumask_map);
271-
/* which node each logical CPU is on */
272-
int cpu_to_node_map[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = 0 };
273-
EXPORT_SYMBOL(cpu_to_node_map);
274-
275-
/* set up a mapping between cpu and node. */
276-
static inline void map_cpu_to_node(int cpu, int node)
277-
{
278-
printk("Mapping cpu %d to node %d\n", cpu, node);
279-
cpu_set(cpu, node_to_cpumask_map[node]);
280-
cpu_to_node_map[cpu] = node;
281-
}
282-
283-
/* undo a mapping between cpu and node. */
284-
static inline void unmap_cpu_to_node(int cpu)
285-
{
286-
int node;
287-
288-
printk("Unmapping cpu %d from all nodes\n", cpu);
289-
for (node = 0; node < MAX_NUMNODES; node ++)
290-
cpu_clear(cpu, node_to_cpumask_map[node]);
291-
cpu_to_node_map[cpu] = 0;
292-
}
293-
#else /* !CONFIG_NUMA */
294-
295-
#define map_cpu_to_node(cpu, node) ({})
296-
#define unmap_cpu_to_node(cpu) ({})
297-
298-
#endif /* CONFIG_NUMA */
299-
300-
u8 cpu_2_logical_apicid[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = BAD_APICID };
301-
302-
static void map_cpu_to_logical_apicid(void)
303-
{
304-
int cpu = smp_processor_id();
305-
int apicid = logical_smp_processor_id();
306-
int node = apicid_to_node(apicid);
307-
308-
if (!node_online(node))
309-
node = first_online_node;
310-
311-
cpu_2_logical_apicid[cpu] = apicid;
312-
map_cpu_to_node(cpu, node);
313-
}
314-
315-
static void unmap_cpu_to_logical_apicid(int cpu)
316-
{
317-
cpu_2_logical_apicid[cpu] = BAD_APICID;
318-
unmap_cpu_to_node(cpu);
319-
}
320-
321266
static inline void __inquire_remote_apic(int apicid)
322267
{
323268
unsigned i, regs[] = { APIC_ID >> 4, APIC_LVR >> 4, APIC_SPIV >> 4 };

0 commit comments

Comments
 (0)