Skip to content

Commit 3b1313e

Browse files
Vladimir Kondratievpaulburton
authored andcommitted
mips: cacheinfo: report shared CPU map
Report L1 caches as shared per core; L2 - per cluster. This fixes "perf" that went crazy if shared_cpu_map attribute not reported on sysfs, in form of /sys/devices/system/cpu/cpu*/cache/index*/shared_cpu_list /sys/devices/system/cpu/cpu*/cache/index*/shared_cpu_map Signed-off-by: Vladimir Kondratiev <[email protected]> Signed-off-by: Paul Burton <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: James Hogan <[email protected]> Cc: [email protected] Cc: [email protected]
1 parent a8d0f11 commit 3b1313e

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

arch/mips/kernel/cacheinfo.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,46 @@ static int __init_cache_level(unsigned int cpu)
5050
return 0;
5151
}
5252

53+
static void fill_cpumask_siblings(int cpu, cpumask_t *cpu_map)
54+
{
55+
int cpu1;
56+
57+
for_each_possible_cpu(cpu1)
58+
if (cpus_are_siblings(cpu, cpu1))
59+
cpumask_set_cpu(cpu1, cpu_map);
60+
}
61+
62+
static void fill_cpumask_cluster(int cpu, cpumask_t *cpu_map)
63+
{
64+
int cpu1;
65+
int cluster = cpu_cluster(&cpu_data[cpu]);
66+
67+
for_each_possible_cpu(cpu1)
68+
if (cpu_cluster(&cpu_data[cpu1]) == cluster)
69+
cpumask_set_cpu(cpu1, cpu_map);
70+
}
71+
5372
static int __populate_cache_leaves(unsigned int cpu)
5473
{
5574
struct cpuinfo_mips *c = &current_cpu_data;
5675
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
5776
struct cacheinfo *this_leaf = this_cpu_ci->info_list;
5877

5978
if (c->icache.waysize) {
79+
/* L1 caches are per core */
80+
fill_cpumask_siblings(cpu, &this_leaf->shared_cpu_map);
6081
populate_cache(dcache, this_leaf, 1, CACHE_TYPE_DATA);
82+
fill_cpumask_siblings(cpu, &this_leaf->shared_cpu_map);
6183
populate_cache(icache, this_leaf, 1, CACHE_TYPE_INST);
6284
} else {
6385
populate_cache(dcache, this_leaf, 1, CACHE_TYPE_UNIFIED);
6486
}
6587

66-
if (c->scache.waysize)
88+
if (c->scache.waysize) {
89+
/* L2 cache is per cluster */
90+
fill_cpumask_cluster(cpu, &this_leaf->shared_cpu_map);
6791
populate_cache(scache, this_leaf, 2, CACHE_TYPE_UNIFIED);
92+
}
6893

6994
if (c->tcache.waysize)
7095
populate_cache(tcache, this_leaf, 3, CACHE_TYPE_UNIFIED);

0 commit comments

Comments
 (0)