From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752283AbdKVVO3 (ORCPT ); Wed, 22 Nov 2017 16:14:29 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:48263 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751822AbdKVVIT (ORCPT ); Wed, 22 Nov 2017 16:08:19 -0500 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 39/62] shmem: Convert find_swap_entry to XArray Date: Wed, 22 Nov 2017 13:07:16 -0800 Message-Id: <20171122210739.29916-40-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 This is a 1:1 conversion. Signed-off-by: Matthew Wilcox --- mm/shmem.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 98944cff6319..b6f7fc283aad 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1076,28 +1076,27 @@ static void shmem_evict_inode(struct inode *inode) clear_inode(inode); } -static unsigned long find_swap_entry(struct radix_tree_root *root, void *item) +static unsigned long find_swap_entry(struct xarray *xa, void *item) { - struct radix_tree_iter iter; - void **slot; - unsigned long found = -1; + XA_STATE(xas, 0); unsigned int checked = 0; + void *entry; rcu_read_lock(); - radix_tree_for_each_slot(slot, root, &iter, 0) { - if (*slot == item) { - found = iter.index; + xas_for_each(xa, &xas, entry, ULONG_MAX) { + if (xas_retry(&xas, entry)) + continue; + if (entry == item) break; - } checked++; if ((checked % 4096) != 0) continue; - slot = radix_tree_iter_resume(slot, &iter); + xas_pause(&xas); cond_resched_rcu(); } - rcu_read_unlock(); - return found; + + return xas_invalid(&xas) ? -1 : xas.xa_index; } /* -- 2.15.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 39/62] shmem: Convert find_swap_entry to XArray Date: Wed, 22 Nov 2017 13:07:16 -0800 Message-Id: <20171122210739.29916-40-willy@infradead.org> In-Reply-To: <20171122210739.29916-1-willy@infradead.org> References: <20171122210739.29916-1-willy@infradead.org> Sender: owner-linux-mm@kvack.org List-ID: From: Matthew Wilcox This is a 1:1 conversion. Signed-off-by: Matthew Wilcox --- mm/shmem.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 98944cff6319..b6f7fc283aad 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1076,28 +1076,27 @@ static void shmem_evict_inode(struct inode *inode) clear_inode(inode); } -static unsigned long find_swap_entry(struct radix_tree_root *root, void *item) +static unsigned long find_swap_entry(struct xarray *xa, void *item) { - struct radix_tree_iter iter; - void **slot; - unsigned long found = -1; + XA_STATE(xas, 0); unsigned int checked = 0; + void *entry; rcu_read_lock(); - radix_tree_for_each_slot(slot, root, &iter, 0) { - if (*slot == item) { - found = iter.index; + xas_for_each(xa, &xas, entry, ULONG_MAX) { + if (xas_retry(&xas, entry)) + continue; + if (entry == item) break; - } checked++; if ((checked % 4096) != 0) continue; - slot = radix_tree_iter_resume(slot, &iter); + xas_pause(&xas); cond_resched_rcu(); } - rcu_read_unlock(); - return found; + + return xas_invalid(&xas) ? -1 : xas.xa_index; } /* -- 2.15.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org