Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4255720imm; Mon, 11 Jun 2018 09:19:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJWSbdFORt0GqnmRcG5Z0dhcMvTi5QQyrqQ7/v8cVS3G/cYxXdRzxzvs7mLgHP8NTuyd/X6 X-Received: by 2002:a17:902:292b:: with SMTP id g40-v6mr3391008plb.273.1528733966068; Mon, 11 Jun 2018 09:19:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528733966; cv=none; d=google.com; s=arc-20160816; b=y/glf7W1wAliuvwfHuD5RBCyKMx4uZVxlGmkt1lV5ZQxlXKTHF5lFuWTknmgMPM73G BKgjmIjo3r+tNjDeamuPri9g+aaK3zhV9nyUX0ys4FNb/joqOtrVj+ds7V9r3sWwHQ88 cUbVlUQ5cqCL2WO/5McNCZ4iyOn+Vsu6CabAI9MW/k/4cLQg4W2QrJmMlVNBPSPoi7UU q90gviwXk2EBV8J6pSy95O/GuqHG/z7IK7JvmmxkdoJ60MZblPjHdAlxyxRP/D1gRbV/ EYODx9Khvqby6Vi7wVTkQI1wTWpYoNk10b94ZHAblBorObgaF2YOj2rlY71/ryb7WHgo 8EZw== 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=vztI3PFiV1oRpjbw6Dx7xbzxLIG1vQILFc4ZeoFT7jQ=; b=MXnWpAKiXp/Ty2BfWrhu0AbwXeuJ7A7JOhvnRWHbqTP+zqIiykpMqVG7gjtY773xxL d3hv8BetMkEhqmlwfdR+W6XdXRQhKcY+xD3cMboN3gTsmRXpXzpohki7tp/CuFtD9gLe jSL4PiVp835LLYF1AolhBKMhLph6ijI5Eh4nOVP3R9IluV2V2z9m3hZ9t9Olkb6WKd4q WgSpQbUTIbkH32ZcHK73+3Dw/c13slBdQIgYhUCm1PQgIfudFGgOtJeY1INn9EnYwsNI s2jpZY+IsbpoSqD8gDBWencX6PfYlAnnVaNkgmSPLE+63qUj3xcpZYF0TQArqZ4U6Pxa 5aGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=QsSqvfde; 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 j12-v6si18387966pgc.584.2018.06.11.09.19.12; Mon, 11 Jun 2018 09:19:26 -0700 (PDT) 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=QsSqvfde; 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 S934223AbeFKOW3 (ORCPT + 99 others); Mon, 11 Jun 2018 10:22:29 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45464 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933501AbeFKOGx (ORCPT ); Mon, 11 Jun 2018 10:06:53 -0400 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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++) -- 2.17.1