summaryrefslogtreecommitdiff
path: root/lib/cpumask.c
blob: 7a2a73f88d594dc73282c24e3d0304a602a10a25 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#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);

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);

#if MAX_NUMNODES > 1
/*
 * Find the highest possible node id.
 */
int highest_possible_node_id(void)
{
	unsigned int node;
	unsigned int highest = 0;

	for_each_node_mask(node, node_possible_map)
		highest = node;
	return highest;
}
EXPORT_SYMBOL(highest_possible_node_id);
#endif