* [PATCH v2 00/21] Reduce the scope of 'nr_irqs'
@ 2024-10-08 20:25 Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 01/22] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
` (21 more replies)
0 siblings, 22 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche
Hi Thomas,
In addition to the global 'nr_irqs' variable, there are plenty of local
variables with the same name. This makes reviewing kernel patches and
auditing kernel source code harder than necessary. Hence this patch series
that reduces the scope of the global 'nr_irqs' variable to file scope and
that introduces functions for retrieving and setting the value of this
variable.
Accesses of the global variable 'nr_irqs' have been identified with
Coccinelle.
Please consider this patch series for the next merge window.
Thanks,
Bart.
Changes compared to v1:
- Renamed the accessor functions: number_of_interrupts() has been renamed into
irq_get_nr_irqs() and set_number_of_interrupts() has been renamed into
set_number_of_interrupts().
- Made the description of patch 01 more detailed. It is now explained in
detail why it is useful to introduce accessor functions for 'nr_irqs'.
- Cache the irq_get_nr_irqs() return value if it is used as a loop upper bound
or inside a loop body instead of relying on CSE (common subexpression
elimination) by the compiler.
- Split the hamradio patch into two patches - one patch per driver.
Bart Van Assche (22):
genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs()
ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs()
LoongArch: Switch to irq_set_nr_irqs()
powerpc/cell: Switch to irq_get_nr_irqs()
s390/irq: Switch to irq_get_nr_irqs()
x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs()
hpet: Switch to irq_get_nr_irqs()
net: 3com: 3c59x: Switch to irq_get_nr_irqs()
net: hamradio: baycom_ser_fdx: Switch to irq_get_nr_irqs()
net: hamradio: scc: Switch to irq_get_nr_irqs()
scsi: aha152x: Switch to irq_get_nr_irqs()
serial: core: Switch to irq_get_nr_irqs()
serial: 8250: Switch to irq_get_nr_irqs()
serial: amba-pl010: Switch to irq_get_nr_irqs()
serial: amba-pl011: Switch to irq_get_nr_irqs()
serial: cpm_uart: Switch to irq_get_nr_irqs()
serial: ucc_uart: Switch to irq_get_nr_irqs()
sh: intc: Switch to irq_get_nr_irqs()
xen/events: Switch to irq_get_nr_irqs()
fs/procfs: Switch to irq_get_nr_irqs()
genirq: Switch to irq_get_nr_irqs()
genirq: Unexport nr_irqs
arch/arm/kernel/irq.c | 5 ++--
arch/loongarch/kernel/irq.c | 4 +--
arch/powerpc/platforms/cell/axon_msi.c | 2 +-
arch/s390/kernel/irq.c | 2 +-
arch/x86/kernel/acpi/boot.c | 6 +++--
arch/x86/kernel/apic/vector.c | 8 +++---
drivers/char/hpet.c | 1 +
drivers/net/ethernet/3com/3c59x.c | 2 +-
drivers/net/hamradio/baycom_ser_fdx.c | 1 +
drivers/net/hamradio/scc.c | 4 ++-
drivers/scsi/aha152x.c | 2 +-
drivers/sh/intc/virq-debugfs.c | 1 +
drivers/tty/serial/8250/8250_port.c | 2 +-
drivers/tty/serial/amba-pl010.c | 2 +-
drivers/tty/serial/amba-pl011.c | 2 +-
drivers/tty/serial/cpm_uart.c | 2 +-
drivers/tty/serial/serial_core.c | 2 +-
drivers/tty/serial/ucc_uart.c | 2 +-
drivers/xen/events/events_base.c | 2 +-
fs/proc/interrupts.c | 4 +--
fs/proc/stat.c | 4 +--
include/linux/irqnr.h | 36 +++++++++++++++-----------
kernel/irq/irqdesc.c | 26 +++++++++++++++++--
kernel/irq/irqdomain.c | 2 +-
kernel/irq/proc.c | 3 ++-
25 files changed, 81 insertions(+), 46 deletions(-)
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v2 01/22] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 02/22] ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs() Bart Van Assche
` (20 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche
Prepare for changing 'nr_irqs' from an exported global variable into a
variable with file scope. This change will prevent accidental changes of
assignments to a local variable 'nr_irqs' into assignments to the global
'nr_irqs' variable. Suppose that a patch would be submitted for review that
removes a declaration of a local variable with the name 'nr_irqs' and that
that patch does not remove all assignments to that local variable. Such a
patch converts an assignment to a local variable into an assignment into a
global variable. If the 'nr_irqs' assignment is more than three lines away
from other changes, the assignment won't be included in the diff context
lines and hence won't be visible without inspecting the modified file. With
this patch series applied, such accidental conversions from assignments to
a local variable into an assignment to a global variable are converted into
a compilation error.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
include/linux/irqnr.h | 2 ++
kernel/irq/irqdesc.c | 23 +++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index 3496baa0b07f..7419b807b71b 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -6,6 +6,8 @@
extern int nr_irqs;
+unsigned int irq_get_nr_irqs(void) __pure;
+unsigned int irq_set_nr_irqs(unsigned int nr);
extern struct irq_desc *irq_to_desc(unsigned int irq);
unsigned int irq_get_next_irq(unsigned int offset);
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 1dee88ba0ae4..b0733959f8ae 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -141,6 +141,29 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
int nr_irqs = NR_IRQS;
EXPORT_SYMBOL_GPL(nr_irqs);
+/**
+ * irq_get_nr_irqs() - Number of interrupts supported by the system.
+ */
+unsigned int irq_get_nr_irqs(void)
+{
+ return nr_irqs;
+}
+EXPORT_SYMBOL_GPL(irq_get_nr_irqs);
+
+/**
+ * irq_set_nr_irqs() - Set the number of interrupts supported by the system.
+ * @nr: New number of interrupts.
+ *
+ * Return: @nr.
+ */
+unsigned int irq_set_nr_irqs(unsigned int nr)
+{
+ nr_irqs = nr;
+
+ return nr;
+}
+EXPORT_SYMBOL_GPL(irq_set_nr_irqs);
+
static DEFINE_MUTEX(sparse_irq_lock);
static struct maple_tree sparse_irqs = MTREE_INIT_EXT(sparse_irqs,
MT_FLAGS_ALLOC_RANGE |
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 02/22] ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 01/22] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 03/22] LoongArch: Switch to irq_set_nr_irqs() Bart Van Assche
` (19 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche
Use the irq_get_nr_irqs() and irq_set_nr_irqs() functions instead of the
global variable 'nr_irqs'. This patch prepares for changing 'nr_irqs' from
an exported global variable into a variable with file scope.
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
arch/arm/kernel/irq.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index dab42d066d06..e1993e28a9ec 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -111,7 +111,7 @@ void handle_IRQ(unsigned int irq, struct pt_regs *regs)
* Some hardware gives randomly wrong interrupts. Rather
* than crashing, do something sensible.
*/
- if (unlikely(!irq || irq >= nr_irqs))
+ if (unlikely(!irq || irq >= irq_get_nr_irqs()))
desc = NULL;
else
desc = irq_to_desc(irq);
@@ -151,7 +151,6 @@ void __init init_IRQ(void)
#ifdef CONFIG_SPARSE_IRQ
int __init arch_probe_nr_irqs(void)
{
- nr_irqs = machine_desc->nr_irqs ? machine_desc->nr_irqs : NR_IRQS;
- return nr_irqs;
+ return irq_set_nr_irqs(machine_desc->nr_irqs ? : NR_IRQS);
}
#endif
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 03/22] LoongArch: Switch to irq_set_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 01/22] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 02/22] ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs() Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 04/22] powerpc/cell: Switch to irq_get_nr_irqs() Bart Van Assche
` (18 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
Huacai Chen, WANG Xuerui
Use the irq_set_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
arch/loongarch/kernel/irq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/loongarch/kernel/irq.c b/arch/loongarch/kernel/irq.c
index d129039b368b..80946cafaec1 100644
--- a/arch/loongarch/kernel/irq.c
+++ b/arch/loongarch/kernel/irq.c
@@ -92,9 +92,9 @@ int __init arch_probe_nr_irqs(void)
int nr_io_pics = bitmap_weight(loongson_sysconf.cores_io_master, NR_CPUS);
if (!cpu_has_avecint)
- nr_irqs = (64 + NR_VECTORS * nr_io_pics);
+ irq_set_nr_irqs(64 + NR_VECTORS * nr_io_pics);
else
- nr_irqs = (64 + NR_VECTORS * (nr_cpu_ids + nr_io_pics));
+ irq_set_nr_irqs(64 + NR_VECTORS * (nr_cpu_ids + nr_io_pics));
return NR_IRQS_LEGACY;
}
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 04/22] powerpc/cell: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (2 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 03/22] LoongArch: Switch to irq_set_nr_irqs() Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 05/22] s390/irq: " Bart Van Assche
` (17 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
linuxppc-dev
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
arch/powerpc/platforms/cell/axon_msi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c
index 28dc86744cac..d243f7fd8982 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -112,7 +112,7 @@ static void axon_msi_cascade(struct irq_desc *desc)
pr_devel("axon_msi: woff %x roff %x msi %x\n",
write_offset, msic->read_offset, msi);
- if (msi < nr_irqs && irq_get_chip_data(msi) == msic) {
+ if (msi < irq_get_nr_irqs() && irq_get_chip_data(msi) == msic) {
generic_handle_irq(msi);
msic->fifo_virt[idx] = cpu_to_le32(0xffffffff);
} else {
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 05/22] s390/irq: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (3 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 04/22] powerpc/cell: Switch to irq_get_nr_irqs() Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 06/22] x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
` (16 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
Heiko Carstens
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
arch/s390/kernel/irq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index 2639a3d12736..a2c867181b5a 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -253,7 +253,7 @@ int show_interrupts(struct seq_file *p, void *v)
seq_putc(p, '\n');
goto out;
}
- if (index < nr_irqs) {
+ if (index < irq_get_nr_irqs()) {
show_msi_interrupt(p, index);
goto out;
}
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 06/22] x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (4 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 05/22] s390/irq: " Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-09 9:07 ` Thomas Gleixner
2024-10-08 20:25 ` [PATCH v2 07/22] hpet: Switch to irq_get_nr_irqs() Bart Van Assche
` (15 subsequent siblings)
21 siblings, 1 reply; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
Ingo Molnar, Borislav Petkov, Rafael J. Wysocki
Use the irq_get_nr_irqs() and irq_set_nr_irqs() functions instead of the
global variable 'nr_irqs'. This patch prepares for changing 'nr_irqs' from
an exported global variable into a variable with file scope.
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
arch/x86/kernel/acpi/boot.c | 6 ++++--
arch/x86/kernel/apic/vector.c | 8 ++++----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 4efecac49863..3a44a9dc3fb7 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1171,7 +1171,8 @@ static int __init acpi_parse_madt_ioapic_entries(void)
}
count = acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE,
- acpi_parse_int_src_ovr, nr_irqs);
+ acpi_parse_int_src_ovr,
+ irq_get_nr_irqs());
if (count < 0) {
pr_err("Error parsing interrupt source overrides entry\n");
/* TBD: Cleanup to allow fallback to MPS */
@@ -1191,7 +1192,8 @@ static int __init acpi_parse_madt_ioapic_entries(void)
mp_config_acpi_legacy_irqs();
count = acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE,
- acpi_parse_nmi_src, nr_irqs);
+ acpi_parse_nmi_src,
+ irq_get_nr_irqs());
if (count < 0) {
pr_err("Error parsing NMI SRC entry\n");
/* TBD: Cleanup to allow fallback to MPS */
diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 557318145038..736f62812f5c 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -712,8 +712,8 @@ int __init arch_probe_nr_irqs(void)
{
int nr;
- if (nr_irqs > (NR_VECTORS * nr_cpu_ids))
- nr_irqs = NR_VECTORS * nr_cpu_ids;
+ if (irq_get_nr_irqs() > NR_VECTORS * nr_cpu_ids)
+ irq_set_nr_irqs(NR_VECTORS * nr_cpu_ids);
nr = (gsi_top + nr_legacy_irqs()) + 8 * nr_cpu_ids;
#if defined(CONFIG_PCI_MSI)
@@ -725,8 +725,8 @@ int __init arch_probe_nr_irqs(void)
else
nr += gsi_top * 16;
#endif
- if (nr < nr_irqs)
- nr_irqs = nr;
+ if (nr < irq_get_nr_irqs())
+ irq_set_nr_irqs(nr);
/*
* We don't know if PIC is present at this point so we need to do
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 07/22] hpet: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (5 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 06/22] x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 08/22] net: 3com: 3c59x: " Bart Van Assche
` (14 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
Clemens Ladisch
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/char/hpet.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index e904e476e49a..48fe96ab4649 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -162,6 +162,7 @@ static irqreturn_t hpet_interrupt(int irq, void *data)
static void hpet_timer_set_irq(struct hpet_dev *devp)
{
+ const unsigned int nr_irqs = irq_get_nr_irqs();
unsigned long v;
int irq, gsi;
struct hpet_timer __iomem *timer;
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 08/22] net: 3com: 3c59x: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (6 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 07/22] hpet: Switch to irq_get_nr_irqs() Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 09/22] net: hamradio: baycom_ser_fdx: " Bart Van Assche
` (13 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
Steffen Klassert
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Steffen Klassert <klassert@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/net/ethernet/3com/3c59x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c
index 082388bb6169..790270912913 100644
--- a/drivers/net/ethernet/3com/3c59x.c
+++ b/drivers/net/ethernet/3com/3c59x.c
@@ -1302,7 +1302,7 @@ static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq,
if (print_info)
pr_cont(", IRQ %d\n", dev->irq);
/* Tell them about an invalid IRQ. */
- if (dev->irq <= 0 || dev->irq >= nr_irqs)
+ if (dev->irq <= 0 || dev->irq >= irq_get_nr_irqs())
pr_warn(" *** Warning: IRQ %d is unlikely to work! ***\n",
dev->irq);
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 09/22] net: hamradio: baycom_ser_fdx: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (7 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 08/22] net: 3com: 3c59x: " Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 10/22] net: hamradio: scc: " Bart Van Assche
` (12 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
Thomas Sailer
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Thomas Sailer <t.sailer@alumni.ethz.ch>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/net/hamradio/baycom_ser_fdx.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c
index 646f605e358f..799f8ece7824 100644
--- a/drivers/net/hamradio/baycom_ser_fdx.c
+++ b/drivers/net/hamradio/baycom_ser_fdx.c
@@ -373,6 +373,7 @@ static enum uart ser12_check_uart(unsigned int iobase)
static int ser12_open(struct net_device *dev)
{
+ const unsigned int nr_irqs = irq_get_nr_irqs();
struct baycom_state *bc = netdev_priv(dev);
enum uart u;
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 10/22] net: hamradio: scc: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (8 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 09/22] net: hamradio: baycom_ser_fdx: " Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 11/22] scsi: aha152x: " Bart Van Assche
` (11 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
Joerg Reuter
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Joerg Reuter <jreuter@yaina.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/net/hamradio/scc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index a9184a78650b..c71e52249289 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -1460,6 +1460,7 @@ scc_start_calibrate(struct scc_channel *scc, int duration, unsigned char pattern
static void z8530_init(void)
{
+ const unsigned int nr_irqs = irq_get_nr_irqs();
struct scc_channel *scc;
int chip, k;
unsigned long flags;
@@ -1735,7 +1736,7 @@ static int scc_net_siocdevprivate(struct net_device *dev,
if (hwcfg.irq == 2) hwcfg.irq = 9;
- if (hwcfg.irq < 0 || hwcfg.irq >= nr_irqs)
+ if (hwcfg.irq < 0 || hwcfg.irq >= irq_get_nr_irqs())
return -EINVAL;
if (!Ivec[hwcfg.irq].used && hwcfg.irq)
@@ -2117,6 +2118,7 @@ static int __init scc_init_driver (void)
static void __exit scc_cleanup_driver(void)
{
+ const unsigned int nr_irqs = irq_get_nr_irqs();
io_port ctrl;
int k;
struct scc_channel *scc;
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 11/22] scsi: aha152x: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (9 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 10/22] net: hamradio: scc: " Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 12/22] serial: core: " Bart Van Assche
` (10 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
Juergen E. Fischer
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Juergen E. Fischer <fischer@norbit.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/aha152x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index a0fb330b8df5..4276f868cd91 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -295,7 +295,7 @@ CMD_INC_RESID(struct scsi_cmnd *cmd, int inc)
#else
#define IRQ_MIN 9
#if defined(__PPC)
-#define IRQ_MAX (nr_irqs-1)
+#define IRQ_MAX (irq_get_nr_irqs()-1)
#else
#define IRQ_MAX 12
#endif
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 12/22] serial: core: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (10 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 11/22] scsi: aha152x: " Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 13/22] serial: 8250: " Bart Van Assche
` (9 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/tty/serial/serial_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index d94d73e45fb6..74fa02b23772 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -919,7 +919,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
if (uport->ops->verify_port)
retval = uport->ops->verify_port(uport, new_info);
- if ((new_info->irq >= nr_irqs) || (new_info->irq < 0) ||
+ if ((new_info->irq >= irq_get_nr_irqs()) || (new_info->irq < 0) ||
(new_info->baud_base < 9600))
retval = -EINVAL;
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 13/22] serial: 8250: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (11 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 12/22] serial: core: " Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 14/22] serial: amba-pl010: " Bart Van Assche
` (8 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/tty/serial/8250/8250_port.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 3509af7dc52b..0b886c0924da 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -3176,7 +3176,7 @@ static void serial8250_config_port(struct uart_port *port, int flags)
static int
serial8250_verify_port(struct uart_port *port, struct serial_struct *ser)
{
- if (ser->irq >= nr_irqs || ser->irq < 0 ||
+ if (ser->irq >= irq_get_nr_irqs() || ser->irq < 0 ||
ser->baud_base < 9600 || ser->type < PORT_UNKNOWN ||
ser->type >= ARRAY_SIZE(uart_config) || ser->type == PORT_CIRRUS ||
ser->type == PORT_STARTECH)
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 14/22] serial: amba-pl010: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (12 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 13/22] serial: 8250: " Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 15/22] serial: amba-pl011: " Bart Van Assche
` (7 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/tty/serial/amba-pl010.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
index eabbf8afc9b5..c3a7fad02ac9 100644
--- a/drivers/tty/serial/amba-pl010.c
+++ b/drivers/tty/serial/amba-pl010.c
@@ -499,7 +499,7 @@ static int pl010_verify_port(struct uart_port *port, struct serial_struct *ser)
int ret = 0;
if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMBA)
ret = -EINVAL;
- if (ser->irq < 0 || ser->irq >= nr_irqs)
+ if (ser->irq < 0 || ser->irq >= irq_get_nr_irqs())
ret = -EINVAL;
if (ser->baud_base < 9600)
ret = -EINVAL;
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 15/22] serial: amba-pl011: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (13 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 14/22] serial: amba-pl010: " Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 16/22] serial: cpm_uart: " Bart Van Assche
` (6 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/tty/serial/amba-pl011.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 7d0134ecd82f..1c60850030b1 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2202,7 +2202,7 @@ static int pl011_verify_port(struct uart_port *port, struct serial_struct *ser)
if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMBA)
ret = -EINVAL;
- if (ser->irq < 0 || ser->irq >= nr_irqs)
+ if (ser->irq < 0 || ser->irq >= irq_get_nr_irqs())
ret = -EINVAL;
if (ser->baud_base < 9600)
ret = -EINVAL;
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 16/22] serial: cpm_uart: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (14 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 15/22] serial: amba-pl011: " Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 17/22] serial: ucc_uart: " Bart Van Assche
` (5 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/tty/serial/cpm_uart.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/cpm_uart.c b/drivers/tty/serial/cpm_uart.c
index a927478f581d..6eb8625de435 100644
--- a/drivers/tty/serial/cpm_uart.c
+++ b/drivers/tty/serial/cpm_uart.c
@@ -631,7 +631,7 @@ static int cpm_uart_verify_port(struct uart_port *port,
if (ser->type != PORT_UNKNOWN && ser->type != PORT_CPM)
ret = -EINVAL;
- if (ser->irq < 0 || ser->irq >= nr_irqs)
+ if (ser->irq < 0 || ser->irq >= irq_get_nr_irqs())
ret = -EINVAL;
if (ser->baud_base < 9600)
ret = -EINVAL;
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 17/22] serial: ucc_uart: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (15 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 16/22] serial: cpm_uart: " Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 18/22] sh: intc: " Bart Van Assche
` (4 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
Timur Tabi
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Timur Tabi <timur@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/tty/serial/ucc_uart.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
index 53bb8c5ef499..4eed909468ff 100644
--- a/drivers/tty/serial/ucc_uart.c
+++ b/drivers/tty/serial/ucc_uart.c
@@ -1045,7 +1045,7 @@ static int qe_uart_verify_port(struct uart_port *port,
if (ser->type != PORT_UNKNOWN && ser->type != PORT_CPM)
return -EINVAL;
- if (ser->irq < 0 || ser->irq >= nr_irqs)
+ if (ser->irq < 0 || ser->irq >= irq_get_nr_irqs())
return -EINVAL;
if (ser->baud_base < 9600)
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 18/22] sh: intc: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (16 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 17/22] serial: ucc_uart: " Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 19/22] xen/events: " Bart Van Assche
` (3 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
Yoshinori Sato
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/sh/intc/virq-debugfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/sh/intc/virq-debugfs.c b/drivers/sh/intc/virq-debugfs.c
index 939915a07d99..5dd8febe6da5 100644
--- a/drivers/sh/intc/virq-debugfs.c
+++ b/drivers/sh/intc/virq-debugfs.c
@@ -18,6 +18,7 @@
static int intc_irq_xlate_show(struct seq_file *m, void *priv)
{
+ const unsigned int nr_irqs = irq_get_nr_irqs();
int i;
seq_printf(m, "%-5s %-7s %-15s\n", "irq", "enum", "chip name");
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 19/22] xen/events: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (17 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 18/22] sh: intc: " Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 20/22] fs/procfs: " Bart Van Assche
` (2 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
Juergen Gross
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Juergen Gross <jgross@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/xen/events/events_base.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 81effbd53dc5..985e155ebe4b 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -411,7 +411,7 @@ static evtchn_port_t evtchn_from_irq(unsigned int irq)
{
const struct irq_info *info = NULL;
- if (likely(irq < nr_irqs))
+ if (likely(irq < irq_get_nr_irqs()))
info = info_for_irq(irq);
if (!info)
return 0;
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 20/22] fs/procfs: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (18 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 19/22] xen/events: " Bart Van Assche
@ 2024-10-08 20:25 ` Bart Van Assche
2024-10-08 20:26 ` [PATCH v2 21/22] genirq: " Bart Van Assche
2024-10-08 20:26 ` [PATCH v2 22/22] genirq: Unexport nr_irqs Bart Van Assche
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:25 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
Alexey Dobriyan
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. This patch prepares for changing 'nr_irqs' from an exported
global variable into a variable with file scope.
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
fs/proc/interrupts.c | 4 ++--
fs/proc/stat.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
index cb0edc7cbf09..714a22ded8a8 100644
--- a/fs/proc/interrupts.c
+++ b/fs/proc/interrupts.c
@@ -11,13 +11,13 @@
*/
static void *int_seq_start(struct seq_file *f, loff_t *pos)
{
- return (*pos <= nr_irqs) ? pos : NULL;
+ return *pos <= irq_get_nr_irqs() ? pos : NULL;
}
static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos)
{
(*pos)++;
- if (*pos > nr_irqs)
+ if (*pos > irq_get_nr_irqs())
return NULL;
return pos;
}
diff --git a/fs/proc/stat.c b/fs/proc/stat.c
index da60956b2915..8b444e862319 100644
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -76,7 +76,7 @@ static void show_all_irqs(struct seq_file *p)
seq_put_decimal_ull(p, " ", kstat_irqs_usr(i));
next = i + 1;
}
- show_irq_gap(p, nr_irqs - next);
+ show_irq_gap(p, irq_get_nr_irqs() - next);
}
static int show_stat(struct seq_file *p, void *v)
@@ -196,7 +196,7 @@ static int stat_open(struct inode *inode, struct file *file)
unsigned int size = 1024 + 128 * num_online_cpus();
/* minimum size to display an interrupt count : 2 bytes */
- size += 2 * nr_irqs;
+ size += 2 * irq_get_nr_irqs();
return single_open_size(file, show_stat, NULL, size);
}
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 21/22] genirq: Switch to irq_get_nr_irqs()
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (19 preceding siblings ...)
2024-10-08 20:25 ` [PATCH v2 20/22] fs/procfs: " Bart Van Assche
@ 2024-10-08 20:26 ` Bart Van Assche
2024-10-08 20:26 ` [PATCH v2 22/22] genirq: Unexport nr_irqs Bart Van Assche
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:26 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Cache the result of this function in a local variable in
order not to rely on CSE (common subexpression elimination). This patch
prepares for changing 'nr_irqs' from an exported global variable into a
variable with file scope.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
include/linux/irqnr.h | 33 +++++++++++++++++++--------------
kernel/irq/irqdomain.c | 2 +-
kernel/irq/proc.c | 3 ++-
3 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index 7419b807b71b..a33088d27c54 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -11,26 +11,31 @@ unsigned int irq_set_nr_irqs(unsigned int nr);
extern struct irq_desc *irq_to_desc(unsigned int irq);
unsigned int irq_get_next_irq(unsigned int offset);
-# define for_each_irq_desc(irq, desc) \
- for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \
- irq++, desc = irq_to_desc(irq)) \
- if (!desc) \
- ; \
- else
-
+#define for_each_irq_desc(irq, desc) \
+ for (unsigned int __nr_irqs__ = irq_get_nr_irqs(); __nr_irqs__; \
+ __nr_irqs__ = 0) \
+ for (irq = 0, desc = irq_to_desc(irq); irq < __nr_irqs__; \
+ irq++, desc = irq_to_desc(irq)) \
+ if (!desc) \
+ ; \
+ else
# define for_each_irq_desc_reverse(irq, desc) \
- for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \
- irq--, desc = irq_to_desc(irq)) \
+ for (irq = irq_get_nr_irqs() - 1, desc = irq_to_desc(irq); \
+ irq >= 0; irq--, desc = irq_to_desc(irq)) \
if (!desc) \
; \
else
-# define for_each_active_irq(irq) \
- for (irq = irq_get_next_irq(0); irq < nr_irqs; \
- irq = irq_get_next_irq(irq + 1))
+#define for_each_active_irq(irq) \
+ for (unsigned int __nr_irqs__ = irq_get_nr_irqs(); __nr_irqs__; \
+ __nr_irqs__ = 0) \
+ for (irq = irq_get_next_irq(0); irq < __nr_irqs__; \
+ irq = irq_get_next_irq(irq + 1))
-#define for_each_irq_nr(irq) \
- for (irq = 0; irq < nr_irqs; irq++)
+#define for_each_irq_nr(irq) \
+ for (unsigned int __nr_irqs__ = irq_get_nr_irqs(); __nr_irqs__; \
+ __nr_irqs__ = 0) \
+ for (irq = 0; irq < __nr_irqs__; irq++)
#endif
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index e0bff21f30e0..ec6d8e72d980 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1225,7 +1225,7 @@ int irq_domain_alloc_descs(int virq, unsigned int cnt, irq_hw_number_t hwirq,
virq = __irq_alloc_descs(virq, virq, cnt, node, THIS_MODULE,
affinity);
} else {
- hint = hwirq % nr_irqs;
+ hint = hwirq % irq_get_nr_irqs();
if (hint == 0)
hint++;
virq = __irq_alloc_descs(-1, hint, cnt, node, THIS_MODULE,
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 9081ada81c3d..d226282c5b66 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -457,11 +457,12 @@ int __weak arch_show_interrupts(struct seq_file *p, int prec)
}
#ifndef ACTUAL_NR_IRQS
-# define ACTUAL_NR_IRQS nr_irqs
+# define ACTUAL_NR_IRQS irq_get_nr_irqs()
#endif
int show_interrupts(struct seq_file *p, void *v)
{
+ const unsigned int nr_irqs = irq_get_nr_irqs();
static int prec;
int i = *(loff_t *) v, j;
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 22/22] genirq: Unexport nr_irqs
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
` (20 preceding siblings ...)
2024-10-08 20:26 ` [PATCH v2 21/22] genirq: " Bart Van Assche
@ 2024-10-08 20:26 ` Bart Van Assche
21 siblings, 0 replies; 24+ messages in thread
From: Bart Van Assche @ 2024-10-08 20:26 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche
Unexport nr_irqs and declare it static now that all code that reads or
modifies nr_irqs has been converted to number_of_interrupts() /
set_number_of_interrupts().
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
include/linux/irqnr.h | 1 -
kernel/irq/irqdesc.c | 3 +--
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index a33088d27c54..e97206c721a0 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -5,7 +5,6 @@
#include <uapi/linux/irqnr.h>
-extern int nr_irqs;
unsigned int irq_get_nr_irqs(void) __pure;
unsigned int irq_set_nr_irqs(unsigned int nr);
extern struct irq_desc *irq_to_desc(unsigned int irq);
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index b0733959f8ae..8696500309e3 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -138,8 +138,7 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
desc_smp_init(desc, node, affinity);
}
-int nr_irqs = NR_IRQS;
-EXPORT_SYMBOL_GPL(nr_irqs);
+static int nr_irqs = NR_IRQS;
/**
* irq_get_nr_irqs() - Number of interrupts supported by the system.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH v2 06/22] x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs()
2024-10-08 20:25 ` [PATCH v2 06/22] x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
@ 2024-10-09 9:07 ` Thomas Gleixner
0 siblings, 0 replies; 24+ messages in thread
From: Thomas Gleixner @ 2024-10-09 9:07 UTC (permalink / raw)
To: Bart Van Assche
Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
Ingo Molnar, Borislav Petkov, Rafael J. Wysocki
On Tue, Oct 08 2024 at 13:25, Bart Van Assche wrote:
> Use the irq_get_nr_irqs() and irq_set_nr_irqs() functions instead of the
> global variable 'nr_irqs'. This patch prepares for changing 'nr_irqs' from
> an exported global variable into a variable with file scope.
I asked you this before:
git grep 'This patch' Documentation/process/
Please fix this up all over the place.
Thanks,
tglx
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2024-10-09 9:07 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 20:25 [PATCH v2 00/21] Reduce the scope of 'nr_irqs' Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 01/22] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 02/22] ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs() Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 03/22] LoongArch: Switch to irq_set_nr_irqs() Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 04/22] powerpc/cell: Switch to irq_get_nr_irqs() Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 05/22] s390/irq: " Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 06/22] x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
2024-10-09 9:07 ` Thomas Gleixner
2024-10-08 20:25 ` [PATCH v2 07/22] hpet: Switch to irq_get_nr_irqs() Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 08/22] net: 3com: 3c59x: " Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 09/22] net: hamradio: baycom_ser_fdx: " Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 10/22] net: hamradio: scc: " Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 11/22] scsi: aha152x: " Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 12/22] serial: core: " Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 13/22] serial: 8250: " Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 14/22] serial: amba-pl010: " Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 15/22] serial: amba-pl011: " Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 16/22] serial: cpm_uart: " Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 17/22] serial: ucc_uart: " Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 18/22] sh: intc: " Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 19/22] xen/events: " Bart Van Assche
2024-10-08 20:25 ` [PATCH v2 20/22] fs/procfs: " Bart Van Assche
2024-10-08 20:26 ` [PATCH v2 21/22] genirq: " Bart Van Assche
2024-10-08 20:26 ` [PATCH v2 22/22] genirq: Unexport nr_irqs Bart Van Assche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox