Skip to content

Commit 45cce4c

Browse files
heicarstMartin Schwidefsky
authored andcommitted
s390/cacheinfo: don't use smp_processor_id() in preemptible context
show_cacheinfo() needs to access the cacheinfo structure of any online cpu. This was done with using smp_processor_id() as in index while in preemtible context. This means the cpu could be offline and the data be gone when it would be accessed. Better use any online cpu address and protect the data by get_online_cpus() and put_online_cpus(). Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent ea96f78 commit 45cce4c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎arch/s390/kernel/cache.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ static const enum cache_type cache_type_map[] = {
6666

6767
void show_cacheinfo(struct seq_file *m)
6868
{
69-
int cpu = smp_processor_id(), idx;
70-
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
69+
struct cpu_cacheinfo *this_cpu_ci;
7170
struct cacheinfo *cache;
71+
int idx;
7272

73+
get_online_cpus();
74+
this_cpu_ci = get_cpu_cacheinfo(cpumask_any(cpu_online_mask));
7375
for (idx = 0; idx < this_cpu_ci->num_leaves; idx++) {
7476
cache = this_cpu_ci->info_list + idx;
7577
seq_printf(m, "cache%-11d: ", idx);
@@ -82,6 +84,7 @@ void show_cacheinfo(struct seq_file *m)
8284
seq_printf(m, "associativity=%d", cache->ways_of_associativity);
8385
seq_puts(m, "\n");
8486
}
87+
put_online_cpus();
8588
}
8689

8790
static inline enum cache_type get_cache_type(struct cache_info *ci, int level)

0 commit comments

Comments
 (0)