From: Kent Overstreet <kmo@daterainc.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Jens Axboe <axboe@kernel.dk>, Andi Kleen <andi@firstfloor.org>,
kvm-devel <kvm@vger.kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
lkml <linux-kernel@vger.kernel.org>,
lf-virt <virtualization@lists.linux-foundation.org>,
target-devel <target-devel@vger.kernel.org>,
Christoph Lameter <cl@gentwo.org>,
Oleg Nesterov <oleg@redhat.com>, Tejun Heo <tj@kernel.org>,
Christoph Lameter <cl@linux-foundation.org>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH-v3 1/4] idr: Percpu ida
Date: Wed, 28 Aug 2013 14:12:17 -0700 [thread overview]
Message-ID: <20130828211217.GE1357@kmo-pixel> (raw)
In-Reply-To: <20130828135042.9e460b27699b52bb4eb53d9e@linux-foundation.org>
On Wed, Aug 28, 2013 at 01:50:42PM -0700, Andrew Morton wrote:
> On Wed, 28 Aug 2013 13:44:54 -0700 Kent Overstreet <kmo@daterainc.com> wrote:
>
> > > > > What guarantees that this wait will terminate?
> > > >
> > > > It seems fairly clear to me from the break statement a couple lines up;
> > > > if we were passed __GFP_WAIT we terminate iff we succesfully allocated a
> > > > tag. If we weren't passed __GFP_WAIT we never actually sleep.
> > >
> > > OK ;) Let me rephrase. What guarantees that a tag will become available?
> > >
> > > If what we have here is an open-coded __GFP_NOFAIL then that is
> > > potentially problematic.
> >
> > It's the same semantics as a mempool, really - it'll succeed when a tag
> > gets freed.
>
> OK, that's reasonable if the code is being used to generate IO tags -
> we expect the in-flight tags to eventually be returned.
>
> But if a client of this code is using the allocator for something
> totally different, there is no guarantee that the act of waiting will
> result in any tags being returned.
Yeah, and I did wonder a bit whether the waiting mechanism belonged in
the percpu ida code; arguably (certainly just looking at this code, not
any of the users) if it belongs in this code it should be common to
regular ida, not specific to percpu ida.
For now I've just decided to punt on changing that for now, since all
the percpu ida users I've come across do want the waiting mechanism, but
none of the regular ida users that I've looked at want it. There's
probably a reason for that I haven't thought of yet.
> (These are core design principles/constraints which should be
> explicitly documented in a place where future readers will see them!)
*nod* I suppose it should be said explicitly that the gfp_t parameter
indicates whether or not to wait until a _tag_ is available, and not
some internal memory allocation or something.
How's this look?
diff --git a/lib/idr.c b/lib/idr.c
index 15c021c..a3f8e9a 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -1288,6 +1288,11 @@ static inline unsigned alloc_local_tag(struct percpu_ida *pool,
* Safe to be called from interrupt context (assuming it isn't passed
* __GFP_WAIT, of course).
*
+ * @gfp indicates whether or not to wait until a free id is available (it's not
+ * used for internal memory allocations); thus if passed __GFP_WAIT we may sleep
+ * however long it takes until another thread frees an id (same semantics as a
+ * mempool).
+ *
* Will not fail if passed __GFP_WAIT.
*/
int percpu_ida_alloc(struct percpu_ida *pool, gfp_t gfp)
next prev parent reply other threads:[~2013-08-28 21:12 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-16 23:09 [PATCH-v3 0/4] target/vhost-scsi: Add per-cpu ida tag pre-allocation for v3.12 Nicholas A. Bellinger
2013-08-16 23:09 ` [PATCH-v3 1/4] idr: Percpu ida Nicholas A. Bellinger
2013-08-20 21:31 ` Andrew Morton
2013-08-26 20:14 ` Kent Overstreet
2013-08-28 19:53 ` Kent Overstreet
2013-08-28 20:23 ` Andrew Morton
2013-08-28 20:44 ` Kent Overstreet
2013-08-28 20:50 ` Andrew Morton
2013-08-28 21:12 ` Kent Overstreet [this message]
2013-08-28 21:15 ` Andrew Morton
2013-08-28 19:55 ` [PATCH] percpu ida: Switch to cpumask_t, add some comments Kent Overstreet
2013-08-28 20:25 ` Andrew Morton
2013-08-28 21:00 ` Kent Overstreet
2013-08-28 21:10 ` Andrew Morton
2013-08-28 21:26 ` Kent Overstreet
2013-08-28 21:36 ` Andrew Morton
2013-08-31 3:10 ` Nicholas A. Bellinger
2013-08-21 18:25 ` [PATCH-v3 1/4] idr: Percpu ida Christoph Lameter
2013-08-26 20:23 ` Kent Overstreet
2013-08-16 23:09 ` [PATCH-v3 2/4] target: Add transport_init_session_tags using per-cpu ida Nicholas A. Bellinger
2013-08-16 23:09 ` [PATCH-v3 3/4] vhost/scsi: Convert to per-cpu ida_alloc + ida_free command map Nicholas A. Bellinger
2013-08-16 23:09 ` [PATCH-v3 4/4] vhost/scsi: Add pre-allocation for tv_cmd SGL + upages memory 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=20130828211217.GE1357@kmo-pixel \
--to=kmo@daterainc.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=axboe@kernel.dk \
--cc=cl@gentwo.org \
--cc=cl@linux-foundation.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mst@redhat.com \
--cc=oleg@redhat.com \
--cc=target-devel@vger.kernel.org \
--cc=tj@kernel.org \
--cc=virtualization@lists.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