lkml.org 
[lkml]   [2023]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] locking/atomic: atomic: Use arch_atomic_{read,set} in generic atomic ops
    On Thu, Jan 26, 2023 at 06:33:54PM +0100, Jules Maselbas wrote:

    > @@ -58,9 +61,11 @@ static inline int generic_atomic_fetch_##op(int i, atomic_t *v) \
    > static inline void generic_atomic_##op(int i, atomic_t *v) \
    > { \
    > unsigned long flags; \
    > + int c; \
    > \
    > raw_local_irq_save(flags); \
    > - v->counter = v->counter c_op i; \
    > + c = arch_atomic_read(v); \
    > + arch_atomic_set(v, c c_op i); \
    > raw_local_irq_restore(flags); \
    > }

    This and the others like it are a bit sad, it explicitly dis-allows the
    compiler from using memops and forces a load-store.

    The alternative is writing it like:

    *(volatile int *)&v->counter c_op i;

    but that's pretty shit too I suppose.


    \
     
     \ /
      Last update: 2023-03-26 23:58    [W:4.235 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site