Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4254553imm; Mon, 11 Jun 2018 09:18:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJsot2qCJqyBn6rLvmcpM8J8EK4vh++4dxogeihGGJ5xfYdxjKFw/XSnPZk+EJI3hBosqec X-Received: by 2002:a62:d0c5:: with SMTP id p188-v6mr18491247pfg.101.1528733898282; Mon, 11 Jun 2018 09:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528733898; cv=none; d=google.com; s=arc-20160816; b=NZ+plD6kiyXEhYljUFVtOOVYUGdSzNP5/w2PUZEB3uRkqnoL+cZju1iaX4ulBQHWgc 8NP+lFspcdv+3G4sOr/tU1bmPp1Evnf8syin6fJ6+lrdLBa9GJojH4G4fvM6fJYf2s0L 668Ix3nZN+jndnxu3Ofrgr5Qe3BsyBm9Nl2OhE4nTPfXMVHcDOa4RmkNLLWlU91aVrq/ YWxzvYvca1dftaVUXOQzgB2781j3fZs7OHUdqhEvx5SBzQBdBBwHSxhJX6utO64j1TSz mnQ2e+1kyV47yACQo/8pNpLnPksc75d8p7wdKYemOAzBsXTYeGbF5kPN5GOMxsqXwChx C1Xg== 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=t6zM/qfm33anwBHTDJRDqef1HwwyX7RB48+ecTyMpRE=; b=D9kT5ZKyMr0R3IQl3GfPtjSz9UiZffgfQTQJM6wrpcOjYj36Xa2pB033OyiKLxRU7l hq/BS9hxP0HZDSysYNsCCjKRwJfIf/ZMZOAJHHPbKcI86bg+9guIcmssc+6LJKBZuZju nhMwhdQa/MxaXnq0cuiIyCRyg8udPmvzjOTpc1gJhpI3lHi6d7d/2kNzDvUTdKJ3koD3 fUsjMejU7WvpUPuIXn9PbK7WluZG/VUPzDsfginkmbGRKNDbHhGnv+zNDhClWwMX85n7 Oxc4GxGKSNcVz6jGYQZu0OulSOc6DJWChpGGdm+kQqM6A4VUaMHhdJI8TaMH/tnKDj2M wrOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FnvKd5k0; 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 r12-v6si14184699pfe.9.2018.06.11.09.18.03; Mon, 11 Jun 2018 09:18:18 -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=FnvKd5k0; 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 S934296AbeFKOUf (ORCPT + 99 others); Mon, 11 Jun 2018 10:20:35 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45188 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933493AbeFKOGt (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=t6zM/qfm33anwBHTDJRDqef1HwwyX7RB48+ecTyMpRE=; b=FnvKd5k0mRY3tpyDxpW8zkaxy Qksjm/1NbQtSQqwZvTLuPVg1DPG0IrxfxWhP6XSrUPD1nW+Ie06qfuhi5qeaUQ6fHRtS/gapSRDJt J0L8eNUc0ykFt/OxWaMKcJBLKTZU92R9+qWZlgSkpHd5qnviQBFdlXP6JvLdDCNpv+s4rwhU+XGMf m1I4rA+CccFm6egoeLNhJxcSJTq/yI1LV4uB9vKabAbahlyhMKBoiqjbKOQH2Dk5b17WY0Op8rxPG LP4Qy3PO5A9uGvrp7rUDfDnzVC/5XDEa34VrqjiOfaVIXeQVgcaEFaGevDcUhuIwTCjSY0EKa4wpY ivUTAjmiA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNT7-0004em-17; Mon, 11 Jun 2018 14:06:49 +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 23/72] page cache: Convert find_get_entry to XArray Date: Mon, 11 Jun 2018 07:05:50 -0700 Message-Id: <20180611140639.17215-24-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 Slightly shorter and simpler code. Signed-off-by: Matthew Wilcox --- mm/filemap.c | 63 +++++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 7cdb1d4b8117..6db3d35ff5f6 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1382,47 +1382,40 @@ EXPORT_SYMBOL(page_cache_prev_gap); */ struct page *find_get_entry(struct address_space *mapping, pgoff_t offset) { - void **pagep; + XA_STATE(xas, &mapping->i_pages, offset); struct page *head, *page; rcu_read_lock(); repeat: - page = NULL; - pagep = radix_tree_lookup_slot(&mapping->i_pages, offset); - if (pagep) { - page = radix_tree_deref_slot(pagep); - if (unlikely(!page)) - goto out; - if (radix_tree_exception(page)) { - if (radix_tree_deref_retry(page)) - goto repeat; - /* - * A shadow entry of a recently evicted page, - * or a swap entry from shmem/tmpfs. Return - * it without attempting to raise page count. - */ - goto out; - } + xas_reset(&xas); + page = xas_load(&xas); + if (xas_retry(&xas, page)) + goto repeat; + /* + * A shadow entry of a recently evicted page, or a swap entry from + * shmem/tmpfs. Return it without attempting to raise page count. + */ + if (!page || xa_is_value(page)) + goto out; - head = compound_head(page); - if (!page_cache_get_speculative(head)) - goto repeat; + head = compound_head(page); + if (!page_cache_get_speculative(head)) + goto repeat; - /* The page was split under us? */ - if (compound_head(page) != head) { - put_page(head); - goto repeat; - } + /* The page was split under us? */ + if (compound_head(page) != head) { + put_page(head); + goto repeat; + } - /* - * Has the page moved? - * This is part of the lockless pagecache protocol. See - * include/linux/pagemap.h for details. - */ - if (unlikely(page != *pagep)) { - put_page(head); - goto repeat; - } + /* + * Has the page moved? + * This is part of the lockless pagecache protocol. See + * include/linux/pagemap.h for details. + */ + if (unlikely(page != xas_reload(&xas))) { + put_page(head); + goto repeat; } out: rcu_read_unlock(); @@ -1453,7 +1446,7 @@ struct page *find_lock_entry(struct address_space *mapping, pgoff_t offset) repeat: page = find_get_entry(mapping, offset); - if (page && !radix_tree_exception(page)) { + if (page && !xa_is_value(page)) { lock_page(page); /* Has the page been truncated? */ if (unlikely(page_mapping(page) != mapping)) { -- 2.17.1