Skip to contentSkip to conversation

cpu_relax(): interrupt.h

PATCH In review Andreas Mohr 2 participants 2 messages Jun 21, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 cpu_relax(): interrupt.h

Add cpu_relax() to tasklet_unlock_wait() loop.

I kept barrier() since it is said to still be required, in various older postings.
Took care of kernel style formatting.

Tested on 2.6.17-mm1.

This is the first patch within a set, which aims to improve P4 HT performance a bit:
these SMT CPUs want a rep nop (pause) (as done by cpu_relax()) when busy-polling, in order to free pipeline resources for the SMT CPU sibling.

During I/O polling cpu_relax() will help for non-P4 CPUs, too (reduce power consumption there).

include/linux/interrupt.h +4 -1
diff -urN linux-2.6.17-mm1.orig/include/linux/interrupt.h linux-2.6.17-mm1.my/include/linux/interrupt.h
@@ -227,7 +227,10 @@
 
 static inline void tasklet_unlock_wait(struct tasklet_struct *t)
 {
-	while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
+	while (test_bit(TASKLET_STATE_RUN, &(t)->state)) {
+		barrier();
+		cpu_relax();
+	}
 }
 #else
 #define tasklet_trylock(t) 1
#1 lore raw
Quoted 5 lines · Andreas Mohr

Add cpu_relax() to tasklet_unlock_wait() loop.

I kept barrier() since it is said to still be required, in various older postings.

cpu_relax() includes a barrier always, per definition. (simply because anywhere you would use cpu_relax() you would also put a barrier)