From patchwork Sun Jun 17 02:00:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10468259 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 736D0603B4 for ; Sun, 17 Jun 2018 02:02:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6380228C5E for ; Sun, 17 Jun 2018 02:02:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5818928C6A; Sun, 17 Jun 2018 02:02:48 +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 EB67A28C5E for ; Sun, 17 Jun 2018 02:02:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7FD06B027E; Sat, 16 Jun 2018 22:01:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9E21E6B027F; Sat, 16 Jun 2018 22:01:11 -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 8ADAA6B0280; Sat, 16 Jun 2018 22:01:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id 4EF7F6B027E for ; Sat, 16 Jun 2018 22:01:11 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id u21-v6so6691047pfn.0 for ; Sat, 16 Jun 2018 19:01:11 -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=UL7Dd8P+07FgmPfVgBxdWbMx7UGqU9gll23MkeO9Cj4=; b=cm24UUOSlWZf7J/qHAp8gliQ9YcM/RJXBK89e27UiKCFKeoaCWCgsi6oxA7DoWiZUr /XzmCXDyJBmnLD2M2d8SFnpBv/Ov9M9IkvShA5TyIRE0JrKskJGav/eXJuzg01pBbq0d qJam91FDlWf484utexRELWFmrWJqCYBLiBe8zEsY1BySEslGdQN/NMUJFOnyYFuuBYgp l2pZpOK79g6Z4ynQUKrQlwr/dsIk32a/aNnqfRcRsKbmH/c1hwJNKTRQkMksPS2AyC28 vrylHIX7UiXiC+nzTWWfVfq9oBhj5796QMXhXBIrv5FMtz504NMhiVjI4QmmD9yNVDbE cJjw== X-Gm-Message-State: APt69E3nNJ9MWRT/KwFhxVeq3fGWuB+5/QdFWk7gR5xsItBIRevACX9o C5QJKeJs3HdD97M0ut7Ic7DJInlnzeGAERvUIvnfDqI4h27Fv5Isi2R7Sj3enq8bE/FAYkgCfQy 0CLpNT2T/QE018s8Z30aHxw9jCas//zMkTFhKZcpsEqL2blPoCE7aQPNuuuLSrqb/KA== X-Received: by 2002:a63:bf0b:: with SMTP id v11-v6mr6397787pgf.29.1529200870946; Sat, 16 Jun 2018 19:01:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIkLCrxAi9eMBsn+ick5GvRImtUKGK7DuOI16+Dfb4/R3iXUQVajqIaK9f5PlG8PUgXtDUt X-Received: by 2002:a63:bf0b:: with SMTP id v11-v6mr6397763pgf.29.1529200870236; Sat, 16 Jun 2018 19:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529200870; cv=none; d=google.com; s=arc-20160816; b=HmDixuSudsoKmw4rBpNhpUEMKM53aVdOceY3nndiKLSwgUl3IiNTIn+eZg29WQ7PTN d1KcznF/syzzkmE6rhNQPbqVDbw8iJyEIuYQBnXFBMWgCNSdR/+ZmXZC6lg0K7LDoyAK oc+IEec+TBAkY4eefOjYus0QWX0Jxs24tiljy31JsoIdmmoKAI0CHlE4Qp7WSlyB+0Gd AN9g0Sz+rJr9IQJuPKnqpcwOJW+Hjj8lPT/E5AeXbcthMDmvB7yqHs37UQhNq1foo6yX xxSMNz41njDcamhC/j+Azvr0dOuAMUALDu63lF8t8TmMMaEGOYqC8CvfUscA+1w5KXEP WWUQ== 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=UL7Dd8P+07FgmPfVgBxdWbMx7UGqU9gll23MkeO9Cj4=; b=THDHTWN+vAmkX0vtPE3qIcQylXBGraDRUmCsNos08x+YnxLSbnjAAJnsZIfJG4rq40 7iMarESR4gzud8FWdYz1SNJJGzixj+CLQMRDkjKixFNeoKlhMi54r632xa6JUk8NfrmH UQlfcyfx56h4eh+lmJ7TFZ9SXw9YUnwdxqzF8t0AnUwxAwzj6qlBBdEKMqUGvcyJaycC 1zNFdpaahNQjy7HkxlZ00z6HVAkxigke6twzcJvzGcA/nGuutsj7yrZlkIa8kBkBZRXU G3vM6H6n+H1psWHjQzGvqpwsXWZJHqMXZGW0uDUh0a9ZZHEcThinCfTi7dgoxa2rxkNs p9VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=ObeYbgFH; 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 n7-v6si9813522pgr.31.2018.06.16.19.01.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 16 Jun 2018 19:01:10 -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=ObeYbgFH; 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=UL7Dd8P+07FgmPfVgBxdWbMx7UGqU9gll23MkeO9Cj4=; b=ObeYbgFHW40CIoI9Iay9YDcWB R1kLjrm1K4zSgLFf60/M+hfgncpEpteXsSNjqaVrhSZvqoTB2A0s+iXwQq1cN9GVs5+sRvopf5eMH B703/nXeYHsQFY6Lkn2WXqx3JncFQC1iCAFeZHlG+RkpUFWs9kAyLv24VPpLXF9tyOdje0VuVPW2B o1I2d7ZOtcKOHNlNKbd0UjtCs+Gz4jQ23VF2GTFIX0G3jFkRjv1Jvo6LOmX9tm/xmecUSqeyfjHqz mz5vLYkpNOs+kyQZv7ToapcRmRYgjsF7lWY8j6fbwTiEXriorLtlJkugjjUMNw/rNpYoPWNDZoxe3 g/CiG4N/A==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUN09-0001OE-1u; Sun, 17 Jun 2018 02:01:09 +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 v14 49/74] shmem: Convert find_swap_entry to XArray Date: Sat, 16 Jun 2018 19:00:27 -0700 Message-Id: <20180617020052.4759-50-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180617020052.4759-1-willy@infradead.org> References: <20180617020052.4759-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 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; } /*