linux-um.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] um: Support SPARSE_IRQ
@ 2025-08-25 21:19 Brian Norris
  2025-08-26  1:38 ` David Gow
  2025-08-27 19:38 ` Johannes Berg
  0 siblings, 2 replies; 4+ messages in thread
From: Brian Norris @ 2025-08-25 21:19 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg
  Cc: linux-um, linux-kernel, David Gow, Sinan Nalkaya, Brian Norris

From: Sinan Nalkaya <sardok@gmail.com>

Motivation: IRQ KUnit tests are going to require CONFIG_SPARSE_IRQ [1] in
order to:
(a) reliably allocate additional (fake) IRQs and
(b) ensure we can test managed affinity, which is only supported with
    SPARSE_IRQ.

It seems that the only thing necessary for ARCH=um is to tell the genirq
core to skip over our preallocated NR_IRQS.

Tested with:

  $ ./tools/testing/kunit/kunit.py run
  [...]
  [13:55:58] Testing complete. Ran 676 tests: passed: 646, skipped: 30
  [...]

This comparse with pre-patch results:

    Ran 672 tests: passed: 644, skipped: 28

i.e., we no longer skip tests that 'depend on SPARSE_IRQ', and existing
tests all pass.

[1]
[PATCH v2 4/6] genirq/test: Depend on SPARSE_IRQ
https://lore.kernel.org/all/CABVgOSngoD0fh1WEkUCEwSdk0Joypo3dA_Y_SjW+K=nVDnZs3Q@mail.gmail.com/

Signed-off-by: Sinan Nalkaya <sardok@gmail.com>
[Brian: Adapted Sinan's patch; rewrote commit message]
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
This is adapted from Sinan's work at:
[PATCH 1/1] um: Fix broken IRQs if SPARSE_IRQ is selected
https://lore.kernel.org/all/1360193940-31504-1-git-send-email-sardok@gmail.com/

Place any blame for errors on me of course.

I'm not much of a UML developer, although I've been developing KUnit
tests which default to running on ARCH=um.

I also can't quite tell if MAY_HAVE_SPARSE_IRQ or SPARSE_IRQ is a better
'select' target. Almost every other architecture uses 'select
SPARSE_IRQ', with the one exception of arch/csky. For my purposes, it's
better to 'select SPARSE_IRQ', for consistency with other ARCH'es, and
to make it easier for KUnit builds to get it. But I'm less sure if there
are good reasons to want to make it user-(un)selectable.

 arch/um/Kconfig      | 1 +
 arch/um/kernel/irq.c | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index 9083bfdb7735..8161cc5ae6f7 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -38,6 +38,7 @@ config UML
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_SYSCALL_TRACEPOINTS
 	select THREAD_INFO_IN_TASK
+	select SPARSE_IRQ
 
 config MMU
 	bool
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index 0dfaf96bb7da..d59a5a0f7fbf 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -691,6 +691,13 @@ void __init init_IRQ(void)
 	os_setup_epoll();
 }
 
+#ifdef CONFIG_SPARSE_IRQ
+int __init arch_probe_nr_irqs(void)
+{
+	return NR_IRQS;
+}
+#endif
+
 void sigchld_handler(int sig, struct siginfo *unused_si,
 		     struct uml_pt_regs *regs, void *mc)
 {
-- 
2.51.0.261.g7ce5a0a67e-goog



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] um: Support SPARSE_IRQ
  2025-08-25 21:19 [PATCH] um: Support SPARSE_IRQ Brian Norris
@ 2025-08-26  1:38 ` David Gow
  2025-08-27 19:38 ` Johannes Berg
  1 sibling, 0 replies; 4+ messages in thread
From: David Gow @ 2025-08-26  1:38 UTC (permalink / raw)
  To: Brian Norris
  Cc: Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um,
	linux-kernel, Sinan Nalkaya

