Received: by 10.223.164.202 with SMTP id h10csp657511wrb; Wed, 22 Nov 2017 13:10:44 -0800 (PST) X-Google-Smtp-Source: AGs4zMZqzZeaa3bJNJXSwdrFs49JKFiws5z/6MdSahAAyJgVPqxos6czWlxI4rP+tqbLyfdsdY7m X-Received: by 10.84.160.203 with SMTP id v11mr1238485plg.449.1511385044380; Wed, 22 Nov 2017 13:10:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511385044; cv=none; d=google.com; s=arc-20160816; b=c4b9Bs7YfDKARqmR5d6var3Jjz64Fz5YsgoM+XuouGrrxQPeN2gVRe/PivoKCWu5KA QnF5jAqhYw5i0wqdOVlCH9kTbOucAv85HrjwXRc8Im2dDELzzRpxLkz6odpTdZkuYeDM /56vUyQ9Ltihu5t+19D49ipoDutZe6jbyXzMHAD3ygDdDn6DgkqS81vOLigRmjZLatLb NilVxoN1lTT6PpkBRvN5uOQf87nUMgO0aXuNSPaOwomsQvxjZsjfOu0AyxwwvwPRdX8Y xmvBQVUvpO45xSdROptPcQjEWK/UjmTqJvljQu8Pil5dOL07RZl1PNWF4Qxjk17kcvS1 TxRQ== 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=9ME8RF20v9/tQFJ/lzPLMAaYr9o65onb9TlG+J07aIQ=; b=PXXiuocoU7Sv6mf4PnXuL9Yiyl2zNlwUrHvd4Ty9ZVcNP45yjBr4ryPQDRYDRuGTBK 234tgY/KQBPai8zvdCJTX1FnIEObyCyXTqgotNdO3f7pOTt7JLrQFLdg6HLmJ9Pg9jIl kpd7GVOMFZ5hZ8Mtx8f/+CD//fNWy/HmTnGbNfWCadn7iWN2ILWCd0m6AJ682vfF/ZCV EkqGTOyh6fOqbEVcYIGZzWxZ7HG1age00gEW0j1RiC1a5tnn9R5iu1i0RIWPRcFfHtuc K01Y6svT/o7mbTtUxtAuw5SfZTxv5kFPr1D5SjulXyvMyHnn6fmp4DlHspNTmYPCOpLK CeKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=jIZsKypN; 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 d15si11828324pli.594.2017.11.22.13.10.33; Wed, 22 Nov 2017 13:10:44 -0800 (PST) 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=jIZsKypN; 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 S1752103AbdKVVJT (ORCPT + 77 others); Wed, 22 Nov 2017 16:09:19 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:58689 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751888AbdKVVIU (ORCPT ); Wed, 22 Nov 2017 16:08:20 -0500 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=9ME8RF20v9/tQFJ/lzPLMAaYr9o65onb9TlG+J07aIQ=; b=jIZsKypNT95/amoKkdVyfyN4u WgSFTRoAW6NG3uNceTbyUBUlmlcS5onWswiaYhDHtfaZCaVN+JpE4rGTpkgStYC3wMYRc5LnNHUqX bsdxMhSm9lOkuiHE+G1bBbBG8M7g4YcgdgR6ViMW+IrZwm/AiMRv+ZkK6fbJ+oaGWga92+Mdi23Pj kMPnCjgSWftyNhHYHitgrXKzb9uebhJ7lwI4bNrzSXoNkvucNbiuj+phC60kDd0WCfFu+s+iM/y+s F0Xf4HT8yB0nF4fHfcpbZH/meW24ur1JI+E8ujcVdBFR1Y8DyEOtepYtGhhvgiY/0JdPfaJ4T4CIF ItRzJJh7Q==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eHcFn-0007xU-Iq; Wed, 22 Nov 2017 21:08:19 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 48/62] block: Remove IDR preloading Date: Wed, 22 Nov 2017 13:07:25 -0800 Message-Id: <20171122210739.29916-49-willy@infradead.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171122210739.29916-1-willy@infradead.org> References: <20171122210739.29916-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox The IDR now handles its own locking, so if we remove the locking in genhd, we can also remove the memory preloading. The genhd needs to protect the object retrieved from the IDR against removal until its refcount has been elevated, so hold the IDR's lock during lookup. Signed-off-by: Matthew Wilcox --- block/genhd.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index c2223f12a805..d50bd99e8ce2 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -30,10 +30,7 @@ struct kobject *block_depr; /* for extended dynamic devt allocation, currently only one major is used */ #define NR_EXT_DEVT (1 << MINORBITS) -/* For extended devt allocation. ext_devt_lock prevents look up - * results from going away underneath its user. - */ -static DEFINE_SPINLOCK(ext_devt_lock); +/* For extended devt allocation. */ static DEFINE_IDR(ext_devt_idr); static const struct device_type disk_type; @@ -467,14 +464,7 @@ int blk_alloc_devt(struct hd_struct *part, dev_t *devt) return 0; } - /* allocate ext devt */ - idr_preload(GFP_KERNEL); - - spin_lock_bh(&ext_devt_lock); - idx = idr_alloc(&ext_devt_idr, part, 0, NR_EXT_DEVT, GFP_NOWAIT); - spin_unlock_bh(&ext_devt_lock); - - idr_preload_end(); + idx = idr_alloc(&ext_devt_idr, part, 0, NR_EXT_DEVT, GFP_KERNEL); if (idx < 0) return idx == -ENOSPC ? -EBUSY : idx; @@ -496,11 +486,8 @@ void blk_free_devt(dev_t devt) if (devt == MKDEV(0, 0)) return; - if (MAJOR(devt) == BLOCK_EXT_MAJOR) { - spin_lock_bh(&ext_devt_lock); + if (MAJOR(devt) == BLOCK_EXT_MAJOR) idr_remove(&ext_devt_idr, blk_mangle_minor(MINOR(devt))); - spin_unlock_bh(&ext_devt_lock); - } } static char *bdevt_str(dev_t devt, char *buf) @@ -789,13 +776,13 @@ struct gendisk *get_gendisk(dev_t devt, int *partno) } else { struct hd_struct *part; - spin_lock_bh(&ext_devt_lock); + idr_lock_bh(&ext_devt_idr); part = idr_find(&ext_devt_idr, blk_mangle_minor(MINOR(devt))); if (part && get_disk(part_to_disk(part))) { *partno = part->partno; disk = part_to_disk(part); } - spin_unlock_bh(&ext_devt_lock); + idr_unlock_bh(&ext_devt_idr); } if (disk && unlikely(disk->flags & GENHD_FL_HIDDEN)) { -- 2.15.0 From 1583306679208899120@xxx Mon Nov 06 09:01:54 +0000 2017 X-GM-THRID: 1583306679208899120 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread