public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kent Overstreet <kmo@daterainc.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org>,
	target-devel <target-devel@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@redhat.com>, Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH-v2 1/3] percpu_ida: Make percpu_ida_alloc + callers accept task state bitmask
Date: Tue, 21 Jan 2014 14:18:52 -0800	[thread overview]
Message-ID: <20140121221852.GT9037@kmo> (raw)
In-Reply-To: <20140120113415.GE30183@twins.programming.kicks-ass.net>

On Mon, Jan 20, 2014 at 12:34:15PM +0100, Peter Zijlstra wrote:
> On Mon, Jan 20, 2014 at 03:44:44AM +0000, Nicholas A. Bellinger wrote:
> > From: Kent Overstreet <kmo@daterainc.com>
> > 
> > This patch changes percpu_ida_alloc() + callers to accept task state
> > bitmask for prepare_to_wait() for code like target/iscsi that needs
> > it for interruptible sleep, that is provided in a subsequent patch.
> > 
> > It now expects TASK_UNINTERRUPTIBLE when the caller is able to sleep
> > waiting for a new tag, or TASK_RUNNING when the caller cannot sleep,
> > and is forced to return a negative value when no tags are available.
> > 
> > v2 changes:
> >   - Include blk-mq + tcm_fc + vhost/scsi + target/iscsi changes
> >   - Drop signal_pending_state() call
> 
> Urgh, you made me look at percpu_ida... steal_tags() does a
> for_each_cpus() with IRQs disabled. This mean you'll disable IRQs for
> multiple ticks on SGI class hardware. That is a _very_ long time indeed.

It's not that bad in practice - the looping is limited by the number of other
CPUs that actually have tags on their freelists - i.e. the CPUs that have
recently been using that block device or whatever the percpu_ida is for. And we
loop while cpu_have_tags is greater than some threshold (there's another debate
about that) - the intention is not to steal tags unless too many other CPUs have
tags on their local freelists.

That said, for huge SGI class hardware I think you'd want the freelists to not
be percpu, but rather be per core or something - that's probably a reasonable
optimization for most hardware anyways.

> Then there's alloc_global_tags() vs alloc_local_tags(), one gets an
> actual tag, while the other only moves tags about -- semantic mismatch.

Yeah, kind of. It is doing allocation, but not the same sort of allocation.

> I do not get the comment near prepare to wait -- why does it matter if
> percpu_ida_free() flips a cpus_have_tags bit?

Did I write that comment? It is a crappy comment...

Ok, in userspace we'd be using condition variables here, but this is the kernel
so we need to carefully order putting ourselves on a waitlist, and checking the
condition that determines whether we wait, and on the wakeup end changing things
that affect that condition and doing the wakeup. steal_tags() is checking the
condition that goes with the prepare_to_wait(), that's all.

  parent reply	other threads:[~2014-01-21 22:19 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-20  3:44 [PATCH-v2 0/3] percpu_ida+Co: Make percpu_ida_alloc accept task state bitmask Nicholas A. Bellinger
2014-01-20  3:44 ` [PATCH-v2 1/3] percpu_ida: Make percpu_ida_alloc + callers " Nicholas A. Bellinger
2014-01-20 11:34   ` Peter Zijlstra
2014-01-21 22:09     ` Nicholas A. Bellinger
2014-01-21 22:18     ` Kent Overstreet [this message]
2014-01-22 19:53       ` Nicholas A. Bellinger
2014-01-23 18:40         ` Nicholas A. Bellinger
2014-01-23 19:12           ` Peter Zijlstra
2014-01-23 19:31             ` Nicholas A. Bellinger
2014-01-23 19:38               ` Nicholas A. Bellinger
2014-01-24 15:14                 ` Peter Zijlstra
2014-01-25  6:33                   ` Nicholas A. Bellinger
2014-01-23 19:34             ` Kent Overstreet
2014-01-23 12:47       ` Peter Zijlstra
2014-01-23 13:28         ` Kent Overstreet
2014-01-23 13:50           ` Peter Zijlstra
2014-01-23 13:55             ` Kent Overstreet
2014-01-23 15:43               ` Peter Zijlstra
2014-01-23 16:22                 ` Peter Zijlstra
2014-01-23 16:46                   ` Peter Zijlstra
2014-01-23 19:31                   ` Kent Overstreet
2014-02-10  9:30                   ` Alexander Gordeev
2014-01-20  3:44 ` [PATCH-v2 2/3] blk-mq: Convert gfp_t parameters to " Nicholas A. Bellinger
2014-01-20  3:44 ` [PATCH-v2 3/3] iscsi-target: Fix connection reset hang with percpu_ida_alloc Nicholas A. Bellinger
2014-01-22 19:58 ` [PATCH-v2 0/3] percpu_ida+Co: Make percpu_ida_alloc accept task state bitmask Nicholas A. Bellinger

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=20140121221852.GT9037@kmo \
    --to=kmo@daterainc.com \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nab@linux-iscsi.org \
    --cc=peterz@infradead.org \
    --cc=target-devel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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