Skip to content

Commit dbbe13a

Browse files
author
Ingo Molnar
committed
x86/cpu: Improve readability of per-CPU cpumask initialization code
In smp_prepare_cpus_common() and x2apic_prepare_cpu(): - use 'cpu' instead of 'i' - use 'node' instead of 'n' - use vertical alignment to improve readability - better structure basic blocks - reduce col80 checkpatch damage Signed-off-by: Ingo Molnar <[email protected]> Cc: [email protected]
1 parent e0a9ac1 commit dbbe13a

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

arch/x86/kernel/apic/x2apic_cluster.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,16 @@ static int x2apic_prepare_cpu(unsigned int cpu)
178178
u32 phys_apicid = apic->cpu_present_to_apicid(cpu);
179179
u32 cluster = apic_cluster(phys_apicid);
180180
u32 logical_apicid = (cluster << 16) | (1 << (phys_apicid & 0xf));
181+
int node = cpu_to_node(cpu);
181182

182183
x86_cpu_to_logical_apicid[cpu] = logical_apicid;
183184

184-
if (alloc_clustermask(cpu, cluster, cpu_to_node(cpu)) < 0)
185+
if (alloc_clustermask(cpu, cluster, node) < 0)
185186
return -ENOMEM;
186-
if (!zalloc_cpumask_var_node(&per_cpu(ipi_mask, cpu), GFP_KERNEL,
187-
cpu_to_node(cpu)))
187+
188+
if (!zalloc_cpumask_var_node(&per_cpu(ipi_mask, cpu), GFP_KERNEL, node))
188189
return -ENOMEM;
190+
189191
return 0;
190192
}
191193

arch/x86/kernel/smpboot.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,21 +1033,22 @@ static __init void disable_smp(void)
10331033

10341034
void __init smp_prepare_cpus_common(void)
10351035
{
1036-
unsigned int i, n;
1036+
unsigned int cpu, node;
10371037

10381038
/* Mark all except the boot CPU as hotpluggable */
1039-
for_each_possible_cpu(i) {
1040-
if (i)
1041-
per_cpu(cpu_info.cpu_index, i) = nr_cpu_ids;
1039+
for_each_possible_cpu(cpu) {
1040+
if (cpu)
1041+
per_cpu(cpu_info.cpu_index, cpu) = nr_cpu_ids;
10421042
}
10431043

1044-
for_each_possible_cpu(i) {
1045-
n = cpu_to_node(i);
1046-
zalloc_cpumask_var_node(&per_cpu(cpu_sibling_map, i), GFP_KERNEL, n);
1047-
zalloc_cpumask_var_node(&per_cpu(cpu_core_map, i), GFP_KERNEL, n);
1048-
zalloc_cpumask_var_node(&per_cpu(cpu_die_map, i), GFP_KERNEL, n);
1049-
zalloc_cpumask_var_node(&per_cpu(cpu_llc_shared_map, i), GFP_KERNEL, n);
1050-
zalloc_cpumask_var_node(&per_cpu(cpu_l2c_shared_map, i), GFP_KERNEL, n);
1044+
for_each_possible_cpu(cpu) {
1045+
node = cpu_to_node(cpu);
1046+
1047+
zalloc_cpumask_var_node(&per_cpu(cpu_sibling_map, cpu), GFP_KERNEL, node);
1048+
zalloc_cpumask_var_node(&per_cpu(cpu_core_map, cpu), GFP_KERNEL, node);
1049+
zalloc_cpumask_var_node(&per_cpu(cpu_die_map, cpu), GFP_KERNEL, node);
1050+
zalloc_cpumask_var_node(&per_cpu(cpu_llc_shared_map, cpu), GFP_KERNEL, node);
1051+
zalloc_cpumask_var_node(&per_cpu(cpu_l2c_shared_map, cpu), GFP_KERNEL, node);
10511052
}
10521053

10531054
set_cpu_sibling_map(0);

0 commit comments

Comments
 (0)