Skip to contentSkip to conversation

asm-generic: Use raw_local_irq_save/restore instead local_irq_save/restore

PATCH Steven Rostedt 5 participants 11 messages May 26, 2010 – Jul 28, 2010 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Steven Rostedt

author Acked-by
#2 lore raw
Quoted 9 lines · On Wed, 2010-05-26 at 10:48 +0200, [email protected] wrote:

From: Michal Simek <[email protected]>

start/stop_critical_timing function for preemptirqsoff, preemptoff and irqsoff tracers contains atomic_inc and atomic_dec operations.

Atomic operations used local_irq_save/restore macros to ensure atomic access but they are traced by the same function which is causing recursion problem.

Quoted 7 lines

The reason is when these tracers are turn ON then local_irq_save/restore macros are changed in include/linux/irqflags.h to call trace_hardirqs_on/off which call start/stop_critical_timing.

Microblaze was affected because use generic atomic implementation.

-- Steve

Quoted 48 lines
---
 include/asm-generic/atomic.h |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
include/asm-generic/atomic.h +6 -6
index 058129e..6c190fd 100644
@@ -57,11 +57,11 @@ static inline int atomic_add_return(int i, atomic_t *v)
 	unsigned long flags;
 	int temp;
 
-	local_irq_save(flags);
+	raw_local_irq_save(flags);
 	temp = v->counter;
 	temp += i;
 	v->counter = temp;
-	local_irq_restore(flags);
+	raw_local_irq_restore(flags);
 
 	return temp;
 }
@@ -78,11 +78,11 @@ static inline int atomic_sub_return(int i, atomic_t *v)
 	unsigned long flags;
 	int temp;
 
-	local_irq_save(flags);
+	raw_local_irq_save(flags);
 	temp = v->counter;
 	temp -= i;
 	v->counter = temp;
-	local_irq_restore(flags);
+	raw_local_irq_restore(flags);
 
 	return temp;
 }
@@ -135,9 +135,9 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
 	unsigned long flags;
 
 	mask = ~mask;
-	local_irq_save(flags);
+	raw_local_irq_save(flags);
 	*addr &= mask;
-	local_irq_restore(flags);
+	raw_local_irq_restore(flags);
 }
 
 #define atomic_xchg(ptr, v)		(xchg(&(ptr)->counter, (v)))
#3 lore raw
Quoted 14 lines · On Wed, 26 May 2010 10:42:43 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 13 lines · On Wed, 2010-05-26 at 10:48 +0200, [email protected] wrote:

From: Michal Simek <[email protected]>

start/stop_critical_timing function for preemptirqsoff, preemptoff and irqsoff tracers contains atomic_inc and atomic_dec operations.

Atomic operations used local_irq_save/restore macros to ensure atomic access but they are traced by the same function which is causing recursion problem.

The reason is when these tracers are turn ON then local_irq_save/restore macros are changed in include/linux/irqflags.h to call trace_hardirqs_on/off which call start/stop_critical_timing.

Quoted 6 lines
Quoted 3 lines

Microblaze was affected because use generic atomic implementation.

Sighed-at-by: me.

Quoted 16 lines
Quoted 16 lines
include/asm-generic/atomic.h +2 -2
index 058129e..6c190fd 100644
@@ -57,11 +57,11 @@ static inline int atomic_add_return(int i, atomic_t *v)
 	unsigned long flags;
 	int temp;
 
-	local_irq_save(flags);
+	raw_local_irq_save(flags);
 	temp = v->counter;
 	temp += i;
 	v->counter = temp;
-	local_irq_restore(flags);
+	raw_local_irq_restore(flags);
 
Quoted 2 lines

include/asm-generic/atomic.h static inline int atomic_add_return(int i, atomic_t *v) · line 67

Quoted 2 lines
include/asm-generic/atomic.h +0 -0
 	return temp;
 }

If a developer looks at atomic_add_return() and asks himself "why did this use raw_local_irq_save()", the only way of answering that question is to go groveling through the git logs, which is a right PITA if you're trying to get some coding work done.

Guys, any time you add code which is non-obvious at the raw C level, it *needs* a comment!

#4 lore raw
Quoted 8 lines · Andrew Morton

If a developer looks at atomic_add_return() and asks himself "why did this use raw_local_irq_save()", the only way of answering that question is to go groveling through the git logs, which is a right PITA if you're trying to get some coding work done.

Guys, any time you add code which is non-obvious at the raw C level, it *needs* a comment!

Totally agree! I've gotten pretty good at adding comments to changes like this that I do. I need to get better at telling others to comment their work ;-)

-- Steve

#5 lore raw
Quoted 7 lines · Steven Rostedt
Quoted 5 lines · Andrew Morton

If a developer looks at atomic_add_return() and asks himself "why did this use raw_local_irq_save()", the only way of answering that question is to go groveling through the git logs, which is a right PITA if you're trying to get some coding work done.

Quoted 6 lines
Quoted 2 lines

