From patchwork Mon Jun 11 14:05:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10457899 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5935960467 for ; Mon, 11 Jun 2018 14:08:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4762E2846D for ; Mon, 11 Jun 2018 14:08:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BFF928475; Mon, 11 Jun 2018 14:08:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD4032846D for ; Mon, 11 Jun 2018 14:08:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 526836B0276; Mon, 11 Jun 2018 10:06:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 28B466B0277; Mon, 11 Jun 2018 10:06:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BBAA6B0278; Mon, 11 Jun 2018 10:06:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f69.google.com (mail-pg0-f69.google.com [74.125.83.69]) by kanga.kvack.org (Postfix) with ESMTP id 8532F6B0275 for ; Mon, 11 Jun 2018 10:06:50 -0400 (EDT) Received: by mail-pg0-f69.google.com with SMTP id o7-v6so6314107pgc.23 for ; Mon, 11 Jun 2018 07:06:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=xgN5I86dlSi53bLy0zP0slssD0IoeCly8roO5uiBf6g=; b=A+YIwUqjRbqcAH/7QwdqrWhMfrnmK5Uz87SWKi+PuG8bRz/+xvkcGIgtc/BrtAbwgK zy45Os+PgUgEpKXYeUlgS5W2aPJnaM6VyqxrxezOYznmml9BtaBbQ8JW4MB9h5DecpMZ ++hk3LkFjnJ+ZIrbSSSuA38BTnxPnwaYiAZY3Bcu+B/AnTuO0Spzj0brP6TOW7Rtpcf/ 5scqi8vf/L9M8iH++RiKS27TLQcmvBF/hOP9y8J5uLI/qXuxXDJqAYcrOPuwnC4FEClm gabGhso0ocNz1VQ6JR0RkQUG3GQSOXqh9RdAcYy97qjF6FHNqcJ76a/qe7sG6jivIcID kGLQ== X-Gm-Message-State: APt69E1WiqsbbyT1zdI9tuZ9OiL669qg2vnEbtSMzGtITotYESJAJc53 SirUQ9sDCxTwOdMnexAnuRvG6gtME52dRzlZjbSFla3cGNX9+Jg4klkxKv1/ZyaVJIv7QiJnp9z 8p9OMGvo1Y+tqamMX0Z7O3Yf+r52WTJos9e2Gik6aKR85oL2Mk/0wYQLliqPLti1Ngw== X-Received: by 2002:a65:660c:: with SMTP id w12-v6mr6241367pgv.404.1528726010219; Mon, 11 Jun 2018 07:06:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIE1+sC89RxBMxx1cY8UISUxqfIvoGusPkol6qaN7gKdRvMEr323OSXyhO6Cp0HhSGAruVY X-Received: by 2002:a65:660c:: with SMTP id w12-v6mr6241314pgv.404.1528726009239; Mon, 11 Jun 2018 07:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528726009; cv=none; d=google.com; s=arc-20160816; b=yxIdvJVYxN62qfheYuBmD90wAxB/MF0Eptrx7H2TQGWhJTxnwuQhsDvyG1hwiLOhsN GV8z0SP8u3h7lSxcRWPYPYwD+zJb8tQdX7AYCzTJkY7CXxg+qaOwGiWXnl3qkjTavSG5 I/84nbxIi9eJOe+nD6T/hAdQUlnlOm/DchF8ZWhfyP0/a1iUYRlpujXUOnUFMdPu5S3k UPPsRoXAnX6hYaZ9JZuAGp4tyLzGiULmMPBT5NH7oCBxWjUrd9XFrQ4YRXwHNmQknGlp hA4iFsreKavSwshVwpU6Kp/iK1zndEtH+Ua0cTHE4uIFySKfkoal9uVbUo6oe/YF9ZMW jgMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=xgN5I86dlSi53bLy0zP0slssD0IoeCly8roO5uiBf6g=; b=qyNTdt87yRvpbjNaLPPh0/+fXcFDHG9odU2qmiD4GJ080PPyvkgQIAAgC71PFurr7g +6X9cuVFuBAy5HZd2+7gvbamy4yz/pfDk9rCiJw/vd3P/Drd7HWggVZxwg267lAkyTYI OuLFeIGjvZE5aC4f4XA9swgXV59w8OqUmS0S7Z9DJsBl+gLKh1RdZ3ZfOAEJh41WTrY3 6AI6ohwGVYmII0AT0uUNXqzEDUvaQ40Mdr4Km3CgZ8GEiWh9j6WQPZie5WNVhrYymbdx Kzd2J+PrAtn0QKRKOl2a0kNDPP/eJmk4ySBE4UOFTVPo/So7jYKz+XlxrrWOXu0ZPFoC fRbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=R1VwQYpN; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id v39-v6si16868614pgn.510.2018.06.11.07.06.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 07:06:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=R1VwQYpN; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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,