Skip to contentSkip to conversation

spinlock.h cleanup

PATCH In review Robert Love 4 participants 9 messages Jul 29, 2002 – Jul 30, 2002

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spinlock.h cleanup

Linus,

Ingo's IRQ rewrite cleaned up include/linux/spinlock.h a bit but it still resembles a dying albatross. Some of the defines are redundant, the coding style used by the remaining defines is likely drug induced, and there are a couple other issues...

- cleanup #defines: I do not follow the rationale behind the odd
line-wrapped defines at the beginning of the file. If we have to
use multiple lines, then we might as well do so cleanly and
according to normal practice...

- we do not need to define the spin_lock functions twice, once for CONFIG_PREEMPT and once for !CONFIG_PREEMPT. Defining them once with the preempt macros will optimize away fine.

- remove the egcs compiler workarounds: we do not need them

- other misc. minor cleanup, improved comments, et cetera

Tested on UP, SMP, and preempt. Object code is unchanged. Patch is against 2.5-bk but should apply to 2.5.29. Please, apply.

Robert Love

include/linux/preempt.h +6 -1
diff -urN linux-2.5.29-bk/include/linux/preempt.h linux/include/linux/preempt.h
@@ -1,6 +1,11 @@
 #ifndef __LINUX_PREEMPT_H
 #define __LINUX_PREEMPT_H
 
+/*
+ * include/linux/preempt.h - macros for accessing and manipulating
+ * preempt_count (used for kernel preemption, interrupt count, etc.)
+ */
+
 #include <linux/config.h>
 
 #define preempt_count() (current_thread_info()->preempt_count)
@@ -37,7 +42,7 @@
 #else
 
 #define preempt_disable()		do { } while (0)
-#define preempt_enable_no_resched()	do {} while(0)
+#define preempt_enable_no_resched()	do { } while (0)
 #define preempt_enable()		do { } while (0)
 #define preempt_check_resched()		do { } while (0)
 
include/linux/spinlock.h +81 -65

193 lines not on this page · raw message

#1 lore raw
Quoted 3 lines · Robert Love

Tested on UP, SMP, and preempt. Object code is unchanged. Patch is against 2.5-bk but should apply to 2.5.29. Please, apply.

Hmm.. Why did you remove the gcc workaround? Are all gcc's > 2.95 known to be ok wrt empty initializers?

Linus

#2 lore raw
Quoted 2 lines · Linus Torvalds

Hmm.. Why did you remove the gcc workaround? Are all gcc's > 2.95 known to be ok wrt empty initializers?

I hope so, we only check for gcc < 2.0.

If I recall correctly, the fix was for older egcs compilers.

Robert Love

#3 lore raw
Quoted 6 lines · Robert Love
Quoted 2 lines · Linus Torvalds

Hmm.. Why did you remove the gcc workaround? Are all gcc's > 2.95 known to be ok wrt empty initializers?

If I recall correctly, the fix was for older egcs compilers.

To better answer your question, I just checked and indeed it seems all gcc's >= 2.95 are OK.

Robert Love

#4 lore raw
Quoted 2 lines · Robert Love

To better answer your question, I just checked and indeed it seems all gcc's >= 2.95 are OK.

I was informed by Andrew Morton that he uses egcs... normally I would prefer to abandon an old compiler, but Andrew is an immediate exception in my book :)

I do not know if egcs 1.1.2 has the bug or not. For Andrew's sake, and architectures that still recommend egcs-1.1.2, attached is a version of the patch that keeps the compiler workaround.

We can either merge the original and see who screams or merge this now... either is fine with me. If the former, I will be prepared to send of a patch to restore the workaround.

Robert Love

include/linux/preempt.h +6 -1
diff -urN linux-2.5.29-bk/include/linux/preempt.h linux/include/linux/preempt.h
@@ -1,6 +1,11 @@
 #ifndef __LINUX_PREEMPT_H
 #define __LINUX_PREEMPT_H
 
+/*
+ * include/linux/preempt.h - macros for accessing and manipulating
+ * preempt_count (used for kernel preemption, interrupt count, etc.)
+ */
+
 #include <linux/config.h>
 
 #define preempt_count() (current_thread_info()->preempt_count)
@@ -37,7 +42,7 @@
 #else
 
 #define preempt_disable()		do { } while (0)
-#define preempt_enable_no_resched()	do {} while(0)
+#define preempt_enable_no_resched()	do { } while (0)
 #define preempt_enable()		do { } while (0)
 #define preempt_check_resched()		do { } while (0)
 
include/linux/spinlock.h +78 -48

158 lines not on this page · raw message

#5 lore raw
In reply to Robert Love

From: Robert Love <[email protected]>
Date: 29 Jul 2002 17:33:39 -0700

Quoted 6 lines · Robert Love
Quoted 2 lines · Linus Torvalds

Hmm.. Why did you remove the gcc workaround? Are all gcc's > 2.95 known to be ok wrt empty initializers?

If I recall correctly, the fix was for older egcs compilers.

To better answer your question, I just checked and indeed it seems all gcc's >= 2.95 are OK.

Some platforms (sparc64) are still using things like egcs-2.92.x vintage compilers as their main supported kernel build compiler.

init/main.c allows 2.91 or greater to pass so that should be the rule enforced kernel wide.

I don't remember when the empty initializer thing was fixed.

#6 lore raw
In reply to Robert Love
Quoted 2 lines · Robert Love

I hope so, we only check for gcc < 2.0.

Check that again. The old check was for "(__GNUC__ > 2)", ie it would only trigger for gcc-3 and up.

Quoted 1 line

If I recall correctly, the fix was for older egcs compilers.

I've got this memory of fairly recent gcc's messing up on sparc, for example.

Linus

#7 lore raw

Em Mon, Jul 29, 2002 at 06:46:40PM -0700, Linus Torvalds escreveu:

Quoted 5 lines · Robert Love
Quoted 1 line

If I recall correctly, the fix was for older egcs compilers.

I've got this memory of fairly recent gcc's messing up on sparc, for example.

And IIRC the current supported compiled for Sparc32 is an old hacked egcs.

- Arnaldo

#8 lore raw
In reply to Linus Torvalds
Quoted 2 lines · Linus Torvalds

Check that again. The old check was for "(__GNUC__ > 2)", ie it would only trigger for gcc-3 and up.

Err, right.

Quoted 4 lines
Quoted 1 line

If I recall correctly, the fix was for older egcs compilers.

I've got this memory of fairly recent gcc's messing up on sparc, for example.

The problem is indeed fixed in 2.95... the problem is not with those compilers on sparc but that sparc64 uses an old compiler (DaveM recommends 2.91.66 for sparc64).

Consequently, I sent you a rediff of the patch - this time without removing the compiler workaround. It should be acceptable.

Robert Love