Fix atomic64 return value conventions (v2)
Subsystems (2)
cover Fix atomic64 return value conventions (v2)
Changes in v2:
- Resent patches with more verbose descriptions
This patchset fixes the return value conventions in the atomic64 test, generic implementation and the x86-32 implementation in x86/tip/atomic.
Luca Barbieri (5):
lib: fix atomic64_add_unless test
x86-32: fix atomic64_add_unless return value convention
lib: fix atomic64_add_unless return value convention
lib: fix atomic64_inc_not_zero test
x86-32: fix atomic64_inc_not_zero return value convention
arch/x86/lib/atomic64_386_32.S | 7 +++---- arch/x86/lib/atomic64_cx8_32.S | 7 +++---- lib/atomic64.c | 4 ++-- lib/atomic64_test.c | 10 +++++----- 4 files changed, 13 insertions(+), 15 deletions(-)
PATCH 1/5 lib: fix atomic64_add_unless test
atomic64_add_unless must return 1 if it perfomed the add and 0 otherwise. The test assumed the opposite convention.
--- lib/atomic64_test.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
lib/atomic64_test.c +2 -2
@@ -104,11 +104,11 @@ static __init int test_atomic64(void)BUG_ON (v.counter != r);INIT (v0); -BUG_ON (!atomic64_add_unless (&v, one, v0)); +BUG_ON (atomic64_add_unless (&v, one, v0));BUG_ON (v.counter != r);INIT (v0); -BUG_ON (atomic64_add_unless (&v, one, v1)); +BUG_ON (!atomic64_add_unless (&v, one, v1)); r += one;BUG_ON (v.counter != r);
Signature · 1 line
1.6.6.1.476.g01ddb
[tip:x86/atomic] lib: Fix atomic64_add_unless test
Commit-ID: 9efbcd590243045111670c171a951923b877b57d Gitweb: http://git.kernel.org/tip/9efbcd590243045111670c171a951923b877b57d Author: Luca Barbieri <[email protected]> AuthorDate: Mon, 1 Mar 2010 19:55:45 +0100 Committer: H. Peter Anvin <[email protected]> CommitDate: Mon, 1 Mar 2010 11:38:46 -0800
lib: Fix atomic64_add_unless test
atomic64_add_unless must return 1 if it perfomed the add and 0 otherwise. The test assumed the opposite convention.
LKML-Reference: <[email protected]>
--- lib/atomic64_test.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
lib/atomic64_test.c +2 -2
@@ -104,11 +104,11 @@ static __init int test_atomic64(void)BUG_ON (v.counter != r);INIT (v0); -BUG_ON (!atomic64_add_unless (&v, one, v0)); +BUG_ON (atomic64_add_unless (&v, one, v0));BUG_ON (v.counter != r);INIT (v0); -BUG_ON (atomic64_add_unless (&v, one, v1)); +BUG_ON (!atomic64_add_unless (&v, one, v1)); r += one;BUG_ON (v.counter != r);
PATCH 2/5 x86-32: fix atomic64_add_unless return value convention
In reply to Luca Barbieriatomic64_add_unless must return 1 if it perfomed the add and 0 otherwise. The implementation did the opposite thing.
--- arch/x86/lib/atomic64_386_32.S | 4 ++-- arch/x86/lib/atomic64_cx8_32.S | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/lib/atomic64_386_32.S +2 -2
@@ -133,13 +133,13 @@ BEGIN add_unless %ecx 1: movl %eax, ($v) movl %edx, 4($v) - xorl %eax, %eax + movl $1, %eax 2: RETURN 3: cmpl %edx, %edi jne 1b - movl $1, %eax + xorl %eax, %eax jmp 2b END_
arch/x86/lib/atomic64_cx8_32.S +2 -2
@@ -180,7 +180,7 @@ ENTRY(atomic64_add_unless_cx8) cmpxchg8b (%ebp) jne 1b - xorl %eax, %eax + movl $1, %eax 3: addl $8, %esp CFI_ADJUST_CFA_OFFSET -8
@@ -190,7 +190,7 @@ ENTRY(atomic64_add_unless_cx8) 4: cmpl %edx, 4(%esp) jne 2b - movl $1, %eax + xorl %eax, %eax jmp 3b CFI_ENDPROC ENDPROC(atomic64_add_unless_cx8)
Signature · 1 line
1.6.6.1.476.g01ddb
[tip:x86/atomic] x86-32: Fix atomic64_add_unless return value convention
Commit-ID: 6e6104fe085026e6ef82cc5cc303d6c8ceb7e411 Gitweb: http://git.kernel.org/tip/6e6104fe085026e6ef82cc5cc303d6c8ceb7e411 Author: Luca Barbieri <[email protected]> AuthorDate: Mon, 1 Mar 2010 19:55:46 +0100 Committer: H. Peter Anvin <[email protected]> CommitDate: Mon, 1 Mar 2010 11:38:46 -0800
x86-32: Fix atomic64_add_unless return value convention
atomic64_add_unless must return 1 if it perfomed the add and 0 otherwise. The implementation did the opposite thing.
LKML-Reference: <[email protected]>
--- arch/x86/lib/atomic64_386_32.S | 4 ++-- arch/x86/lib/atomic64_cx8_32.S | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/lib/atomic64_386_32.S +2 -2
@@ -133,13 +133,13 @@ BEGIN add_unless %ecx 1: movl %eax, ($v) movl %edx, 4($v) - xorl %eax, %eax + movl $1, %eax 2: RETURN 3: cmpl %edx, %edi jne 1b - movl $1, %eax + xorl %eax, %eax jmp 2b END_
arch/x86/lib/atomic64_cx8_32.S +2 -2
@@ -180,7 +180,7 @@ ENTRY(atomic64_add_unless_cx8) cmpxchg8b (%ebp) jne 1b - xorl %eax, %eax + movl $1, %eax 3: addl $8, %esp CFI_ADJUST_CFA_OFFSET -8
@@ -190,7 +190,7 @@ ENTRY(atomic64_add_unless_cx8) 4: cmpl %edx, 4(%esp) jne 2b - movl $1, %eax + xorl %eax, %eax jmp 3b CFI_ENDPROC ENDPROC(atomic64_add_unless_cx8)
PATCH 3/5 lib: fix atomic64_add_unless return value convention
In reply to Luca Barbieriatomic64_add_unless must return 1 if it perfomed the add and 0 otherwise. The generic implementation did the opposite thing.
--- lib/atomic64.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
lib/atomic64.c +2 -2
@@ -162,12 +162,12 @@ int atomic64_add_unless(atomic64_t *v, long long a, long long u) {unsigned long flags;spinlock_t *lock =lock_addr (v); -int ret =1 ; +int ret =0 ;spin_lock_irqsave (lock, flags);if (v->counter != u) { v->counter += a; - ret =0 ; + ret =1 ; }spin_unlock_irqrestore (lock, flags);return ret;
Signature · 1 line
1.6.6.1.476.g01ddb
[tip:x86/atomic] lib: Fix atomic64_add_unless return value convention
Commit-ID: 97577896f6b9c056fa0a5e9f6a608110cb3dcd33 Gitweb: http://git.kernel.org/tip/97577896f6b9c056fa0a5e9f6a608110cb3dcd33 Author: Luca Barbieri <[email protected]> AuthorDate: Mon, 1 Mar 2010 19:55:47 +0100 Committer: H. Peter Anvin <[email protected]> CommitDate: Mon, 1 Mar 2010 11:38:46 -0800
lib: Fix atomic64_add_unless return value convention
atomic64_add_unless must return 1 if it perfomed the add and 0 otherwise. The generic implementation did the opposite thing.
LKML-Reference: <[email protected]>
--- lib/atomic64.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
lib/atomic64.c +2 -2
@@ -162,12 +162,12 @@ int atomic64_add_unless(atomic64_t *v, long long a, long long u) {unsigned long flags;spinlock_t *lock =lock_addr (v); -int ret =1 ; +int ret =0 ;spin_lock_irqsave (lock, flags);if (v->counter != u) { v->counter += a; - ret =0 ; + ret =1 ; }spin_unlock_irqrestore (lock, flags);return ret;
PATCH 4/5 lib: fix atomic64_inc_not_zero test
In reply to Luca Barbieriatomic64_inc_not_zero must return 1 if it perfomed the add and 0 otherwise. The test assumed the opposite convention.
--- lib/atomic64_test.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
lib/atomic64_test.c +3 -3
@@ -130,16 +130,16 @@ static __init int test_atomic64(void)#endif INIT (onestwos); -BUG_ON (atomic64_inc_not_zero (&v)); +BUG_ON (!atomic64_inc_not_zero (&v)); r += one;BUG_ON (v.counter != r);INIT (0 ); -BUG_ON (!atomic64_inc_not_zero (&v)); +BUG_ON (atomic64_inc_not_zero (&v));BUG_ON (v.counter != r);INIT (-one); -BUG_ON (atomic64_inc_not_zero (&v)); +BUG_ON (!atomic64_inc_not_zero (&v)); r += one;BUG_ON (v.counter != r);
Signature · 1 line
1.6.6.1.476.g01ddb
[tip:x86/atomic] lib: Fix atomic64_inc_not_zero test
Commit-ID: 25a304f277ad70166eeae25a4958d2049005c33a Gitweb: http://git.kernel.org/tip/25a304f277ad70166eeae25a4958d2049005c33a Author: Luca Barbieri <[email protected]> AuthorDate: Mon, 1 Mar 2010 19:55:48 +0100 Committer: H. Peter Anvin <[email protected]> CommitDate: Mon, 1 Mar 2010 11:39:02 -0800
lib: Fix atomic64_inc_not_zero test
atomic64_inc_not_zero must return 1 if it perfomed the add and 0 otherwise. The test assumed the opposite convention.
LKML-Reference: <[email protected]>
--- lib/atomic64_test.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
lib/atomic64_test.c +3 -3
@@ -130,16 +130,16 @@ static __init int test_atomic64(void)#endif INIT (onestwos); -BUG_ON (atomic64_inc_not_zero (&v)); +BUG_ON (!atomic64_inc_not_zero (&v)); r += one;BUG_ON (v.counter != r);INIT (0 ); -BUG_ON (!atomic64_inc_not_zero (&v)); +BUG_ON (atomic64_inc_not_zero (&v));BUG_ON (v.counter != r);INIT (-one); -BUG_ON (atomic64_inc_not_zero (&v)); +BUG_ON (!atomic64_inc_not_zero (&v)); r += one;BUG_ON (v.counter != r);
PATCH 5/5 x86-32: fix atomic64_inc_not_zero return value convention
In reply to Luca Barbieriatomic64_inc_not_zero must return 1 if it perfomed the add and 0 otherwise. It was doing the opposite thing.
--- arch/x86/lib/atomic64_386_32.S | 3 +-- arch/x86/lib/atomic64_cx8_32.S | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/lib/atomic64_386_32.S +1 -2
@@ -153,13 +153,12 @@ BEGIN inc_not_zero %esi adcl $0, %edx movl %eax, ($v) movl %edx, 4($v) - xorl %eax, %eax + movl $1, %eax 2: RETURN 3: testl %edx, %edx jne 1b - movl $1, %eax jmp 2b END_
arch/x86/lib/atomic64_cx8_32.S +1 -2
@@ -212,14 +212,13 @@ ENTRY(atomic64_inc_not_zero_cx8) cmpxchg8b (%esi) jne 1b - xorl %eax, %eax + movl $1, %eax 3: RESTORE ebx ret 4: testl %edx, %edx jne 2b - movl $1, %eax jmp 3b CFI_ENDPROC ENDPROC(atomic64_inc_not_zero_cx8)
Signature · 1 line
1.6.6.1.476.g01ddb
[tip:x86/atomic] x86-32: Fix atomic64_inc_not_zero return value convention
Commit-ID: f3e83131469e29032a700217aa394996107b8fc5 Gitweb: http://git.kernel.org/tip/f3e83131469e29032a700217aa394996107b8fc5 Author: Luca Barbieri <[email protected]> AuthorDate: Mon, 1 Mar 2010 19:55:49 +0100 Committer: H. Peter Anvin <[email protected]> CommitDate: Mon, 1 Mar 2010 11:39:03 -0800
x86-32: Fix atomic64_inc_not_zero return value convention
atomic64_inc_not_zero must return 1 if it perfomed the add and 0 otherwise. It was doing the opposite thing.
LKML-Reference: <[email protected]>
--- arch/x86/lib/atomic64_386_32.S | 3 +-- arch/x86/lib/atomic64_cx8_32.S | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/lib/atomic64_386_32.S +1 -2
@@ -153,13 +153,12 @@ BEGIN inc_not_zero %esi adcl $0, %edx movl %eax, ($v) movl %edx, 4($v) - xorl %eax, %eax + movl $1, %eax 2: RETURN 3: testl %edx, %edx jne 1b - movl $1, %eax jmp 2b END_
arch/x86/lib/atomic64_cx8_32.S +1 -2
@@ -212,14 +212,13 @@ ENTRY(atomic64_inc_not_zero_cx8) cmpxchg8b (%esi) jne 1b - xorl %eax, %eax + movl $1, %eax 3: RESTORE ebx ret 4: testl %edx, %edx jne 2b - movl $1, %eax jmp 3b CFI_ENDPROC ENDPROC(atomic64_inc_not_zero_cx8)