linux-2.4.9: atomic_dec_and_lock sometimes used while not defined
If I try to build a kernel that can do SMP and run on a 386,
the linux-2.4.9 NFS client gets compiled with an undefined reference to atomic_dec_and_lock(). I imagine that the correct fix is to change the ifdefs that bracket the following line in include/linux/spinlock.h:
#define atomic_dec_and_lock(atomic,lock) atomic_dec_and_test(atomic)
However, I'm really not clear enough on the semantics ofatomic_dec_and_lock vs. atomic_dec_and_test to know whether this is safe.
Also, it looks like arch/sparc64/sparc64_ksyms.c referencesatomic_dec_and_test without it every being defined on any architecture other than x86, so I am suspicious of a partially applied patch here.
If nobody has a better idea, I'm going to move the
#define statement that I mentioned above out of its current ifdef logic and just bracket it like so:
#ifndef CONFIG_HAVE_DEC_LOCK
#define atomic_dec_and_lock(atomic,lock) atomic_dec_and_test(atomic) #endif
Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 104 [email protected] \ / San Jose, California 95129-1034 +1 408 261-6630 | g g d r a s i l United States of America
fax +1 408 261-6631 "Free Software For The Rest Of Us."
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
" " == Adam J Richter <[email protected]> writes:
> If I try to build a kernel that can do SMP and run on a 386,
> the linux-2.4.9 NFS client gets compiled with an undefined > reference to atomic_dec_and_lock().
Why aren't you seeing the same error in linux/fs/inode.c? That also references atomic_dec_and_lock when compiling 386 SMP...
> However, I'm really not clear enough on the semantics of
> atomic_dec_and_lock vs. atomic_dec_and_test to know whether > this is safe.
> Also, it looks like arch/sparc64/sparc64_ksyms.c references
> atomic_dec_and_test without it every being defined on any > architecture other than x86, so I am suspicious of a partially > applied patch here.
See linux/arch/sparc64/lib/dec_and_lock.S. atomic_dec_and_lock should indeed be defined on a sparc64.
Cheers,
Trond
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
" " == Adam J Richter <[email protected]> writes:
If I try to build a kernel that can do SMP and run on a 386, the linux-2.4.9 NFS client gets compiled with an undefined reference to
atomic_dec_and_lock().
Bummer I found the bug. It's not a missing define, but a missing export...
Cheers,
Trond
lib/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o ifneq ($(CONFIG_HAVE_DEC_LOCK),y) + export-objs += dec_and_lock.o obj-y += dec_and_lock.o endif
lib/dec_and_lock.c +3 -0
@@ -1,3 +1,4 @@ +#include <linux/module.h> #include <linux/spinlock.h> #include <asm/atomic.h>
@@ -34,4 +35,6 @@spin_unlock (lock); return 0; } + +EXPORT_SYMBOL (atomic_dec_and_lock);#endif
Hi Trond,
lib/Makefile line 21
Quoted 10 lines · In article <[email protected]> you wrote:
diff -u --recursive --new-file linux-2.4.9.orig/lib/Makefile linux-2.4.9/lib/Makefile
lib/Makefile +1
-0@@ -16,6 +16,7 @@ obj-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o ifneq ($(CONFIG_HAVE_DEC_LOCK),y) + export-objs += dec_and_lock.o obj-y += dec_and_lock.o endif
Nonono! Please add it to export-objs _always_ not dependand on some CONFIG_ symbol, that's how the 2.4 makefiles work.
Christoph
Signature · 1 line
Of course it doesn't work. We've performed a software upgrade.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
" " == Christoph Hellwig <[email protected]> writes:
> Hi Trond, In article <[email protected]> you > wrote: >> diff -u --recursive --new-file linux-2.4.9.orig/lib/Makefile >> linux-2.4.9/lib/Makefile >> --- linux-2.4.9.orig/lib/Makefile Wed Apr 25 22:31:03 2001 >> +++ linux-2.4.9/lib/Makefile Fri Aug 17 11:52:35 2001 >> @@ -16,6 +16,7 @@ obj-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += >> rwsem.o >> >> ifneq ($(CONFIG_HAVE_DEC_LOCK),y) >> + export-objs += dec_and_lock.o >> obj-y += dec_and_lock.o endif > Nonono! Please add it to export-objs _always_ not dependand on > some CONFIG_ symbol, that's how the 2.4 makefiles work.
Revised patch follows...
Cheers,
Trond
lib/Makefile +1 -1
@@ -8,7 +8,7 @@ L_TARGET := lib.a -export-objs := cmdline.o rwsem-spinlock.o rwsem.o +export-objs := cmdline.o dec_and_lock.o rwsem-spinlock.o rwsem.o obj-y := errno.o ctype.o string.o vsprintf.o brlock.o cmdline.o
lib/dec_and_lock.c +3 -0
@@ -1,3 +1,4 @@ +#include <linux/module.h> #include <linux/spinlock.h> #include <asm/atomic.h>
@@ -34,4 +35,6 @@spin_unlock (lock); return 0; } + +EXPORT_SYMBOL (atomic_dec_and_lock);#endif