Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: Rework /proc/interrupts

On a large machine I noticed the columns of /proc/interrupts failed to line up
with the header after CPU9. At sufficiently large numbers of CPUs it becomes
impossible to line up the CPU number with the counts.

While fixing this I noticed x86 has a number of updates that we may as well
pull in. On PowerPC we currently omit an interrupt completely if there is no
active handler, whereas on x86 it is printed if there is a non zero count.

The x86 code also spaces the first column correctly based on nr_irqs.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Anton Blanchard and committed by
Benjamin Herrenschmidt
c86845ed fda9d861

+48 -35
+48 -35
arch/powerpc/kernel/irq.c
··· 183 183 EXPORT_SYMBOL(raw_local_irq_restore); 184 184 #endif /* CONFIG_PPC64 */ 185 185 186 + static int show_other_interrupts(struct seq_file *p, int prec) 187 + { 188 + int j; 189 + 190 + #if defined(CONFIG_PPC32) && defined(CONFIG_TAU_INT) 191 + if (tau_initialized) { 192 + seq_printf(p, "%*s: ", prec, "TAU"); 193 + for_each_online_cpu(j) 194 + seq_printf(p, "%10u ", tau_interrupts(j)); 195 + seq_puts(p, " PowerPC Thermal Assist (cpu temp)\n"); 196 + } 197 + #endif /* CONFIG_PPC32 && CONFIG_TAU_INT */ 198 + 199 + seq_printf(p, "%*s: %10u\n", prec, "BAD", ppc_spurious_interrupts); 200 + 201 + return 0; 202 + } 203 + 186 204 int show_interrupts(struct seq_file *p, void *v) 187 205 { 188 - int i = *(loff_t *)v, j; 206 + unsigned long flags, any_count = 0; 207 + int i = *(loff_t *) v, j, prec; 189 208 struct irqaction *action; 190 209 struct irq_desc *desc; 191 - unsigned long flags; 192 210 193 - if (i == 0) { 194 - seq_puts(p, " "); 195 - for_each_online_cpu(j) 196 - seq_printf(p, "CPU%d ", j); 197 - seq_putc(p, '\n'); 198 - } else if (i == nr_irqs) { 199 - #if defined(CONFIG_PPC32) && defined(CONFIG_TAU_INT) 200 - if (tau_initialized){ 201 - seq_puts(p, "TAU: "); 202 - for_each_online_cpu(j) 203 - seq_printf(p, "%10u ", tau_interrupts(j)); 204 - seq_puts(p, " PowerPC Thermal Assist (cpu temp)\n"); 205 - } 206 - #endif /* CONFIG_PPC32 && CONFIG_TAU_INT*/ 207 - seq_printf(p, "BAD: %10u\n", ppc_spurious_interrupts); 208 - 211 + if (i > nr_irqs) 209 212 return 0; 213 + 214 + for (prec = 3, j = 1000; prec < 10 && j <= nr_irqs; ++prec) 215 + j *= 10; 216 + 217 + if (i == nr_irqs) 218 + return show_other_interrupts(p, prec); 219 + 220 + /* print header */ 221 + if (i == 0) { 222 + seq_printf(p, "%*s", prec + 8, ""); 223 + for_each_online_cpu(j) 224 + seq_printf(p, "CPU%-8d", j); 225 + seq_putc(p, '\n'); 210 226 } 211 227 212 228 desc = irq_to_desc(i); ··· 230 214 return 0; 231 215 232 216 raw_spin_lock_irqsave(&desc->lock, flags); 233 - 217 + for_each_online_cpu(j) 218 + any_count |= kstat_irqs_cpu(i, j); 234 219 action = desc->action; 235 - if (!action || !action->handler) 236 - goto skip; 220 + if (!action && !any_count) 221 + goto out; 237 222 238 - seq_printf(p, "%3d: ", i); 239 - #ifdef CONFIG_SMP 223 + seq_printf(p, "%*d: ", prec, i); 240 224 for_each_online_cpu(j) 241 225 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j)); 242 - #else 243 - seq_printf(p, "%10u ", kstat_irqs(i)); 244 - #endif /* CONFIG_SMP */ 245 226 246 227 if (desc->chip) 247 - seq_printf(p, " %s ", desc->chip->name); 228 + seq_printf(p, " %-16s", desc->chip->name); 248 229 else 249 - seq_puts(p, " None "); 230 + seq_printf(p, " %-16s", "None"); 231 + seq_printf(p, " %-8s", (desc->status & IRQ_LEVEL) ? "Level" : "Edge"); 250 232 251 - seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge "); 252 - seq_printf(p, " %s", action->name); 233 + if (action) { 234 + seq_printf(p, " %s", action->name); 235 + while ((action = action->next) != NULL) 236 + seq_printf(p, ", %s", action->name); 237 + } 253 238 254 - for (action = action->next; action; action = action->next) 255 - seq_printf(p, ", %s", action->name); 256 239 seq_putc(p, '\n'); 257 - 258 - skip: 240 + out: 259 241 raw_spin_unlock_irqrestore(&desc->lock, flags); 260 - 261 242 return 0; 262 243 } 263 244