atomic ops for a VM fix
Subsystems (2)
Guys, I have four patches here which I'd like to merge into Linus's tree within a week.
They require that the architecture implement atomic_add_negative() and atomic_inc_and_test(). I managed to cobble these together for many architectures, but there are a few gaps. Please review the third and fourth patches.
Dave, sparc64 is missing atomic_add_negative(), sorry.
oh, and open-coded references to page->count are deliberately broken at compile time. Please convert any leftovers to get_page(), set_page_count(), page_count() and __put_page(), thanks.
Quoted 4 lines · Andrew Morton
They require that the architecture implement
atomic_add_negative()andatomic_inc_and_test(). I managed to cobble these together for many architectures, but there are a few gaps. Please review the third and fourth patches.
It seems atomic_inc_and_test() is missing on alpha.
Ivan.
include/asm-alpha/atomic.h +1 -0
@@ -178,6 +178,7 @@ static __inline__ long atomic64_sub_retu#define atomic_sub_and_test (i,v) (atomic_sub_return((i), (v)) == 0)#define atomic64_sub_and_test (i,v) (atomic64_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 atomic64_dec_and_test (v) (atomic64_sub_return(1, (v)) == 0)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Ivan Kokshaysky
Ivan> It seems atomic_inc_and_test() is missing on alpha.
Ivan> +#define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0)
And I seem to have gotten the ia64-version wrong (it tests for != 0). I'll fix that now.
Can someone say with certainty whether the s390 version is also wrong?
--david
Quoted 9 lines · David Mosberger
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Ivan Kokshaysky
Ivan> It seems
atomic_inc_and_test()is missing on alpha.Ivan> +#define
atomic_inc_and_test(v)(atomic_add_return(1, (v))== 0)And I seem to have gotten the ia64-version wrong (it tests for != 0). I'll fix that now.
Neato.
From: David Mosberger <[email protected]>
---
25-akpm/include/asm-ia64/atomic.h | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
include/asm-ia64/atomic.h renamed from include/asm-ia64/atomic.h~ia64-atomic_inc_and_test-fix +1 -1
@@ -159,7 +159,7 @@ atomic64_add_negative (__s64 i, atomic64#define atomic_sub_and_test (i,v) (atomic_sub_return((i), (v)) == 0)#define atomic_dec_and_test (v) (atomic_sub_return(1, (v)) == 0) -#define atomic_inc_and_test (v) (atomic_add_return(1, (v)) != 0) +#define atomic_inc_and_test (v) (atomic_add_return(1, (v)) == 0)#define atomic64_sub_and_test (i,v) (atomic64_sub_return((i), (v)) == 0)#define atomic64_dec_and_test (v) (atomic64_sub_return(1, (v)) == 0)#define atomic64_inc_and_test (v) (atomic64_add_return(1, (v)) != 0)
_
Quoted 3 lines
Can someone say with certainty whether the s390 version is also wrong?
Either s390's atomic_inc_and_test() is wrong, or their atomic_inc_return() is wrong. I think the former.
David Mosberger <[email protected]>
---
25-akpm/include/asm-s390/atomic.h | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
include/asm-s390/atomic.h renamed from include/asm-s390/atomic.h~s390-atomic_inc_and_test-fix +1 -1
@@ -72,7 +72,7 @@ static __inline__ int atomic_inc_return(static __inline__int atomic_inc_and_test (volatile atomic_t * v) { -return __CS_LOOP (v,1 ,"ar" ) !=0 ; +return __CS_LOOP (v,1 ,"ar" ) ==0 ; }static __inline__void atomic_dec (volatile atomic_t * v) {
_