Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4244361imm; Mon, 11 Jun 2018 09:09:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJROA6ln1eB3H/mx4yZwtwdWX9Iv+L3Wpa3ejgr1lrLa1qDO43+t3I64PIhM4fg+jx69e5u X-Received: by 2002:a62:449b:: with SMTP id m27-v6mr17962135pfi.130.1528733374414; Mon, 11 Jun 2018 09:09:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528733374; cv=none; d=google.com; s=arc-20160816; b=vCZh2OE+pHp37G3S7tzgWiOrp05MHM6ePmx/cUQYwAyfHkiy2QkeohZMNVbgEUvDjN 8Y/qi61+ukALLioZxLdCVs7atMSE2HC9Wytu5DkGpY8LL2HSOsVpQPQtO5/gZrAls9rf wBU4yirpclEeYPApmyppee5Hu+7Vlwdj8lS+QG+d+4JllMVxFCrtSiurKWa7E4HcNqXB BlmmOb0BPokNT3hoXLVPYgApNEx5XuHdV8jaiEt9mK3aUINL3/hpDobGNaZ6Srx8cUTQ +roYV1LZ0XbiOKLBbbHdiiezySSQQQg564cGqs7e7vu7lHHJD2fMKfk+vzflaMm+9RJ7 6sXw== 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=jGmi8q2eJKLoEu0xg6LdGVZ3YCLCZYH2N+fwRAOSbTc=; b=yFvm4BvV/pn2TypVN5FxbqzI6uohjyJzFQ9cHrNQzLfMIEmB7paOYsrJlje6fZQEvI Zl1Xmuzycte5vM6EX+KVEkK4pMRMjXIcHhIk8UG8acfLFTVm02fxxHzzxrvbRKhdjXI9 /sPjLa038dwutfVRUyivHnjEvYPi/Czsu0ZG6Cee9b3kHDE5ObmIgmEOV78U/y/6FSre GZDcu/lUNwFtYKoFSzIluDwsnIl151U7xpcv12ilhx0RvY6/25ZyKIoxpPZYpeJHm8t5 /ndDXMDqOS1POFRWZRahdfpz9Ovx3rK4tSwnHGZYjhbXII+cH842HHmG4pOeNcgA7Qx2 C2Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=nw5wsaxA; 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 m18-v6si20197109pgc.654.2018.06.11.09.09.19; Mon, 11 Jun 2018 09:09:34 -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=nw5wsaxA; 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 S933984AbeFKOOh (ORCPT + 99 others); Mon, 11 Jun 2018 10:14:37 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:46120 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933595AbeFKOHD (ORCPT ); Mon, 11 Jun 2018 10:07:03 -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=jGmi8q2eJKLoEu0xg6LdGVZ3YCLCZYH2N+fwRAOSbTc=; b=nw5wsaxAg7PXkxISMGsjS8auB exTQMXQmjdTXaF6KLSbpPUiWdc1XjGtKxLW3jdNr9ilXGBLBLjj/QXv3adaAXAwFo08bN+RcDmafy U1xBJF9Iz7EIMOlFMIpSUnCOgOfw7A761enXRxKmHjwUGqC4MoWffQQsTtHLA8CuHLs1JSbje7R9c HBlQgTEUXhxtJ9dtdh2yA0BhDc62PQPkx9KoDlx8SodXIMuxsfHu1JYJTLBNqfiSa1TdS4y0H56C8 fgsleLGoFeo72pRnDoL63XgHbv9pfdGUb2Ezdi3TCFDf9/vdT0SwtqOnqBzo/oC/txDEAF0ZyyG0k pC1qXzGXg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNTK-0004s8-KC; Mon, 11 Jun 2018 14:07:02 +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 48/72] shmem: Convert find_swap_entry to XArray Date: Mon, 11 Jun 2018 07:06:15 -0700 Message-Id: <20180611140639.17215-49-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 This is a 1:1 conversion. Signed-off-by: Matthew Wilcox --- mm/shmem.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 479e4a8e6d68..983a27656e2e 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1099,34 +1099,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 __rcu **slot; - unsigned long found = -1; + XA_STATE(xas, xa, 0); unsigned int checked = 0; + void *entry; rcu_read_lock(); - radix_tree_for_each_slot(slot, root, &iter, 0) { - void *entry = radix_tree_deref_slot(slot); - - if (radix_tree_deref_retry(entry)) { - slot = radix_tree_iter_retry(&iter); + xas_for_each(&xas, entry, ULONG_MAX) { + if (xas_retry(&xas, entry)) continue; - } - if (entry == item) { - found = iter.index; + if (entry == item) break; - } checked++; - if ((checked % 4096) != 0) + if ((checked % XA_CHECK_SCHED) != 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.17.1