mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
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>
This commit is contained in:
parent
ea96f78813
commit
45cce4ccaf
1 changed files with 5 additions and 2 deletions
|
@ -66,10 +66,12 @@ static const enum cache_type cache_type_map[] = {
|
||||||
|
|
||||||
void show_cacheinfo(struct seq_file *m)
|
void show_cacheinfo(struct seq_file *m)
|
||||||
{
|
{
|
||||||
int cpu = smp_processor_id(), idx;
|
struct cpu_cacheinfo *this_cpu_ci;
|
||||||
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
|
|
||||||
struct cacheinfo *cache;
|
struct cacheinfo *cache;
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
get_online_cpus();
|
||||||
|
this_cpu_ci = get_cpu_cacheinfo(cpumask_any(cpu_online_mask));
|
||||||
for (idx = 0; idx < this_cpu_ci->num_leaves; idx++) {
|
for (idx = 0; idx < this_cpu_ci->num_leaves; idx++) {
|
||||||
cache = this_cpu_ci->info_list + idx;
|
cache = this_cpu_ci->info_list + idx;
|
||||||
seq_printf(m, "cache%-11d: ", idx);
|
seq_printf(m, "cache%-11d: ", idx);
|
||||||
|
@ -82,6 +84,7 @@ void show_cacheinfo(struct seq_file *m)
|
||||||
seq_printf(m, "associativity=%d", cache->ways_of_associativity);
|
seq_printf(m, "associativity=%d", cache->ways_of_associativity);
|
||||||
seq_puts(m, "\n");
|
seq_puts(m, "\n");
|
||||||
}
|
}
|
||||||
|
put_online_cpus();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline enum cache_type get_cache_type(struct cache_info *ci, int level)
|
static inline enum cache_type get_cache_type(struct cache_info *ci, int level)
|
||||||
|
|
Loading…
Reference in a new issue