From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox 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> References: <20180617020052.4759-1-willy@infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; 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=SKulVe6yBClRzKN2MOn5HKFYy4 dDqSu9Z+eJvp3KDgzYlNGSmH+Fe9QBR5Vs+kselHIXsW5zw+0Z5ic22NSq87ScAfoWPXgxi6Gt+yu GUHv3dEvlwS/lxygbp/5sF8Rup+K2G9hTpATqryWT9c3Rk36wgrhuH4JF1pSUJpQpmrM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; 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=C3dw6Ywf33YDhuQZy0Xi6Yv3W5 oXQdp4/l7MyqrT2y2dCJO3HrLuyhW78+/DkNUcoF2wRopba9UCQX9r+WtVPZtMcZComp1UHOnxHs9 /+acq4DruO+ieTzXjH8FTFmfOrP4SeelkOqmGGMCVbjf4t6spPeGaB/UpWFo0EwgjCBA=; 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==; In-Reply-To: <20180617020052.4759-1-willy@infradead.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-nilfs@vger.kernel.org, Jan Kara , Jeff Layton , Jaegeuk Kim , Matthew Wilcox , linux-f2fs-devel@lists.sourceforge.net, Nicholas Piggin , Ryusuke Konishi , Lukas Czerner , Ross Zwisler , Christoph Hellwig , Goldwyn Rodrigues 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 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot