[PATCHSET percpu/for-3.18] percpu_ref: implement switch_to_atomic/percpu()

From: Tejun Heo
Date: Tue Sep 23 2014 - 01:55:26 EST


Hello,

Over the past several months, percpu_ref grew use cases where it's
used as a persistent on/off switch which may be cycled multiple times
using percpu_ref_reinit(). One of such use cases is blk-mq's
mq_usage_counter which tracks the number of in-flight commands and is
used to drain them. Unfortunately, SCSI device probing involves
synchronously creating and destroying request_queues for non-existent
devices and the sched RCU grace period involved in percpu_ref killing
adds upto a significant amount of latency.

Block layer already experienced the same issue in other areas and
works around it by starting the queue in a degraded mode which is
faster to shut down and making it fully functional only after it's
known that the queue isn't a temporary one for probing.

This patchset implements percpu_ref mechanisms to manually switch
between atomic and percpu operation modes so that blk-mq can implement
a similar degraded operation mode. This will also allow implementing
debug mode for percpu_ref so that underflow can be detected sooner.

This patchset contains the following nine patches.

0001-percpu_ref-relocate-percpu_ref_reinit.patch
0002-percpu_ref-minor-code-and-comment-updates.patch
0003-percpu_ref-replace-pcpu_-prefix-with-percpu_.patch
0004-percpu_ref-rename-things-to-prepare-for-decoupling-p.patch
0005-percpu_ref-add-PCPU_REF_DEAD.patch
0006-percpu_ref-decouple-switching-to-atomic-mode-and-kil.patch
0007-percpu_ref-decouple-switching-to-percpu-mode-and-rei.patch
0008-percpu_ref-add-PERCPU_REF_INIT_-flags.patch
0009-percpu_ref-make-INIT_ATOMIC-and-switch_to_atomic-sti.patch

0001-0005 are prep patches.

0006-0007 implement percpu_ref_switch_to_atomic/percpu().

0008 extends percpu_ref_init() so that a percpu_ref can be initialized
in different states including atomic mode.

0009 makes atomic mode sticky so that it survives through reinits.

This patchset is on top of percpu/for-3.18 and available in the
following git branch.

git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu.git review-percpu_ref-switch

diffstat follows.

block/blk-mq.c | 2
fs/aio.c | 4
include/linux/percpu-refcount.h | 108 +++++++++-----
kernel/cgroup.c | 7
lib/percpu-refcount.c | 291 +++++++++++++++++++++++++++++-----------
5 files changed, 295 insertions(+), 117 deletions(-)

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/