aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/affinity.c
diff options
context:
space:
mode:
Diffstat (limited to 'litmus/affinity.c')
-rw-r--r--litmus/affinity.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/litmus/affinity.c b/litmus/affinity.c
new file mode 100644
index 000000000000..9adab7a3bcd7
--- /dev/null
+++ b/litmus/affinity.c
@@ -0,0 +1,44 @@
1#include <linux/cpu.h>
2
3#include <litmus/affinity.h>
4
5struct neighborhood neigh_info[NR_CPUS];
6
7/* called by _init_litmus() */
8void init_topology(void) {
9 int cpu;
10 int i;
11 int chk;
12 int depth = num_cache_leaves;
13
14 if (depth > NUM_CACHE_LEVELS)
15 depth = NUM_CACHE_LEVELS;
16
17 for_each_online_cpu(cpu) {
18 for (i = 0; i < depth; ++i) {
19 long unsigned int firstbits;
20
21 chk = get_shared_cpu_map((struct cpumask *)&neigh_info[cpu].neighbors[i], cpu, i);
22 if (chk) {
23 /* failed */
24 neigh_info[cpu].size[i] = 0;
25 } else {
26 /* size = num bits in mask */
27 neigh_info[cpu].size[i] =
28 cpumask_weight((struct cpumask *)&neigh_info[cpu].neighbors[i]);
29 }
30 firstbits = *neigh_info[cpu].neighbors[i]->bits;
31 printk("CPU %d has %d neighbors at level %d. (mask = %lx)\n",
32 cpu, neigh_info[cpu].size[i], i, firstbits);
33 }
34
35 /* set data for non-existent levels */
36 for (; i < NUM_CACHE_LEVELS; ++i) {
37 neigh_info[cpu].size[i] = 0;
38
39 printk("CPU %d has %d neighbors at level %d. (mask = %lx)\n",
40 cpu, neigh_info[cpu].size[i], i, 0lu);
41 }
42 }
43}
44