All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Amir Noohi <amirmnoohi@gmail.com>
Cc: Thomas Gleixner <tglx@kernel.org>,
	Oliver Upton <oupton@kernel.org>, Radu Rendec <radu@rendec.net>,
	Igor Velkov <iav@iav.lv>, Fuad Tabba <fuad.tabba@linux.dev>,
	Joey Gouly <joey.gouly@arm.com>,
	Steffen Eiden <seiden@linux.ibm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Christoffer Dall <cdall@linaro.org>,
	kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] genirq/manage: Provide irq_set_percpu_irqchip_state()
Date: Tue, 27 Oct 2026 16:44:10 +0000	[thread overview]
Message-ID: <86se1rxfdx.wl-maz@kernel.org> (raw)
In-Reply-To: <20261024212844.3405617-1-amirmnoohi@gmail.com>

On Sat, 24 Oct 2026 22:28:44 +0100,
Amir Noohi <amirmnoohi@gmail.com> wrote:
> 
> Hi Marc,
> 
> On Sat, 24 Oct 2026 13:21:00 +0100, Marc Zyngier <maz@kernel.org> wrote:
> > It really feels like a leap of faith.
> >
> > There is nothing that says that it is safe to call this without
> > holding the global lock. For all we know, drivers have been relying on
> > it for a good decade, and I don't feel confident letting things rip
> > just because it (mostly) works with the GIC.
> >
> > At the very least, something exposed by the irqchip (a per-IRQ flag?)
> > should tell you whether it is safe to elide the lock.
> 
> Agreed, and v2 does that. There's a new IRQCHIP_PERCPU_STATE_LOCKLESS
> flag, and irq_set_percpu_irqchip_state() only skips the descriptor lock
> if the chip implementing irq_set_irqchip_state() has it set. Otherwise,
> or if there's a bus lock, it just calls irq_set_irqchip_state(), so
> drivers that don't opt in see no change.

I'm not sure this is the correct option. Making it per irqchip is
again assuming that the irqchip has a uniform handling of the state
across all interrupts. I'm afraid that's not universally true, which
is why I hinted at a per-IRQ flag.

Alternatively, you can audit all the providers of this API and work
out if is it safe to do so, and split the corresponding callbacks.
Good luck with that. :-/

> 
> Only GICv3 sets it, in a separate patch. For SGIs/PPIs/EPPIs its
> callback only touches the local redistributor (gic_data_rdist_sgi_base()
> and the RWP poll), nothing shared.

Read the code again. There is *one* callback for all distributor-owned
interrupts, which also involves SPIs/ESPIs.

> FWIW, irq-gic.c, irq-gic-v3.c and
> irq-gic-v5.c are the only drivers with both per-CPU devid interrupts and
> an irq_set_irqchip_state() callback. KVM's own timer chip (GICv5, no HW
> deactivation) doesn't set it either, so those keep the lock.

The KVM chip inherits whatever it is pushed upon, and it is still a
per-CPU interrupt. To be clear, this is an all or nothing approach as
far as KVM is concerned, so anything that KVM uses should be converted
to the lockless approach.

Even in the GICv5 case, the ICC_PPI_ENABLER0 register cannot be
modified concurrently, so it should be safe to advertise these as
lockless.

> 
> On GICv2 in QEMU it still takes the lock like mainline does (333k vs
> 321k acquisitions in lock_stat, within 4%), and on GICv3 it doesn't
> take it at all. arch_timer, arch_timer_edge_cases, vgic_irq and
> vgic_init pass on the Altra. Under QEMU with lockdep, DEBUG_PREEMPT and
> DEBUG_ATOMIC_SLEEP, the selftests pass on GICv3 (VHE and nVHE) and
> GICv2 (the vGICv3 ones skip there). No splats.
> 
> I made it a chip flag since it's about the callback, but I can make it
> per-IRQ if you prefer.

I reckon this is a requirement.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2026-10-27 16:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-24  2:24 [PATCH 0/2] genirq, KVM: arm64: Avoid the irq descriptor lock on vCPU load Amir Noohi
2026-10-24  2:24 ` [PATCH 1/2] genirq/manage: Provide irq_set_percpu_irqchip_state() Amir Noohi
2026-10-24 12:21   ` Marc Zyngier
2026-10-24 21:28     ` Amir Noohi
2026-10-27 16:44       ` Marc Zyngier [this message]
2026-10-24  2:24 ` [PATCH 2/2] KVM: arm64: timer: Avoid the irq descriptor lock on vCPU load Amir Noohi
2026-10-24 11:52 ` [PATCH 0/2] genirq, KVM: arm64: " Marc Zyngier
2026-10-24 21:23   ` Amir Noohi

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=86se1rxfdx.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=amirmnoohi@gmail.com \
    --cc=catalin.marinas@arm.com \
    --cc=cdall@linaro.org \
    --cc=fuad.tabba@linux.dev \
    --cc=iav@iav.lv \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=oupton@kernel.org \
    --cc=radu@rendec.net \
    --cc=seiden@linux.ibm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tglx@kernel.org \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.