diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-19 17:31:52 -0400 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-19 17:31:52 -0400 |
commit | f70a290e8a889caa905ab7650c696f2bb299be1a (patch) | |
tree | 56f0886d839499e9f522f189999024b3e86f9be2 /litmus/affinity.c | |
parent | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (diff) | |
parent | 7ef4a793a624c6e66c16ca1051847f75161f5bec (diff) |
Merge branch 'wip-nested-locking' into tegra-nested-lockingwip-nested-locking
Conflicts:
Makefile
include/linux/fs.h
Diffstat (limited to 'litmus/affinity.c')
-rw-r--r-- | litmus/affinity.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/litmus/affinity.c b/litmus/affinity.c new file mode 100644 index 00000000000..3fa6dd78940 --- /dev/null +++ b/litmus/affinity.c | |||
@@ -0,0 +1,42 @@ | |||
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 | 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 | chk = get_shared_cpu_map((struct cpumask *)&neigh_info[cpu].neighbors[i], cpu, i); | ||
20 | if (chk) { | ||
21 | /* failed */ | ||
22 | neigh_info[cpu].size[i] = 0; | ||
23 | } else { | ||
24 | /* size = num bits in mask */ | ||
25 | neigh_info[cpu].size[i] = | ||
26 | cpumask_weight((struct cpumask *)&neigh_info[cpu].neighbors[i]); | ||
27 | } | ||
28 | printk("CPU %d has %d neighbors at level %d. (mask = %lx)\n", | ||
29 | cpu, neigh_info[cpu].size[i], i, | ||
30 | *cpumask_bits(neigh_info[cpu].neighbors[i])); | ||
31 | } | ||
32 | |||
33 | /* set data for non-existent levels */ | ||
34 | for (; i < NUM_CACHE_LEVELS; ++i) { | ||
35 | neigh_info[cpu].size[i] = 0; | ||
36 | |||
37 | printk("CPU %d has %d neighbors at level %d. (mask = %lx)\n", | ||
38 | cpu, neigh_info[cpu].size[i], i, 0lu); | ||
39 | } | ||
40 | } | ||
41 | } | ||
42 | |||