linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: richard clark <richard.xnu.clark@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, will@kernel.org,
	"Russell King (Oracle)" <linux@armlinux.org.uk>,
	Mark Rutland <mark.rutland@arm.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: Question about interrupt prioriyt of ARM GICv3/4
Date: Fri, 06 Dec 2024 09:37:04 +0000	[thread overview]
Message-ID: <86cyi5tanz.wl-maz@kernel.org> (raw)
In-Reply-To: <CAJNi4rMfhZOCT+7Ki14vUs+dZbv9cxCZ0s+jgn6=_om4NTgo_A@mail.gmail.com>

On Fri, 06 Dec 2024 08:33:11 +0000,
richard clark <richard.xnu.clark@gmail.com> wrote:
> 
> Hi,
> Currently seems the GICv3/4 irqchip configures all the interrupts as
> the same priority, I am thinking about to minimize the latency of the
> interrupt for a particular device, e.g, the arm arch_timer in the RTL
> system. The question is,
> 1. Why don't we provide a /proc or /sys interface for the enduser to
> set the priority of a specific interrupt(SPI/PPI)?

I'm afraid this really has nothing to do with any particular interrupt
architecture.

Before thinking of exposing the interrupt priority to userspace, you
should look at what this translates into for the kernel once you allow
interrupts to be preempted by another one with a higher priority.

This means that at every point where you would normally see a
local_irq_save(), spinlock_irqsave() or equivalent, you would need to
explicitly specify the priority that you allow for preemption. You
should then make sure that any code that can be run during an
interrupt is reentrant. You need to define which data structures can
be manipulated at which priority level... The list goes on.

If you want a small taste of the complexity, just look at what
handling NMIs (or even pseudo-NMIs in the case of GICv3) means, and
generalise it to not just two, but an arbitrary range of priorities.

If you want the full blown experience, look at the BSDs and their use
of spl*(). I don't think anyone has any plan to get there, and the RT
patches have shown that there is little need for it.

> 2. Is there any way to verify the higher priority interrupt will have
> more dominant to be selected to the CPU (IOW, the priority is really
> working) in case of multiple different interrupts asserted to the GIC
> at the same time(some debug registers of GIC like GICD_REEMPT_CNT :-)
> to record higher priority wins)?

The GIC architecture makes no promise that the interrupt you
acknowledge is the highest priority pending interrupt, because this is
by definition a very racy process.

Also, even on busy systems, you will very rarely see two interrupts
targeting the same CPU being made pending at the same time, so that
the interrupt delivery system would have to arbitrate between the two.
That's because interrupts are vanishingly rare in the grand scheme of
things.

Thanks,

	M.

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


  reply	other threads:[~2024-12-06  9:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-06  8:33 Question about interrupt prioriyt of ARM GICv3/4 richard clark
2024-12-06  9:37 ` Marc Zyngier [this message]
2024-12-12  9:18   ` richard clark
2024-12-12 10:12     ` Marc Zyngier
2024-12-12 13:02       ` Mark Kettenis
2024-12-13  9:27         ` Richard Clark
2024-12-13 14:22         ` Marc Zyngier
2024-12-13  9:13       ` Richard Clark

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=86cyi5tanz.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=richard.xnu.clark@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=will@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).