From patchwork Wed Aug 28 21:12:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 2851047 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AE3F8BF546 for ; Wed, 28 Aug 2013 21:12:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D765A205B3 for ; Wed, 28 Aug 2013 21:12:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF2C0205B1 for ; Wed, 28 Aug 2013 21:12:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755557Ab3H1VMJ (ORCPT ); Wed, 28 Aug 2013 17:12:09 -0400 Received: from mail-pb0-f52.google.com ([209.85.160.52]:46696 "EHLO mail-pb0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755291Ab3H1VMH (ORCPT ); Wed, 28 Aug 2013 17:12:07 -0400 Received: by mail-pb0-f52.google.com with SMTP id wz12so6722738pbc.39 for ; Wed, 28 Aug 2013 14:12:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=njylVC3b0eWyjkWeOZAVTWOlJneGcsBVy5rus6D2cOs=; b=gNp1dlM//7D8i3FZ8UH+B2eODrOERZr3l9v/OEUFdGYE5At+BvjG59pKLNJbQiJjU2 K46ZmhPS0LOLGgp2zNgr6X9ADhEyxckmcwJVB3yx3w0gPQB8E0GCrRhKopDJqxyEMtl8 ywir+8NStW+/jo9kKyggVdF5SMS1DtNAJ7Zp4v0foRCwWPWBk5UP4ghNHTGv0bFcflbd jiU5WUm9Cnr1HwC7werfLJ35wlPE4N4LbxOtYzhV/ZubvScFCEx3UIyr9cUYjHvGVxOJ e1d97cB2rTOlonoscuiRlE8lniOJzaGIb+UscjxplVnpaEgBkNtVFqrzpk8hcx4VZAQW EX/Q== X-Gm-Message-State: ALoCoQnpuzRu1NQx4sQ85KJvVqu/uCJh19ZUTP00Li1wdJ0k42SaFncoxBbt6n8iXZsc6WQv7Sl9 X-Received: by 10.68.114.132 with SMTP id jg4mr29748019pbb.109.1377724327128; Wed, 28 Aug 2013 14:12:07 -0700 (PDT) Received: from kmo-pixel (c-107-3-149-94.hsd1.ca.comcast.net. [107.3.149.94]) by mx.google.com with ESMTPSA id w8sm36039799paj.4.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 28 Aug 2013 14:12:06 -0700 (PDT) Date: Wed, 28 Aug 2013 14:12:17 -0700 From: Kent Overstreet To: Andrew Morton Cc: "Nicholas A. Bellinger" , target-devel , lf-virt , lkml , kvm-devel , "Michael S. Tsirkin" , Asias He , Jens Axboe , Tejun Heo , Ingo Molnar , Andi Kleen , Christoph Lameter , Oleg Nesterov , Christoph Lameter Subject: Re: [PATCH-v3 1/4] idr: Percpu ida Message-ID: <20130828211217.GE1357@kmo-pixel> References: <1376694549-20609-1-git-send-email-nab@linux-iscsi.org> <1376694549-20609-2-git-send-email-nab@linux-iscsi.org> <20130820143157.f91bf59d16352989b54e431e@linux-foundation.org> <20130828195317.GE8032@kmo-pixel> <20130828132332.6d5263ee9622235ae0fcc615@linux-foundation.org> <20130828204454.GC1357@kmo-pixel> <20130828135042.9e460b27699b52bb4eb53d9e@linux-foundation.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130828135042.9e460b27699b52bb4eb53d9e@linux-foundation.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Aug 28, 2013 at 01:50:42PM -0700, Andrew Morton wrote: > On Wed, 28 Aug 2013 13:44:54 -0700 Kent Overstreet 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? --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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)