On Wed, May 23, 2018 at 02:50:07PM +0200, Sebastian Andrzej Siewior wrote: > On 2018-05-23 14:36:15 [+0200], Peter Zijlstra wrote: > > > Most changes are 1:1 replacements except for > > > BUG_ON(atomic_inc_return(&sh->count) != 1); > > > > That doesn't look right, 'inc_return == 1' implies inc-from-zero, which > > is not allowed by refcount. > > > > > which has been turned into > > > refcount_inc(&sh->count); > > > BUG_ON(refcount_read(&sh->count) != 1); > > > > And that is racy, you can have additional increments in between. > > so do we stay with the atomic* API here or do we extend refcount* API? Stay with the atomic; I'll look at the rest of these patches, but raid5 looks like a usage-count, not a reference count. I'll probably ack your initial set and parts of this.. but let me get to the end of this first.