[-- Attachment #1: Type: text/plain, Size: 3097 bytes --]

On Tue, 26 Aug 2025 at 05:20, Brian Norris <briannorris@chromium.org> wrote:
>
> From: Sinan Nalkaya <sardok@gmail.com>
>
> Motivation: IRQ KUnit tests are going to require CONFIG_SPARSE_IRQ [1] in
> order to:
> (a) reliably allocate additional (fake) IRQs and
> (b) ensure we can test managed affinity, which is only supported with
>     SPARSE_IRQ.
>
> It seems that the only thing necessary for ARCH=um is to tell the genirq
> core to skip over our preallocated NR_IRQS.
>
> Tested with:
>
>   $ ./tools/testing/kunit/kunit.py run
>   [...]
>   [13:55:58] Testing complete. Ran 676 tests: passed: 646, skipped: 30
>   [...]
>
> This comparse with pre-patch results:
>
>     Ran 672 tests: passed: 644, skipped: 28
>
> i.e., we no longer skip tests that 'depend on SPARSE_IRQ', and existing
> tests all pass.
>
> [1]
> [PATCH v2 4/6] genirq/test: Depend on SPARSE_IRQ
> https://lore.kernel.org/all/CABVgOSngoD0fh1WEkUCEwSdk0Joypo3dA_Y_SjW+K=nVDnZs3Q@mail.gmail.com/
>
> Signed-off-by: Sinan Nalkaya <sardok@gmail.com>
> [Brian: Adapted Sinan's patch; rewrote commit message]
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---

Thanks -- this seems to work well here. I can confirm the KUnit tests
pass (including with 32-bit builds), and nothing I've tested has
failed so far.

Tested-by: David Gow <davidgow@google.com>

Cheers,
-- David

> This is adapted from Sinan's work at:
> [PATCH 1/1] um: Fix broken IRQs if SPARSE_IRQ is selected
> https://lore.kernel.org/all/1360193940-31504-1-git-send-email-sardok@gmail.com/
>
> Place any blame for errors on me of course.
>
> I'm not much of a UML developer, although I've been developing KUnit
> tests which default to running on ARCH=um.
>
> I also can't quite tell if MAY_HAVE_SPARSE_IRQ or SPARSE_IRQ is a better
> 'select' target. Almost every other architecture uses 'select
> SPARSE_IRQ', with the one exception of arch/csky. For my purposes, it's
> better to 'select SPARSE_IRQ', for consistency with other ARCH'es, and
> to make it easier for KUnit builds to get it. But I'm less sure if there
> are good reasons to want to make it user-(un)selectable.
>
>  arch/um/Kconfig      | 1 +
>  arch/um/kernel/irq.c | 7 +++++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/arch/um/Kconfig b/arch/um/Kconfig
> index 9083bfdb7735..8161cc5ae6f7 100644
> --- a/arch/um/Kconfig
> +++ b/arch/um/Kconfig
> @@ -38,6 +38,7 @@ config UML
>         select HAVE_ARCH_TRACEHOOK
>         select HAVE_SYSCALL_TRACEPOINTS
>         select THREAD_INFO_IN_TASK
> +       select SPARSE_IRQ
>
>  config MMU
>         bool
> diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
> index 0dfaf96bb7da..d59a5a0f7fbf 100644
> --- a/arch/um/kernel/irq.c
> +++ b/arch/um/kernel/irq.c
> @@ -691,6 +691,13 @@ void __init init_IRQ(void)
>         os_setup_epoll();
>  }
>
> +#ifdef CONFIG_SPARSE_IRQ
> +int __init arch_probe_nr_irqs(void)
> +{
> +       return NR_IRQS;
> +}
> +#endif
> +
>  void sigchld_handler(int sig, struct siginfo *unused_si,
>                      struct uml_pt_regs *regs, void *mc)
>  {
> --
> 2.51.0.261.g7ce5a0a67e-goog
>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5281 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] um: Support SPARSE_IRQ
  2025-08-25 21:19 [PATCH] um: Support SPARSE_IRQ Brian Norris
  2025-08-26  1:38 ` David Gow
@ 2025-08-27 19:38 ` Johannes Berg
  2025-08-27 19:41   ` Brian Norris
  1 sibling, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2025-08-27 19:38 UTC (permalink / raw)
  To: Brian Norris, Richard Weinberger, Anton Ivanov
  Cc: linux-um, linux-kernel, David Gow, Sinan Nalkaya

On Mon, 2025-08-25 at 14:19 -0700, Brian Norris wrote:
> 
> +#ifdef CONFIG_SPARSE_IRQ
> +int __init arch_probe_nr_irqs(void)
> 

Is there much point in the ifdef if it's anyway always going to be
enabled due to the 'select'?

johannes


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] um: Support SPARSE_IRQ
  2025-08-27 19:38 ` Johannes Berg
@ 2025-08-27 19:41   ` Brian Norris
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Norris @ 2025-08-27 19:41 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Richard Weinberger, Anton Ivanov, linux-um, linux-kernel,
	David Gow, Sinan Nalkaya

On Wed, Aug 27, 2025 at 09:38:17PM +0200, Johannes Berg wrote:
> On Mon, 2025-08-25 at 14:19 -0700, Brian Norris wrote:
> > 
> > +#ifdef CONFIG_SPARSE_IRQ
> > +int __init arch_probe_nr_irqs(void)
> > 
> 
> Is there much point in the ifdef if it's anyway always going to be
> enabled due to the 'select'?

Oh, good question. No, I don't see much point. I think I was waffling
about the MAY_HAVE_SPARSE_IRQ question, but if we go with 'select
SPARSE_IRQ' as proposed, I should probably drop the #ifdef.

Will send v2 if that's the only question/request.

Brian


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-27 20:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-25 21:19 [PATCH] um: Support SPARSE_IRQ Brian Norris
2025-08-26  1:38 ` David Gow
2025-08-27 19:38 ` Johannes Berg
2025-08-27 19:41   ` Brian Norris

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).