Remove the use of statically allocated arrays for IRQ descriptors.
Instead, allocate the necessary NR_IRQ descriptors during the boot
time in early_irq_init().
Signed-off-by: Shanker Donthineni <sdonthineni@nvidia.com>
---
kernel/irq/irqdesc.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 21a968bc468b..a4911f7ebb07 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -556,27 +556,24 @@ int __init early_irq_init(void)
#else /* !CONFIG_SPARSE_IRQ */
-struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
- [0 ... NR_IRQS-1] = {
- .handle_irq = handle_bad_irq,
- .depth = 1,
- .lock = __RAW_SPIN_LOCK_UNLOCKED(irq_desc->lock),
- }
-};
+static struct irq_desc *irq_descs;
int __init early_irq_init(void)
{
- int count, i, node = first_online_node;
+ int i, node = first_online_node;
struct irq_desc *desc;
init_irq_default_affinity();
printk(KERN_INFO "NR_IRQS: %d\n", NR_IRQS);
- desc = irq_desc;
- count = ARRAY_SIZE(irq_desc);
+ desc = kmalloc_array(NR_IRQS, sizeof(*desc), GFP_KERNEL | __GFP_ZERO);
+ if (desc == NULL)
+ return -ENOMEM;
+
+ irq_descs = desc;
- for (i = 0; i < count; i++) {
+ for (i = 0; i < NR_IRQS; i++) {
desc[i].kstat_irqs = alloc_percpu(unsigned int);
alloc_masks(&desc[i], node);
raw_spin_lock_init(&desc[i].lock);
@@ -593,7 +590,7 @@ int __init early_irq_init(void)
struct irq_desc *irq_to_desc(unsigned int irq)
{
- return (irq < NR_IRQS) ? irq_desc + irq : NULL;
+ return (irq < NR_IRQS) ? irq_descs + irq : NULL;
}
EXPORT_SYMBOL(irq_to_desc);
--
2.25.1
On Sun, Jan 29 2023 at 18:57, Shanker Donthineni wrote:
> Remove the use of statically allocated arrays for IRQ descriptors.
> Instead, allocate the necessary NR_IRQ descriptors during the boot
> time in early_irq_init().
That's not what I meant. I was pondering to remove !SPARSEIRQ
completely.
That allocation does not buy us much.
Thanks,
tglx
On 1/31/23 03:16, Thomas Gleixner wrote:
> External email: Use caution opening links or attachments
>
>
> On Sun, Jan 29 2023 at 18:57, Shanker Donthineni wrote:
>
>> Remove the use of statically allocated arrays for IRQ descriptors.
>> Instead, allocate the necessary NR_IRQ descriptors during the boot
>> time in early_irq_init().
>
> That's not what I meant. I was pondering to remove !SPARSEIRQ
> completely.
>
It's touching many files to drop CONFIG_SPARSE_IRQ=n support. Worried
about removing !SPARSEIRQ without testing on legacy platforms.
Can work on this after moving it to maple tree?
arch/arm/Kconfig | 1 -
arch/arm/include/asm/irq.h | 4 --
arch/arm/kernel/irq.c | 2 -
arch/arm64/Kconfig | 1 -
arch/csky/Kconfig | 1 -
arch/loongarch/Kconfig | 1 -
arch/microblaze/Kconfig | 1 -
arch/nios2/Kconfig | 1 -
arch/openrisc/Kconfig | 1 -
arch/powerpc/Kconfig | 1 -
arch/riscv/Kconfig | 1 -
arch/s390/Kconfig | 1 -
arch/sh/Kconfig | 1 -
arch/sparc/Kconfig | 1 -
arch/x86/Kconfig | 1 -
drivers/irqchip/Kconfig | 5 ---
include/linux/irqdesc.h | 8 ----
kernel/irq/Kconfig | 17 --------
kernel/irq/chip.c | 5 ---
kernel/irq/internals.h | 10 -----
kernel/irq/irqdesc.c | 88 --------------------------------------
kernel/irq/irqdomain.c | 14 +++---
22 files changed, 6 insertions(+), 160 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 43c7773b89ae..d4fc6c549660 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -134,7 +134,6 @@ config ARM
select PCI_SYSCALL if PCI
select PERF_USE_VMALLOC
select RTC_LIB
- select SPARSE_IRQ if !(ARCH_FOOTBRIDGE || ARCH_RPC)
select SYS_SUPPORTS_APM_EMULATION
select THREAD_INFO_IN_TASK
select TIMER_OF if OF
diff --git a/arch/arm/include/asm/irq.h b/arch/arm/include/asm/irq.h
index a7c2337b0c7d..6d4ff82c40cf 100644
--- a/arch/arm/include/asm/irq.h
+++ b/arch/arm/include/asm/irq.h
@@ -4,11 +4,7 @@
...
-#ifndef CONFIG_SPARSE_IRQ
-#include <mach/irqs.h>
-#else
#define NR_IRQS NR_IRQS_LEGACY
-#endif
...
# Make sparse irq Kconfig switch below available
-config MAY_HAVE_SPARSE_IRQ
- bool
-
# Legacy support, required for itanic
config GENERIC_IRQ_LEGACY
bool
@@ -107,19 +103,6 @@ config GENERIC_IRQ_RESERVATION_MODE
config IRQ_FORCED_THREADING
bool
> That allocation does not buy us much.
>
Agree, not much value other than reducing kernel binary size. I will drop
this patch in v2.
Thanks,
Shanker
On Tue, Jan 31 2023 at 10:41, Shanker Donthineni wrote:
> On 1/31/23 03:16, Thomas Gleixner wrote:
>> That's not what I meant. I was pondering to remove !SPARSEIRQ
>> completely.
>>
> It's touching many files to drop CONFIG_SPARSE_IRQ=n support. Worried
> about removing !SPARSEIRQ without testing on legacy platforms.
This needs some thought.
> Can work on this after moving it to maple tree?
Yup. Just drop this patch.
Thanks,
tglx
© 2016 - 2026 Red Hat, Inc.