Skip to content

Commit c86845e

Browse files
antonblanchardozbenh
authored andcommitted
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>
1 parent fda9d86 commit c86845e

1 file changed

Lines changed: 46 additions & 33 deletions

File tree

‎arch/powerpc/kernel/irq.c‎

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -183,65 +183,78 @@ notrace void raw_local_irq_restore(unsigned long en)
183183
EXPORT_SYMBOL(raw_local_irq_restore);
184184
#endif /* CONFIG_PPC64 */
185185

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+
186204
int show_interrupts(struct seq_file *p, void *v)
187205
{
188-
int i = *(loff_t *)v, j;
206+
unsigned long flags, any_count = 0;
207+
int i = *(loff_t *) v, j, prec;
189208
struct irqaction *action;
190209
struct irq_desc *desc;
191-
unsigned long flags;
192210

211+
if (i > nr_irqs)
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 */
193221
if (i == 0) {
194-
seq_puts(p, " ");
222+
seq_printf(p, "%*s", prec + 8, "");
195223
for_each_online_cpu(j)
196-
seq_printf(p, "CPU%d ", j);
224+
seq_printf(p, "CPU%-8d", j);
197225
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-
209-
return 0;
210226
}
211227

212228
desc = irq_to_desc(i);
213229
if (!desc)
214230
return 0;
215231

216232
raw_spin_lock_irqsave(&desc->lock, flags);
217-
233+
for_each_online_cpu(j)
234+
any_count |= kstat_irqs_cpu(i, j);
218235
action = desc->action;
219-
if (!action || !action->handler)
220-
goto skip;
236+
if (!action && !any_count)
237+
goto out;
221238

222-
seq_printf(p, "%3d: ", i);
223-
#ifdef CONFIG_SMP
239+
seq_printf(p, "%*d: ", prec, i);
224240
for_each_online_cpu(j)
225241
seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
226-
#else
227-
seq_printf(p, "%10u ", kstat_irqs(i));
228-
#endif /* CONFIG_SMP */
229242

230243
if (desc->chip)
231-
seq_printf(p, " %s ", desc->chip->name);
244+
seq_printf(p, " %-16s", desc->chip->name);
232245
else
233-
seq_puts(p, " None ");
246+
seq_printf(p, " %-16s", "None");
247+
seq_printf(p, " %-8s", (desc->status & IRQ_LEVEL) ? "Level" : "Edge");
234248

235-
seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge ");
236-
seq_printf(p, " %s", action->name);
249+
if (action) {
250+
seq_printf(p, " %s", action->name);
251+
while ((action = action->next) != NULL)
252+
seq_printf(p, ", %s", action->name);
253+
}
237254

238-
for (action = action->next; action; action = action->next)
239-
seq_printf(p, ", %s", action->name);
240255
seq_putc(p, '\n');
241-
242-
skip:
256+
out:
243257
raw_spin_unlock_irqrestore(&desc->lock, flags);
244-
245258
return 0;
246259
}
247260

0 commit comments

Comments
 (0)