Received: by 10.213.65.68 with SMTP id h4csp352601imn; Tue, 13 Mar 2018 06:32:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELtDqSLFK4Z+AvtR3tTs2VVXhArncuKtZt5TeVZHv9Pib8zoiYTwtNP9MaMbkcepdovH189T X-Received: by 10.98.200.131 with SMTP id i3mr672622pfk.40.1520947937451; Tue, 13 Mar 2018 06:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520947937; cv=none; d=google.com; s=arc-20160816; b=iqZnn29fGefn8JedJv0NKA7hQ1mTB6LWj3y5vWBEGRmevTDJGme0MPv1+E1iUXllf9 qkGtwFxANkiUCVFkV2FTF0XycDJapqtltFFpDSu67wQAxfRnEsNMOSX+Pqqg14kOuUDr 3BvVtJcRv4+WqNZ6c2GJFMSdx+t1rs1o0Az4Jk0EEviMjkCKnQLzHWFRfQKluNOICFUZ j3XBRSYa6+ZUKDiNidaz4u5WtRYjoym8GWs0hvvUB/inhP15UUd9qIeWRMfV0ury8TXr mEvSdpasZAA++hoTm6oxJ0LqyNo9480VHWODyjwkEiTWq3x0S+G8kAepsyguT6ktfHiO sXiA== 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=QB9lBewDLPQPuLPUyrQu3li0QQyVZNTK4bLkM2yi5dw=; b=VGvb2lqdnOOSzo9wx7wn5VxoB1+yNfDDLkXxNYY3DOkwA6mszb9nV6E3GSTBQvVtRX ogK7mqVZHL/pRfRJFW6/8DN9TlTec4KHwVTGYkFtmuRkwmXvxpPUdHoOBZXpDCHgYut6 Kqx8ykO0eLk2AdgVo7Hjq/bTkvHKompcY7gvSo9LsLNqpPTY53oFbbgLKQn11CU0teM8 /pYbmKnpLrwgaPs2uYPAkPFXG3PhLw4Z/VJAeB8r+q7vXRXqqrtNmKKR0U5CWGBvyvcc yTw8nXP5F+YotWsQ8ZXkZkkSV5Q5ze2WxfANTvHbjKDVrrPc/TvELwBgiqRC3/QOC5dc c0bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=gq2aVBdD; 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 s1si129563pgr.20.2018.03.13.06.32.02; Tue, 13 Mar 2018 06:32:17 -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=gq2aVBdD; 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 S932689AbeCMN1H (ORCPT + 99 others); Tue, 13 Mar 2018 09:27:07 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35476 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932623AbeCMN1D (ORCPT ); Tue, 13 Mar 2018 09:27: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=QB9lBewDLPQPuLPUyrQu3li0QQyVZNTK4bLkM2yi5dw=; b=gq2aVBdDSLxREDjH3UNLiV+M4 aI939jb7R5SSi74kvhprtf0j6NJBoSpR8jzlC772Wxu2B99T9u5PojeXC10shZyCKdqp4Q6BG/sFV V9ISEVPFoc3lR0beJHUg6uV3zM0JLg//A9e8W3iOu5/yvYEJD8D7/OCGsKvKj5LAL+fhf3rLMr4qr 6G2MERvP3HZP/xhRva8kQAcx2WPCOK5n6/CplEY5oql2YHwe3PSq63rPZLtDum3ZkfIfHGqj4sQCS hF5g9pVHRHHOCEjeTMZpUKDT3HOZm8TihcYZcxgx/0soQRJDoEsH2V7L8VucaZFwK0t05JtJiRsbX pCcURLH7A==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1evjxF-0004jz-JD; Tue, 13 Mar 2018 13:27:01 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Ryusuke Konishi , linux-nilfs@vger.kernel.org Subject: [PATCH v9 45/61] shmem: Convert find_swap_entry to XArray Date: Tue, 13 Mar 2018 06:26:23 -0700 Message-Id: <20180313132639.17387-46-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313132639.17387-1-willy@infradead.org> References: <20180313132639.17387-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 | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 0af8a439dfad..49f42dc9e1dc 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, xa, 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(&xas, entry, ULONG_MAX) { + if (xas_retry(&xas, entry)) + continue; + 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.16.1