Guys, any time you add code which is non-obvious at the raw C level, it *needs* a comment!

Totally agree! I've gotten pretty good at adding comments to changes like this that I do. I need to get better at telling others to comment their work ;-)

ok. Will add any sensible comment.

Michal

Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian
#6 lore raw
In reply to Steven Rostedt
Quoted 8 lines · Steven Rostedt
Quoted 6 lines · Andrew Morton

If a developer looks at atomic_add_return() and asks himself "why did this use raw_local_irq_save()", the only way of answering that question is to go groveling through the git logs, which is a right PITA if you're trying to get some coding work done.

Quoted 6 lines
Quoted 2 lines

Guys, any time you add code which is non-obvious at the raw C level, it *needs* a comment!

Totally agree! I've gotten pretty good at adding comments to changes like this that I do. I need to get better at telling others to comment their work ;-)

Cc'ed Frederic Weisbecker

Seems like this issue has been raised before:
http://marc.info/?l=linux-kernel&m=126292794806169&w=2

I'm afraid this patch will trigger lockdep warning if atomic_inc() is used in some locks.

Acked-by Steven Rostedt
#7 lore raw
In reply to Andrew Morton
Quoted 48 lines · Andrew Morton
Quoted 10 lines · On Wed, 26 May 2010 10:42:43 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 9 lines · On Wed, 2010-05-26 at 10:48 +0200, [email protected] wrote:

From: Michal Simek <[email protected]>

start/stop_critical_timing function for preemptirqsoff, preemptoff and irqsoff tracers contains atomic_inc and atomic_dec operations.

Atomic operations used local_irq_save/restore macros to ensure atomic access but they are traced by the same function which is causing recursion problem.

Quoted 9 lines
Quoted 7 lines

The reason is when these tracers are turn ON then local_irq_save/restore macros are changed in include/linux/irqflags.h to call trace_hardirqs_on/off which call start/stop_critical_timing.

Microblaze was affected because use generic atomic implementation.

Sighed-at-by: me.

Quoted 16 lines
Quoted 16 lines
include/asm-generic/atomic.h +2 -2
index 058129e..6c190fd 100644
@@ -57,11 +57,11 @@ static inline int atomic_add_return(int i, atomic_t *v)
 	unsigned long flags;
 	int temp;
 
-	local_irq_save(flags);
+	raw_local_irq_save(flags);
 	temp = v->counter;
 	temp += i;
 	v->counter = temp;
-	local_irq_restore(flags);
+	raw_local_irq_restore(flags);
 
Quoted 2 lines

include/asm-generic/atomic.h static inline int atomic_add_return(int i, atomic_t *v) · line 67

Quoted 2 lines
include/asm-generic/atomic.h +0 -0
 	return temp;
 }

If a developer looks at atomic_add_return() and asks himself "why did this use raw_local_irq_save()", the only way of answering that question is to go groveling through the git logs, which is a right PITA if you're trying to get some coding work done.

Quoted 2 lines

Guys, any time you add code which is non-obvious at the raw C level, it *needs* a comment!

Andrew: Can you please add this patch to your tree? I have it in microblaze next branch but should go through different tree.

Thanks,
Michal

Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian
Quoted 1 line

From 06c2447c8939227b4c4d3340fba1c712f03e70ca Mon Sep 17 00:00:00 2001

From: Michal Simek <[email protected]>
Date: Wed, 26 May 2010 08:57:36 +0200
Subject: [PATCH] asm-generic: Use raw_local_irq_save/restore instead local_irq_save/restore

start/stop_critical_timing function for preemptirqsoff, preemptoff and irqsoff tracers contains atomic_inc and atomic_dec operations.

Atomic operations used local_irq_save/restore macros to ensure atomic access but they are traced by the same function which is causing recursion problem.

The reason is when these tracers are turn ON then local_irq_save/restore macros are changed in include/linux/irqflags.h to call trace_hardirqs_on/off which call start/stop_critical_timing.

Microblaze was affected because use generic atomic implementation.

---
 include/asm-generic/atomic.h |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
include/asm-generic/atomic.h +6 -6
index 058129e..e53347f 100644
@@ -57,11 +57,11 @@ static inline int atomic_add_return(int i, atomic_t *v)
 	unsigned long flags;
 	int temp;
 
-	local_irq_save(flags);
+	raw_local_irq_save(flags); /* Don't trace it in a irqsoff handler */
 	temp = v->counter;
 	temp += i;
 	v->counter = temp;
-	local_irq_restore(flags);
+	raw_local_irq_restore(flags);
 
 	return temp;
 }
@@ -78,11 +78,11 @@ static inline int atomic_sub_return(int i, atomic_t *v)
 	unsigned long flags;
 	int temp;
 
-	local_irq_save(flags);
+	raw_local_irq_save(flags); /* Don't trace it in a irqsoff handler */
 	temp = v->counter;
 	temp -= i;
 	v->counter = temp;
-	local_irq_restore(flags);
+	raw_local_irq_restore(flags);
 
 	return temp;
 }
