Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1652421
| From | Dmitry Vyukov <dvyukov@google.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 2/7] x86: use long long for 64-bit atomic ops |
| Date | 2017-05-29 13:10 +0200 |
| Message-ID | <tMqIG-7su-17@gated-at.bofh.it> (permalink) |
| References | <tLsWd-1pQ-1@gated-at.bofh.it> <tLsWe-1pQ-19@gated-at.bofh.it> <tMqpk-72M-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, May 29, 2017 at 12:49 PM, Heiko Carstens
<heiko.carstens@de.ibm.com> wrote:
> On Fri, May 26, 2017 at 09:09:04PM +0200, Dmitry Vyukov wrote:
>> Some 64-bit atomic operations use 'long long' as operand/return type
>> (e.g. asm-generic/atomic64.h, arch/x86/include/asm/atomic64_32.h);
>> while others use 'long' (e.g. arch/x86/include/asm/atomic64_64.h).
>> This makes it impossible to write portable code.
>> For example, there is no format specifier that prints result of
>> atomic64_read() without warnings. atomic64_try_cmpxchg() is almost
>> impossible to use in portable fashion because it requires either
>> 'long *' or 'long long *' as argument depending on arch.
>>
>> Switch arch/x86/include/asm/atomic64_64.h to 'long long'.
>>
>> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
>>
>> ---
>> Changes since v1:
>> - reverted stray s/long/long long/ replace in comment
>> - added arch/s390 changes to fix build errors/warnings
>
> If you change s390 code, please add the relevant mailing list and/or
> maintainers please.
>
>> diff --git a/arch/s390/include/asm/atomic_ops.h b/arch/s390/include/asm/atomic_ops.h
>> index ac9e2b939d04..055a9083e52d 100644
>> --- a/arch/s390/include/asm/atomic_ops.h
>> +++ b/arch/s390/include/asm/atomic_ops.h
>> @@ -31,10 +31,10 @@ __ATOMIC_OPS(__atomic_and, int, "lan")
>> __ATOMIC_OPS(__atomic_or, int, "lao")
>> __ATOMIC_OPS(__atomic_xor, int, "lax")
>>
>> -__ATOMIC_OPS(__atomic64_add, long, "laag")
>> -__ATOMIC_OPS(__atomic64_and, long, "lang")
>> -__ATOMIC_OPS(__atomic64_or, long, "laog")
>> -__ATOMIC_OPS(__atomic64_xor, long, "laxg")
>> +__ATOMIC_OPS(__atomic64_add, long long, "laag")
>> +__ATOMIC_OPS(__atomic64_and, long long, "lang")
>> +__ATOMIC_OPS(__atomic64_or, long long, "laog")
>> +__ATOMIC_OPS(__atomic64_xor, long long, "laxg")
>>
>> #undef __ATOMIC_OPS
>> #undef __ATOMIC_OP
>> @@ -46,7 +46,7 @@ static inline void __atomic_add_const(int val, int *ptr)
>> : [ptr] "+Q" (*ptr) : [val] "i" (val) : "cc");
>> }
>>
>> -static inline void __atomic64_add_const(long val, long *ptr)
>> +static inline void __atomic64_add_const(long val, long long *ptr)
>
> If you change this then val should be long long (or s64) too.
>
>> -static inline long op_name(long val, long *ptr) \
>> +static inline long op_name(long val, long long *ptr) \
>> { \
>> long old, new; \
>
> Same here. You only changed the type of *ptr, but left the rest
> alone. Everything should have the same type.
I will try to follow hpa's suggestion in the next version of the
patch. If it work out, I will not need to touch s390 code.
Still thanks for the review.
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH v2 0/7] x86, kasan: add KASAN checks to atomic operations Dmitry Vyukov <dvyukov@google.com> - 2017-05-26 21:20 +0200
[PATCH v2 6/7] asm-generic: add KASAN instrumentation to atomic operations Dmitry Vyukov <dvyukov@google.com> - 2017-05-26 21:20 +0200
[PATCH v2 3/7] asm-generic: add atomic-instrumented.h Dmitry Vyukov <dvyukov@google.com> - 2017-05-26 21:20 +0200
[PATCH v2 1/7] x86: un-macro-ify atomic ops implementation Dmitry Vyukov <dvyukov@google.com> - 2017-05-26 21:20 +0200
[PATCH v2 7/7] asm-generic, x86: add comments for atomic instrumentation Dmitry Vyukov <dvyukov@google.com> - 2017-05-26 21:20 +0200
[PATCH v2 4/7] x86: switch atomic.h to use atomic-instrumented.h Dmitry Vyukov <dvyukov@google.com> - 2017-05-26 21:20 +0200
[PATCH v2 5/7] kasan: allow kasan_check_read/write() to accept pointers to volatiles Dmitry Vyukov <dvyukov@google.com> - 2017-05-26 21:20 +0200
[PATCH v2 2/7] x86: use long long for 64-bit atomic ops Dmitry Vyukov <dvyukov@google.com> - 2017-05-26 21:20 +0200
Re: [PATCH v2 2/7] x86: use long long for 64-bit atomic ops hpa@zytor.com - 2017-05-28 01:20 +0200
Re: [PATCH v2 2/7] x86: use long long for 64-bit atomic ops Dmitry Vyukov <dvyukov@google.com> - 2017-05-28 11:40 +0200
Re: [PATCH v2 2/7] x86: use long long for 64-bit atomic ops hpa@zytor.com - 2017-05-28 11:50 +0200
Re: [PATCH v2 2/7] x86: use long long for 64-bit atomic ops Dmitry Vyukov <dvyukov@google.com> - 2017-05-29 16:50 +0200
Re: [PATCH v2 2/7] x86: use long long for 64-bit atomic ops Dmitry Vyukov <dvyukov@google.com> - 2017-06-06 12:20 +0200
Re: [PATCH v2 2/7] x86: use long long for 64-bit atomic ops Heiko Carstens <heiko.carstens@de.ibm.com> - 2017-05-29 12:50 +0200
Re: [PATCH v2 2/7] x86: use long long for 64-bit atomic ops Dmitry Vyukov <dvyukov@google.com> - 2017-05-29 13:10 +0200
csiph-web