Skip to contentSkip to conversation

genirq/irqaction: Move dev_id and percpu_dev_id in a union

PATCH In review Marc Zyngier 2 participants 3 messages Apr 10, 2021 – Apr 20, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 genirq/irqaction: Move dev_id and percpu_dev_id in a union

dev_id and percpu_dev_id are mutually exclusive in struct irqaction, as they conceptually represent the same thing, only in a per-cpu fashion.

Move them into an anonymous union, saving a few bytes on the way.

---
 include/linux/interrupt.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
include/linux/interrupt.h +4 -2
index 967e25767153..4383ee033acf 100644
@@ -109,8 +109,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;
Signature · 1 line
2.30.2
#1 lore raw
Quoted 5 lines · Marc Zyngier

dev_id and percpu_dev_id are mutually exclusive in struct irqaction, as they conceptually represent the same thing, only in a per-cpu fashion.

Move them into an anonymous union, saving a few bytes on the way.

The reason why they are not in an anomymous union is that any misuse of interfaces will result in an instantaneous explosion while with your variant it will cause hard to diagnose side effects.

I rather waste the extra 4/8 bytes unless there is a compelling reason not to do so.

Thanks,

tglx

#2 lore raw
Quoted 6 lines · Thomas Gleixner
Quoted 4 lines · Marc Zyngier

dev_id and percpu_dev_id are mutually exclusive in struct irqaction, as they conceptually represent the same thing, only in a per-cpu fashion.

Quoted 8 lines
Quoted 1 line

Move them into an anonymous union, saving a few bytes on the way.

The reason why they are not in an anomymous union is that any misuse of interfaces will result in an instantaneous explosion while with your variant it will cause hard to diagnose side effects.

I rather waste the extra 4/8 bytes unless there is a compelling reason not to do so.

Fair enough. I just happened to spot it while doing some vaguely related rework (turning the irqaction.irq field into an irqdesc).

Happy to leave it as is.

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.