From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751415AbdKVVSS (ORCPT ); Wed, 22 Nov 2017 16:18:18 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:39404 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751799AbdKVVIS (ORCPT ); Wed, 22 Nov 2017 16:08:18 -0500 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 33/62] page cache: Convert page_cache_next_hole to XArray Date: Wed, 22 Nov 2017 13:07:10 -0800 Message-Id: <20171122210739.29916-34-willy@infradead.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171122210739.29916-1-willy@infradead.org> References: <20171122210739.29916-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox Use xas_find_any() to scan the entries instead of doing a lookup from the top of the tree each time. Signed-off-by: Matthew Wilcox --- mm/filemap.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 1c03b0ea105e..accc350f9544 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1349,20 +1349,15 @@ int __lock_page_or_retry(struct page *page, struct mm_struct *mm, pgoff_t page_cache_next_hole(struct address_space *mapping, pgoff_t index, unsigned long max_scan) { - unsigned long i; - - for (i = 0; i < max_scan; i++) { - struct page *page; + XA_STATE(xas, index); - page = radix_tree_lookup(&mapping->pages, index); - if (!page || xa_is_value(page)) - break; - index++; - if (index == 0) + while (max_scan--) { + void *entry = xas_find_any(&mapping->pages, &xas); + if (!entry || xa_is_value(entry)) break; } - return index; + return xas.xa_index; } EXPORT_SYMBOL(page_cache_next_hole); -- 2.15.0