Commit 38bef8e5 authored by Yury Norov's avatar Yury Norov

smp: add set_nr_cpu_ids()

In preparation to support compile-time nr_cpu_ids, add a setter for
the variable.

This is a no-op for all arches.
Signed-off-by: default avatarYury Norov <yury.norov@gmail.com>
parent 53fc190c
...@@ -346,7 +346,7 @@ static void __init prefill_possible_map(void) ...@@ -346,7 +346,7 @@ static void __init prefill_possible_map(void)
for (; i < NR_CPUS; i++) for (; i < NR_CPUS; i++)
set_cpu_possible(i, false); set_cpu_possible(i, false);
nr_cpu_ids = possible; set_nr_cpu_ids(possible);
} }
#endif #endif
......
...@@ -750,7 +750,7 @@ static void __init prefill_possible_map(void) ...@@ -750,7 +750,7 @@ static void __init prefill_possible_map(void)
for (; i < NR_CPUS; i++) for (; i < NR_CPUS; i++)
set_cpu_possible(i, false); set_cpu_possible(i, false);
nr_cpu_ids = possible; set_nr_cpu_ids(possible);
} }
#else #else
static inline void prefill_possible_map(void) {} static inline void prefill_possible_map(void) {}
......
...@@ -1316,7 +1316,7 @@ static void __init smp_sanity_check(void) ...@@ -1316,7 +1316,7 @@ static void __init smp_sanity_check(void)
nr++; nr++;
} }
nr_cpu_ids = 8; set_nr_cpu_ids(8);
} }
#endif #endif
...@@ -1569,7 +1569,7 @@ __init void prefill_possible_map(void) ...@@ -1569,7 +1569,7 @@ __init void prefill_possible_map(void)
possible = i; possible = i;
} }
nr_cpu_ids = possible; set_nr_cpu_ids(possible);
pr_info("Allowing %d CPUs, %d hotplug CPUs\n", pr_info("Allowing %d CPUs, %d hotplug CPUs\n",
possible, max_t(int, possible - num_processors, 0)); possible, max_t(int, possible - num_processors, 0));
......
...@@ -179,7 +179,7 @@ static void __init _get_smp_config(unsigned int early) ...@@ -179,7 +179,7 @@ static void __init _get_smp_config(unsigned int early)
* hypercall to expand the max number of VCPUs an already * hypercall to expand the max number of VCPUs an already
* running guest has. So cap it up to X. */ * running guest has. So cap it up to X. */
if (subtract) if (subtract)
nr_cpu_ids = nr_cpu_ids - subtract; set_nr_cpu_ids(nr_cpu_ids - subtract);
#endif #endif
} }
......
...@@ -39,6 +39,11 @@ typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t; ...@@ -39,6 +39,11 @@ typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
#define nr_cpu_ids 1U #define nr_cpu_ids 1U
#else #else
extern unsigned int nr_cpu_ids; extern unsigned int nr_cpu_ids;
static inline void set_nr_cpu_ids(unsigned int nr)
{
nr_cpu_ids = nr;
}
#endif #endif
#ifdef CONFIG_CPUMASK_OFFSTACK #ifdef CONFIG_CPUMASK_OFFSTACK
......
...@@ -1070,7 +1070,7 @@ static int __init nrcpus(char *str) ...@@ -1070,7 +1070,7 @@ static int __init nrcpus(char *str)
int nr_cpus; int nr_cpus;
if (get_option(&str, &nr_cpus) && nr_cpus > 0 && nr_cpus < nr_cpu_ids) if (get_option(&str, &nr_cpus) && nr_cpus > 0 && nr_cpus < nr_cpu_ids)
nr_cpu_ids = nr_cpus; set_nr_cpu_ids(nr_cpus);
return 0; return 0;
} }
...@@ -1097,7 +1097,7 @@ EXPORT_SYMBOL(nr_cpu_ids); ...@@ -1097,7 +1097,7 @@ EXPORT_SYMBOL(nr_cpu_ids);
/* An arch may set nr_cpu_ids earlier if needed, so this would be redundant */ /* An arch may set nr_cpu_ids earlier if needed, so this would be redundant */
void __init setup_nr_cpu_ids(void) void __init setup_nr_cpu_ids(void)
{ {
nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1; set_nr_cpu_ids(find_last_bit(cpumask_bits(cpu_possible_mask), NR_CPUS) + 1);
} }
/* Called by boot processor to activate the rest. */ /* Called by boot processor to activate the rest. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment