Skip to content

Commit e6169c4

Browse files
committed
csky: Add arch_show_interrupts for IPI interrupts
Here is the result: cat /proc/interrupts CPU0 CPU1 CPU2 CPU3 15: 1348 1299 952 1076 C-SKY SMP Intc 15 IPI Interrupt 16: 1203 1825 1598 1307 C-SKY SMP Intc 16 csky_mp_timer 43: 292 0 0 0 C-SKY SMP Intc 43 ttyS0 57: 106 0 0 0 C-SKY SMP Intc 57 virtio0 IPI0: 0 0 0 0 Empty interrupts IPI1: 19 41 45 27 Rescheduling interrupts IPI2: 1330 1259 908 1050 Function call interrupts IPI3: 0 0 0 0 Irq work interrupts Signed-off-by: Guo Ren <guoren@linux.alibaba.com> Cc: Arnd Bergmann <arnd@arndb.de>
1 parent 2c81b07 commit e6169c4

1 file changed

Lines changed: 41 additions & 8 deletions

File tree

arch/csky/kernel/smp.c

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/irq_work.h>
1616
#include <linux/irqdomain.h>
1717
#include <linux/of.h>
18+
#include <linux/seq_file.h>
1819
#include <linux/sched/task_stack.h>
1920
#include <linux/sched/mm.h>
2021
#include <linux/sched/hotplug.h>
@@ -27,11 +28,6 @@
2728
#include <abi/fpu.h>
2829
#endif
2930

30-
struct ipi_data_struct {
31-
unsigned long bits ____cacheline_aligned;
32-
};
33-
static DEFINE_PER_CPU(struct ipi_data_struct, ipi_data);
34-
3531
enum ipi_message_type {
3632
IPI_EMPTY,
3733
IPI_RESCHEDULE,
@@ -40,23 +36,37 @@ enum ipi_message_type {
4036
IPI_MAX
4137
};
4238

39+
struct ipi_data_struct {
40+
unsigned long bits ____cacheline_aligned;
41+
unsigned long stats[IPI_MAX] ____cacheline_aligned;
42+
};
43+
static DEFINE_PER_CPU(struct ipi_data_struct, ipi_data);
44+
4345
static irqreturn_t handle_ipi(int irq, void *dev)
4446
{
47+
unsigned long *stats = this_cpu_ptr(&ipi_data)->stats;
48+
4549
while (true) {
4650
unsigned long ops;
4751

4852
ops = xchg(&this_cpu_ptr(&ipi_data)->bits, 0);
4953
if (ops == 0)
5054
return IRQ_HANDLED;
5155

52-
if (ops & (1 << IPI_RESCHEDULE))
56+
if (ops & (1 << IPI_RESCHEDULE)) {
57+
stats[IPI_RESCHEDULE]++;
5358
scheduler_ipi();
59+
}
5460

55-
if (ops & (1 << IPI_CALL_FUNC))
61+
if (ops & (1 << IPI_CALL_FUNC)) {
62+
stats[IPI_CALL_FUNC]++;
5663
generic_smp_call_function_interrupt();
64+
}
5765

58-
if (ops & (1 << IPI_IRQ_WORK))
66+
if (ops & (1 << IPI_IRQ_WORK)) {
67+
stats[IPI_IRQ_WORK]++;
5968
irq_work_run();
69+
}
6070

6171
BUG_ON((ops >> IPI_MAX) != 0);
6272
}
@@ -88,6 +98,29 @@ send_ipi_message(const struct cpumask *to_whom, enum ipi_message_type operation)
8898
send_arch_ipi(to_whom);
8999
}
90100

101+
static const char * const ipi_names[] = {
102+
[IPI_EMPTY] = "Empty interrupts",
103+
[IPI_RESCHEDULE] = "Rescheduling interrupts",
104+
[IPI_CALL_FUNC] = "Function call interrupts",
105+
[IPI_IRQ_WORK] = "Irq work interrupts",
106+
};
107+
108+
int arch_show_interrupts(struct seq_file *p, int prec)
109+
{
110+
unsigned int cpu, i;
111+
112+
for (i = 0; i < IPI_MAX; i++) {
113+
seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i,
114+
prec >= 4 ? " " : "");
115+
for_each_online_cpu(cpu)
116+
seq_printf(p, "%10lu ",
117+
per_cpu_ptr(&ipi_data, cpu)->stats[i]);
118+
seq_printf(p, " %s\n", ipi_names[i]);
119+
}
120+
121+
return 0;
122+
}
123+
91124
void arch_send_call_function_ipi_mask(struct cpumask *mask)
92125
{
93126
send_ipi_message(mask, IPI_CALL_FUNC);

0 commit comments

Comments
 (0)