summaryrefslogtreecommitdiffstats
path: root/lib/cpumask.c
blob: ea25a034276c047ce479f50c4c2b6de38a570397 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#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);

/*
 * Find the highest possible smp_processor_id()
 *
 * Note: if we're prepared to assume that cpu_possible_map never changes
 * (reasonable) then this function should cache its return value.
 */
int highest_possible_processor_id(void)
{
	unsigned int cpu;
	unsigned highest = 0;

	for_each_cpu_mask(cpu, cpu_possible_map)
		highest = cpu;
	return highest;
}
EXPORT_SYMBOL(highest_possible_processor_id);
OpenPOWER on IntegriCloud