[PATCH v2 0/3] Increase the number of IRQ descriptors for SPARSEIRQ

From: Shanker Donthineni
Date: Sat Apr 08 2023 - 13:16:01 EST


The ARM64 architecture uses SPARSEIRQ with a default value of NR_IRQS,
which is set to 64. This means that only 64+8192 IRQ descriptors are
allowed, which may not be sufficient for modern ARM64 servers that
have a large number of IO devices and GIC hardware that supports
direct vSGI and vLPI injection features.

This limitation has caused issues when attempting to launch multiple
virtual machines with GICv4.1 features, resulting in the error message
'kvm_err("VPE IRQ allocation failure\n")'. The root cause of this issue
is the ~8K IRQ descriptor limit.

To address this issue, an initial proposal was made to define NR_IRQS
to 2^19 for ARM64. However, Marc Zyngier suggested implementing a
generic solution instead of hard-coded values. Thomas Gleixner advised
to use the maple tree data structure and provided most of the necessary
functions.

For more information, refer to the discussion thread at
https://lore.kernel.org/linux-arm-kernel/20230104023738.1258925-1-sdonthineni@xxxxxxxxxx/.

This patch series converts the static memory allocation to dynamic using
the maple tree, and increases the maximum number of IRQ descriptors to
INT_MAX from NR_IRQS+8192. This change has been tested on an ARM64 server
with CONFIG_SPARSE_IRQ=y, where 256 virtual machines were launched,
creating a total of 128K+ IRQ descriptors, and IRQ injection was verified.

The maple_tree RCU mode fixes are prerequisites, expecting all these
changes will be available in v6.4-rc1.
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/lib/maple_tree.c?h=next-20230406
- maple_tree: add RCU lock checking to rcu callback functions
- maple_tree: add smp_rmb() to dead node detection
- maple_tree: fix write memory barrier of nodes once dead for RCU mode
- maple_tree: remove extra smp_wmb() from mas_dead_leaves()
- maple_tree: fix freeing of nodes in rcu mode
- maple_tree: detect dead nodes in mas_start()
- maple_tree: be more cautious about dead nodes

Changes in v2:
- The patches have been updated to v6.3-rc5.
- The patches 2/5 and 4/5 have been removed as they are unnecessary.
- The review comments from Thomas have been addressed.

Shanker Donthineni (3):
genirq: Use hlist for managing resend handlers
genirq: Encapsulate sparse bitmap handling
genirq: Use the maple tree for IRQ descriptors management

include/linux/irqdesc.h | 3 ++
kernel/irq/chip.c | 1 +
kernel/irq/internals.h | 5 +--
kernel/irq/irqdesc.c | 80 ++++++++++++++++++++++++++---------------
kernel/irq/resend.c | 41 ++++++++++++---------
5 files changed, 82 insertions(+), 48 deletions(-)

--
2.25.1