Received: by 10.213.65.68 with SMTP id h4csp360241imn; Tue, 13 Mar 2018 06:45:48 -0700 (PDT) X-Google-Smtp-Source: AG47ELs32YAzaMhGjMOZ9R8t4mFnmfbfm++39Ifhy+vK00dmtogsxMcfHFUXgsgeZJYANrk0QEJG X-Received: by 10.99.167.2 with SMTP id d2mr554500pgf.408.1520948748079; Tue, 13 Mar 2018 06:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520948748; cv=none; d=google.com; s=arc-20160816; b=0EsZrCvSaQoUIVo482PhZYKajcdcOfE7djUZ/VPqn4BP9YvdInOnvzih5olcmCsBKr Z8QxEqhj8dx5/zunDWc9h33wbj0/m0XZmJ7z5jOXgLVa4KkIL4TTcrlvclWXnZJ8fAoP sGEZu/iE4Zxw/zj953b351/p1NXcStR1Mq4qhTpryVjLeXkC1ilgqixF8QM+JbHnjcmE EE3SrESs4AAJ1PiqIpfkcnT39tvhsomuh4pn7WV4ZxbDtxnHbRlglYKFMkJZqFbmbDpN apToSMTclBrSrMYuStU2g3MDadHmKtlpLvgypkKzbY4FnmDglxn3Kun5R5VZiuSYObJx db5w== 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=AfhSPT6lIdBDimHGD4rCQ3/lGnIg9ct3nIy9Q9t+N4o=; b=brHMB9CGmxbrPQY+CtsT26NKuyxuMvMuuxNnTQ0pCrhyeKUA8HAnJdwNh4ds9l92ml xUq9UH6Bhpjo6mfATtYDqDeIhbjbjUT50wO2xSpuqWyD1NnVRuthS+uJ9Nm/7dTZhy9C WRZ94968gieHfPnYqfL3OG2qdOyuwf0It/WZjstS0UlmlwiNbmmnOqEi62XxKPEPapbE hXRzHUKhZ2H5n3clkjqaXhB+fhvi25icYiIX8zVoWkRlhT6305r15Jy4eD3MEIgpHRVS sJIzt7my+tkqO0UWg4DPRjrvxFXoMauTikzacDItZ7icMdBzajLysSpe1WiHHHtVYAXy NWTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=IHrv/NCb; 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 x1-v6si147716pln.208.2018.03.13.06.45.34; Tue, 13 Mar 2018 06:45:48 -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=IHrv/NCb; 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 S932918AbeCMNo0 (ORCPT + 99 others); Tue, 13 Mar 2018 09:44:26 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35210 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752698AbeCMN0y (ORCPT ); Tue, 13 Mar 2018 09:26:54 -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=AfhSPT6lIdBDimHGD4rCQ3/lGnIg9ct3nIy9Q9t+N4o=; b=IHrv/NCbOPDAkgRDJQe3mmrbi Syza2W2lwVMrh04dJXpgUjr87ZBgxj8dHlG9AxdPPgzarkNYWxi84a7F3cXi4iMo0w0SOftlCT386 qv+vGQpptwhOPfcPZQKPGi5hJyGYG8cgFzVYDXNRJ1dtexcM+OerUhmCRQUPmTtKrq6/6vzWlsE80 /l/v9v+wuuULJR8co2sqk8SpujP7GOvBgxsl5hwJfQD9WJRPmf0yrgsh8wwyZALpNB2dsOD1x+CP6 MF1OeEo7TCnSK2kkPvPnF47sSbxRWWXfbU+ia3NvK18dboUsiexgAoHWW1rgCtUMQDpVvlPhnlQ5l kymncsYvA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1evjx6-0004e6-5a; Tue, 13 Mar 2018 13:26:52 +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 27/61] page cache: Convert page deletion to XArray Date: Tue, 13 Mar 2018 06:26:05 -0700 Message-Id: <20180313132639.17387-28-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 The code is slightly shorter and simpler. Signed-off-by: Matthew Wilcox --- mm/filemap.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 0e19ea454cba..bdda1beda932 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -111,30 +111,28 @@ * ->tasklist_lock (memory_failure, collect_procs_ao) */ -static void page_cache_tree_delete(struct address_space *mapping, +static void page_cache_delete(struct address_space *mapping, struct page *page, void *shadow) { - int i, nr; + XA_STATE(xas, &mapping->i_pages, page->index); + unsigned int i, nr; - /* hugetlb pages are represented by one entry in the radix tree */ + mapping_set_update(&xas, mapping); + + /* hugetlb pages are represented by a single entry in the xarray */ nr = PageHuge(page) ? 1 : hpage_nr_pages(page); VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(PageTail(page), page); VM_BUG_ON_PAGE(nr != 1 && shadow, page); - for (i = 0; i < nr; i++) { - struct radix_tree_node *node; - void **slot; - - __radix_tree_lookup(&mapping->i_pages, page->index + i, - &node, &slot); - - VM_BUG_ON_PAGE(!node && nr != 1, page); - - radix_tree_clear_tags(&mapping->i_pages, node, slot); - __radix_tree_replace(&mapping->i_pages, node, slot, shadow, - workingset_lookup_update(mapping)); + i = nr; +repeat: + xas_store(&xas, shadow); + xas_init_tags(&xas); + if (--i) { + xas_next(&xas); + goto repeat; } page->mapping = NULL; @@ -234,7 +232,7 @@ void __delete_from_page_cache(struct page *page, void *shadow) trace_mm_filemap_delete_from_page_cache(page); unaccount_page_cache_page(mapping, page); - page_cache_tree_delete(mapping, page, shadow); + page_cache_delete(mapping, page, shadow); } static void page_cache_free_page(struct address_space *mapping, -- 2.16.1