Skip to contentSkip to conversation

2.6.9-rc1-mm4 sparc reiser4 build broken - undefined atomic_sub_and_test

DISCUSSION Paul Jackson 6 participants 21 messages Sep 12, 2004 – Sep 14, 2004 Atomic infrastructure

lore
Share & tools
lore
#0 lore raw

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.1373
#1 lore raw
Quoted 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 various include/asm-*/atomic.h files, 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 from cachefs.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

#2 lore raw
In reply to Paul Jackson
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 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.

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=y

then 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.
#3 lore raw
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.1373
#4 lore raw
Quoted 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.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

Quoted 6 lines

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.

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.
#5 lore raw
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_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.

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");
#6 lore raw

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

#7 lore raw
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

#8 lore raw

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

#9 lore raw
Quoted 3 lines · Roman Zippel

So why not add the missing atomic_sub_and_test() (using simply atomic_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

#10 lore raw

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 add asm-generic/atomic.h for 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
diff -ur linux-2.6.9-rc1-mm5.org/include/asm-arm/atomic.h linux-2.6.9-rc1-mm5/include/asm-arm/atomic.h
@@ -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
diff -ur linux-2.6.9-rc1-mm5.org/include/asm-arm26/atomic.h linux-2.6.9-rc1-mm5/include/asm-arm26/atomic.h
@@ -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
diff -ur linux-2.6.9-rc1-mm5.org/include/asm-h8300/atomic.h linux-2.6.9-rc1-mm5/include/asm-h8300/atomic.h
@@ -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
diff -ur linux-2.6.9-rc1-mm5.org/include/asm-parisc/atomic.h linux-2.6.9-rc1-mm5/include/asm-parisc/atomic.h
@@ -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
diff -ur linux-2.6.9-rc1-mm5.org/include/asm-s390/atomic.h linux-2.6.9-rc1-mm5/include/asm-s390/atomic.h
@@ -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
diff -ur linux-2.6.9-rc1-mm5.org/include/asm-sparc/atomic.h linux-2.6.9-rc1-mm5/include/asm-sparc/atomic.h
@@ -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.
#11 lore raw
Quoted 1 line · Roman Zippel

I'm still curious what's up with this portability argument...

What portability argument?

Hugh

#12 lore raw
In reply to Roman Zippel

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 the
atomic_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

#13 lore raw

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_return and 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

#14 lore raw

Re: 2.6.9-rc1-mm4 sparc reiser4 build broken - undefined atomic_s ub_and_test

In reply to Tonnerre
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_return and 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

#15 lore raw
In reply to Hugh Dickins
Quoted 11 lines · Hugh Dickins
Quoted 3 lines · Roman Zippel

So why not add the missing atomic_sub_and_test() (using simply atomic_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

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.
#16 lore raw
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 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

Quoted 4 lines · Alex Zarochentsev

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.

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

#17 lore raw

Hi,

Quoted 5 lines · William Lee Irwin III
Quoted 3 lines

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.

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

#18 lore raw
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 avoiding atomic_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
Index: mm5-2.6.9-rc1/include/asm-sparc/atomic.h
===================================================================
@@ -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.
#19 lore raw

[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
Index: mm5-2.6.9-rc1/include/asm-sparc/atomic.h
===================================================================
@@ -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.
#20 lore raw

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
Index: mm5-2.6.9-rc1/include/asm-sparc/atomic.h
===================================================================
@@ -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.