From: Thomas Gleixner <tglx@linutronix.de>
To: Samuel Holland <samuel.holland@sifive.com>,
Anup Patel <anup@brainfault.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
linux-kernel@vger.kernel.org, Alexandre Ghiti <alex@ghiti.fr>,
linux-riscv@lists.infradead.org, Paul Walmsley <pjw@kernel.org>,
Samuel Holland <samuel.holland@sifive.com>,
Albert Ou <aou@eecs.berkeley.edu>
Subject: Re: [PATCH 4/4] irqchip/riscv-imsic: Remove irq_desc lookup from hot path
Date: Thu, 16 Oct 2025 12:01:53 +0200 [thread overview]
Message-ID: <87v7kf17xq.ffs@tglx> (raw)
In-Reply-To: <20251015195712.3813004-5-samuel.holland@sifive.com>
On Wed, Oct 15 2025 at 12:55, Samuel Holland wrote:
> The IMSIC driver uses the IRQ matrix allocator, so there is an arbitrary
> mapping from the per-CPU interrupt identity to the global irq number. As
> a result, the driver maintains a table of vectors so it can look up the
> virq number during interrupt handling. The driver uses the virq for one
> main purpose: it gets passed to generic_handle_irq(), which then uses it
> to look up the irq_desc in the sparse_irqs tree.
>
> Taking inspiration from the loongarch AVEC irqchip driver, skip the tree
which got the idea from x86 :)
> -struct imsic_vector *imsic_vector_alloc(unsigned int irq, const struct cpumask *mask)
> +struct imsic_vector *imsic_vector_alloc(struct irq_desc *desc, const struct cpumask *mask)
> {
> struct imsic_vector *vec = NULL;
> struct imsic_local_priv *lpriv;
> @@ -450,7 +451,7 @@ struct imsic_vector *imsic_vector_alloc(unsigned int irq, const struct cpumask *
>
> lpriv = per_cpu_ptr(imsic->lpriv, cpu);
> vec = &lpriv->vectors[local_id];
> - vec->irq = irq;
> + vec->desc = desc;
> vec->enable = false;
> vec->move_next = NULL;
> vec->move_prev = NULL;
> @@ -463,7 +464,7 @@ void imsic_vector_free(struct imsic_vector *vec)
> unsigned long flags;
>
> raw_spin_lock_irqsave(&imsic->matrix_lock, flags);
> - vec->irq = 0;
> + vec->desc = NULL;
> irq_matrix_free(imsic->matrix, vec->cpu, vec->local_id, false);
> raw_spin_unlock_irqrestore(&imsic->matrix_lock, flags);
This is only correct when it is guaranteed that the interrupt can't be
raised in the CPU _before_ a interrupt allocation completed throughout
the hierarchy and _after_ the freeing hierarchy walk started. Otherwise
this might end up accessing a half initialized or half torn down
descriptor.
If it is, then please add a comment describing it. If not then you need
to implement the activate/deactivate callbacks for your interrupt domain
and do the store/clear of vec->desc there.
Thanks,
tglx
prev parent reply other threads:[~2025-10-16 10:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 19:55 [PATCH 0/4] irqchip/riscv-imsic: IRQ handling optimizations Samuel Holland
2025-10-15 19:55 ` [PATCH 1/4] irqchip/riscv-imsic: Remove redundant irq_data lookups Samuel Holland
2025-10-16 12:55 ` [tip: irq/drivers] " tip-bot2 for Samuel Holland
2025-10-16 15:46 ` tip-bot2 for Samuel Holland
2025-10-16 19:01 ` tip-bot2 for Samuel Holland
2025-10-15 19:55 ` [PATCH 2/4] irqchip/riscv-imsic: Embed the vector array in lpriv Samuel Holland
2025-10-16 12:55 ` [tip: irq/drivers] " tip-bot2 for Samuel Holland
2025-10-16 15:46 ` tip-bot2 for Samuel Holland
2025-10-16 19:01 ` tip-bot2 for Samuel Holland
2025-10-15 19:55 ` [PATCH 3/4] irqchip/riscv-imsic: Inline imsic_vector_from_local_id() Samuel Holland
2025-10-16 12:55 ` [tip: irq/drivers] " tip-bot2 for Samuel Holland
2025-10-16 15:46 ` tip-bot2 for Samuel Holland
2025-10-16 19:01 ` tip-bot2 for Samuel Holland
2025-10-15 19:55 ` [PATCH 4/4] irqchip/riscv-imsic: Remove irq_desc lookup from hot path Samuel Holland
2025-10-16 10:01 ` Thomas Gleixner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v7kf17xq.ffs@tglx \
--to=tglx@linutronix.de \
--cc=alex@ghiti.fr \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=samuel.holland@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox