2.6.9-rc1-mm4 sparc reiser4 build broken - undefined atomic_sub_and_test
The default config for sparc on 2.6.9-rc1-mm4 doesn't build, using the crosstools from http://developer.osdl.org/dev/plm/cross_compile.
Hans,
Andrew counts on us to build for various arch's, especially when submitting something non-trivial. The above crosstools work pretty good - give them a try.
The final link fails with:
fs/built-in.o(.text+0x58618): In function `end_io_handler':
: undefined reference to `atomic_sub_and_test' make[1]: *** [arch/sparc/boot/image] Error 1
The macro 'atomic_sub_and_test' is defined for more or less every other arch, in various include/asm-*/atomic.h files, but not defined for sparc.
This macro is used in:
fs/reiser4/flush_queue.c:
if (atomic_sub_and_test(bio->bi_vcnt, &fq->nr_submitted))If I disable the config items:
CONFIG_REISER4_FS=y
CONFIG_REISER4_LARGE_KEY=y
then it builds ok (with the bogus #else removed from cachefs.h, as already reported on lkml).
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.650.933.1373Quoted 8 lines · Paul Jackson
The final link fails with:
fs/built-in.o(.text+0x58618): In function `end_io_handler':
: undefined reference to `atomic_sub_and_test'
make[1]: *** [arch/sparc/boot/image] Error 1
The macro 'atomic_sub_and_test' is defined for more or less every other arch, in variousinclude/asm-*/atomic.hfiles, but not defined for sparc.
This macro is used in:
Quoted 7 lines
fs/reiser4/flush_queue.c: if (atomic_sub_and_test(bio->bi_vcnt, &fq->nr_submitted))If I disable the config items:
CONFIG_REISER4_FS=y
CONFIG_REISER4_LARGE_KEY=y
then it builds ok (with the bogus #else removed fromcachefs.h, as already reported on lkml).
I'm loath to add this for the sake of reiser4; I rather favor the use of portable constructs.
-- wli
Quoted 11 lines · Paul Jackson
The default config for sparc on 2.6.9-rc1-mm4 doesn't build, using the crosstools from http://developer.osdl.org/dev/plm/cross_compile.
Hans,
Andrew counts on us to build for various arch's, especially when submitting something non-trivial. The above crosstools work pretty good - give them a try.
The final link fails with:
Quoted 7 lines
fs/built-in.o(.text+0x58618): In function `end_io_handler':
: undefined reference to `atomic_sub_and_test' make[1]: *** [arch/sparc/boot/image] Error 1The macro '
atomic_sub_and_test' is defined for more or less every other arch, in variousinclude/asm-*/atomic.hfiles, but not defined for sparc.
It is defined in both asm-sparc/atomic.h and asm-sparc64/atomic.h, but <asm/atomic.h> was not included into fs/reiser4/flush_queue.c
please try this patch:
=============================
fs/reiser4/flush_queue.c renamed from fs/reiser4/flush_queue.c.orig +1 -0
@@ -11,6 +11,7 @@#include "vfs_ops.h" #include "writeout.h" +#include <asm/atomic.h> #include <linux/bio.h> #include <linux/mm.h> #include <linux/pagemap.h>
===============================
Quoted 22 lines
This macro is used in:
fs/reiser4/flush_queue.c: if (atomic_sub_and_test(bio->bi_vcnt, &fq->nr_submitted))If I disable the config items:
CONFIG_REISER4_FS=y
CONFIG_REISER4_LARGE_KEY=ythen it builds ok (with the bogus #else removed from
cachefs.h, as already reported on lkml).Signature · 8 lines
I won't rest till it's the best ... Programmer, Linux Scalability Paul Jackson <[email protected]> 1.650.933.1373 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Signature · 1 line
Alex.
Quoted 5 lines · Alex
please try this patch:
...
+++reiser4-linux-2.6/fs/reiser4/flush_queue.c
...
+#include <asm/atomic.h>
This patch doesn't help.
Both with and without this patch, I observe the following:
1) include/asm/atomic.h is listed in fs/reiser4/.flush_queue.o.cmd
(apparently it is included indirectly, even if not explicitly so)
2) The command:
make fs/reiser4/flush_queue.o
produces the output:
fs/reiser4/flush_queue.c: In function `end_io_handler':
fs/reiser4/flush_queue.c:451: warning: implicit declaration of function `atomic_sub_and_test'
3) include/asm/atomic.h (which is include/asm-sparc/atomic.h via the asm symlink) does _not_ mention atomic_sub_and_test
4) include/asm-sparc64/atomic.h _does_ mention atomic_sub_and_test (and build ok)
5) the final kernel link fails with:
fs/built-in.o(.text+0x58618): In function `end_io_handler': : undefined reference to `atomic_sub_and_test' make[1]: *** [arch/sparc/boot/image] Error 1
I also saw an email from Bill Irwin go by, explaining that he did not choose to add atomic_sub_and_test to include/asm-sparc/atomic.h, which email is consistent with my observation that sparc atomic.h does not define atomic_sub_and_test.
It would seem that your asm-sparc/atomic.h is not the same as mine.
I believe that mine is the one in 2.6.9-rc1-mm4, which is the same as the latest one in Linus' bk tree, since its most recent change of:
1.10 04/05/14 19:00:05 [email protected][torvalds] +10 -0 Implement atomic_inc_and_test() on various architectures
and continuing through now. This atomic.h is 4550 bytes long, with an md5sum of:
90eb38997e21e579fc1cd1617180d630 include/asm-sparc/atomic.h
And, to repeat myself, it has no mention of atomic_sub_and_test.
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.650.933.1373Quoted 39 lines · Paul Jackson
Quoted 5 lines · Alex
please try this patch:
...
+++reiser4-linux-2.6/fs/reiser4/flush_queue.c
...
+#include <asm/atomic.h>This patch doesn't help.
Both with and without this patch, I observe the following:
1)
include/asm/atomic.his listed infs/reiser4/.flush_queue.o.cmd
(apparently it is included indirectly, even if not explicitly so)
2) The command:
makefs/reiser4/flush_queue.o
produces the output:
fs/reiser4/flush_queue.c: In function `end_io_handler':
fs/reiser4/flush_queue.c:451: warning: implicit declaration of function `atomic_sub_and_test'
3)include/asm/atomic.h(which isinclude/asm-sparc/atomic.hvia the asm symlink) does _not_ mentionatomic_sub_and_test
4)include/asm-sparc64/atomic.h_does_ mentionatomic_sub_and_test(and build ok)
5) the final kernel link fails with:fs/built-in.o(.text+0x58618): In function `end_io_handler': : undefined reference to `atomic_sub_and_test' make[1]: *** [arch/sparc/boot/image] Error 1I also saw an email from Bill Irwin go by, explaining that he did not choose to add
atomic_sub_and_testtoinclude/asm-sparc/atomic.h, which email is consistent with my observation that sparcatomic.hdoes not defineatomic_sub_and_test.It would seem that your
asm-sparc/atomic.his not the same as mine.I believe that mine is the one in 2.6.9-rc1-mm4, which is the same as the latest one in Linus' bk tree, since its most recent change of:
1.10 04/05/14 19:00:05 [email protected][torvalds] +10 -0 Implement
atomic_inc_and_test()on various architectures
Quoted 6 lines
and continuing through now. This
atomic.his 4550 bytes long, with an md5sum of:90eb38997e21e579fc1cd1617180d630 include/asm-sparc/atomic.hAnd, to repeat myself, it has no mention of
atomic_sub_and_test.
ah, that was atomic24_sub_and_test(), marked as
/* This is the old 24-bit implementation. ... */
I think adding the wrappers for atomic_sub_and_test() wouldn't be wrong:
===== include/asm-sparc/atomic.h 1.10 vs edited =====
include/asm-sparc/atomic.h +2 -1
@@ -44,8 +44,9 @@* other cases. */ #define atomic_inc_and_test (v) (atomic_inc_return(v) == 0) -#define atomic_dec_and_test (v) (atomic_dec_return(v) == 0) +#define atomic_add_and_test (i, v) (atomic_add_return(i, v) == 0) +#define atomic_sub_and_test (i, v) (atomic_sub_return(i, v) == 0)/* This is the old 24-bit implementation. It's still used internally * by some sparc-specific code, notably the semaphore implementation.
=============================
Interesting that asm-sparc64/atomic.h defines atomic_add/sub_and_test().
Quoted 3 lines
I won't rest till it's the best ... Programmer, Linux Scalability Paul Jackson <[email protected]> 1.650.933.1373
Signature · 1 line
Alex.
Quoted 8 lines · Alex Zarochentsev
Quoted 5 lines · Paul Jackson
I also saw an email from Bill Irwin go by, explaining that he did not choose to add
atomic_sub_and_testtoinclude/asm-sparc/atomic.h, which email is consistent with my observation that sparcatomic.hdoes not defineatomic_sub_and_test.I think adding the wrappers for
atomic_sub_and_test()wouldn't be wrong:
But Bill already said he doesn't want it, and there are several other architectures than sparc which don't have it - it's unclear why any do.
Several people were working to get atomic_add_return and its friends into the remaining architectures (such as i386), Andrew's taken those patches into -mm5, so it would make sense for reiser4 to use atomic_sub_return now.
Oh, except that particular variant is missing from s390: better add it in.
fs/reiser4/flush_queue.c +1 -1
@@ -447,7 +447,7 @@ end_io_handler(struct bio *bio, unsigned/* If all write requests registered in this "fq" are done we up * the semaphore. */ -if (atomic_sub_and_test (bio->bi_vcnt, &fq->nr_submitted)) +if (atomic_sub_return (bio->bi_vcnt, &fq->nr_submitted) ==0 )up (&fq->io_sem); }
include/asm-s390/atomic.h +4 -0
@@ -61,6 +61,10 @@ static __inline__ void atomic_sub(int i, {__CS_LOOP (v, i,"sr" ); } +static __inline__int atomic_sub_return (int i,atomic_t * v) +{ +return __CS_LOOP (v, i,"sr" ); +}static __inline__void atomic_inc (volatile atomic_t * v) {__CS_LOOP (v,1 ,"ar" );
Hi,
fs/reiser4/flush_queue.c end_io_handler(struct bio *bio, unsigned · line 450
Quoted 4 lines · Hugh Dickins
But Bill already said he doesn't want it, [...]
fs/reiser4/flush_queue.c +1
-1-if (atomic_sub_and_test (bio->bi_vcnt, &fq->nr_submitted)) +if (atomic_sub_return (bio->bi_vcnt, &fq->nr_submitted) ==0 )
And that is more portable how? atomic_sub_and_test() allows some archs to generate better code and the rest can still fall back to atomic_sub_return. (Maybe it's time for <linux/atomic.h>/ <asm-generic/atomic.h>?)
bye, Roman
Quoted 8 lines · Roman Zippel
fs/reiser4/flush_queue.c end_io_handler(struct bio *bio, unsigned · line 450
Quoted 4 lines · Hugh Dickins
But Bill already said he doesn't want it, [...]
fs/reiser4/flush_queue.c +1
-1-if (atomic_sub_and_test (bio->bi_vcnt, &fq->nr_submitted)) +if (atomic_sub_return (bio->bi_vcnt, &fq->nr_submitted) ==0 )And that is more portable how?
It's more portable in that all but s390 already provide it (and I expect Martin will be happy to add it).
Hugh
Hi,
Quoted 5 lines · Hugh Dickins
Quoted 4 lines · Roman Zippel
Quoted 2 lines · Hugh Dickins
But Bill already said he doesn't want it, [...]
Quoted 7 lines
Quoted 4 lines
fs/reiser4/flush_queue.c end_io_handler(struct bio *bio, unsigned · line 450
Quoted 2 lines
fs/reiser4/flush_queue.c +1
-1-if (atomic_sub_and_test (bio->bi_vcnt, &fq->nr_submitted)) +if (atomic_sub_return (bio->bi_vcnt, &fq->nr_submitted) ==0 )And that is more portable how?
It's more portable in that all but s390 already provide it (and I expect Martin will be happy to add it).
So why not add the missing atomic_sub_and_test() (using simply atomic_sub_return)?
bye, Roman
Quoted 3 lines · Roman Zippel
So why not add the missing
atomic_sub_and_test()(using simplyatomic_sub_return)?
sparc and s390 are not the only arches lacking atomic_sub_and_test.
Go ahead and send the patches changing all the arches that have it to define __ARCH_HAS_ATOMIC_SUB_AND_TEST, and add asm-generic/atomic.h for those that don't etc; but to me that seems like a waste of time - unless Zam convinces us that Reiser4 will need every last ounce of cpu on this particular line of code.
Hugh
Hi,
Quoted 3 lines · Hugh Dickins
Go ahead and send the patches changing all the arches that have it to define
__ARCH_HAS_ATOMIC_SUB_AND_TEST, and addasm-generic/atomic.hfor those that don't etc; but to me that seems like a waste of time -
Well, just doing it for atomic_sub_and_test would indeed be not really useful, but adding the missing macros isn't that difficult. I'm still curious what's up with this portability argument...
bye, Roman
include/asm-arm/atomic.h +2 -0
@@ -147,6 +147,8 @@#define atomic_sub (i, v) (void) atomic_sub_return(i, v)#define atomic_dec (v) (void) atomic_sub_return(1, v) +#define atomic_add_and_test (i,v) (atomic_add_return((i), (v)) == 0) +#define atomic_sub_and_test (i,v) (atomic_sub_return((i), (v)) == 0)#define atomic_inc_and_test (v) (atomic_add_return(1, v) == 0)#define atomic_dec_and_test (v) (atomic_sub_return(1, v) == 0)#define atomic_inc_return (v) (atomic_add_return(1, v))
include/asm-arm26/atomic.h +3 -0
@@ -123,6 +123,9 @@return atomic_add_return (-i, v); } +#define atomic_add_and_test (i,v) (atomic_add_return((i), (v)) == 0) +#define atomic_sub_and_test (i,v) (atomic_sub_return((i), (v)) == 0) +#define atomic_inc_and_test (v) (atomic_add_return(1, v) == 0)#define atomic_inc_return (v) (atomic_add_return(1,v))#define atomic_dec_return (v) (atomic_sub_return(1,v))
include/asm-h8300/atomic.h +2 -0
@@ -26,6 +26,7 @@#define atomic_add (i, v) atomic_add_return(i, v)#define atomic_add_negative (a, v) (atomic_add_return((a), (v)) < 0) +#define atomic_add_and_test (i,v) (atomic_add_return((i), (v)) == 0)static __inline__int atomic_sub_return (int i,atomic_t *v) {
@@ -37,6 +38,7 @@ }#define atomic_sub (i, v) atomic_sub_return(i, v) +#define atomic_sub_and_test (i,v) (atomic_sub_return((i), (v)) == 0)static __inline__int atomic_inc_return (atomic_t *v) {
include/asm-parisc/atomic.h +2 -0
@@ -196,8 +196,10 @@* other cases. */ #define atomic_inc_and_test (v) (atomic_inc_return(v) == 0) +#define atomic_add_and_test (i,v) (atomic_add_return((i), (v)) == 0)#define atomic_dec_and_test (v) (atomic_dec_return(v) == 0) +#define atomic_sub_and_test (i,v) (atomic_sub_return((i), (v)) == 0)#define ATOMIC_INIT (i) { (i) }
include/asm-s390/atomic.h +12 -0
@@ -53,6 +53,10 @@ {return __CS_LOOP (v, i,"ar" ); } +static __inline__int atomic_add_and_test (int i,atomic_t * v) +{ +return __CS_LOOP (v, i,"ar" ) ==0 ; +}static __inline__int atomic_add_negative (int i,atomic_t * v) {return __CS_LOOP (v, i,"ar" ) <0 ;
@@ -61,6 +65,14 @@ {__CS_LOOP (v, i,"sr" ); } +static __inline__int atomic_sub_return (int i,atomic_t * v) +{ +return __CS_LOOP (v, i,"sr" ); +} +static __inline__int atomic_sub_and_test (int i,atomic_t * v) +{ +return __CS_LOOP (v, i,"sr" ) ==0 ; +}static __inline__void atomic_inc (volatile atomic_t * v) {__CS_LOOP (v,1 ,"ar" );
include/asm-sparc/atomic.h +2 -0
@@ -44,8 +44,10 @@* other cases. */ #define atomic_inc_and_test (v) (atomic_inc_return(v) == 0) +#define atomic_add_and_test (i,v) (atomic_add_return((i), (v)) == 0)#define atomic_dec_and_test (v) (atomic_dec_return(v) == 0) +#define atomic_sub_and_test (i,v) (atomic_sub_return((i), (v)) == 0)/* This is the old 24-bit implementation. It's still used internally * by some sparc-specific code, notably the semaphore implementation.
Quoted 1 line · Roman Zippel
I'm still curious what's up with this portability argument...
What portability argument?
Hugh
Quoted 11 lines · Hugh Dickins
Quoted 3 lines · Roman Zippel
So why not add the missing
atomic_sub_and_test()(using simplyatomic_sub_return)?sparc and s390 are not the only arches lacking
atomic_sub_and_test.Go ahead and send the patches changing all the arches that have it to define
__ARCH_HAS_ATOMIC_SUB_AND_TEST, and addasm-generic/atomic.hfor those that don't etc; but to me that seems like a waste of time - unless Zam convinces us that Reiser4 will need every last ounce of
I do not, Hans will ;-)
I just like to know what atomic.h common functions would be in 2.6.9+, because nowdays the API is not consisent accross the arches.
atomic_sub_return() is OK.
Quoted 3 lines
cpu on this particular line of code.
Hugh
Signature · 1 line
Alex.
Salut,
Review
Quoted 2 lines · Roman Zippel
(quoted diff) +2
-0+#define atomic_add_and_test(i,v) (atomic_add_return((i), (v)) == 0) +#define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0)
This is no longer atomic, is it? I mean, there's no guarantee that theatomic_add_return and the comparison are executed without
interruption, is there?
I wonder whether it's supposed to be..
Quoted 1 line
#define
atomic_sub(i, v)atomic_sub_return(i, v)
Maybe for some compilers we should cast away the result?
Tonnerre
Hi,
Quoted 7 lines · Tonnerre
Review
Quoted 2 lines · Roman Zippel
(quoted diff) +2
-0+#define atomic_add_and_test(i,v) (atomic_add_return((i), (v)) == 0) +#define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0)This is no longer atomic, is it? I mean, there's no guarantee that the
atomic_add_returnand the comparison are executed without
interruption, is there?
Only the read/write access needs to be atomic, when the comparison happens is irrelevant.
bye, Roman
Re: 2.6.9-rc1-mm4 sparc reiser4 build broken - undefined atomic_s ub_and_test
In reply to TonnerreQuoted 7 lines · Tonnerre
Review
Quoted 2 lines · Roman Zippel
(quoted diff) +2
-0+#define atomic_add_and_test(i,v) (atomic_add_return((i), (v)) == 0) +#define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0)This is no longer atomic, is it? I mean, there's no guarantee that the
atomic_add_returnand the comparison are executed without
interruption, is there?
It's true that the atomic_add_return and the comparison are not executed atomically, but they don't need to be: a value is equal to 0, or not, however long ago that value was computed, no matter what happened since.
The important thing is that the value is the atomic result of the atomic
operation: which may not be the case when you use atomic_add followed by atomic_read, but is what's guaranteed by atomic_add_return.
Hugh
Quoted 5 lines · Hugh Dickins
Quoted 5 lines
sparc and s390 are not the only arches lacking
atomic_sub_and_test. Go ahead and send the patches changing all the arches that have it to define__ARCH_HAS_ATOMIC_SUB_AND_TEST, and addasm-generic/atomic.hfor those that don't etc; but to me that seems like a waste of time - unless Zam convinces us that Reiser4 will need every last ounce of
Quoted 4 lines · Alex Zarochentsev
I do not, Hans will ;-)
I just like to know whatatomic.hcommon functions would be in 2.6.9+, because nowdays the API is not consisent accross the arches.atomic_sub_return()is OK.
sparc32 is very legacy; in a quick IRC poll of sparc32 users there was approximately zero interest in new filesystems and most users used nfs and/or ext[23]. One should note that as these cpus are very slow and the systems have very little RAM compared to modern ones, kernel memory footprint and the cpu complexity of fs operations for small fs's is of high importance. I really don't expect reiser4 to ever be runtime tested on sparc32. UltraSPARC is another matter entirely.
-- wli
Hi,
Quoted 5 lines · William Lee Irwin III
Quoted 3 lines
I just like to know what
atomic.hcommon functions would be in 2.6.9+, because nowdays the API is not consisent accross the arches.atomic_sub_return()is OK.sparc32 is very legacy;
Sparc is not really relevant in this case, as it basically uses atomic_sub_return() anyway, but i386 or m68k can benefit from avoiding atomic_sub_return() if it's possible and that not only in reiserfs.
bye, Roman
Quoted 1 line · William Lee Irwin III
Quoted 1 line
sparc32 is very legacy;
Quoted 3 lines · Roman Zippel
Sparc is not really relevant in this case, as it basically uses
atomic_sub_return()anyway, but i386 or m68k can benefit from avoidingatomic_sub_return()if it's possible and that not only in reiserfs.
The only point I had to make was that I'd rather avoid adding arch hooks for code that will never be run on the arch. I suppose for the sake of compiletesting...
-- wli
Add atomic_sub_and_test() to sparc32, implemented in terms of atomic_sub_return(), so reiser4 can be simultaneously microoptimized and made to pass compilation testing on sparc32.
include/asm-sparc/atomic.h +1 -0
@@ -46,6 +46,7 @@#define atomic_inc_and_test (v) (atomic_inc_return(v) == 0)#define atomic_dec_and_test (v) (atomic_dec_return(v) == 0) +#define atomic_sub_and_test (v) (atomic_sub_return(v) == 0)/* This is the old 24-bit implementation. It's still used internally * by some sparc-specific code, notably the semaphore implementation.
[sparc32] add atomic_sub_and_test() to make reiser4 code microoptimized for x86 compile on sparc32
Quoted 3 lines · William Lee Irwin III
The only point I had to make was that I'd rather avoid adding arch hooks for code that will never be run on the arch. I suppose for the sake of compiletesting...
Repost with appropriate Subject: line (I'm trying to cut down on these).
-- wli
Add atomic_sub_and_test() to sparc32, implemented in terms of atomic_sub_return(), so reiser4 can be simultaneously microoptimized for x86 and made to pass compilation testing on sparc32.
include/asm-sparc/atomic.h +1 -0
@@ -46,6 +46,7 @@#define atomic_inc_and_test (v) (atomic_inc_return(v) == 0)#define atomic_dec_and_test (v) (atomic_dec_return(v) == 0) +#define atomic_sub_and_test (v) (atomic_sub_return(v) == 0)/* This is the old 24-bit implementation. It's still used internally * by some sparc-specific code, notably the semaphore implementation.
Re: [sparc32] add atomic_sub_and_test() to make reiser4 code microoptimized for x86 compile on sparc32
Quoted 1 line · William Lee Irwin III
Repost with appropriate Subject: line (I'm trying to cut down on these).
Repost with a correct patch.
-- wli
Add atomic_sub_and_test() to sparc32, implemented in terms of atomic_sub_return(), so reiser4 can be simultaneously microoptimized for x86 and made to pass compilation testing on sparc32.
include/asm-sparc/atomic.h +1 -0
@@ -46,6 +46,7 @@#define atomic_inc_and_test (v) (atomic_inc_return(v) == 0)#define atomic_dec_and_test (v) (atomic_dec_return(v) == 0) +#define atomic_sub_and_test (i, v) (atomic_sub_return(i, v) == 0)/* This is the old 24-bit implementation. It's still used internally * by some sparc-specific code, notably the semaphore implementation.