Skip to content

Commit 4c4c6f3

Browse files
committed
x86/cpu/topology: Simplify APIC registration
Having the same check whether the number of assigned CPUs has reached the nr_cpu_ids limit twice in the same code path is pointless. Repeating the information that CPUs are ignored over and over is also pointless noise. Remove the redundant check and reduce the noise by using a pr_warn_once(). Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Michael Kelley <[email protected]> Tested-by: Sohil Mehta <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 58aa34a commit 4c4c6f3

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

arch/x86/kernel/cpu/topology.c

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,6 @@ static int allocate_logical_cpuid(u32 apic_id)
107107
if (cpu >= 0)
108108
return cpu;
109109

110-
/* Allocate a new cpuid. */
111-
if (nr_logical_cpuids >= nr_cpu_ids) {
112-
WARN_ONCE(1, "APIC: NR_CPUS/possible_cpus limit of %u reached. "
113-
"Processor %d/0x%x and the rest are ignored.\n",
114-
nr_cpu_ids, nr_logical_cpuids, apic_id);
115-
return -EINVAL;
116-
}
117-
118110
cpuid_to_apicid[nr_logical_cpuids] = apic_id;
119111
return nr_logical_cpuids++;
120112
}
@@ -135,7 +127,7 @@ static void cpu_update_apic(int cpu, u32 apicid)
135127

136128
static int generic_processor_info(int apicid)
137129
{
138-
int cpu, max = nr_cpu_ids;
130+
int cpu;
139131

140132
/* The boot CPU must be set before MADT/MPTABLE parsing happens */
141133
if (cpuid_to_apicid[0] == BAD_APICID)
@@ -155,21 +147,12 @@ static int generic_processor_info(int apicid)
155147
}
156148

157149
if (num_processors >= nr_cpu_ids) {
158-
int thiscpu = max + disabled_cpus;
159-
160-
pr_warn("APIC: NR_CPUS/possible_cpus limit of %i reached. "
161-
"Processor %d/0x%x ignored.\n", max, thiscpu, apicid);
162-
150+
pr_warn_once("APIC: CPU limit of %d reached. Ignoring further CPUs\n", nr_cpu_ids);
163151
disabled_cpus++;
164-
return -EINVAL;
152+
return -ENOSPC;
165153
}
166154

167155
cpu = allocate_logical_cpuid(apicid);
168-
if (cpu < 0) {
169-
disabled_cpus++;
170-
return -EINVAL;
171-
}
172-
173156
cpu_update_apic(cpu, apicid);
174157
return cpu;
175158
}

0 commit comments

Comments
 (0)