From patchwork Mon Jun 11 14:06:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10457973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 47BD7601A0 for ; Mon, 11 Jun 2018 14:10:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FBCF2847B for ; Mon, 11 Jun 2018 14:10:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D3162858D; Mon, 11 Jun 2018 14:10:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 543A82856B for ; Mon, 11 Jun 2018 14:10:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32DE56B0290; Mon, 11 Jun 2018 10:07:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2B5066B0292; Mon, 11 Jun 2018 10:07:05 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 044DF6B028F; Mon, 11 Jun 2018 10:07:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 9E85A6B0292 for ; Mon, 11 Jun 2018 10:07:04 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id z11-v6so4872813pfn.1 for ; Mon, 11 Jun 2018 07:07:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=jGmi8q2eJKLoEu0xg6LdGVZ3YCLCZYH2N+fwRAOSbTc=; b=XH24sOvS9yFUxF41sdII/XxQfe4kLrVGOkDe8vzxm2SGCTQnI59fiwtMZLxtNrtNcC JC4sYtwJYGMPVn9hHNXkF0uMGd3i5E3vHEs6QltkaWZ9QTfw2pyXzu1YT9r0CXeZdRP6 URse12PieDhfQL4L9vNowHv6wJzH5QKRRlgQVKqhj2/Q29E0aFmJb1WxNJGOwJB5gnOh 1Vp4Dq7idJA/amxO4rUF0fDehavKv+3YfrxqakKbB2xluBzVdZWE6yjYQ7hEkKWWxEGk UDeBgCLvY00+/6EY3tcBNeCPIkQ7zKFbBjoP4uriI2mkoobyw3keUAOZTVerpz4t7LFW jLAQ== X-Gm-Message-State: APt69E3v4w+zLiyfybhI1a1VK9YT3Y/7M4yRfoNx/6mw1shIa2AKujIT mpmmoA+vXPWLHmjDcF4jB/8p6sPfKsg88y84Fb+jBVBoye84rvoOZZIbjxmvHbRn6CYWD0ynxix QJm+4BG8TasVmuObyWJFXAKTp56pDO7fBQNDH0mhU0uH6H52PtafZBJ72gcf6bnJkOA== X-Received: by 2002:a17:902:8a95:: with SMTP id p21-v6mr18821389plo.325.1528726024356; Mon, 11 Jun 2018 07:07:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLFTxDT8aZgpiVKexS7L3V+tdBGkjSdaxkDM976Lee5jq8GOL0JCE+MPee67VXeRARDfS0y X-Received: by 2002:a17:902:8a95:: with SMTP id p21-v6mr18821345plo.325.1528726023646; Mon, 11 Jun 2018 07:07:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528726023; cv=none; d=google.com; s=arc-20160816; b=1BCnHTNLoO8savnfipefbvT1tyTHJil4ccXs+VPVWjL5coIom7Fm7hSnIADxl9CKFK 4Nczlt/Z+0fC+BCN3w0WbdX4v2agh1RdtVAuo/QxrD0cVtKSu37ClfetlShYEMNfLofJ O8irbLRpS8wY6fPpcEsYmphHcjRRtR3yz2sSsIZGLCM5AEKvVj6+ABW5dkLIuWFys+8s PqBLcbB8wbUpExABfQwNv/oXfLL4bc9cLZbPsbC6fb60lMxEyXxVhebTLIFeqWJ5+aWM 1mbf+V76HHMNU7QK7i/f2qGWx0xdYh+EOHhfYZ72ydeiMzuQTVpy1f85LzFPZ0mXVjxm 02lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=jGmi8q2eJKLoEu0xg6LdGVZ3YCLCZYH2N+fwRAOSbTc=; b=jbENeH3PtvptxNGigogto0qhreOj/JOgpaxgzlADnUw2zOQTEovg3N7NGzQMwpj+CU Fn4zynJoPJHE5IA5M0iUJFd38P18yDSN02zP1niR2ic5Xb6Sp16xMp64hLhBr3OPKleg CtTahRZCgnH1hXRBvlynY4pjS9oF48B/pIb9T745sJOIIvlna5t0Nw8Ujtn+U+GQOWAy Te3DxCo5ARVQ12g29x/A0mSfrV338t8BeA77NEl27a8JG5uZpyMec+UJsDAMGxa5N8fy lnCL0+1PbrlQTFPnKPcymiJMoiuvp6tsJiGn6MbjTQFrsUR6Tm5HOjdzLBfTMRQxz0We JXtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=nw5wsaxA; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id f8-v6si44016757plt.35.2018.06.11.07.07.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 07:07:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=nw5wsaxA; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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; } /*