Re: [PATCH 1/2] sparc64: Implement local_irq_save_nmi().

Previous thread: [PATCH][v3.1] blkio: Add io controller stats like by Divyesh Shah on Tuesday, April 6, 2010 - 4:28 pm. (5 messages)

Next thread: [PATCH 2/2] ftrace: Use local_irq_{save,restore}_nmi() in tracers. by David Miller on Tuesday, April 6, 2010 - 4:40 pm. (4 messages)
From: David Miller
Date: Tuesday, April 6, 2010 - 4:39 pm

It disables up to PIL_NMI instead of just PIL_NORMAL_MAX.

Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/arch/sparc/include/asm/irqflags_64.h b/arch/sparc/include/asm/irqflags_64.h
index 8b49bf9..fa1e00e 100644
--- a/arch/sparc/include/asm/irqflags_64.h
+++ b/arch/sparc/include/asm/irqflags_64.h
@@ -49,6 +49,16 @@ static inline void raw_local_irq_disable(void)
 	);
 }
 
+static inline void raw_local_irq_disable_nmi(void)
+{
+	__asm__ __volatile__(
+		"wrpr	%0, %%pil"
+		: /* no outputs */
+		: "i" (PIL_NMI)
+		: "memory"
+	);
+}
+
 static inline void raw_local_irq_enable(void)
 {
 	__asm__ __volatile__(
@@ -83,9 +93,28 @@ static inline unsigned long __raw_local_irq_save(void)
 	return flags;
 }
 
+static inline unsigned long __raw_local_irq_save_nmi(void)
+{
+	unsigned long flags = __raw_local_save_flags();
+
+	raw_local_irq_disable_nmi();
+
+	return flags;
+}
+
 #define raw_local_irq_save(flags) \
 		do { (flags) = __raw_local_irq_save(); } while (0)
 
+#define raw_local_irq_save_nmi(flags) \
+		do { (flags) = __raw_local_irq_save_nmi(); } while (0)
+
+#define local_irq_save_nmi(flags) 			\
+	do {						\
+		 typecheck(unsigned long, flags);	\
+		 raw_local_irq_save_nmi(flags);		\
+		 trace_hardirqs_off();			\
+	} while (0)
+
 #endif /* (__ASSEMBLY__) */
 
 #endif /* !(_ASM_IRQFLAGS_H) */
--

From: Peter Zijlstra
Date: Tuesday, April 6, 2010 - 11:52 pm

Isn't this wrong when used from !NMI context?

Should this thing do something like:

  if (rdpr() < PIL_NORMAL_MAX)
    wrpr(PIL_NORMAL_MAX);

so that it only disables IRQs, but doesn't enable NMIs.
--

From: David Miller
Date: Wednesday, April 7, 2010 - 12:06 am

From: Peter Zijlstra <peterz@infradead.org>

It's immaterial, local_irq_restore() will do the right thing,
and it's ok to disable NMIs in these few cases I think.

I desperately want to avoid that "test and maybe change the
value %pil value we write" business, and honestly that's
the whole point of this exercise.
--

From: Peter Zijlstra
Date: Wednesday, April 7, 2010 - 12:24 am

Sure, its your architecture.. but could you explain why you're trying to
avoid that compare so desperately, the local_irq_save_nmi() calls are
few so surely they could carry that overhead.

Also, doesn't __raw_local_irq_save_flags() already do the read? So its
really just the compare that's gone missing.
--

Previous thread: [PATCH][v3.1] blkio: Add io controller stats like by Divyesh Shah on Tuesday, April 6, 2010 - 4:28 pm. (5 messages)

Next thread: [PATCH 2/2] ftrace: Use local_irq_{save,restore}_nmi() in tracers. by David Miller on Tuesday, April 6, 2010 - 4:40 pm. (4 messages)