aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2016-04-13 08:49:12 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2016-05-10 07:24:48 -0400
commit281eaa8cb67c27e56da1e7fd6b55c6cd3e8c4638 (patch)
tree45225e66680c3cc00e419757641852fa8867c6aa
parent0c756914920fc13061222d12fbbe85990df64928 (diff)
s390/cpuinfo: simplify locking and skip offline cpus early
Move the get_online_cpus() and put_online_cpus() to the start and stop operation of the seqfile ops. This way there is no need to lock cpu hotplug again and again for each single cpu. This way we can also skip offline cpus early if we simply use cpumask_next() within the next operation. 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/processor.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
index 647128d5b983..90a418d5c280 100644
--- a/arch/s390/kernel/processor.c
+++ b/arch/s390/kernel/processor.c
@@ -84,7 +84,6 @@ static int show_cpuinfo(struct seq_file *m, void *v)
84 seq_puts(m, "\n"); 84 seq_puts(m, "\n");
85 show_cacheinfo(m); 85 show_cacheinfo(m);
86 } 86 }
87 get_online_cpus();
88 if (cpu_online(n)) { 87 if (cpu_online(n)) {
89 struct cpuid *id = &per_cpu(cpu_id, n); 88 struct cpuid *id = &per_cpu(cpu_id, n);
90 seq_printf(m, "processor %li: " 89 seq_printf(m, "processor %li: "
@@ -93,23 +92,31 @@ static int show_cpuinfo(struct seq_file *m, void *v)
93 "machine = %04X\n", 92 "machine = %04X\n",
94 n, id->version, id->ident, id->machine); 93 n, id->version, id->ident, id->machine);
95 } 94 }
96 put_online_cpus();
97 return 0; 95 return 0;
98} 96}
99 97
98static inline void *c_update(loff_t *pos)
99{
100 if (*pos)
101 *pos = cpumask_next(*pos - 1, cpu_online_mask);
102 return *pos < nr_cpu_ids ? (void *)*pos + 1 : NULL;
103}
104
100static void *c_start(struct seq_file *m, loff_t *pos) 105static void *c_start(struct seq_file *m, loff_t *pos)
101{ 106{
102 return *pos < nr_cpu_ids ? (void *)((unsigned long) *pos + 1) : NULL; 107 get_online_cpus();
108 return c_update(pos);
103} 109}
104 110
105static void *c_next(struct seq_file *m, void *v, loff_t *pos) 111static void *c_next(struct seq_file *m, void *v, loff_t *pos)
106{ 112{
107 ++*pos; 113 ++*pos;
108 return c_start(m, pos); 114 return c_update(pos);
109} 115}
110 116
111static void c_stop(struct seq_file *m, void *v) 117static void c_stop(struct seq_file *m, void *v)
112{ 118{
119 put_online_cpus();
113} 120}
114 121
115const struct seq_operations cpuinfo_op = { 122const struct seq_operations cpuinfo_op = {