Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4124558imm; Mon, 11 Jun 2018 07:23:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKq4LVrltPS2HI9MIsc2whEEN1fesLAPo7bCyG7wIk5dXN888aqmRsJAfeLkwQSRbNjwpbH X-Received: by 2002:a62:f807:: with SMTP id d7-v6mr12813262pfh.213.1528727029521; Mon, 11 Jun 2018 07:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528727029; cv=none; d=google.com; s=arc-20160816; b=TsngvESZ1tzxp8z+2ol9DelFWvi/gjfGBRHU5fI9uV97ZZxwK1XUIjgPWgD3zQfAPn IziUBU10lQDgvi5LxIS78BGklaec/xxatC9iuz98dpJWvoxZqTYe0zn7Fi9QoCfrSLh5 bZNNjjhhN4m5tdcgcDMkdh+bk6zbitcTJ7APxKtOrLoeKGfKZ7U6AJIwh9imr9XWmiWD 2ezFN+IHQzgssjxwiveTUOd7O5kmhywr6TwUrlcFPHV337N9n2bbiciT2tfp6SDi2aaL Swp9XDYD1bIgcW4ksxVpUresYHJW/VI56cPHO2n1+HWWSRBC3doW8OY8ovCrTcustyDd uimw== 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=xgN5I86dlSi53bLy0zP0slssD0IoeCly8roO5uiBf6g=; b=yFq4ODjsre9WBKWo0w5qebcXEumgQ13M/VTYqnRfVEd+INyVME70bY5fFeocfe5RTs hEf0HBooXPojBOVSNWr4EOBBKhuvcZxaOkAQxfQzYDwEdRfaDfton9SKB59Q5F8QR9Q7 XrV5qOpkU5jcirJCyM3OTqsXV7REJPd7SCiqsAAI3rYncdjqA48pdg3SohOCPvoO0i1U wK1gXuRf17FuT1JFyaus5EvxPE12p4VrAB1oAsPRHDCTErjj49wfVjjzSn5m+JWXT2dD gbwzRGgDjRjO+3QKkUZjVJHuNb7kPGNPyjeomDDA7bEVB1hiyvNFsZlsgWeh9u+e7EHa vLoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=R1VwQYpN; 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 38-v6si17337947pln.390.2018.06.11.07.23.35; Mon, 11 Jun 2018 07:23:49 -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=R1VwQYpN; 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 S934397AbeFKOWd (ORCPT + 99 others); Mon, 11 Jun 2018 10:22:33 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45160 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933491AbeFKOGt (ORCPT ); Mon, 11 Jun 2018 10:06:49 -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=xgN5I86dlSi53bLy0zP0slssD0IoeCly8roO5uiBf6g=; b=R1VwQYpNTyLCGomBjeT//5+TU JDOn3gv29DKZlI7fLZwDSnmlVLadQJE6EAuddV7MO1WzLBKlsg0qUXgar0AVGJBmOSZkPpxtkcnKE MBQuIPWOnjFhPcHi5GhOa3DJo2OW46clunsLADcfquya6wxMRxzhvMJiw/ScTXvq8gclwhBxYyYRr 0So/upa+AODnb60UxFal3h3InRgRHPGkiH9uTBo3ZqJ9rYHu50yLVNe3U4yQWOV6pu2dmYOtlzoUf Tp8a/ck1PE50zcZ4rWJAJ29cxo93qobxaBSjGYXqz2qKv4tPYCANTG06IM13QRoV7k+fmbfByVGpz D9DefgZfA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNT6-0004eU-AX; Mon, 11 Jun 2018 14:06:48 +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 22/72] page cache: Convert page deletion to XArray Date: Mon, 11 Jun 2018 07:05:49 -0700 Message-Id: <20180611140639.17215-23-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 The code is slightly shorter and simpler. Signed-off-by: Matthew Wilcox --- mm/filemap.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 965ff68e5b8d..7cdb1d4b8117 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -111,31 +111,26 @@ * ->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 nr = 1; - /* hugetlb pages are represented by one entry in the radix tree */ - nr = PageHuge(page) ? 1 : hpage_nr_pages(page); + mapping_set_update(&xas, mapping); + + /* hugetlb pages are represented by a single entry in the xarray */ + if (!PageHuge(page)) { + xas_set_order(&xas, page->index, compound_order(page)); + nr = 1U << compound_order(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)); - } + xas_store(&xas, shadow); + xas_init_tags(&xas); page->mapping = NULL; /* Leave page->index set: truncation lookup relies upon it */ @@ -234,7 +229,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.17.1