Received: by 10.213.65.68 with SMTP id h4csp359520imn; Tue, 13 Mar 2018 06:44:24 -0700 (PDT) X-Google-Smtp-Source: AG47ELsS9FJUBujSOF4ihYqcaJ++ZJb+DZTpohTnSvN3gOWlApQEkkO7fcbAoET0qQU+vlwErq+7 X-Received: by 10.99.119.78 with SMTP id s75mr572530pgc.238.1520948664129; Tue, 13 Mar 2018 06:44:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520948664; cv=none; d=google.com; s=arc-20160816; b=XZsmZ6Kx1fAWBVAW7y3AZmRJlUIz7Uiz/BmQK3LTVfRbNCq4gHcPCLLSK1ApuwxcMk 4+Ip920wEA9GXuFWb5adWBscF1l1POjkmiXyrSPQRM+qzZn7zRTXDa16tsJTbL/+bZFF nOqO3gZvZ3ZTreDR9SUcLQ0c/qp3pZrRD6XCkWDvSwcmDC9qlmgB7EX2//mAtpKABJqH ecj9wxZK/kVbl4FU7QwFbFNumBkyZTjoct2u6N+Fb/XJRVT/871UFcMxtpieSoojxbFL TF0cj1zyW5dvj6cwJO3XhzJnJITdTXfJfPOsM2RL/8fup+V92C3/jrGeHRNWKVyNlewu 4snA== 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=dDEsTewQQQIDWgJMtqHX0kZmwiRB8c7pGcIvmxu/0k4=; b=S6YzwGbnm4YcUGxDlKeniMrupVaIwjpXaZVirniiaNnsGyApxxAD9xjA6og3HML6vm +V5RebJm9ZdlAqJ9h8ci04AqsgEpqeACK+w/eKrGKbhb8zCjRSPRmh/wQuAKZKTO/q/h 7fE1NK5FFv3VyFD2HGF6illzg9+mKJDaDsvaUYlu4Fkx2Jqg2ClVjC1n1mfiKxACNTNQ FbWEwMTJm9+UAdIDfqj4OBreUjFkOmW5jiOovRVxlxI46xDdybjKwjgEj0enkGCjBOCx Yi+huY9lPid2upqta6pW4OM61d+eg6RVo2M+ZoNGUrY6MPyLgnVkJzJhqltMDbQwKaRx YB6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=KFFOKwbZ; 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 z8-v6si133007plh.379.2018.03.13.06.44.09; Tue, 13 Mar 2018 06:44:24 -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=KFFOKwbZ; 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 S933105AbeCMNnR (ORCPT + 99 others); Tue, 13 Mar 2018 09:43:17 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35240 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752240AbeCMN04 (ORCPT ); Tue, 13 Mar 2018 09:26:56 -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=dDEsTewQQQIDWgJMtqHX0kZmwiRB8c7pGcIvmxu/0k4=; b=KFFOKwbZiRni2aAa43iod001u /TSDbV5yJWIk7GBhx0prFI2nexqJ/g9eWMjaUQjEB5nL0ZmqYGRLq4XoqQdtEo/GX44IorhZ93E6Q zgMQBj5x20JovJD4F3rHWHfI/CfQ5IItdTHe1q/f2MzTYUCPc1boN/h93NAJclDXSpG35XoSDDM+s 2bhpu/SwU/9EyWijXZzw8RkJ53cySFW4wRjQ2TJlvpIXdaN5SZfWOi40XSt7YGzwZx9HAI4FUEMj4 XQCJoBi3gWw/72wP0hU3aYA9xI7K1scEBs3iXrto1pUEOnmAlG3KTxe8/09D4C7q87oytRfvCttfC fouR9Q2oA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1evjx7-0004eQ-6o; Tue, 13 Mar 2018 13:26:53 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Ryusuke Konishi , linux-nilfs@vger.kernel.org Subject: [PATCH v9 29/61] page cache: Convert delete_batch to XArray Date: Tue, 13 Mar 2018 06:26:07 -0700 Message-Id: <20180313132639.17387-30-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313132639.17387-1-willy@infradead.org> References: <20180313132639.17387-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 5a6c7c874d45..0635e9cdbc06 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -275,7 +275,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 * @@ -288,23 +288,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) { @@ -313,8 +308,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; @@ -325,11 +323,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; @@ -350,7 +348,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.16.1