mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-21 08:53:41 +00:00
476f35348e
The nr_cpu_ids value is currently only calculated in smp_init. However, it may be needed before (SLUB needs it on kmem_cache_init!) and other kernel components may also want to allocate dynamically sized per cpu array before smp_init. So move the determination of possible cpus into sched_init() where we already loop over all possible cpus early in boot. Also initialize both nr_node_ids and nr_cpu_ids with the highest value they could take. If we have accidental users before these values are determined then the current valud of 0 may cause too small per cpu and per node arrays to be allocated. If it is set to the maximum possible then we only waste some memory for early boot users. Signed-off-by: Christoph Lameter <clameter@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
29 lines
565 B
C
29 lines
565 B
C
#include <linux/kernel.h>
|
|
#include <linux/bitops.h>
|
|
#include <linux/cpumask.h>
|
|
#include <linux/module.h>
|
|
|
|
int __first_cpu(const cpumask_t *srcp)
|
|
{
|
|
return min_t(int, NR_CPUS, find_first_bit(srcp->bits, NR_CPUS));
|
|
}
|
|
EXPORT_SYMBOL(__first_cpu);
|
|
|
|
int __next_cpu(int n, const cpumask_t *srcp)
|
|
{
|
|
return min_t(int, NR_CPUS, find_next_bit(srcp->bits, NR_CPUS, n+1));
|
|
}
|
|
EXPORT_SYMBOL(__next_cpu);
|
|
|
|
int __any_online_cpu(const cpumask_t *mask)
|
|
{
|
|
int cpu;
|
|
|
|
for_each_cpu_mask(cpu, *mask) {
|
|
if (cpu_online(cpu))
|
|
break;
|
|
}
|
|
return cpu;
|
|
}
|
|
EXPORT_SYMBOL(__any_online_cpu);
|