Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp92844imm; Thu, 21 Jun 2018 14:32:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKmYtVxMxOsTRgHJyDLKgMDozB9km/ZD90PVJ8CzYptJiYlmwBGWxOii8Jnqgp/0vul2weX X-Received: by 2002:a17:902:3081:: with SMTP id v1-v6mr31071218plb.266.1529616762397; Thu, 21 Jun 2018 14:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529616762; cv=none; d=google.com; s=arc-20160816; b=HTRO+cyevyfc7mOGcS9RWexUp/MTFuiGL3kz7Qep/f0EM2ZQLWQncYkumK/NVVbEOM yR3L9edW3/J5VFXeo6u93RJw3UffC9t7tqJh9qFCTN/Od7wMdt+qT9T26Ft79qF6rTw5 7+7/wcAi3i1D2djzpaRYz7bP+vxO9OZcc+1XHQtAF5svUD9unNAsCttENGs13z6h+cIO ZUIjdJzk9qkyBxoyNN1xeINCXGN08gORZVNnvEIo1Vhc5iXQ5Qn52GoTC0dn01RYnN82 5O/yVsnRHT+o+sUVVSqU2PVKmxolRQr9datMPDJMuADNNfSoL19ZbnAQz/k6w369G37N PzjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=nYeeoWQ+885jk0DIMw6lrAOaIXXaNbz0ItnLOxhvbs8=; b=BCVsZG2nS/sz4kY5xXJu1byX/BZnaDDvq21F1lGNStfKzpkPYREP4MfLidJFEo4Vwp Af+NRA42JyBntXXaRr2wb/1PiJkDk3+N37BfoD6yMtUP4pADuk0BvY/BFsZl8xG4QOdI TabmoN1TEG3EVhTgw9IOr3sg5VuHSQacGWa5xq2okJ+GPJ8NWL7JqWuR7G61pQnUxq7K OG0GeRWOzkrSYQJe0S9kOGRmz9xGi1QZvpfKiPjd4PwM82JpvhzzYynXYWaeWJ1oNyDZ cs0758/iKXmtBqWv0dRFN91lY3tWUL0ef0eW3gS8fBYsvUioVao/zon7VsJiwDEqGMV4 rrCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=SF6QeT79; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u16-v6si4580446pgv.409.2018.06.21.14.32.27; Thu, 21 Jun 2018 14:32:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=SF6QeT79; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934055AbeFUVad (ORCPT + 99 others); Thu, 21 Jun 2018 17:30:33 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41860 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933993AbeFUV3M (ORCPT ); Thu, 21 Jun 2018 17:29:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nYeeoWQ+885jk0DIMw6lrAOaIXXaNbz0ItnLOxhvbs8=; b=SF6QeT79doMSajD0g7kJyL8o0 WWx/6Lz89Q/nBZOC2mAVHqsh0HPjMVkbID0DxvC9EReVwv67Ydm5cb3eqZP25lq8TsOMI3h8/lcnp oDoBDqDgSAT36+4kVV8C7JV52QNOHJSrHZsYFKMkxrGuWLHJYLKgVMYHpZVySv4Ror2tIid/KMfOb 8MGIbS2mB6reydyR9XBoeix+RtedZzxS9Fl3q4n3VQtwa8fCZ5Ok5eJl+Um3SDZQaQkYWAdB1lAxd PsZaKQ9U7fXFcGrNlXoDvRN2Gj/UL6JGFaIGFxVrCDwVu8nW44rnVowHFC313sjlT71UPecayOhsP kmELAK4yw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fW78h-0001dT-NX; Thu, 21 Jun 2018 21:29:11 +0000 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Andrew Morton , Eric Biggers , Chris Mi , Rasmus Villemoes , Mel Gorman Subject: [PATCH 26/26] ida: Change ida_get_new_above to return the id Date: Thu, 21 Jun 2018 14:28:35 -0700 Message-Id: <20180621212835.5636-27-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180621212835.5636-1-willy@infradead.org> References: <20180621212835.5636-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This calling convention makes more sense for the implementation as well as the callers. It even shaves 32 bytes off the compiled code size. Signed-off-by: Matthew Wilcox --- lib/idr.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/idr.c b/lib/idr.c index 1dc52191acb6..fab2fd5bc326 100644 --- a/lib/idr.c +++ b/lib/idr.c @@ -363,7 +363,7 @@ EXPORT_SYMBOL(idr_replace); #define IDA_MAX (0x80000000U / IDA_BITMAP_BITS - 1) -static int ida_get_new_above(struct ida *ida, int start, int *id) +static int ida_get_new_above(struct ida *ida, int start) { struct radix_tree_root *root = &ida->ida_rt; void __rcu **slot; @@ -402,8 +402,8 @@ static int ida_get_new_above(struct ida *ida, int start, int *id) if (ebit < BITS_PER_LONG) { tmp |= 1UL << ebit; rcu_assign_pointer(*slot, (void *)tmp); - *id = new + ebit - RADIX_TREE_EXCEPTIONAL_SHIFT; - return 0; + return new + ebit - + RADIX_TREE_EXCEPTIONAL_SHIFT; } bitmap = this_cpu_xchg(ida_bitmap, NULL); if (!bitmap) @@ -434,8 +434,7 @@ static int ida_get_new_above(struct ida *ida, int start, int *id) RADIX_TREE_EXCEPTIONAL_ENTRY); radix_tree_iter_replace(root, &iter, slot, bitmap); - *id = new; - return 0; + return new; } bitmap = this_cpu_xchg(ida_bitmap, NULL); if (!bitmap) @@ -444,8 +443,7 @@ static int ida_get_new_above(struct ida *ida, int start, int *id) radix_tree_iter_replace(root, &iter, slot, bitmap); } - *id = new; - return 0; + return new; } } @@ -534,7 +532,7 @@ EXPORT_SYMBOL(ida_destroy); int ida_alloc_range(struct ida *ida, unsigned int min, unsigned int max, gfp_t gfp) { - int ret, id = 0; + int id = 0; unsigned long flags; if ((int)min < 0) @@ -545,24 +543,20 @@ int ida_alloc_range(struct ida *ida, unsigned int min, unsigned int max, again: xa_lock_irqsave(&ida->ida_rt, flags); - ret = ida_get_new_above(ida, min, &id); - if (!ret) { - if (id > max) { - ida_remove(ida, id); - ret = -ENOSPC; - } else { - ret = id; - } + id = ida_get_new_above(ida, min); + if (id > (int)max) { + ida_remove(ida, id); + id = -ENOSPC; } xa_unlock_irqrestore(&ida->ida_rt, flags); - if (unlikely(ret == -EAGAIN)) { + if (unlikely(id == -EAGAIN)) { if (!ida_pre_get(ida, gfp)) return -ENOMEM; goto again; } - return ret; + return id; } EXPORT_SYMBOL(ida_alloc_range); -- 2.17.1