From patchwork Mon Jun 11 14:06:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10457985 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6EE2A601A0 for ; Mon, 11 Jun 2018 14:10:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B79A2857F for ; Mon, 11 Jun 2018 14:10:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 574322858E; Mon, 11 Jun 2018 14:10:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 869BA285CD for ; Mon, 11 Jun 2018 14:10:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D3896B0292; Mon, 11 Jun 2018 10:07:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 80A3D6B0293; Mon, 11 Jun 2018 10:07:06 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6AC4E6B0294; Mon, 11 Jun 2018 10:07:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f69.google.com (mail-pg0-f69.google.com [74.125.83.69]) by kanga.kvack.org (Postfix) with ESMTP id 135BF6B0292 for ; Mon, 11 Jun 2018 10:07:06 -0400 (EDT) Received: by mail-pg0-f69.google.com with SMTP id e1-v6so6618154pgp.20 for ; Mon, 11 Jun 2018 07:07:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=dIxHgBOv6pgPfuiAK0rYpNrQbLlk2aplXo3SctHWK5E=; b=pTT/qhMdQz+d0a7JhOj2Rw138iydshnxhTL39cYrJTtJOLRSx7Dj+9bDe0PYwumjD5 4hyPn2azD7lQpvL5z/OSPYkCuNZXwxIK0xC8H5kHDFCRAGDkJaK5ukd9JcYVoZqePRG4 JFuhiYPRxrHVnmZv3HWOy3LwQwSFV3atn0eeN8YYv5YGOOflCna/ujy7W8vOcQmAOusr RQWRMIGFz2bIJ3437pFFNPGZGPlRsRfBh/m9jE2l0rKq2bRCJQjMu97ZZSh/l6vxPCJk EZSH4yid1JOyGNfKJL1z16379sjRTWPNJAcYftuUXU5Cc+IUGmBKvjmMTwQrZUhC/V2h LgNg== X-Gm-Message-State: APt69E08vkjfOJqMKIXjzl0XtNMpWgmx8q+M/20fSMkWk5vrID2W365z DYDeTb4Cuo9bxRcnfHWJDJw+TXYUlfg/NCl4nDfJwAzSa+3WhNZFhk6rfzLyEASSFmCFozj2g7e 1WH7rqUuSZyJZ61FxGnAg6DSAbh03eO5j+GnA/4Vg0HYSj/ZKDfqqlxsx7ihiaD/8ww== X-Received: by 2002:a63:2505:: with SMTP id l5-v6mr15347141pgl.40.1528726025719; Mon, 11 Jun 2018 07:07:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ8OwUZLnwWwWMGUp/YVkcX9ai3EyzJM6ff5A8NT8xvyTobklpPOjT/NuKGSEdUHcUKP/OX X-Received: by 2002:a63:2505:: with SMTP id l5-v6mr15347075pgl.40.1528726024755; Mon, 11 Jun 2018 07:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528726024; cv=none; d=google.com; s=arc-20160816; b=Kt7oAjdmy5Bhs1I3MguyjJHD3yMS9q7Xj0FI/y96CIl/ZIlnifF01gM5DXop8sYzYI DoK6AAg2M9fnV5xJlz+NfD5wH4jNI7UrkofeJyglTylvMZcZ5hD+v8dpQkIPM6isdp+s G6ZdD72+t5P7Wf1ggrbUm9OZDACU05MRgXhAQcjTYZVW+4jAH7uBiopO9d25xvk1oHuH uw5DMlv88wgY3L750klj2GRNi5w2hJZJAzzDDzArkVReElY5WVuFTU1FNE2f4vRMLZLi O3MCWbUGxAzT+zMjUEdAtw6BORmap7dsIM2vGd4hzPRGC2oZts1ZszOF1/D6K3Umk3ue z/2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=dIxHgBOv6pgPfuiAK0rYpNrQbLlk2aplXo3SctHWK5E=; b=t/w/7gh9ZXOrRQCC5Ae5jAfevbZtmI29GgTEF4TRODkjpdRQyb/43D+ooayGHQj1vt gX2dbBuJdIqUZgz+YLuSoYqVw//nuP8wNAF9EcDV19JPZMSyj2gSZtUBBxyAq7qlBrAx kqaWvJQQoUOOv15QdX49l0hNBdB3UPQc1pVztHsFF1q2dpsj9X2qQyz6AMImLwTVKJxz iCH0aWS5/Vhp0j9evUeMXg37Kwpuilxj95jU+vB2NwpDNPxhRLQX91m5q5hUELhatdeK /z5OI9h11EC4gBlY6jRDPOyr09iwUti7/zNxC7euClDixSkLB1EPZHwYj+t9Xrjq0gjD /YNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=WCmPm52N; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id u5-v6si7512859pfn.339.2018.06.11.07.07.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 07:07:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=WCmPm52N; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org 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=dIxHgBOv6pgPfuiAK0rYpNrQbLlk2aplXo3SctHWK5E=; b=WCmPm52No5vlvtBIbzSjg2eot eHVrbEufiqmR7C3VkDQMlywV+aYD9dwGUz4ikWGDU2AccjuCvKZodENhqAmxLpm1SWfTce5HzjWG5 4TdgyyFRWWJoe7bhq9xagGsrSR7WU2ocuJB3Mh52whXD2Kr1kqvNqrzPMngq1sPtRDtX0YSJ3S3Rq Eycbt3S8gsTD/+FlYSORbl32uKVFDAZSY5/50VespkFept0iMcEi9J9GYJkLHYonaEwM+AI9rZ20C xMNTY4CTwYsqs+NvqAWRMHhunvA70sAdIEZWjS/D1irL19tAk+soAZlBdO3mwMd5Lsf1DC9Jv3DhF XJRQE4tdw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNTM-0004tp-0G; Mon, 11 Jun 2018 14:07:04 +0000 From: Matthew Wilcox To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Jan Kara , Jeff Layton , Lukas Czerner , Ross Zwisler , Christoph Hellwig , Goldwyn Rodrigues , Nicholas Piggin , Ryusuke Konishi , linux-nilfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH v13 50/72] shmem: Convert shmem_alloc_hugepage to XArray Date: Mon, 11 Jun 2018 07:06:17 -0700 Message-Id: <20180611140639.17215-51-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180611140639.17215-1-willy@infradead.org> References: <20180611140639.17215-1-willy@infradead.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox xa_find() is a slightly easier API to use than radix_tree_gang_lookup_slot() because it contains its own RCU locking. This commit removes the last user of radix_tree_gang_lookup_slot() so remove the function too. Signed-off-by: Matthew Wilcox --- include/linux/radix-tree.h | 6 +----- lib/radix-tree.c | 44 +------------------------------------- mm/shmem.c | 14 ++++-------- 3 files changed, 6 insertions(+), 58 deletions(-) diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h index eefa0b099dd5..081e68b4376b 100644 --- a/include/linux/radix-tree.h +++ b/include/linux/radix-tree.h @@ -147,12 +147,11 @@ static inline unsigned int iter_shift(const struct radix_tree_iter *iter) * radix_tree_lookup_slot * radix_tree_tag_get * radix_tree_gang_lookup - * radix_tree_gang_lookup_slot * radix_tree_gang_lookup_tag * radix_tree_gang_lookup_tag_slot * radix_tree_tagged * - * The first 8 functions are able to be called locklessly, using RCU. The + * The first 7 functions are able to be called locklessly, using RCU. The * caller must ensure calls to these functions are made within rcu_read_lock() * regions. Other readers (lock-free or otherwise) and modifications may be * running concurrently. @@ -263,9 +262,6 @@ void radix_tree_clear_tags(struct radix_tree_root *, struct radix_tree_node *, unsigned int radix_tree_gang_lookup(const struct radix_tree_root *, void **results, unsigned long first_index, unsigned int max_items); -unsigned int radix_tree_gang_lookup_slot(const struct radix_tree_root *, - void __rcu ***results, unsigned long *indices, - unsigned long first_index, unsigned int max_items); int radix_tree_preload(gfp_t gfp_mask); int radix_tree_maybe_preload(gfp_t gfp_mask); int radix_tree_maybe_preload_order(gfp_t gfp_mask, int order); diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 5c8a262f506c..d0f44ea96945 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -1138,7 +1138,7 @@ void __radix_tree_replace(struct radix_tree_root *root, * @slot: pointer to slot * @item: new item to store in the slot. * - * For use with radix_tree_lookup_slot(), radix_tree_gang_lookup_slot(), + * For use with radix_tree_lookup_slot() and * radix_tree_gang_lookup_tag_slot(). Caller must hold tree write locked * across slot lookup and replacement. * @@ -1772,48 +1772,6 @@ radix_tree_gang_lookup(const struct radix_tree_root *root, void **results, } EXPORT_SYMBOL(radix_tree_gang_lookup); -/** - * radix_tree_gang_lookup_slot - perform multiple slot lookup on radix tree - * @root: radix tree root - * @results: where the results of the lookup are placed - * @indices: where their indices should be placed (but usually NULL) - * @first_index: start the lookup from this key - * @max_items: place up to this many items at *results - * - * Performs an index-ascending scan of the tree for present items. Places - * their slots at *@results and returns the number of items which were - * placed at *@results. - * - * The implementation is naive. - * - * Like radix_tree_gang_lookup as far as RCU and locking goes. Slots must - * be dereferenced with radix_tree_deref_slot, and if using only RCU - * protection, radix_tree_deref_slot may fail requiring a retry. - */ -unsigned int -radix_tree_gang_lookup_slot(const struct radix_tree_root *root, - void __rcu ***results, unsigned long *indices, - unsigned long first_index, unsigned int max_items) -{ - struct radix_tree_iter iter; - void __rcu **slot; - unsigned int ret = 0; - - if (unlikely(!max_items)) - return 0; - - radix_tree_for_each_slot(slot, root, &iter, first_index) { - results[ret] = slot; - if (indices) - indices[ret] = iter.index; - if (++ret == max_items) - break; - } - - return ret; -} -EXPORT_SYMBOL(radix_tree_gang_lookup_slot); - /** * radix_tree_gang_lookup_tag - perform multiple lookup on a radix tree * based on a tag diff --git a/mm/shmem.c b/mm/shmem.c index 8e702b6d84a5..09452ca79220 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1434,23 +1434,17 @@ static struct page *shmem_alloc_hugepage(gfp_t gfp, struct shmem_inode_info *info, pgoff_t index) { struct vm_area_struct pvma; - struct inode *inode = &info->vfs_inode; - struct address_space *mapping = inode->i_mapping; - pgoff_t idx, hindex; - void __rcu **results; + struct address_space *mapping = info->vfs_inode.i_mapping; + pgoff_t hindex; struct page *page; if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) return NULL; hindex = round_down(index, HPAGE_PMD_NR); - rcu_read_lock(); - if (radix_tree_gang_lookup_slot(&mapping->i_pages, &results, &idx, - hindex, 1) && idx < hindex + HPAGE_PMD_NR) { - rcu_read_unlock(); + if (xa_find(&mapping->i_pages, &hindex, hindex + HPAGE_PMD_NR - 1, + XA_PRESENT)) return NULL; - } - rcu_read_unlock(); shmem_pseudo_vma_init(&pvma, info, hindex); page = alloc_pages_vma(gfp | __GFP_COMP | __GFP_NORETRY | __GFP_NOWARN,