Skip to contentSkip to conversation

Build breakage ...

DISCUSSION Ralf Baechle 6 participants 13 messages Nov 26, 2006 – Nov 27, 2006 Locking primitives

lore
Share & tools
lore
#0 lore raw

ee3ce191e8eaa4cc15c51a28b34143b36404c4f5 breaks MIPS completely:

In file included from include/linux/bitops.h:9,
from include/linux/thread_info.h:20,
from include/linux/preempt.h:9,
from include/linux/spinlock.h:49,
from include/linux/capability.h:45,
from include/linux/sched.h:46,
from arch/mips/kernel/asm-offsets.c:13:
include/asm/bitops.h: In function ‘set_bit’:
include/asm/bitops.h:100: warning: implicit declaration of function ‘BUILD_BUG_ON’ include/asm/bitops.h:100: warning: implicit declaration of function ‘typecheck’ include/asm/bitops.h:100: error: expected expression before ‘unsigned’ include/asm/bitops.h:102: error: expected expression before ‘unsigned’ include/asm/bitops.h: In function ‘clear_bit’:
include/asm/bitops.h:148: error: expected expression before ‘unsigned’ include/asm/bitops.h:150: error: expected expression before ‘unsigned’ include/asm/bitops.h: In function ‘change_bit’:
include/asm/bitops.h:198: error: expected expression before ‘unsigned’ include/asm/bitops.h:200: error: expected expression before ‘unsigned’

That sort of patches really should go to /dev/null so short before a release.

Ralf

#1 lore raw
Quoted 21 lines · Ralf Baechle

ee3ce191e8eaa4cc15c51a28b34143b36404c4f5 breaks MIPS completely:

In file included from include/linux/bitops.h:9,
from include/linux/thread_info.h:20,
from include/linux/preempt.h:9,
from include/linux/spinlock.h:49,
from include/linux/capability.h:45,
from include/linux/sched.h:46,
from arch/mips/kernel/asm-offsets.c:13:
include/asm/bitops.h: In function ???set_bit???:
include/asm/bitops.h:100: warning: implicit declaration of function ???BUILD_BUG_ON??? include/asm/bitops.h:100: warning: implicit declaration of function ???typecheck??? include/asm/bitops.h:100: error: expected expression before ???unsigned??? include/asm/bitops.h:102: error: expected expression before ???unsigned??? include/asm/bitops.h: In function ???clear_bit???:
include/asm/bitops.h:148: error: expected expression before ???unsigned??? include/asm/bitops.h:150: error: expected expression before ???unsigned??? include/asm/bitops.h: In function ???change_bit???:
include/asm/bitops.h:198: error: expected expression before ???unsigned??? include/asm/bitops.h:200: error: expected expression before ???unsigned???

Quoted 1 line

That sort of patches really should go to /dev/null so short before a release.

Ditto on ARM. This level of breakage is simply not acceptable soo close to a release, and needs the change reverting.

Note that on ARM, "allmodconfig" is really meaningless since it only tests one configuration. Ditto for the other all*config options. kautobuild (or building a range of defconfigs) is the only real way to check for breakage on ARM.

