Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2456344imm; Sat, 16 Jun 2018 19:19:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI8ro+ZgObnVKBzYKFgPtTGNZeU2qK5ICZgWeVkIijDK3uctY8fj8cuBGSHR8ZqbQ4RAnLU X-Received: by 2002:a63:12:: with SMTP id 18-v6mr6784563pga.121.1529201961722; Sat, 16 Jun 2018 19:19:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529201961; cv=none; d=google.com; s=arc-20160816; b=zUbkUPFoYOfToUATeUca5Rv2LyO65hsb+ZFcaXTVzEwr+3QU+TWojUw2wAVtlQE8hh abkjof4QzSarcpeWGcdR1gNJW2QH1fm4XsCFJoTYLN5yBbec2gsCsmop7sO/jVrSxm7M j3c5Es+audU1/ySE5V7ObXFMM9iXfxHi9xYlKnW033MPt3ZT7DKJUVWKWFPe0iVHZiET X5iGsWilitvf802gdSPF4WWQMrchGw9StTToZNTFxmYFVikvm7WZ+1l1YTKl07pFfuVn t7UVUfGXtedD47MbBZsAH4CxAcf6rTnwC8+YV3os/vhmVDAdcia0TEjKVSv6HI0flJTr 3cQg== 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=IhOnC9qrQIRQCbXcJfzozkcu7sXEUwfUNWOWmL6r87o=; b=VQgSHxmwW5lfMbhTlNlBZ4+3BAPCJAQ5vjLgBcHvkdaxFR2w8833fw/MbIOcGhGTlw SfZf+ESFTYsAVCN4eQg3y99UUhkk9rg4eFtIOghVEJNc1dtoLsB90tHy27jFUD5+6riE z9uGhd3+6BdUI6B0n2fiokeO3UiqPzzfzk18BZrGZtFv79/dOihU0sA47G4jgTDl2IY7 DrmGuv8PiObycQaPxUgLvlqERWOwTmD8J8qts/RayibJwXZ+1icr0oZpf3dmAbRkTKUK p4qmjK33T7ZcratTqcniPjt3LA1ThTc+eOW+nsxXUm4zZnzVObYW4nrDyGon/tQvA1EV dgQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=OrrRtMm3; 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 a13-v6si9533322pgv.158.2018.06.16.19.19.07; Sat, 16 Jun 2018 19:19:21 -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=OrrRtMm3; 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 S934566AbeFQCS3 (ORCPT + 99 others); Sat, 16 Jun 2018 22:18:29 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58738 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933530AbeFQCBA (ORCPT ); Sat, 16 Jun 2018 22:01:00 -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=IhOnC9qrQIRQCbXcJfzozkcu7sXEUwfUNWOWmL6r87o=; b=OrrRtMm3fhw+EDcD+NaUdg5DV eAUVbpQHxEEqG+pVwEQLXzz6FZQv8Aiz/6/Qvcb33AGqW8NaQZIXQ3VwklGkXWxmHy8ES9GmUhKl4 NtYR9RFGGX/A2eB6XXnN5OW7MKaoZ92ACW2/BYAn5fuqMdAcJT2KXkMvHokicvzdPT8kFY94cbC5i llSY+pAuTlceOVQGaWWLTnmFYiUBmPR+ddJQeERZ/5AUIuxZQFUhAJfRI6+Y8BAE+INKZ+L/V0LKH 8JO7aKYd9MAeeVpvbL4ZkF0oXx94GA0DweD4WWW1pUrn7RdBil+4WtfCqkXZaCIfu4hHQTMznUWqM c8yrOeoXQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUMzz-0001IG-NB; 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 25/74] page cache: Convert find_get_entries to XArray Date: Sat, 16 Jun 2018 19:00:03 -0700 Message-Id: <20180617020052.4759-26-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 Slightly shorter and simpler code. Signed-off-by: Matthew Wilcox --- mm/filemap.c | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 6db3d35ff5f6..b49290131e85 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1578,53 +1578,48 @@ unsigned find_get_entries(struct address_space *mapping, pgoff_t start, unsigned int nr_entries, struct page **entries, pgoff_t *indices) { - void **slot; + XA_STATE(xas, &mapping->i_pages, start); + struct page *page; unsigned int ret = 0; - struct radix_tree_iter iter; if (!nr_entries) return 0; rcu_read_lock(); - radix_tree_for_each_slot(slot, &mapping->i_pages, &iter, start) { - struct page *head, *page; -repeat: - page = radix_tree_deref_slot(slot); - if (unlikely(!page)) + xas_for_each(&xas, page, ULONG_MAX) { + struct page *head; + if (xas_retry(&xas, page)) continue; - if (radix_tree_exception(page)) { - if (radix_tree_deref_retry(page)) { - slot = radix_tree_iter_retry(&iter); - continue; - } - /* - * A shadow entry of a recently evicted page, a swap - * entry from shmem/tmpfs or a DAX entry. Return it - * without attempting to raise page count. - */ + /* + * A shadow entry of a recently evicted page, a swap + * entry from shmem/tmpfs or a DAX entry. Return it + * without attempting to raise page count. + */ + if (xa_is_value(page)) goto export; - } head = compound_head(page); if (!page_cache_get_speculative(head)) - goto repeat; + goto retry; /* The page was split under us? */ - if (compound_head(page) != head) { - put_page(head); - goto repeat; - } + if (compound_head(page) != head) + goto put_page; /* Has the page moved? */ - if (unlikely(page != *slot)) { - put_page(head); - goto repeat; - } + if (unlikely(page != xas_reload(&xas))) + goto put_page; + export: - indices[ret] = iter.index; + indices[ret] = xas.xa_index; entries[ret] = page; if (++ret == nr_entries) break; + continue; +put_page: + put_page(head); +retry: + xas_reset(&xas); } rcu_read_unlock(); return ret; -- 2.17.1