[PATCH] genirq: Increment irq count for second edge irq when
From: Ning Jiang
Date: Sun Jun 03 2012 - 21:54:08 EST
kstat_incr_irqs_this_cpu() records the real number of interruptions
to a certain CPU, regardless of the current irq state. That includes
interrupts which are delivered in a state where the device handler
cannot be called.
For level irq, if its disabled or no action available, we'll skip
irq handling. When it is enabled later, the irq will be retriggered
and kstat_incr_irqs_this_cpu() will be incremented again. This counts
the number of interrupts arrived at the CPU and therefor it counts
TWO in this situation. The CPU is interrupted twice, not once. The
accounting works correctly as expected.
But for edge irq, we have a subtle problem. Suppose a second irq
happens when the first is still in progress, it will mark itself
pending and quit, then it will be handled in the same loop after
the first one has been handled. Thus kstat_incr_irqs_this_cpu()
will only be counted once for two irqs.
Add a check in edge handler if there is a irq already in progress,
we'll first kstat_incr_irqs_this_cpu() before we mask and quit, so
that we can get correct irq count in this case.
[ Thanks Thomas for his excellent comments ]
Signed-off-by: Ning Jiang <ning.n.jiang@xxxxxxxxx>
---
kernel/irq/chip.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index eebd6d5..254b8aa 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -489,6 +489,8 @@ handle_edge_irq(unsigned int irq, struct irq_desc *desc)
if (unlikely(irqd_irq_disabled(&desc->irq_data) ||
irqd_irq_inprogress(&desc->irq_data) || !desc->action)) {
if (!irq_check_poll(desc)) {
+ if (irqd_irq_inprogress(&desc->irq_data))
+ kstat_incr_irqs_this_cpu(irq, desc);
desc->istate |= IRQS_PENDING;
mask_ack_irq(desc);
goto out_unlock;
@@ -550,6 +552,8 @@ void handle_edge_eoi_irq(unsigned int irq, struct
irq_desc *desc)
if (unlikely(irqd_irq_disabled(&desc->irq_data) ||
irqd_irq_inprogress(&desc->irq_data) || !desc->action)) {
if (!irq_check_poll(desc)) {
+ if (irqd_irq_inprogress(&desc->irq_data))
+ kstat_incr_irqs_this_cpu(irq, desc);
desc->istate |= IRQS_PENDING;
goto out_eoi;
}
--
1.7.1
--e89a8f22c72b893b3804c19ea5e6
Content-Type: application/octet-stream;
name="0001-genirq-Increment-irq-count-for-second-edge-irq-when-.patch"
Content-Disposition: attachment;
filename="0001-genirq-Increment-irq-count-for-second-edge-irq-when-.patch"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_h313315n0
RnJvbSA5Mzk2MGM2OWU1ODg5ODkzNDY1ODlmYWM3OGIzMTFhYzYyZmI3NTUyIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBOaW5nIEppYW5nIDxuaW5nLm4uamlhbmdAZ21haWwuY29tPgpE
YXRlOiBNb24sIDQgSnVuIDIwMTIgMDk6NTQ6MDggKzA4MDAKU3ViamVjdDogW1BBVENIXSBnZW5p
cnE6IEluY3JlbWVudCBpcnEgY291bnQgZm9yIHNlY29uZCBlZGdlIGlycSB3aGVuIHRoZSBmaXJz
dCBpcyBpbiBwcm9ncmVzcwoKa3N0YXRfaW5jcl9pcnFzX3RoaXNfY3B1KCkgcmVjb3JkcyB0aGUg
cmVhbCBudW1iZXIgb2YgaW50ZXJydXB0aW9ucwp0byBhIGNlcnRhaW4gQ1BVLCByZWdhcmRsZXNz
IG9mIHRoZSBjdXJyZW50IGlycSBzdGF0ZS4gVGhhdCBpbmNsdWRlcwppbnRlcnJ1cHRzIHdoaWNo
IGFyZSBkZWxpdmVyZWQgaW4gYSBzdGF0ZSB3aGVyZSB0aGUgZGV2aWNlIGhhbmRsZXIKY2Fubm90
IGJlIGNhbGxlZC4KCkZvciBsZXZlbCBpcnEsIGlmIGl0cyBkaXNhYmxlZCBvciBubyBhY3Rpb24g
YXZhaWxhYmxlLCB3ZSdsbCBza2lwCmlycSBoYW5kbGluZy4gV2hlbiBpdCBpcyBlbmFibGVkIGxh
dGVyLCB0aGUgaXJxIHdpbGwgYmUgcmV0cmlnZ2VyZWQKYW5kIGtzdGF0X2luY3JfaXJxc190aGlz
X2NwdSgpIHdpbGwgYm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3Jlc3MoJmRlc2MtPmlycV9kYXRhKSB8
fCAhZGVzYy0+YWN0aW9uKSkgewogCQlpZiAoIWlycV9jaGVja19wb2xsKGRlc2MpKSB7CisJCQlp
ZiAoaXJxZF9pcnFfaW5wcm9ncmVzcygmZGVzYy0+aXJxX2RhdGEpKQorCQkJCWtzdGF0X2luY3Jf
aXJxc190aGlzX2NwdShpcnEsIGRlc2MpOwogCQkJZGVzYy0+aXN0YXRlIHw9IElSUVNfUEVORElO
RzsKIAkJCWdvdG8gb3V0X2VvaTsKIAkJfQotLSAKMS43LjEKCg==
--e89a8f22c72b893b3804c19ea5e6--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/