@@ -135,9 +135,9 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
 	unsigned long flags;
 
 	mask = ~mask;
-	local_irq_save(flags);
+	raw_local_irq_save(flags); /* Don't trace it in a irqsoff handler */
 	*addr &= mask;
-	local_irq_restore(flags);
+	raw_local_irq_restore(flags);
 }
 
 #define atomic_xchg(ptr, v)		(xchg(&(ptr)->counter, (v)))
Signature · 1 line
1.5.5.6
#8 lore raw
Quoted 7 lines · On Mon, 26 Jul 2010 10:49:50 +0200 Michal Simek <[email protected]> wrote:

start/stop_critical_timing function for preemptirqsoff, preemptoff and irqsoff tracers contains atomic_inc and atomic_dec operations.

Atomic operations used local_irq_save/restore macros to ensure atomic access but they are traced by the same function which is causing recursion problem.

Quoted 5 lines

The reason is when these tracers are turn ON then local_irq_save/restore macros are changed in include/linux/irqflags.h to call trace_hardirqs_on/off which call start/stop_critical_timing.

Microblaze was affected because use generic atomic implementation.

Seems that this will also affect blackfin, mn10300 and score. I guess they aren't supporting tracing yet?

Quoted 3 lines

hm, I wonder how my signoff got there. Doesn't matter.

#9 lore raw
Quoted 8 lines · Andrew Morton
Quoted 7 lines · On Mon, 26 Jul 2010 10:49:50 +0200 Michal Simek wrote:

start/stop_critical_timing function for preemptirqsoff, preemptoff and irqsoff tracers contains atomic_inc and atomic_dec operations.

Atomic operations used local_irq_save/restore macros to ensure atomic access but they are traced by the same function which is causing recursion problem.

Quoted 8 lines
Quoted 5 lines

The reason is when these tracers are turn ON then local_irq_save/restore macros are changed in include/linux/irqflags.h to call trace_hardirqs_on/off which call start/stop_critical_timing.

Microblaze was affected because use generic atomic implementation.

Seems that this will also affect blackfin, mn10300 and score.  I guess they aren't supporting tracing yet?

do you mean TRACE_IRQFLAGS_SUPPORT ? Blackfin should ... my understanding was that arches just needed to implement asm/irqflags.h for it.
-mike

#10 lore raw
Quoted 13 lines · Mike Frysinger
Quoted 12 lines · Andrew Morton
Quoted 11 lines · On Mon, 26 Jul 2010 10:49:50 +0200 Michal Simek wrote:

start/stop_critical_timing function for preemptirqsoff, preemptoff and irqsoff tracers contains atomic_inc and atomic_dec operations.

Atomic operations used local_irq_save/restore macros to ensure atomic access but they are traced by the same function which is causing recursion problem.

The reason is when these tracers are turn ON then local_irq_save/restore macros are changed in include/linux/irqflags.h to call trace_hardirqs_on/off which call start/stop_critical_timing.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Microblaze was affected because use generic atomic implementation.

Seems that this will also affect blackfin, mn10300 and score. I guess they aren't supporting tracing yet?

do you mean TRACE_IRQFLAGS_SUPPORT ? Blackfin should ... my understanding was that arches just needed to implement asm/irqflags.h for it.

Blackin uses own include/asm/atomic.h implementation where shouldn't be a problem with irqflags tracer. Look at my second post.

Michal

Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian
#11 lore raw
In reply to Andrew Morton
Quoted 10 lines · Andrew Morton
Quoted 7 lines · On Mon, 26 Jul 2010 10:49:50 +0200 Michal Simek <[email protected]> wrote:

start/stop_critical_timing function for preemptirqsoff, preemptoff and irqsoff tracers contains atomic_inc and atomic_dec operations.

Atomic operations used local_irq_save/restore macros to ensure atomic access but they are traced by the same function which is causing recursion problem.

Quoted 8 lines
Quoted 5 lines

The reason is when these tracers are turn ON then local_irq_save/restore macros are changed in include/linux/irqflags.h to call trace_hardirqs_on/off which call start/stop_critical_timing.

Microblaze was affected because use generic atomic implementation.

Seems that this will also affect blackfin, mn10300 and score. I guess they aren't supporting tracing yet?

If they uses asm-generic/atomic.h, then yes. It seems to me that Blackfin uses own asm/atomic.h. nm10300 and score are the same case as Microblaze.

In include/linux/irqflags.h is written this commentary.

/*
* The local_irq_*() APIs are equal to the raw_local_irq*()
* if !TRACE_IRQFLAGS.
*/

If architecture doesn't enable TRACE_IRQFLAGS then there is no difference in behavior. If yes and use asm-generic/atomic.h code, then IRQFLAG tracer freeze because it is traced part of irqsoff tracer because of recursion as is describe in patch description.

Quoted 6 lines
Quoted 4 lines

hm, I wonder how my signoff got there. Doesn't matter.

http://lkml.org/lkml/2010/5/26/364

Michal

Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian