From patchwork Mon Jun 11 14:05:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10457931 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 E26BA60467 for ; Mon, 11 Jun 2018 14:08:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D022A28434 for ; Mon, 11 Jun 2018 14:08:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4A942846D; Mon, 11 Jun 2018 14:08:54 +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 54A8828434 for ; Mon, 11 Jun 2018 14:08:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C80796B027F; Mon, 11 Jun 2018 10:06:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BDAB46B0280; Mon, 11 Jun 2018 10:06:55 -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 A7DB56B0281; Mon, 11 Jun 2018 10:06:55 -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 587286B0280 for ; Mon, 11 Jun 2018 10:06:55 -0400 (EDT) Received: by mail-pg0-f69.google.com with SMTP id t5-v6so6575041pgt.18 for ; Mon, 11 Jun 2018 07:06:55 -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=vztI3PFiV1oRpjbw6Dx7xbzxLIG1vQILFc4ZeoFT7jQ=; b=VL/bjVywU+av0CYaloR4iRnUTNjnBVwje/ekn9nY9TzyrSKOWTE2//txoHJ0TErN/n 9UV/yzYoUAd1ArCuobJ16eEt+q06385eExS7M0pG/NruUXdFQXGizi9IfpNrDfeXkSX0 IA1grEpkr5tJBfUVaQstVgwO14xI/19iQUZtR/vcKfn2xMBpaUIFIrTPIICQlmx6hW34 C/UmhEX2KQqVX0FmqRnyZfTEhuSqvHSMr88WOqfqhE27zRr2yNzaBriNkSy8cGJcvbCX CP7BZqFtatn6eEDKbROZ7HcTi0JtCVKqvHeMtu7kKNxoDJC0vDBQQGQ1umf3JLZyOfrI TH5g== X-Gm-Message-State: APt69E0O3N+WaLSKNfl9O7mREEJUydBcSRakGNMsZzx/MH24URgLrdDB IeklhXuJyNI7I9BA0CCRLr/Kg7nSRG38rlHSH358V8/f5Z/6PXIA7dRuN1tWE1T60/mv9K032WT VOCbNHCKa4iBwaZqNSzv/a0i0W9jn7I/pZ9KsAwNJ/J3ftujuDsNIHmu7uFewxD9Tow== X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr18624036pla.88.1528726015069; Mon, 11 Jun 2018 07:06:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJFjGqQEqyg2fNo/Z0N68QZsNAyf9/e1gMsxYhl4oA4OES9/mEHhGMfPEGPAen7UaD71qKQ X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr18623969pla.88.1528726014175; Mon, 11 Jun 2018 07:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528726014; cv=none; d=google.com; s=arc-20160816; b=ymvhVw8gODhiAzqfQcD7XFqhIdepFLLlX2qwOBwFwgqUbrE67ibIWEtAkdLA7E7qFW FiUMytdId5/EF4dC/tlRCXCPB0bSmMTtvlDwTaTzoHP76BD6Yykt2Ts8+c8z4oMcSgZf x1/rKmUEhdjYgcGgyFcIqqMhI+czPG8/UT5pB/KNqqCuTqykp1CfXSWFlR8CyufVYgGU HwR+B+Igrjx+PYNdKx35Eruc3JYVDTcjTIM+C7EwIfztn6u4jDP/I4YMZL6w7IhqQ2kI F37/D3ngP/kxIVXzkajmCITn6ncxt0QrvL6IQlBWX+DR3ZKjigNprWOOAbd0iGHr00ta Ulqg== 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=vztI3PFiV1oRpjbw6Dx7xbzxLIG1vQILFc4ZeoFT7jQ=; b=uTCa61IWQPk+kZlcGEviRiIMs0cDEc94FQOU41SD+TJ3Hu1nUyzaSAkGl54Qy0l2Gx jIMUbToDP01t3KpV005JjDKq0YBHwR+q20bOZmD+kQI24K4EgztZs7aOjdAm6cNkdsff XBDzBDuqA9ObTr14yZm2ICx9RBnfmw/N6QvWFOUbuwaTNxi24eQiyXZFrS6mxfODkEGz fCX2Sl1McGRhA2bIBjPCKzHq91RZGXAx3gC5nDUUNMMguIRjURz/iKSJ+8XdzEw/K6xh 19ACUWiFnI3BjfqjL2N2vOM/OIzDXWA1bWaIonT+UsKiDkRsoAEOqBItwbWj/uQzlNc1 sqMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=QsSqvfde; 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 j11-v6si34025501pgn.129.2018.06.11.07.06.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 07:06:54 -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=QsSqvfde; 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=vztI3PFiV1oRpjbw6Dx7xbzxLIG1vQILFc4ZeoFT7jQ=; b=QsSqvfde7ULwth2/m6sPiXpMt IHoKK9JldhZgUv1uX6GqtD/jcVdTFowlPB8z+YoYA/1sR7qNihZCVGzTxrMdjK5t1uXF5dgp0uNfz QFte+gkPYdclv+rHvRU70CeK8okGF9zQUn4F6AlTWEcPHfTFX7PZtc8K56PlBSl4pws142u6owaf9 CHBfIthvND2uMWcRTFy+2B7tiA9f2JeKbbxpdzw8/oleG/HNzlVSucd/p2OAqagyUmYGGtH9CYuoK 7T+fs7kPfZ6ArfvErXR6DfuKH2BwKUzTyN64LEuinRfIhA5sbx56fwj6KpiT47efgeKRxLm0eMUhA meG6MLCvA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNTB-0004ic-6u; Mon, 11 Jun 2018 14:06:53 +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 31/72] page cache: Convert delete_batch to XArray Date: Mon, 11 Jun 2018 07:05:58 -0700 Message-Id: <20180611140639.17215-32-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 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++)