From patchwork Sun Jun 17 02:00:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10468371 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 BFFCF603B4 for ; Sun, 17 Jun 2018 02:05:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0A0128D38 for ; Sun, 17 Jun 2018 02:05:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4FDF28D44; Sun, 17 Jun 2018 02:05:18 +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 1AD8D28D38 for ; Sun, 17 Jun 2018 02:05:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12F4C6B02CA; Sat, 16 Jun 2018 22:02:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0B9266B02CB; Sat, 16 Jun 2018 22:02:39 -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 E9BCC6B02CE; Sat, 16 Jun 2018 22:02:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id 7073A6B02CA for ; Sat, 16 Jun 2018 22:02:38 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id 89-v6so7734788plc.1 for ; Sat, 16 Jun 2018 19:02:38 -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=I3UYxOubL92+FRQCHMpYAsogvmB5EZGLLIeZ/JtzqLA=; b=Muq1+vAB3RyuOREa9IiFZ/Wv286ZpJAlMNvdR77G01m7FZ0F3ct23VOgSRLOA7LT0F NMZWj6t+SRg9d5ZPIOvhML656vICLdR9cthPH9SvpdzbfWGnHaNGX+Xdscst8IjLqWAE /4qc1OsXSJjT6H4t8bgMgde4hMnByYPDvNyBNQskbuMmUxsxTQra0fmXJsFIox9XgiHE EDZ9hEJCuIJkkk45197a6crnd3pzRBRegN5sUZhhzhtasWMWJzRFQ5z6Wl1nv77UMN5B GRvDw2gtd4zW4kZqB5L07imoDT1kS6juF3QNlUTiFa2RrWM6mdfJasNho9fIkip4D+pt 7qwA== X-Gm-Message-State: APt69E1YeH7PaOqoS0aZl3JdjxTj4E3GkS3Df5wsznAl5RxmR/C47AoL gU1AfE9ZLOeD/9fkC6hHwZ7H6qslzy4aHZkl1Pdi6XGJ976w9WtCZn7giZsIOmcjhRQb/BVqJl/ 29LK7BHaLaOrEByXYVOBILe5oqiUj3TTmXESGxrkZ7SvNNCc3Fm2ze1CrLJ87Qq6L5Q== X-Received: by 2002:a17:902:294a:: with SMTP id g68-v6mr8628565plb.58.1529200958166; Sat, 16 Jun 2018 19:02:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIpYenTdpLWT1FhxEtCuRZpSbalnvZaxd1YFgfQgIq4PsF65EKSf5Oo9GTWk4m9o7nB8Wcy X-Received: by 2002:a17:902:294a:: with SMTP id g68-v6mr8623965plb.58.1529200862016; Sat, 16 Jun 2018 19:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529200861; cv=none; d=google.com; s=arc-20160816; b=pAEqH1aAm68U7Uh98nMnM8NlhxRQbJHGg43o/FuMfo3rkpJpZktM+WTicBp5Iv9Vv0 Khlc8D4Sin0V16+cKXsAi//7XKr/rcyliVP2cH/F5hEvXT2zNxGW8WI58u4NUPz46j8L ulcDhXClU2TFMLL9MpLEBeQ10VLobMQkwtPo+b9+fmd0JJjLpl2u2/2bmdt/pTZjAYK5 0L8gXbY605gzZkQYHr2l+HlFKgva+BXwvgbnJBH3fhKZ7zsY6NGhF031dYvgZ/5ihXcM 0+DZHSlryW7wx5HsTU39AaYtxMyy4MtBUA9nwshM4okNEK+guwGigH3fjBSxaBEuc7BO wydA== 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=I3UYxOubL92+FRQCHMpYAsogvmB5EZGLLIeZ/JtzqLA=; b=yC9OuV77VDF0vgT2P69XVvHyG13DnqtCqcTptaz7k/i9z+BLESfvEvnTNDUOVwsXTS CWTAk2oasdtwfEHpkBVK08pAKdsDRv8HJOAd6IcazodWAQg1PwoYLXjh2dvrElhnlkjb aoiYSxZbb8Aaz+sRqY8Rv7nvUM3Xts53JDhKuQfm0dT58p4DdPhXssxrglHpwN37eId0 7fCFgxUZNVHKWk/cl7L0tZD8EAnDVQCmG9uLFapytOQ1NigKc+cBTExh3teARspeckQA +iOW7PVm6RdFgXe+GdL00kBgOJwlBMKCkVGXMnwO5j8PYUEMQa9+se75cG9IT1Jzq0Jh Re3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=EQE3FOTE; 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 r6-v6si9476335pgp.426.2018.06.16.19.01.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 16 Jun 2018 19:01:01 -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=EQE3FOTE; 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=I3UYxOubL92+FRQCHMpYAsogvmB5EZGLLIeZ/JtzqLA=; b=EQE3FOTEF9wQtH0fGRuJdRy51 Uppi47EMy2yO6d1DXQSRTcumVl3sFNX19HANo1Cu7IQ0IAWyYJHftsWZnn+HAiIU8aCxQXSbMMuA8 7XjgOUnwjnyUYpEDOHi617u44LKBvG/ztdbIsKnrWe0r7YC1vruDTnmjlyfXq4fDrLLonktNGKVIf YEdiywJWQkhWRAmmRqHIVcUTNw5qT4y1hSJszTPwy9OUzqMqieGmNYuQkT6Z66jkfT8ySLWJEv1GG /lLTyO9SmDpLtoHSMVdlKPVxxFZnqpWz0RFIifkzMLJ9hC3H5YtHao+vTnWHoJ8WsXhiHteRjcXik UFAmXRh+g==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUN01-0001JB-4u; Sun, 17 Jun 2018 02:01:01 +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 32/74] page cache: Convert delete_batch to XArray Date: Sat, 16 Jun 2018 19:00:10 -0700 Message-Id: <20180617020052.4759-33-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 Rename the function from page_cache_tree_delete_batch to just page_cache_delete_batch. Signed-off-by: Matthew Wilcox --- mm/filemap.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 4204d9df003b..025077bc82be 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -272,7 +272,7 @@ void delete_from_page_cache(struct page *page) EXPORT_SYMBOL(delete_from_page_cache); /* - * page_cache_tree_delete_batch - delete several pages from page cache + * page_cache_delete_batch - delete several pages from page cache * @mapping: the mapping to which pages belong * @pvec: pagevec with pages to delete * @@ -285,23 +285,18 @@ EXPORT_SYMBOL(delete_from_page_cache); * * The function expects the i_pages lock to be held. */ -static void -page_cache_tree_delete_batch(struct address_space *mapping, +static void page_cache_delete_batch(struct address_space *mapping, struct pagevec *pvec) { - struct radix_tree_iter iter; - void **slot; + XA_STATE(xas, &mapping->i_pages, pvec->pages[0]->index); int total_pages = 0; int i = 0, tail_pages = 0; struct page *page; - pgoff_t start; - start = pvec->pages[0]->index; - radix_tree_for_each_slot(slot, &mapping->i_pages, &iter, start) { + mapping_set_update(&xas, mapping); + xas_for_each(&xas, page, ULONG_MAX) { if (i >= pagevec_count(pvec) && !tail_pages) break; - page = radix_tree_deref_slot_protected(slot, - &mapping->i_pages.xa_lock); if (xa_is_value(page)) continue; if (!tail_pages) { @@ -310,8 +305,11 @@ page_cache_tree_delete_batch(struct address_space *mapping, * have our pages locked so they are protected from * being removed. */ - if (page != pvec->pages[i]) + if (page != pvec->pages[i]) { + VM_BUG_ON_PAGE(page->index > + pvec->pages[i]->index, page); continue; + } WARN_ON_ONCE(!PageLocked(page)); if (PageTransHuge(page) && !PageHuge(page)) tail_pages = HPAGE_PMD_NR - 1; @@ -322,11 +320,11 @@ page_cache_tree_delete_batch(struct address_space *mapping, */ i++; } else { + VM_BUG_ON_PAGE(page->index + HPAGE_PMD_NR - tail_pages + != pvec->pages[i]->index, page); tail_pages--; } - radix_tree_clear_tags(&mapping->i_pages, iter.node, slot); - __radix_tree_replace(&mapping->i_pages, iter.node, slot, NULL, - workingset_lookup_update(mapping)); + xas_store(&xas, NULL); total_pages++; } mapping->nrpages -= total_pages; @@ -347,7 +345,7 @@ void delete_from_page_cache_batch(struct address_space *mapping, unaccount_page_cache_page(mapping, pvec->pages[i]); } - page_cache_tree_delete_batch(mapping, pvec); + page_cache_delete_batch(mapping, pvec); xa_unlock_irqrestore(&mapping->i_pages, flags); for (i = 0; i < pagevec_count(pvec); i++)