Skip to contentSkip to conversation

2.4.10 build failure - atomic_dec_and_lock export

PATCH New Ian Grant 4 participants 5 messages Oct 2, 2001 – Oct 3, 2001 Library code

lore
Share & tools
lore

Ian Grant

author
#0 lore raw

Trond,

2.4.10 won't link with CONFIG_SMP and i386 CPU selected. I believe the problem lies in in the #ifndef atomic_dec_and_lock in lib/dec_and_lock.c. As far as I can see this symbol is always defined because it's exported.

The following patch works for me, but I barely understand the kernel build machinery(*) so please don't use this without checking it carefully.

Ian

* e.g. I cannot understand why this symbol isn't versioned in the object file.

lib/dec_and_lock.c renamed from lib/dec_and_lock.c.orig +4 -1
@@ -1,3 +1,4 @@
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <asm/atomic.h>
@@ -26,7 +27,8 @@
  * store-conditional approach, for example.
  */
 
-#ifndef atomic_dec_and_lock
+#ifdef CONFIG_SMP
+#ifndef CONFIG_HAVE_DEC_LOCK
 int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
 {
 	spin_lock(lock);
@@ -37,4 +39,5 @@
 }
 
 EXPORT_SYMBOL(atomic_dec_and_lock);
+#endif
 #endif
Signature · 2 lines
Ian Grant, Computer Lab., William Gates Building, JJ Thomson Ave., Cambridge
Phone: +44 1223 334420
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

" " == Ian Grant <[email protected]> writes:

> Trond,
> 2.4.10 won't link with CONFIG_SMP and i386 CPU selected. I
> believe the problem
> lies in in the #ifndef atomic_dec_and_lock in
> lib/dec_and_lock.c. As far as I can see this symbol is always > defined because it's exported.

This patch looks very redundant.

If you have CONFIG_SMP defined then atomic_dec_and_lock will never get defined, and if CONFIG_HAVE_DEC_LOCK is not defined, then dec_and_lock.c will never even get compiled. Even the config.h include is superfluous as linux/module.h will include it.

I don't understand though: I have no problems compiling and linking stock 2.4.10 with CONFIG_M386=y + CONFIG_SMP=y.
Are you sure that you didn't miss a 'make dep' after doing 'make config'/'make oldconfig'?

Cheers,
Trond

PS: sorry that you received this mail twice Ian. I didn't notice the first time around that you had Cced the l-k list.

#2 lore raw
In reply to Ian Grant

Trond Myklebust <[email protected]> writes:

|> >>>>> " " == Ian Grant <[email protected]> writes:
|> 
|>      > Trond,
|>      > 2.4.10 won't link with CONFIG_SMP and i386 CPU selected. I
|>      >        believe the problem
|>      > lies in in the #ifndef atomic_dec_and_lock in
|>      > lib/dec_and_lock.c. As far as I can see this symbol is always
|>      > defined because it's exported.
|> 
|> This patch looks very redundant.
|> 
|> If you have CONFIG_SMP defined then atomic_dec_and_lock will never get
|> defined

Unless you use CONFIG_MODVERSIONS, which causes atomic_dec_and_lock to be versioned and defined as a macro via <linux/modversions.h>.

Andreas.

Signature · 4 lines
Andreas Schwab                                  "And now for something
[email protected]				completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
#3 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

" " == Andreas Schwab <[email protected]> writes:

> Trond Myklebust <[email protected]> writes:
> |> If you have CONFIG_SMP defined then atomic_dec_and_lock will > |> never get defined

> Unless you use CONFIG_MODVERSIONS, which causes
> atomic_dec_and_lock to be versioned and defined as a macro via > <linux/modversions.h>.

Oh great... That's going to confound the test in <linux/spinlock.h> too.

Urgh. Can anybody propose a less ugly solution than EXPORT_SYMBOL_NOVERS()?

Cheers,
Trond

#4 lore raw

PATCH 1/1 2.4.10 build failure - atomic_dec_and_lock export

Quoted 6 lines · Trond Myklebust
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

" " == Andreas Schwab <[email protected]> writes:

Trond Myklebust <[email protected]> writes:
|> If you have CONFIG_SMP defined then atomic_dec_and_lock will |> never get defined

Quoted 8 lines
Quoted 3 lines

Unless you use CONFIG_MODVERSIONS, which causes atomic_dec_and_lock to be versioned and defined as a macro via <linux/modversions.h>.

Oh great... That's going to confound the test in <linux/spinlock.h> too.

Urgh. Can anybody propose a less ugly solution than EXPORT_SYMBOL_NOVERS()?

Use a second flag when atomic_dec_and_lock() is #defined. No conflict with modversions then.

Index: 10.1/lib/dec_and_lock.c

lib/dec_and_lock.c Wed, 03 Oct 2001 12:24:35 +1000 kaos (linux-2.4/j/21_dec_and_lo 1.1.1.1 644) renamed from lib/dec_and_lock.c Wed, 29 Aug 2001 09:36:05 +1000 kaos (linux-2.4/j/21_dec_and_lo 1.1.1.1 644) +1 -1
@@ -26,7 +26,7 @@
  * store-conditional approach, for example.
  */
 
-#ifndef atomic_dec_and_lock
+#ifndef ATOMIC_DEC_AND_LOCK
 int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
 {
 	spin_lock(lock);

Index: 10.1/include/linux/spinlock.h

include/linux/spinlock.h Wed, 03 Oct 2001 12:27:02 +1000 kaos (linux-2.4/X/48_spinlock.h 1.1.2.1 644) renamed from include/linux/spinlock.h Thu, 05 Jul 2001 14:00:51 +1000 kaos (linux-2.4/X/48_spinlock.h 1.1.2.1 644) +2 -1
@@ -42,6 +42,7 @@
 #if (DEBUG_SPINLOCKS < 1)
 
 #define atomic_dec_and_lock(atomic,lock) atomic_dec_and_test(atomic)
+#define ATOMIC_DEC_AND_LOCK
 
 /*
  * Your basic spinlocks, allowing only a single CPU anywhere
@@ -128,7 +129,7 @@ typedef struct {
 #endif /* !SMP */
 
 /* "lock on reference count zero" */
-#ifndef atomic_dec_and_lock
+#ifndef ATOMIC_DEC_AND_LOCK
 #include <asm/atomic.h>
 extern int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
 #endif