lkml.org 
[lkml]   [2018]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCHv2 01/11] atomic/tty: Fix up atomic abuse in ldsem
On Mon, Jun 25, 2018 at 1:59 PM, Mark Rutland <mark.rutland@arm.com> wrote:
> From: Peter Zijlstra <peterz@infradead.org>
>
> Mark found ldsem_cmpxchg() needed an (atomic_long_t *) cast to keep
> working after making the atomic_long interface type safe.
>
> Needing casts is bad form, which made me look at the code. There are no
> ld_semaphore::count users outside of these functions so there is no
> reason why it can not be an atomic_long_t in the first place, obviating
> the need for this cast.
>
> That also ensures the loads use atomic_long_read(), which implies (at
> least) READ_ONCE() in order to guarantee single-copy-atomic loads.
>
> When using atomic_long_try_cmpxchg() the ldsem_cmpxchg() wrapper gets
> very thin (the only difference is not changing *old on success, which
> most callers don't seem to care about).
>
> So rework the whole thing to use atomic_long_t and its accessors
> directly.
>
> While there, fixup all the horrible comment styles.


> - ldsem_atomic_update(-LDSEM_WAIT_BIAS, sem);
> + atomic_long_add_return(-LDSEM_WAIT_BIAS, &sem->count);

I suppose it's simple atomic_long_add() here?

Good fix!
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2018-06-26 20:54    [W:0.525 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site