Skip to contentSkip to conversation

irq: better struct irqaction layout

PATCH In review Eric Dumazet 2 participants 2 messages Nov 4, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irq: better struct irqaction layout

We currently use kmalloc-96 slab for struct irqaction allocations on 64bit arches.

This is unfortunate because of possible false sharing and two cache lines accesses.

Move 'name' and 'dir' fields at the end of the structure, and force a suitable alignement.

Hot path fields now use one cache line on x86_64.

Cc Thomas Gleixner <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 include/linux/interrupt.h |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/interrupt.h +3 -3
index 79d0c4f..55e0d42 100644
@@ -114,15 +114,15 @@ typedef irqreturn_t (*irq_handler_t)(int, void *);
 struct irqaction {
 	irq_handler_t handler;
 	unsigned long flags;
-	const char *name;
 	void *dev_id;
 	struct irqaction *next;
 	int irq;
-	struct proc_dir_entry *dir;
 	irq_handler_t thread_fn;
 	struct task_struct *thread;
 	unsigned long thread_flags;
-};
+	const char *name;
+	struct proc_dir_entry *dir;
+} ____cacheline_internodealigned_in_smp;
 
 extern irqreturn_t no_action(int cpl, void *dev_id);
 
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Eric Dumazet

We currently use kmalloc-96 slab for struct irqaction allocations on 64bit arches.

This is unfortunate because of possible false sharing and two cache lines accesses.

Move 'name' and 'dir' fields at the end of the structure, and force a suitable alignement.

Hot path fields now use one cache line on x86_64.

Looks good. It would be nice if some of the fields could be merged (like thread_flags and flags), but I assume it would be tought to get it back to 64 bytes again.

-Andi