Skip to contentSkip to conversation

genirq: introduce handle_fasteoi_edge_irq flow handler

RFC PATCH In review Yipeng Zou 2 participants 3 messages Mar 10, 2023 – Apr 15, 2023

Subsystems (3)
lore
Share & tools
lore

Yipeng Zou

author
#0 lore raw

RFC PATCH 1/1 genirq: introduce handle_fasteoi_edge_irq flow handler

Recently, We have a LPI migration issue on the ARM SMP platform.

For example, NIC device generates MSI and sends LPI to CPU0 via ITS, meanwhile irqbalance running on CPU1 set irq affinity of NIC to CPU1, the next interrupt will be sent to CPU2, due to the state of irq is still in progress, kernel does not end up performing irq handler on CPU2, which results in some userland service timeouts, the sequence of events is shown as follows:

NIC CPU0 CPU1

Generate IRQ#1 READ_IAR
Lock irq_desc
Set IRQD_IN_PROGRESS
Unlock irq_desc
Lock irq_desc Change LPI Affinity Unlock irq_desc
Call irq_handler
Generate IRQ#2
READ_IAR Lock irq_desc Check IRQD_IN_PROGRESS Unlock irq_desc Return from interrupt#2
Lock irq_desc
Clear IRQD_IN_PROGRESS
Unlock irq_desc
return from interrupt#1

For this scenario, The IRQ#2 will be lost. This does cause some exceptions.

For further information, see [1].

This patch introduced a new flow handler which combines fasteoi and edge type as a workaround.
An additional loop will be executed if the IRQS_PENDING has been setup.

[1]: https://lore.kernel.org/all/[email protected]/

Fixes cc2d3216f53c ("irqchip: GICv3: ITS command queue")
---
 drivers/irqchip/irq-gic-v3.c |  2 +-
 include/linux/irq.h          |  1 +
 kernel/irq/chip.c            | 62 ++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +1 -1
index fd134e1f481a..625ec64f0218 100644
@@ -1456,7 +1456,7 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int irq,
 		if (!gic_dist_supports_lpis())
 			return -EPERM;
 		irq_domain_set_info(d, irq, hw, chip, d->host_data,
-				    handle_fasteoi_irq, NULL, NULL);
+				    handle_fasteoi_edge_irq, NULL, NULL);
 		break;
 
 	default:
include/linux/irq.h +1 -0
index b1b28affb32a..adca5340edeb 100644
@@ -656,6 +656,7 @@ static inline int irq_set_parent(int irq, int parent_irq)
  */
 extern void handle_level_irq(struct irq_desc *desc);
 extern void handle_fasteoi_irq(struct irq_desc *desc);
+extern void handle_fasteoi_edge_irq(struct irq_desc *desc);
 extern void handle_edge_irq(struct irq_desc *desc);
 extern void handle_edge_eoi_irq(struct irq_desc *desc);
 extern void handle_simple_irq(struct irq_desc *desc);
kernel/irq/chip.c +62 -0

68 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 31 lines · Yipeng Zou

Recently, We have a LPI migration issue on the ARM SMP platform.

For example, NIC device generates MSI and sends LPI to CPU0 via ITS, meanwhile irqbalance running on CPU1 set irq affinity of NIC to CPU1, the next interrupt will be sent to CPU2, due to the state of irq is still in progress, kernel does not end up performing irq handler on CPU2, which results in some userland service timeouts, the sequence of events is shown as follows:

NIC CPU0 CPU1

Generate IRQ#1 READ_IAR
Lock irq_desc
Set IRQD_IN_PROGRESS
Unlock irq_desc
Lock irq_desc Change LPI Affinity Unlock irq_desc
Call irq_handler
Generate IRQ#2
READ_IAR Lock irq_desc Check IRQD_IN_PROGRESS Unlock irq_desc Return from interrupt#2
Lock irq_desc
Clear IRQD_IN_PROGRESS
Unlock irq_desc
return from interrupt#1

Quoted 1 line

For this scenario, The IRQ#2 will be lost. This does cause some exceptions.

Please see my reply to James at [1]. I'd appreciate if you could give that patch a go, which I expect to be a better avenue to fix what is effectively a GIC architecture defect.

Thanks,

	M.

[1] https://lore.kernel.org/all/[email protected]/

Signature · 1 line
Without deviation from the norm, progress is not possible.
author
#2 lore raw
Quoted 37 lines · Marc Zyngier
Quoted 30 lines · Yipeng Zou

Recently, We have a LPI migration issue on the ARM SMP platform.

For example, NIC device generates MSI and sends LPI to CPU0 via ITS, meanwhile irqbalance running on CPU1 set irq affinity of NIC to CPU1, the next interrupt will be sent to CPU2, due to the state of irq is still in progress, kernel does not end up performing irq handler on CPU2, which results in some userland service timeouts, the sequence of events is shown as follows:

NIC CPU0 CPU1

Generate IRQ#1 READ_IAR
Lock irq_desc
Set IRQD_IN_PROGRESS
Unlock irq_desc
Lock irq_desc Change LPI Affinity Unlock irq_desc
Call irq_handler
Generate IRQ#2
READ_IAR Lock irq_desc Check IRQD_IN_PROGRESS Unlock irq_desc Return from interrupt#2
Lock irq_desc
Clear IRQD_IN_PROGRESS
Unlock irq_desc
return from interrupt#1

Quoted 1 line

For this scenario, The IRQ#2 will be lost. This does cause some exceptions.

Please see my reply to James at [1]. I'd appreciate if you could give that patch a go, which I expect to be a better avenue to fix what is effectively a GIC architecture defect.

Quoted 5 lines

Thanks,

	M.

[1] https://lore.kernel.org/all/[email protected]/

Hi Marc:

    Thanks for your time about this issue.

    I have seen your latest patch, and I am preparing the environment for testing, I will sent the testing status of this patch later.

Signature · 2 lines
Regards,
Yipeng Zou