Skip to content

Commit

Permalink
genirq: Update irq stats from NMI handlers
Browse files Browse the repository at this point in the history
[ Upstream commit c09cb12 ]

The NMI handlers handle_percpu_devid_fasteoi_nmi() and handle_fasteoi_nmi()
do not update the interrupt counts. Due to that the NMI interrupt count
does not show up correctly in /proc/interrupts.

Add the statistics and treat the NMI handlers in the same way as per cpu
interrupts and prevent them from updating irq_desc::tot_count as this might
be corrupted due to concurrency.

[ tglx: Massaged changelog ]

Fixes: 2dcf1fb ("genirq: Provide NMI handlers")
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/1562313336-11888-1-git-send-email-sthotton@marvell.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Shijith Thotton authored and gregkh committed Jul 26, 2019
1 parent 0eb7999 commit f260fc0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions kernel/irq/chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ void handle_fasteoi_nmi(struct irq_desc *desc)
unsigned int irq = irq_desc_get_irq(desc);
irqreturn_t res;

__kstat_incr_irqs_this_cpu(desc);

trace_irq_handler_entry(irq, action);
/*
* NMIs cannot be shared, there is only one action.
Expand Down Expand Up @@ -968,6 +970,8 @@ void handle_percpu_devid_fasteoi_nmi(struct irq_desc *desc)
unsigned int irq = irq_desc_get_irq(desc);
irqreturn_t res;

__kstat_incr_irqs_this_cpu(desc);

trace_irq_handler_entry(irq, action);
res = action->handler(irq, raw_cpu_ptr(action->percpu_dev_id));
trace_irq_handler_exit(irq, action, res);
Expand Down
8 changes: 7 additions & 1 deletion kernel/irq/irqdesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,11 @@ unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
*per_cpu_ptr(desc->kstat_irqs, cpu) : 0;
}

static bool irq_is_nmi(struct irq_desc *desc)
{
return desc->istate & IRQS_NMI;
}

/**
* kstat_irqs - Get the statistics for an interrupt
* @irq: The interrupt number
Expand All @@ -962,7 +967,8 @@ unsigned int kstat_irqs(unsigned int irq)
if (!desc || !desc->kstat_irqs)
return 0;
if (!irq_settings_is_per_cpu_devid(desc) &&
!irq_settings_is_per_cpu(desc))
!irq_settings_is_per_cpu(desc) &&
!irq_is_nmi(desc))
return desc->tot_count;

for_each_possible_cpu(cpu)
Expand Down

0 comments on commit f260fc0

Please sign in to comment.