Skip to contentSkip to conversation

Updates for ipipe-2.6.35-x86

GIT PULL New Jan Kiszka 1 participant 4 messages Nov 25, 2010 x86

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

The following changes since commit 00b6a9994fe4d8c978a9a56d20d01c49fde0a2c3:

Merge branch 'ipipe-2.6.35-noarch' into ipipe-2.6.35-x86 (2010-11-05 13:59:15 +0100)

are available in the git repository at:

git://git.kiszka.org/ipipe-2.6 queues/2.6.35-x86

[edited changelog]
Jan Kiszka (8):
ipipe: Provide wrapper for IRQ mask/unmask at chip level
ipipe: Drop spurious irq_enter/exit from __ipipe_sync_stage
ipipe: Provide __ipipe_spin_trylock_irq for !CONFIG_IPIPE
Merge commit 'v2.6.35.9' into queues/2.6.35-noarch
Merge branch 'queues/2.6.35-noarch' into queues/2.6.35-x86
ipipe: x86-32: Drop IRQ flag virtualization from syscall/interrupt entry/exit
ipipe: x86: Push IF as set to stack of root IRQ handlers
ipipe: x86: Fix up root state after __do_root_[vx]irq under CONFIG_TRACE_IRQFLAGS

Will follow up with the x86-specific ipipe patches for review.

author
#1 lore raw

PATCH 1/3 ipipe: x86-32: Drop IRQ flag virtualization from syscall/interrupt entry/exit

The virtualization of the IRQ flag in entry_32.S turned out to be buggy [1]. Instead of trying to fix it again, this patch removes the virtualization, conceptually aligning x86-32 with x86-64. This simplifies quite some code and should help keeping both in sync /wrt this critical code paths.

[1] http://thread.gmane.org/gmane.linux.kernel.adeos.general/1706

---

Patch is moderately tested (both w/ and w/o IPIPE) and behaved properly so far. Still, careful review would be welcome.

 arch/x86/include/asm/irqflags.h |   42 ++++++++++--------
 arch/x86/kernel/entry_32.S      |   52 +++++++++--------------
 arch/x86/kernel/ipipe.c         |   88 +-------------------------------------
 3 files changed, 47 insertions(+), 135 deletions(-)
arch/x86/include/asm/irqflags.h +23 -19
index 59c8be8..5c18214 100644
@@ -213,26 +213,15 @@ static inline unsigned long __raw_local_irq_save(void)
 }
 #else
 
+#define ENABLE_INTERRUPTS(x)	sti
+#define DISABLE_INTERRUPTS(x)	cli
+
 #ifdef CONFIG_IPIPE
-#ifdef CONFIG_X86_32
-#define DISABLE_INTERRUPTS(clobbers)	PER_CPU(ipipe_percpu_darray, %eax); btsl $0,(%eax); sti
-#define ENABLE_INTERRUPTS(clobbers)	call __ipipe_unstall_root
-#else /* CONFIG_X86_64 */
-/* Not worth virtualizing in x86_64 mode. */
-#define DISABLE_INTERRUPTS(clobbers)	cli
-#define ENABLE_INTERRUPTS(clobbers)	sti
-#endif /* CONFIG_X86_64 */
 #define ENABLE_INTERRUPTS_HW_COND	sti
 #define DISABLE_INTERRUPTS_HW_COND	cli
-#define DISABLE_INTERRUPTS_HW(clobbers)	cli
-#define ENABLE_INTERRUPTS_HW(clobbers)	sti
 #else /* !CONFIG_IPIPE */
-#define ENABLE_INTERRUPTS(x)		sti
-#define DISABLE_INTERRUPTS(x)		cli
 #define ENABLE_INTERRUPTS_HW_COND
 #define DISABLE_INTERRUPTS_HW_COND
-#define DISABLE_INTERRUPTS_HW(clobbers)	DISABLE_INTERRUPTS(clobbers)
-#define ENABLE_INTERRUPTS_HW(clobbers)	ENABLE_INTERRUPTS(clobbers)
 #endif /* !CONFIG_IPIPE */
 
 #ifdef CONFIG_X86_64
@@ -323,23 +312,38 @@ static inline int raw_irqs_disabled(void)
 #endif
 
 #ifdef CONFIG_TRACE_IRQFLAGS
-# if defined(CONFIG_IPIPE) && defined(CONFIG_X86_64)
-#  define TRACE_IRQS_ON				\
+# ifdef CONFIG_IPIPE
+#  ifdef CONFIG_X86_64
+#   define TRACE_IRQS_ON			\
 	call trace_hardirqs_on_thunk;		\
 	pushq %rax;				\
 	PER_CPU(ipipe_percpu_darray, %rax);	\
 	btrl $0,(%rax);				\
 	popq %rax
