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