[PATCH v4 12/26] genirq: Merge irqaction::{dev_id,percpu_dev_id}

Marc Zyngier posted 26 patches 1 month, 3 weeks ago
[PATCH v4 12/26] genirq: Merge irqaction::{dev_id,percpu_dev_id}
Posted by Marc Zyngier 1 month, 3 weeks ago
When irqaction::percpu_dev_id was introduced, it was hoped that it
could be part of an anonymous union with dev_id, as the two fields
are mutually exclusive.

However, toolchains used at the time were often showing terrible
support for anonymous unions, breaking the build on a number of
architectures. It was therefore decided to keep the two fields separate
and address this down the line.

14 years later, the compiler dark age is over, and there is universal
support for anonymous unions. Let's get a whole pointer back that can
immediately be spent on something else.

Tested-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 include/linux/interrupt.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 51b6484c04934..0ec1a71ab4e84 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -121,8 +121,10 @@ typedef irqreturn_t (*irq_handler_t)(int, void *);
  */
 struct irqaction {
 	irq_handler_t		handler;
-	void			*dev_id;
-	void __percpu		*percpu_dev_id;
+	union {
+		void		*dev_id;
+		void __percpu	*percpu_dev_id;
+	};
 	struct irqaction	*next;
 	irq_handler_t		thread_fn;
 	struct task_struct	*thread;
-- 
2.47.3
Re: [PATCH v4 12/26] genirq: Merge irqaction::{dev_id,percpu_dev_id}
Posted by Jonathan Cameron 1 month ago
On Mon, 20 Oct 2025 13:29:29 +0100
Marc Zyngier <maz@kernel.org> wrote:

> When irqaction::percpu_dev_id was introduced, it was hoped that it
> could be part of an anonymous union with dev_id, as the two fields
> are mutually exclusive.
> 
> However, toolchains used at the time were often showing terrible
> support for anonymous unions, breaking the build on a number of
> architectures. It was therefore decided to keep the two fields separate
> and address this down the line.
> 
> 14 years later, the compiler dark age is over, and there is universal
> support for anonymous unions. Let's get a whole pointer back that can
> immediately be spent on something else.
> 
> Tested-by: Will Deacon <will@kernel.org>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
I'm glad I either never saw that anon union problem or have blanked it from
my mind.

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
[tip: irq/core] genirq: Merge irqaction::{dev_id,percpu_dev_id}
Posted by tip-bot2 for Marc Zyngier 1 month, 2 weeks ago
The following commit has been merged into the irq/core branch of tip:

Commit-ID:     5c2b2cc472e015e79c4f0170893a1e0883bd3bb4
Gitweb:        https://git.kernel.org/tip/5c2b2cc472e015e79c4f0170893a1e0883bd3bb4
Author:        Marc Zyngier <maz@kernel.org>
AuthorDate:    Mon, 20 Oct 2025 13:29:29 +01:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 27 Oct 2025 17:16:34 +01:00

genirq: Merge irqaction::{dev_id,percpu_dev_id}

When irqaction::percpu_dev_id was introduced, it was hoped that it could be
part of an anonymous union with dev_id, as the two fields are mutually
exclusive.

However, toolchains used at the time were often showing terrible support
for anonymous unions, breaking the build on a number of architectures. It
was therefore decided to keep the two fields separate and address this down
the line.

14 years later, the compiler dark age is over, and there is universal
support for anonymous unions. Get a whole pointer back that can immediately
be spent on something else.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Will Deacon <will@kernel.org>
Link: https://patch.msgid.link/20251020122944.3074811-13-maz@kernel.org
---
 include/linux/interrupt.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 51b6484..0ec1a71 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -121,8 +121,10 @@ typedef irqreturn_t (*irq_handler_t)(int, void *);
  */
 struct irqaction {
 	irq_handler_t		handler;
-	void			*dev_id;
-	void __percpu		*percpu_dev_id;
+	union {
+		void		*dev_id;
+		void __percpu	*percpu_dev_id;
+	};
 	struct irqaction	*next;
 	irq_handler_t		thread_fn;
 	struct task_struct	*thread;