Received: by 10.223.185.116 with SMTP id b49csp4139837wrg; Mon, 19 Feb 2018 11:53:56 -0800 (PST) X-Google-Smtp-Source: AH8x227iBLVSdWv3apcxuX8vLu4esjq4GHymrD7C3Y7j+1paqd8iJLmdO7Hc1qVgIbaONkkUPWub X-Received: by 2002:a17:902:24a5:: with SMTP id w34-v6mr14865216pla.221.1519070035955; Mon, 19 Feb 2018 11:53:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519070035; cv=none; d=google.com; s=arc-20160816; b=IQGTVQOR2+e8jTumFbW269FmIRb0gzkCxe37Nw7p5Habd4r0K1MwyAcG9aNdcvBV6L 7+ykM3YVBugVcZeIvlO6h90D66co0mqY3AnfbLLMzMVWeU3QXrg/0sgNnwbo0ZTdPdrx vqMgBHycINqjOxdYB0dvcYV/94epe9Gfr1w9ygmFrKz2yAhWoEyf+RUJga6l/F5gnjhT iva+7+RVSbDcKLX2TBcILNSbln4QNGpZ4NaS9DqeZJwyyThoG0HY6f2TBRwXX52/LIcd ZnCykWodpyKRZ+kd8WDvVuUNL+lZ+OxHjlcD77AyBVf50R8TTfnq7ZMz9YDDTxbfoLlV 79WQ== 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=FYTNF7E3v69doJJySNHibX8eNkoS8i5DQ1m4Eaeg26Q=; b=fM9rTFKQO/5kLZUwuhGAREJqk2NkpwMRbcQvI8HMMerbscl7sIir6L7JF/dT2+vfFl gUHjv5+r9lOFqjGSMwdCEF809euXV0IxcXAPIlYJQv4vVb7SaxeWXZwLsyqtDK+o5vty bHJ2+7zA9KeOWyjbI6VKRLGEUDaPhRWtRHPniuImS7DifiZ/uZIji/duzt9rl2Mc67sM Goe55NDAZ+gjnxdYJOafWLEYltLcO9wZu7Z3l9vePo1R/aF/ME/yXwng1fim7i++UTXn ZzfWzf1qoUWdAr7jJD9cwKA1xS2DC9B00oOnjpymrYMUZcJlR8vgs9AcS3iH0ZmC3II3 9+EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=B/uIuzvo; 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 a64si4596270pfb.405.2018.02.19.11.53.41; Mon, 19 Feb 2018 11:53:55 -0800 (PST) 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=B/uIuzvo; 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 S1753870AbeBSTvn (ORCPT + 99 others); Mon, 19 Feb 2018 14:51:43 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:44974 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753801AbeBSTq0 (ORCPT ); Mon, 19 Feb 2018 14:46:26 -0500 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=FYTNF7E3v69doJJySNHibX8eNkoS8i5DQ1m4Eaeg26Q=; b=B/uIuzvoVegfMnTtxzmKhswgs cO6/fro2qSj6R6ZuEf08DAcaTrj7NbmUYfuj8YZCdCTOswAQxfbJ3+5NzoVIXg/GfKD0L3u7hLyE3 8AiDZYqlahRxiz7WweFZYKbCcbfwZ8Gyr9skuNG8LZVXwcJdYju45pwFIBHOSUIyALMEKWLptWBww 3u5QmnkCH1/xERDC8qJHPXHUh5QUIk2h+3dAlFka3dGuT9a8O1qcYzLmBje0oA4la0rUr3vAB+YsO eprpzl0S6kfYqk9cdvPW0VDtZ0YhH4FDtWHdvXVLX9P7fvwVVeiyoEEFcz9wJ3uX/xgxjuQ57dUhT cpnpxEcNA==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1enrOL-0001uC-Db; Mon, 19 Feb 2018 19:46:25 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v7 46/61] shmem: Convert find_swap_entry to XArray Date: Mon, 19 Feb 2018 11:45:41 -0800 Message-Id: <20180219194556.6575-47-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180219194556.6575-1-willy@infradead.org> References: <20180219194556.6575-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 25a8e611bf1b..0179f9aa7d0e 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