From patchwork Sun Jun 17 02:00:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10468271 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 DAFDC600CC for ; Sun, 17 Jun 2018 02:02:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8CCB28C6A for ; Sun, 17 Jun 2018 02:02:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD1FC28C75; Sun, 17 Jun 2018 02:02:58 +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 284B428C6A for ; Sun, 17 Jun 2018 02:02:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DDC7A6B0282; Sat, 16 Jun 2018 22:01:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D65876B0284; Sat, 16 Jun 2018 22:01:12 -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 B8FB36B0283; Sat, 16 Jun 2018 22:01:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 6406A6B027F for ; Sat, 16 Jun 2018 22:01:12 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id l2-v6so3115378pff.3 for ; Sat, 16 Jun 2018 19:01:12 -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=NN4Zkd8fg6q/Ddft8oEngd+e5mAY6McH/K0Jtt+4emE=; b=Di5NIAzu45iqxfGVBhQn4mr2ELZi0WB3irHqDvjbk8+6W9unYh31vobNINcbvqdArB Xbpfu6DOJGIa2tiE+WodK/KVt6Yyo1UWOgRZPfZN1XAFcTZuXBivG4/e+JIpqGRKQqHJ +RzKDKs0KgsjS+3L1i+zfOTAZ1Idhggb9MFs4j1qF1M0s0rHAg1+omrPJjDGAj2c7ReI 02rD/2ohQRjR/NixKzg4aJE5kSfdSpCc33/05PKoFW7ssUTtkA2e1XEPvxdPis9D1mwH byN5+zsUSuIL7XMhS5QL/uu3nxqRjtODvBQmCFBqWx0KIOitr4kOVJlB92WvN87sqK2v 2oww== X-Gm-Message-State: APt69E2NEA927oeFhP/8gMiV/bHXNCdwSravMCWuhKP+BOFZad8dYAZv R5aZaZ2WLYqMz/rLOycmDXJGWWVJQK/ZoNUW+9uiuWQ0fEme02SamEIOXz/dhZnCvG88sCof5BE 48Dpd0XPyC8GcVU7NlJAXJYLT88roU0eSU36+ivDQEqQBfyqdhOitoRhyhA2uSIDLxA== X-Received: by 2002:a17:902:3a5:: with SMTP id d34-v6mr8497408pld.103.1529200872099; Sat, 16 Jun 2018 19:01:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK4uHHApsZmAE004Upk1ZTkfunxltpPUg3xkBVNC3Yk9cP3kJVWCQWRKkI4wj7skV5mRsHV X-Received: by 2002:a17:902:3a5:: with SMTP id d34-v6mr8497368pld.103.1529200871271; Sat, 16 Jun 2018 19:01:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529200871; cv=none; d=google.com; s=arc-20160816; b=SHEv6zJIRfe01bDROnvUHaT16Z9bH2gqkfOTB33tgSkWao+AQIurUDpIKro4Ewymx0 nadbvXP8kf8CyXiUr8AOV4+oglKTt28LmX0l9YnAyy11Kso6qyMHQF5ViXlBfi8/bn/8 Y9YBKTbuF6J/utCdQ3cyQD6ZG8Il9f6c2Bfsr7QFAnbHihKjkpTE0O07s87rkVl/mMSl 5Jv4iococ8I+N9H24qLAx7IHcNk0dSBQRS77sGFoCTfGoFKyr+ME+LqbLFTjOkUFWIjx za6ZMmA3qcgPvI9WtTZ+kx+7//CDs4NCEQ1TIN/UyQAjiuSdAWhBsnBeQ8n6ZRoQEg+Y E38A== 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=NN4Zkd8fg6q/Ddft8oEngd+e5mAY6McH/K0Jtt+4emE=; b=W+1QgltXuF3lJTZqkbTtvszuvYCnYWOdqhk3SjI1FgUoN05rR6U/s12vZ/ntFad1yR XYsVcw7J3tdY28urQzpB0tm3yOUVvV82zIh6OLS9JGj15Q+mnjO4bunmFBGaYtBKafta ZE8gO3lhnUvrvSAoX1XsrhhEWryi2b7LEIJTqA/Kl4vtY9n5P8aZpVCE5dGgnEnPxmPa WGIhZtTNP+FnczKExRud+H4NQEkj79DA6HqrbzpS1lMCpxMjHMxk8gF35/zYSqk9C/Y4 Sk86j3g8gStsSQU1A7YYGx7EcLMnkQ0AvODpvEss3QwmLEuFWy2AqBI/1Y77hhaCr/4S RtWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b="gVXIz/NQ"; 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 r59-v6si11289500plb.314.2018.06.16.19.01.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 16 Jun 2018 19:01:11 -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="gVXIz/NQ"; 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=NN4Zkd8fg6q/Ddft8oEngd+e5mAY6McH/K0Jtt+4emE=; b=gVXIz/NQ7xNYWFBur05MdsBfR AubC2EcotKvxAlPvdpiXLMRQ67OK1ovHDzNAKXaDOroV3j4IlZT91Nw1vG2xEFnaOsgrZ5PixQ/QC E1k1l5sOvjIvpLY00tfqOtCD7ePgYuLUgFrnexJQj1puXHtCvU5i5Yz2e06/7Rcp7g6YSA67/7KNt X+DeRowbuBoUfo3lJ719BQ+Kd96Mw+ef661jvJzPXylKbecGEiP+ESogI9lHg+6Z4od4WPxmqEXS4 H7FAPQg9hiDpgYB9f2B5HU3r+i74GOiuRDsryxnlLps7L8zKwQ46LNx6f2Kz5PwcrtWxZBMXULlmu iw7kdI8Dw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUN0A-0001Ok-1U; Sun, 17 Jun 2018 02:01:10 +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 v14 51/74] shmem: Convert shmem_alloc_hugepage to XArray Date: Sat, 16 Jun 2018 19:00:29 -0700 Message-Id: <20180617020052.4759-52-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180617020052.4759-1-willy@infradead.org> References: <20180617020052.4759-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 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,