-#  define TRACE_IRQS_OFF			\
+#   define TRACE_IRQS_OFF			\
 	pushq %rax;				\
 	PER_CPU(ipipe_percpu_darray, %rax);	\
 	btsl $0,(%rax);				\
 	popq %rax;				\
 	call trace_hardirqs_off_thunk
-# else /* !(CONFIG_IPIPE && CONFIG_X86_64) */
+#  else /* CONFIG_X86_32 */
+#   define TRACE_IRQS_ON			\
+	call trace_hardirqs_on_thunk;		\
+	pushl %eax;				\
+	PER_CPU(ipipe_percpu_darray, %eax);	\
+	btrl $0,(%eax);				\
+	popl %eax
+#   define TRACE_IRQS_OFF			\
+	pushl %eax;				\
+	PER_CPU(ipipe_percpu_darray, %eax);	\
+	btsl $0,(%eax);				\
+	popl %eax;				\
+	call trace_hardirqs_off_thunk
+#  endif /* CONFIG_X86_32 */
+# else /* !CONFIG_IPIPE */
 #  define TRACE_IRQS_ON		call trace_hardirqs_on_thunk;
 #  define TRACE_IRQS_OFF	call trace_hardirqs_off_thunk;
-# endif /* !(CONFIG_IPIPE && CONFIG_X86_64) */
+# endif /* !CONFIG_IPIPE */
 #else
 #  define TRACE_IRQS_ON
 #  define TRACE_IRQS_OFF
arch/x86/kernel/entry_32.S +21 -31

156 lines not on this page · raw message

arch/x86/kernel/ipipe.c +3 -85

123 lines not on this page · raw message

Signature · 1 line
1.7.1
author
#2 lore raw

PATCH 2/3 ipipe: x86: Push IF as set to stack of root IRQ handlers

In reply to Jan Kiszka

Preemption check of the Linux interrupt tail verifies, among other things, that IF set for the preempted context. If it's not, no Linux task switch is initiated. As we fake the context on root IRQ replay, we must ensure that IF is faked properly as well, otherwise long Linux rescheduling latencies up to deadlocks can occur.

Based on suggestion by Philippe.

---
 arch/x86/include/asm/ipipe_32.h |    8 ++++++--
 arch/x86/include/asm/ipipe_64.h |    8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)
arch/x86/include/asm/ipipe_32.h +6 -2
index 4263a7f..61d7913 100644
@@ -70,6 +70,7 @@ static inline void __do_root_xirq(ipipe_irq_handler_t handler,
 	regs->orig_ax = ~__ipipe_get_irq_vector(irq);
 
 	__asm__ __volatile__("pushfl\n\t"
+			     "orl %[x86if],(%%esp)\n\t"
 			     "pushl %%cs\n\t"
 			     "pushl $__xirq_end\n\t"
 			     "pushl %%eax\n\t"
@@ -89,7 +90,8 @@ static inline void __do_root_xirq(ipipe_irq_handler_t handler,
 			     "jmp ret_from_intr\n\t"
 			     "__xirq_end: cli\n"
 			     : /* no output */
-			     : "a" (~irq), "r" (handler), "rm" (regs));
+			     : "a" (~irq), "r" (handler), "rm" (regs),
+			       [x86if] "i" (X86_EFLAGS_IF));
 }
 
 #define __ipipe_do_root_xirq(ipd, irq)			\
@@ -103,6 +105,7 @@ static inline void __do_root_virq(ipipe_irq_handler_t handler,
 
 	irq_enter();
 	__asm__ __volatile__("pushfl\n\t"
+			     "orl %[x86if],(%%esp)\n\t"
 			     "pushl %%cs\n\t"
 			     "pushl $__virq_end\n\t"
 			     "pushl $-1\n\t"
@@ -122,7 +125,8 @@ static inline void __do_root_virq(ipipe_irq_handler_t handler,
 			     "call *%1\n\t"
 			     "addl $8,%%esp\n"
 			     : /* no output */
-			     : "a" (irq), "r" (handler), "d" (cookie));
+			     : "a" (irq), "r" (handler), "d" (cookie),
+			       [x86if] "i" (X86_EFLAGS_IF));
 	irq_exit();
 	__asm__ __volatile__("jmp ret_from_intr\n\t"
 			     "__virq_end: cli\n"
arch/x86/include/asm/ipipe_64.h +6 -2
index b9367f6..c8f2c54 100644
@@ -71,6 +71,7 @@ static inline void __do_root_xirq(ipipe_irq_handler_t handler,
 			     "pushq $0\n\t"
 			     "pushq %%rax\n\t"
 			     "pushfq\n\t"
+			     "orq %[x86if],(%%rsp)\n\t"
 			     "pushq %[kernel_cs]\n\t"
 			     "pushq $__xirq_end\n\t"
 			     "pushq %[vector]\n\t"
@@ -91,7 +92,8 @@ static inline void __do_root_xirq(ipipe_irq_handler_t handler,
 			     : /* no output */
 			     : [kernel_cs] "i" (__KERNEL_CS),
 			       [vector] "rm" (regs->orig_ax),
-			       [handler] "r" (handler), "D" (regs)
+			       [handler] "r" (handler), "D" (regs),
+			       [x86if] "i" (X86_EFLAGS_IF)
 			     : "rax");
 }
 
@@ -109,6 +111,7 @@ static inline void __do_root_virq(ipipe_irq_handler_t handler,
 			     "pushq $0\n\t"
 			     "pushq %%rax\n\t"
 			     "pushfq\n\t"
+			     "orq %[x86if],(%%rsp)\n\t"
 			     "pushq %[kernel_cs]\n\t"
 			     "pushq $__virq_end\n\t"
 			     "pushq $-1\n\t"
@@ -125,7 +128,8 @@ static inline void __do_root_virq(ipipe_irq_handler_t handler,
 			     "call  *%[handler]\n\t"
 			     : /* no output */
 			     : [kernel_cs] "i" (__KERNEL_CS),
-			       [handler] "r" (handler), "D" (irq), "S" (cookie)
+			       [handler] "r" (handler), "D" (irq),
+			       "S" (cookie), [x86if] "i" (X86_EFLAGS_IF)
 			     : "rax");
 	irq_exit();
 	__asm__ __volatile__("cli\n\t"
Signature · 1 line
1.7.1
author
#3 lore raw

PATCH 3/3 ipipe: x86: Fix up root state after __do_root_[vx]irq under CONFIG_TRACE_IRQFLAGS

In reply to Jan Kiszka

As TRACE_IRQS_ON, thus also TRACE_IRQS_IRET, synchronizes the root pipeline state with the pseudo state that __do_root_[vx]irq creates on entry. We need to fix that up, disabling root IRQs again as __ipipe_sync_stage may inject more IRQs.

---
 arch/x86/include/asm/ipipe_32.h |    9 +++++++++
 arch/x86/include/asm/ipipe_64.h |    9 +++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)
arch/x86/include/asm/ipipe_32.h +9 -0
index 61d7913..38d7870 100644
@@ -92,6 +92,11 @@ static inline void __do_root_xirq(ipipe_irq_handler_t handler,
 			     : /* no output */
 			     : "a" (~irq), "r" (handler), "rm" (regs),
 			       [x86if] "i" (X86_EFLAGS_IF));
+#ifdef CONFIG_TRACE_IRQFLAGS
+	/* TRACE_IRQS_IRET fully enables root IRQs - disable them again in
+	 * case __ipipe_sync_stage injects another one. */
+	local_irq_disable();
+#endif
 }
 
 #define __ipipe_do_root_xirq(ipd, irq)			\
@@ -132,6 +137,10 @@ static inline void __do_root_virq(ipipe_irq_handler_t handler,
 			     "__virq_end: cli\n"
 			     : /* no output */
 			     : /* no input */);
+#ifdef CONFIG_TRACE_IRQFLAGS
+	/* see __do_root_xirq */
+	local_irq_disable();
+#endif
 }
 
 #define __ipipe_do_root_virq(ipd, irq)	\
arch/x86/include/asm/ipipe_64.h +9 -0
index c8f2c54..91d7397 100644
@@ -95,6 +95,11 @@ static inline void __do_root_xirq(ipipe_irq_handler_t handler,
 			       [handler] "r" (handler), "D" (regs),
 			       [x86if] "i" (X86_EFLAGS_IF)
 			     : "rax");
+#ifdef CONFIG_TRACE_IRQFLAGS
+	/* TRACE_IRQS_IRETQ fully enables root IRQs - disable them again in
+	 * case __ipipe_sync_stage injects another one. */
+	local_irq_disable();
+#endif
 }
 
 #define __ipipe_do_root_xirq(ipd, irq)			\
@@ -137,6 +142,10 @@ static inline void __do_root_virq(ipipe_irq_handler_t handler,
 			     "__virq_end: cli\n"
 			     : /* no output */
 			     : /* no input */);
+#ifdef CONFIG_TRACE_IRQFLAGS
+	/* see __do_root_xirq */
+	local_irq_disable();
+#endif
 }
 
 #define __ipipe_do_root_virq(ipd, irq)	\
Signature · 1 line
1.7.1