mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: kmo@daterainc.com, axboe@kernel.dk, hch@infradead.org,
	hannes@cmpxchg.org
Subject: [PATCHSET percpu/for-3.18] percpu_ref: implement switch_to_atomic/percpu()
Date: Tue, 23 Sep 2014 01:55:09 -0400	[thread overview]
Message-ID: <1411451718-17807-1-git-send-email-tj@kernel.org> (raw)

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

             reply	other threads:[~2014-09-23  5:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23  5:55 Tejun Heo [this message]
2014-09-23  5:55 ` [PATCH 1/9] percpu_ref: relocate percpu_ref_reinit() Tejun Heo
2014-09-23 21:01   ` Kent Overstreet
2014-09-23 21:07   ` Kent Overstreet
2014-09-23  5:55 ` [PATCH 2/9] percpu_ref: minor code and comment updates Tejun Heo
2014-09-23 21:09   ` Kent Overstreet
2014-09-23  5:55 ` [PATCH 3/9] percpu_ref: replace pcpu_ prefix with percpu_ Tejun Heo
2014-09-23 21:10   ` Kent Overstreet
2014-09-23  5:55 ` [PATCH 4/9] percpu_ref: rename things to prepare for decoupling percpu/atomic mode switch Tejun Heo
2014-09-23 21:11   ` Kent Overstreet
2014-09-23  5:55 ` [PATCH 5/9] percpu_ref: add PCPU_REF_DEAD Tejun Heo
2014-09-23 13:48   ` [PATCH v2 " Tejun Heo
2014-09-23 21:14     ` Kent Overstreet
2014-09-23  5:55 ` [PATCH 6/9] percpu_ref: decouple switching to atomic mode and killing Tejun Heo
2014-09-23 21:13   ` Kent Overstreet
2014-09-23  5:55 ` [PATCH 7/9] percpu_ref: decouple switching to percpu mode and reinit Tejun Heo
2014-09-23 13:49   ` [PATCH v2 " Tejun Heo
2014-09-23 21:15     ` Kent Overstreet
2014-09-23  5:55 ` [PATCH 8/9] percpu_ref: add PERCPU_REF_INIT_* flags Tejun Heo
2014-09-23 21:16   ` Kent Overstreet
2014-09-23  5:55 ` [PATCH 9/9] percpu_ref: make INIT_ATOMIC and switch_to_atomic() sticky Tejun Heo
2014-09-23 21:17   ` Kent Overstreet
2014-09-24 17:32 ` [PATCHSET percpu/for-3.18] percpu_ref: implement switch_to_atomic/percpu() Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1411451718-17807-1-git-send-email-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=hannes@cmpxchg.org \
    --cc=hch@infradead.org \
    --cc=kmo@daterainc.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome