Re: [PATCH v2 1/3] genirq: Use hlist for managing resend handlers

From: Shanker Donthineni
Date: Mon Apr 10 2023 - 07:52:45 EST




On 4/10/23 05:05, Marc Zyngier wrote:
External email: Use caution opening links or attachments


On Sun, 09 Apr 2023 13:00:27 +0100,
Shanker Donthineni <sdonthineni@xxxxxxxxxx> wrote:

@@ -30,18 +31,17 @@ static DECLARE_BITMAP(irqs_resend, IRQ_BITMAP_BITS);
static void resend_irqs(struct tasklet_struct *unused)
{
struct irq_desc *desc;
- int irq;
-
- while (!bitmap_empty(irqs_resend, nr_irqs)) {
- irq = find_first_bit(irqs_resend, nr_irqs);
- clear_bit(irq, irqs_resend);
- desc = irq_to_desc(irq);
- if (!desc)
- continue;
- local_irq_disable();
+
+ raw_spin_lock_irq(&irq_resend_lock);
+ while (!hlist_empty(&irq_resend_list)) {
+ desc = hlist_entry(irq_resend_list.first, struct irq_desc,
+ resend_node);
+ hlist_del_init(&desc->resend_node);
+ raw_spin_unlock(&irq_resend_lock);
desc->handle_irq(desc);
- local_irq_enable();
+ raw_spin_lock(&irq_resend_lock);

What makes it safe to drop the local_irq_*able()?

tasklet_action_common() explicitly enables interrupts when calling the
callback, so unless there is some other interrupt disabling that I
can't immediately spot, the handler may run in the wrong context.


Unless I am overlooking something, interrupts are disabled within the while
loop unless desc->handle_irq() is enabling it. The existing code disables
and enables interrupts for each handler invocation, whereas the modified
code does it only once for all outstanding handlers.

Ah, you use raw_spinlock_irq() outside of the loop. I somehow glanced
over that, apologies for the noise. Unless we expect a really long
list of interrupts to be resent, your current code should be OK.


Thanks, I'll post v3 patches to address the other review comments.