diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2015-02-09 06:54:16 -0500 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2015-02-10 04:15:57 -0500 |
commit | 45cce4ccafe3cddc924ef5221d22b9853fc9a13c (patch) | |
tree | 3afaaeec8ecc47be92aa209b715c84522ff9c1f5 | |
parent | ea96f78813823ab186e7e52122c06fb9c3cf6e20 (diff) |
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>
-rw-r--r-- | arch/s390/kernel/cache.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/s390/kernel/cache.c b/arch/s390/kernel/cache.c index fe21f074cf9f..632fa06ea162 100644 --- a/arch/s390/kernel/cache.c +++ b/arch/s390/kernel/cache.c | |||
@@ -66,10 +66,12 @@ static const enum cache_type cache_type_map[] = { | |||
66 | 66 | ||
67 | void show_cacheinfo(struct seq_file *m) | 67 | void show_cacheinfo(struct seq_file *m) |
68 | { | 68 | { |
69 | int cpu = smp_processor_id(), idx; | 69 | struct cpu_cacheinfo *this_cpu_ci; |
70 | struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); | ||
71 | struct cacheinfo *cache; | 70 | struct cacheinfo *cache; |
71 | int idx; | ||
72 | 72 | ||
73 | get_online_cpus(); | ||
74 | this_cpu_ci = get_cpu_cacheinfo(cpumask_any(cpu_online_mask)); | ||
73 | for (idx = 0; idx < this_cpu_ci->num_leaves; idx++) { | 75 | for (idx = 0; idx < this_cpu_ci->num_leaves; idx++) { |
74 | cache = this_cpu_ci->info_list + idx; | 76 | cache = this_cpu_ci->info_list + idx; |
75 | seq_printf(m, "cache%-11d: ", idx); | 77 | seq_printf(m, "cache%-11d: ", idx); |
@@ -82,6 +84,7 @@ void show_cacheinfo(struct seq_file *m) | |||
82 | seq_printf(m, "associativity=%d", cache->ways_of_associativity); | 84 | seq_printf(m, "associativity=%d", cache->ways_of_associativity); |
83 | seq_puts(m, "\n"); | 85 | seq_puts(m, "\n"); |
84 | } | 86 | } |
87 | put_online_cpus(); | ||
85 | } | 88 | } |
86 | 89 | ||
87 | static inline enum cache_type get_cache_type(struct cache_info *ci, int level) | 90 | static inline enum cache_type get_cache_type(struct cache_info *ci, int level) |