arch/arm/mach-sa1100/leds-assabet.c:34: warning: implicit declaration of function 'BUILD_BUG_ON' arch/arm/mach-sa1100/leds-assabet.c:34: warning: implicit declaration of function 'typecheck' arch/arm/mach-sa1100/leds-assabet.c:34: error: syntax error before 'unsigned' arch/arm/mach-sa1100/leds-assabet.c:113: error: syntax error before 'unsigned' arch/arm/mach-sa1100/leds-cerf.c:31: warning: implicit declaration of function 'BUILD_BUG_ON' arch/arm/mach-sa1100/leds-cerf.c:31: warning: implicit declaration of function 'typecheck' arch/arm/mach-sa1100/leds-cerf.c:31: error: syntax error before 'unsigned' arch/arm/mach-sa1100/leds-cerf.c:109: error: syntax error before 'unsigned' arch/arm/mach-sa1100/leds-hackkit.c:35: warning: implicit declaration of function 'BUILD_BUG_ON' arch/arm/mach-sa1100/leds-hackkit.c:35: warning: implicit declaration of function 'typecheck' arch/arm/mach-sa1100/leds-hackkit.c:35: error: syntax error before 'unsigned' arch/arm/mach-sa1100/leds-hackkit.c:111: error: syntax error before 'unsigned' arch/arm/mach-sa1100/leds-lart.c:34: warning: implicit declaration of function 'BUILD_BUG_ON' arch/arm/mach-sa1100/leds-lart.c:34: warning: implicit declaration of function 'typecheck' arch/arm/mach-sa1100/leds-lart.c:34: error: syntax error before 'unsigned' arch/arm/mach-sa1100/leds-lart.c:100: error: syntax error before 'unsigned' arch/arm/mach-pxa/leds-idp.c:36: warning: implicit declaration of function 'BUILD_BUG_ON' arch/arm/mach-pxa/leds-idp.c:36: warning: implicit declaration of function 'typecheck' arch/arm/mach-pxa/leds-idp.c:36: error: syntax error before 'unsigned' arch/arm/mach-pxa/leds-idp.c:115: error: syntax error before 'unsigned' arch/arm/mach-pxa/leds-lubbock.c:50: warning: implicit declaration of function 'BUILD_BUG_ON' arch/arm/mach-pxa/leds-lubbock.c:50: warning: implicit declaration of function 'typecheck' arch/arm/mach-pxa/leds-lubbock.c:50: error: syntax error before 'unsigned' arch/arm/mach-pxa/leds-lubbock.c:124: error: syntax error before 'unsigned' arch/arm/mach-pxa/leds-mainstone.c:45: warning: implicit declaration of function 'BUILD_BUG_ON' arch/arm/mach-pxa/leds-mainstone.c:45: warning: implicit declaration of function 'typecheck' arch/arm/mach-pxa/leds-mainstone.c:45: error: syntax error before 'unsigned' arch/arm/mach-pxa/leds-mainstone.c:119: error: syntax error before 'unsigned' arch/arm/mach-pxa/leds-trizeps4.c:39: warning: implicit declaration of function 'BUILD_BUG_ON' arch/arm/mach-pxa/leds-trizeps4.c:39: warning: implicit declaration of function 'typecheck' arch/arm/mach-pxa/leds-trizeps4.c:39: error: syntax error before 'unsigned' arch/arm/mach-pxa/leds-trizeps4.c:132: error: syntax error before 'unsigned'

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:
#2 lore raw
Quoted 7 lines · Russell King

Ditto on ARM. This level of breakage is simply not acceptable soo close to a release, and needs the change reverting.

Note that on ARM, "allmodconfig" is really meaningless since it only tests one configuration. Ditto for the other all*config options. kautobuild (or building a range of defconfigs) is the only real way to check for breakage on ARM.

BTW, it should be pointed out that ARM has for the last I don't know how many months been checking the type of "flags" passed into local_irq_save() and friends... If a generic solution is adopted (during the merge phase _only_ please) then the ARM specific version should probably be removed.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:
#3 lore raw
In reply to Ralf Baechle
Quoted 2 lines · Ralf Baechle

That sort of patches really should go to /dev/null so short before a release.

Yeah, I don't think it was worth it.

That said, Alexey did check it more than most patches like this get checked (ie checking allmodconfig on i386, x86_64, alpha, arm), so it's a bit unlucky that MIPS got bitten by this - it was not a badly tested patch per se.

Does the obvious fix (to include <linux/kernel.h> in irqflags.h) fix it for you?

Linus

#4 lore raw
Quoted 3 lines · Linus Torvalds

Does the obvious fix (to include <linux/kernel.h> in irqflags.h) fix it for you?

Btw, Alexey, why did you do _both a BUILD_BUG_ON and a "typecheck()"?

If there are any broken users, we shouldn't break the build, but a _warning_ is certainly appropriate.

I think I'll just commit this..

Ralf, Russell, does this work for you guys?

Linus
---

include/linux/irqflags.h +4 -5
index 4fe740b..8c5d9d1 100644
@@ -11,11 +11,10 @@
 #ifndef _LINUX_TRACE_IRQFLAGS_H
 #define _LINUX_TRACE_IRQFLAGS_H
 
-#define BUILD_CHECK_IRQ_FLAGS(flags)					\
-	do {								\
-		BUILD_BUG_ON(sizeof(flags) != sizeof(unsigned long));	\
-		typecheck(unsigned long, flags);			\
-	} while (0)
+#include <linux/kernel.h>
+
+#define BUILD_CHECK_IRQ_FLAGS(flags) \
+	typecheck(unsigned long, flags)
 
 #ifdef CONFIG_TRACE_IRQFLAGS
   extern void trace_hardirqs_on(void);
#5 lore raw
Quoted 7 lines · Linus Torvalds
Quoted 3 lines · Linus Torvalds

Does the obvious fix (to include <linux/kernel.h> in irqflags.h) fix it for you?

Quoted 8 lines

Btw, Alexey, why did you do _both a BUILD_BUG_ON and a "typecheck()"?

If there are any broken users, we shouldn't break the build, but a _warning_ is certainly appropriate.

I think I'll just commit this..

Ralf, Russell, does this work for you guys?

Not at all. It creates even more problems for me, with this circular dependency:

linux/bitops.h -> asm-arm/bitops.h -> asm-arm/system.h
-> linux/irqflags.h -> linux/kernel.h -> linux/bitops.h

We really need, as a priority, to sort out these include files ASAP, and stop bunging random stuff into unrelated random headers. Shouldn't stuff like roundup_pow_of_two() and long_log2() live somewhere else other than such a generic run-of-the-mill include such as linux/kernel.h ?

CHK include/linux/version.h
make[2]: `include/asm-arm/mach-types.h' is up to date.
Using /home/rmk/git/linux-2.6-rmk as source for kernel

  GEN     /home/rmk/git/build/assabet/Makefile
  CHK     include/linux/utsrelease.h
  CC      arch/arm/kernel/asm-offsets.s
In file included from /home/rmk/git/linux-2.6-rmk/include/linux/irqflags.h:14,
                 from include2/asm/system.h:214,
                 from include2/asm/bitops.h:23,
                 from /home/rmk/git/linux-2.6-rmk/include/linux/bitops.h:9,
                 from /home/rmk/git/linux-2.6-rmk/include/linux/thread_info.h:20,
                 from /home/rmk/git/linux-2.6-rmk/include/linux/preempt.h:9,
                 from /home/rmk/git/linux-2.6-rmk/include/linux/spinlock.h:49,
                 from /home/rmk/git/linux-2.6-rmk/include/linux/capability.h:45,
                 from /home/rmk/git/linux-2.6-rmk/include/linux/sched.h:46,
                 from /home/rmk/git/linux-2.6-rmk/arch/arm/kernel/asm-offsets.c:13:
/home/rmk/git/linux-2.6-rmk/include/linux/kernel.h: In function `roundup_pow_of_two':
/home/rmk/git/linux-2.6-rmk/include/linux/kernel.h:169: warning: implicit declaration of function `fls_long'
In file included from /home/rmk/git/linux-2.6-rmk/include/linux/thread_info.h:20,
                 from /home/rmk/git/linux-2.6-rmk/include/linux/preempt.h:9,
                 from /home/rmk/git/linux-2.6-rmk/include/linux/spinlock.h:49,
                 from /home/rmk/git/linux-2.6-rmk/include/linux/capability.h:45,
                 from /home/rmk/git/linux-2.6-rmk/include/linux/sched.h:46,
                 from /home/rmk/git/linux-2.6-rmk/arch/arm/kernel/asm-offsets.c:13:

/home/rmk/git/linux-2.6-rmk/include/linux/bitops.h: At top level:
/home/rmk/git/linux-2.6-rmk/include/linux/bitops.h:57: error: conflicting types for 'fls_long' /home/rmk/git/linux-2.6-rmk/include/linux/kernel.h:169: error: previous implicit declaration of 'fls_long' was here make[2]: *** [arch/arm/kernel/asm-offsets.s] Error 1
make[1]: *** [prepare0] Error 2
make: *** [_all] Error 2

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:
#6 lore raw
Quoted 5 lines · Russell King
Quoted 2 lines

Ralf, Russell, does this work for you guys?

Not at all. It creates even more problems for me, with this circular dependency:

Ok. I just reverted it then.

Pls verify that this is all good, and I didn't mess anything up due to the manual conflict resolution.

Linus

---
commit b8e6ec865fd1d8838b6ce9516977b65e9f08f876

Author: Linus Torvalds <[email protected]>
Date:   Sun Nov 26 16:27:17 2006 -0800

Revert "[PATCH] Enforce "unsigned long flags;" when spinlocking"

This reverts commit ee3ce191e8eaa4cc15c51a28b34143b36404c4f5, since it broke on at least ARM, MIPS and PA-RISC due to complicated header file dependencies.

Conflicts in include/linux/spinlock.h (due to the "nested" variety fixes) fixed up by hand.

Cc Alexey Dobriyan <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Kyle McMartin <[email protected]>
Cc Russell King <[email protected]>
include/linux/irqflags.h +5 -32
index 4fe740b..412e025 100644
@@ -11,12 +11,6 @@
 #ifndef _LINUX_TRACE_IRQFLAGS_H
 #define _LINUX_TRACE_IRQFLAGS_H
 
-#define BUILD_CHECK_IRQ_FLAGS(flags)					\
-	do {								\
-		BUILD_BUG_ON(sizeof(flags) != sizeof(unsigned long));	\
-		typecheck(unsigned long, flags);			\
-	} while (0)
-
 #ifdef CONFIG_TRACE_IRQFLAGS
   extern void trace_hardirqs_on(void);
   extern void trace_hardirqs_off(void);
@@ -56,15 +50,10 @@
 #define local_irq_disable() \
 	do { raw_local_irq_disable(); trace_hardirqs_off(); } while (0)
 #define local_irq_save(flags) \
-	do {					\
-		BUILD_CHECK_IRQ_FLAGS(flags);	\
-		raw_local_irq_save(flags);	\
-		trace_hardirqs_off();		\
-	} while (0)
+	do { raw_local_irq_save(flags); trace_hardirqs_off(); } while (0)
 
 #define local_irq_restore(flags)				\
 	do {							\
-		BUILD_CHECK_IRQ_FLAGS(flags);			\
 		if (raw_irqs_disabled_flags(flags)) {		\
 			raw_local_irq_restore(flags);		\
 			trace_hardirqs_off();			\
@@ -80,16 +69,8 @@
  */
 # define raw_local_irq_disable()	local_irq_disable()
 # define raw_local_irq_enable()		local_irq_enable()
-# define raw_local_irq_save(flags)		\
-	do {					\
-		BUILD_CHECK_IRQ_FLAGS(flags);	\
-		local_irq_save(flags);		\
-	} while (0)
-# define raw_local_irq_restore(flags)		\
-	do {					\
-		BUILD_CHECK_IRQ_FLAGS(flags);	\
-		local_irq_restore(flags);	\
-	} while (0)
+# define raw_local_irq_save(flags)	local_irq_save(flags)
+# define raw_local_irq_restore(flags)	local_irq_restore(flags)
 #endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */
 
 #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
@@ -99,11 +80,7 @@
 		raw_safe_halt();				\
 	} while (0)
 
-#define local_save_flags(flags)			\
-	do {					\
-		BUILD_CHECK_IRQ_FLAGS(flags);	\
-		raw_local_save_flags(flags);	\
-	} while (0)
+#define local_save_flags(flags)		raw_local_save_flags(flags)
 
 #define irqs_disabled()						\
 ({								\
@@ -113,11 +90,7 @@
 	raw_irqs_disabled_flags(flags);				\
 })
 
-#define irqs_disabled_flags(flags)	\
-({					\
-	BUILD_CHECK_IRQ_FLAGS(flags);	\
-	raw_irqs_disabled_flags(flags);	\
-})
+#define irqs_disabled_flags(flags)	raw_irqs_disabled_flags(flags)
 #endif		/* CONFIG_X86 */
 
 #endif
include/linux/spinlock.h +15 -54

105 lines not on this page · raw message

#7 lore raw
Quoted 11 lines · Linus Torvalds
Quoted 5 lines · Russell King
Quoted 2 lines

Ralf, Russell, does this work for you guys?

Not at all. It creates even more problems for me, with this circular dependency:

Ok. I just reverted it then.

Pls verify that this is all good, and I didn't mess anything up due to the manual conflict resolution.

That fixes the ARM assabet build, which should mean the other ARM builds are also fixed. Thanks.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:
#8 lore raw
In reply to Linus Torvalds
Quoted 9 lines · Linus Torvalds
Quoted 4 lines
Quoted 1 line

Ralf, Russell, does this work for you guys?

Not at all. It creates even more problems for me, with this circular dependency:

Ok. I just reverted it then.

Pls verify that this is all good, and I didn't mess anything up due to the manual conflict resolution.

Thanks, 2ea5814472c3c910aed5c5b60f1f3b1000e353f1 builds again for MIPS.

If you deciede to put the patch back in after 2.6.19 I'm considering to replace the local_irq_{save,restore} calls in the various atomic operations in <asm/{atomic,bitops,system}.h with their raw_* equivalents.

What I dislike about Alexey's patch is that is finally tries to cast unsigned long as the data type for the flags into stone. The natural data type to use on MIPS and several other architectures is a 32-bit integer - or just a single bit on a stingy day ;-). Time for flags_t maybe?

Ralf

#9 lore raw
Quoted 17 lines · Ralf Baechle
Quoted 9 lines · Linus Torvalds
Quoted 4 lines
Quoted 1 line

Ralf, Russell, does this work for you guys?

Not at all. It creates even more problems for me, with this circular dependency:

Ok. I just reverted it then.

Pls verify that this is all good, and I didn't mess anything up due to the manual conflict resolution.

Thanks, 2ea5814472c3c910aed5c5b60f1f3b1000e353f1 builds again for MIPS.

If you deciede to put the patch back in after 2.6.19 I'm considering to replace the local_irq_{save,restore} calls in the various atomic operations in <asm/{atomic,bitops,system}.h with their raw_* equivalents.

Quoted 5 lines

What I dislike about Alexey's patch is that is finally tries to cast unsigned long as the data type for the flags into stone. The natural data type to use on MIPS and several other architectures is a 32-bit integer - or just a single bit on a stingy day ;-). Time for flags_t maybe?

Hey, I've even posted RFC about that! IMO, flags_t is way too generic.

I can do

1) typedef unsigned long __bitwise__ irq_flags_t;
2) very core locking functions switched to irq_flags_t + additional small patch to keep level of compiler warnings the same
2) conversion to irq_flags_t: can be done slowly, only sparse sees new warnigns
3) irq_flags_t forked and became arch specific type
4) arch maintatiners choose better than "unsigned long" type if they want

#10 lore raw
In reply to Linus Torvalds
Quoted 7 lines · Linus Torvalds

That said, Alexey did check it more than most patches like this get checked (ie checking allmodconfig on i386, x86_64, alpha, arm), so it's a bit unlucky that MIPS got bitten by this - it was not a badly tested patch per se.

Does the obvious fix (to include <linux/kernel.h> in irqflags.h) fix it for you?

It changes the sympthoms:

CC arch/mips/kernel/asm-offsets.s
In file included from include/linux/irqflags.h:14,
from include/asm/bitops.h:34,
from include/linux/bitops.h:9,
from include/linux/thread_info.h:20,
from include/linux/preempt.h:9,
from include/linux/spinlock.h:49,
from include/linux/capability.h:45,
from include/linux/sched.h:46,
from arch/mips/kernel/asm-offsets.c:13:
include/linux/kernel.h: In function ‘roundup_pow_of_two’:
include/linux/kernel.h:169: warning: implicit declaration of function ‘fls_long’ In file included from include/linux/thread_info.h:20,
from include/linux/preempt.h:9,
from include/linux/spinlock.h:49,
from include/linux/capability.h:45,
from include/linux/sched.h:46,
from arch/mips/kernel/asm-offsets.c:13:
include/linux/bitops.h: At top level:
include/linux/bitops.h:57: error: conflicting types for ‘fls_long’ include/linux/kernel.h:169: error: previous implicit declaration of ‘fls_long’ was here

So the new problem is circular includes:

... <linux/bitops.h> -> <asm/bitops.h> -> <linux/irqflags.h> ->
<linux/kernel.h> -> <linux/bitops.h> ...

include/asm-mips/bitops.h needs to include irqflags because some older MIPS variants do not have any atomic instructions. So the fix needs to to break that loop.

Ralf

#12 lore raw

[PARISC] Fix incorrent type of flags in <asm/semaphore.h>

I still think using BUILD_BUG_ON() is unacceptable, especially given how vague the error message was.

---

include/asm-parisc/semaphore.h +4 -2
index c9ee41c..d45827a 100644
@@ -115,7 +115,8 @@ extern __inline__ int down_interruptible
  */
 extern __inline__ int down_trylock(struct semaphore * sem)
 {
-	int flags, count;
+	unsigned long flags;
+	int count;
 
 	spin_lock_irqsave(&sem->sentry, flags);
 	count = sem->count - 1;
@@ -131,7 +132,8 @@ extern __inline__ int down_trylock(struc
  */
 extern __inline__ void up(struct semaphore * sem)
 {
-	int flags;
+	unsigned long flags;
+
 	spin_lock_irqsave(&sem->sentry, flags);
 	if (sem->count < 0) {
 		__up(sem);