Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2456703imm; Sat, 16 Jun 2018 19:20:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLJ9AxJaG6h8mf8K4hbsGgy+SsnIUdKBm6dSc5ggapY/Ut1VlDzon4jeMdMg4kFjnnihagI X-Received: by 2002:a63:7b1e:: with SMTP id w30-v6mr6348711pgc.402.1529202007955; Sat, 16 Jun 2018 19:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529202007; cv=none; d=google.com; s=arc-20160816; b=VSo/byWKxKvz5e9xxEHT+Be0gutpmIIslaMiXxJ2eoxhqyFPWPFdoj7+8vrsW7R/j1 HVGiIN20Toa3mWRAnkbXeI5mTtaJuAjVHg3UBDdUtdvBUDZD0U0+HUobhlsePwnTBmM9 Y2Z1Xvp4BIY3h1LHJXBvNQSPPXsYQwKb/u0RA8IeS3StrUf/XiD9mXzX9sh5WUK8honR r7fhFxr60LwIDuhSA4vXNzNXPL5KGdrzB2z94U9vHUaJaQPn3q6a0H84rIApFDh5eJqW tXsaiHNpIzu2fxue4joPFHc0OHCsEjCYwkNPNhmLHArkpJ5AfTFqKWkafOcgdCCjBYvd U6HQ== 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=VdpoJRm08Fy75h+aB/tZALbxOrorEzQ33N3ElwwjXic=; b=eOzs77sfJWxMeSagDVSGAb+lNQxkH7pN23T+6T1UEhE4VYD//crpllg7DWWSxfcNuz VOzz8mNLhFShzl/KO775+EP/YVHkJ35RRAIPoND0xpdR/PcTBKMPAQo53TYq2KUNTH8D QiB8y+ptn9VmFe6M8BEnQDh/LFk58b4WC3kQ0rJHoFKStaKgLX8oJFV3kFZWlEp8MzXP p1/vEUf83cjA58AlBXfcWRT9nSPyQXSlcQq+862Zf+x/W2SUweRVMu92kCSusw085ZIv Zk0HmvDpEU6aKW3CHCxxXdHLyP4na2j9MZs7dCy7YVW7fjRLrUenAX2DeVQh5hWVP47i ddgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Qk0kdlsh; 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 x4-v6si9326909pgv.592.2018.06.16.19.19.53; Sat, 16 Jun 2018 19:20:07 -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=Qk0kdlsh; 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 S933944AbeFQCTd (ORCPT + 99 others); Sat, 16 Jun 2018 22:19:33 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58726 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933512AbeFQCA7 (ORCPT ); Sat, 16 Jun 2018 22:00:59 -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=VdpoJRm08Fy75h+aB/tZALbxOrorEzQ33N3ElwwjXic=; b=Qk0kdlsh4Ep6idoSb/jl6gD1b azUsOgqA5gvnbRrfU1orJygex5AlA5CrXQUWdQxviF9d2Y3qN+o67xPYf5PWGikoKwk9yfo/Q693A /13vI3PJQlHyQB3eyGzWLHdHwmfpwboG8nnCp3omEdANd6DILTcOjieZsOng7v2OBs5rumg8cAcyL YNnpJC9WuCDYtszaivGd3bUkJJoNwcuTKow4ZmsN4fsUCJG4xypR6fWoPsyiaaZ8timQ7HoE5m5nm Zva4dhQ9e8rxmjEGR8/G+pDm7pLC0KbGRoby8zG7w141RokAX/ZqT5NpPOYEschpzgt84F2kABrcN /UEZV/e6g==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUMzz-0001Hs-AP; Sun, 17 Jun 2018 02:00:59 +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 v14 23/74] page cache: Convert page deletion to XArray Date: Sat, 16 Jun 2018 19:00:01 -0700 Message-Id: <20180617020052.4759-24-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180617020052.4759-1-willy@infradead.org> References: <20180617020052.4759-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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