percpu_ref: unify staggered atomic switching wait behavior
authorTejun Heo <tj@kernel.org>
Tue, 29 Sep 2015 21:47:18 +0000 (17:47 -0400)
committerTejun Heo <tj@kernel.org>
Wed, 10 Aug 2016 19:02:58 +0000 (15:02 -0400)
commit18808354b79622ed11857e41f9044ba17aec5b01
tree44f91394a6c0385b30e5271432ff0300cc17ef83
parentb2302c7fdc654d249c546aac6228b8e10969bc1e
percpu_ref: unify staggered atomic switching wait behavior

When an atomic or percpu switching starts before the previous atomic
switching finishes, the taken behaviors are

* If the new atomic switching has confirmation callback, it waits
  for the previous atomic switching to complete.

* If the new percpu switching is the first percpu switching following
  the previous atomic switching, it waits the previous atomic
  switching to complete.

No percpu_ref user depends on these subtleties.  The only meaningful
part is that, if the caller ensures that atomic switching isn't in
progress, mode switching operations can be issued from any context.

This patch pulls the wait logic to the top of both switching functions
so that they always wait for the previous atomic switching to
complete.  This makes the behavior simpler and consistent for both
directions and will help allowing concurrent invocations of mode
switching functions.

Signed-off-by: Tejun Heo <tj@kernel.org>
lib/percpu-refcount.c