From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox Subject: [PATCH v11 41/63] shmem: Convert shmem_partial_swap_usage to XArray Date: Sat, 14 Apr 2018 07:12:54 -0700 Message-ID: <20180414141316.7167-42-willy@infradead.org> References: <20180414141316.7167-1-willy@infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; 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=FrdJTSGDGYtOBv5wMLBdDSGoaZDilxISk17xdYOfK/0=; b=NboAL04T56RU2FNL60mngE0bVv SkcGMDpmb1a32z8Of/4YmCN9OV4y1KAAYiqc19m8EH8pAs0A4AIQsjY4FRSCR9imPCzl4HRVmnyrD zUsx1uvG/Dx94EMkKKN3eGqgmQadIRZqR+TWg+OyUXwETbQR9oKk9UlQnz17IVRCPeP0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; 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=FrdJTSGDGYtOBv5wMLBdDSGoaZDilxISk17xdYOfK/0=; b=IVBjpPW0Ex2snnSWkS6mk5vCT5 FHnnVATFAmDRjdUVIAzPUeLmUbK69ZuKLejXXHfOik/2qtzQBfjknXlsHf7d/PhD+NcoAuo0sjjUl TfIYeL+H/eYbPDZZzEtIy7f9JsJfOtLX8tejNcKp248hNBzn1+HxUlajUEWG4txzmzUI=; 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=FrdJTSGDGYtOBv5wMLBdDSGoaZDilxISk17xdYOfK/0=; b=djPZgFjlKvFPdprV+WGFsEFwZ H6yMx30AScf+uTz9imzhp1AIwuOTqAhTp7fCMwrPa71iAK2VaWCJEcHUTQ+cJ4dV8GxdQG9Gt8hv/ hlx/5UMuzOhmPchrEsh2EWRM5j5jHtQEFksmN0DrkzU3iy0ExC9jjgPPIGD1lP/f5XNEdpH8TiPWT 51MZpaFw8G6VIQ4Thj0F78Te7pmZENAG5ib0uYKWh+nQzwZY+RIjt+6RwKSpj+5NNoW4dqP9ZOga6 8/IEH1fN/cR2mSADjgQrHV5Ch/Tnp07suwgxeErppHtCdTmZAlmwgNVGf9QRfLWh2Yg3AjRBchkRg ihJMD/3aw==; In-Reply-To: <20180414141316.7167-1-willy@infradead.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: linux-nilfs@vger.kernel.org, Jan Kara , Jeff Layton , Matthew Wilcox , James Simmons , Jaegeuk Kim , Andreas Dilger , Nicholas Piggin , linux-f2fs-devel@lists.sourceforge.net, Oleg Drokin , Ryusuke Konishi , Lukas Czerner , Ross Zwisler , Christoph Hellwig , Goldwyn Rodrigues , Mike Kravetz From: Matthew Wilcox Simpler code because the xarray takes care of things like the limit and dereferencing the slot. Signed-off-by: Matthew Wilcox --- mm/shmem.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 0ead678725c4..e1a0d1c7513e 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -667,29 +667,19 @@ static int shmem_free_swap(struct address_space *mapping, unsigned long shmem_partial_swap_usage(struct address_space *mapping, pgoff_t start, pgoff_t end) { - struct radix_tree_iter iter; - void **slot; + XA_STATE(xas, &mapping->i_pages, start); struct page *page; unsigned long swapped = 0; rcu_read_lock(); - - radix_tree_for_each_slot(slot, &mapping->i_pages, &iter, start) { - if (iter.index >= end) - break; - - page = radix_tree_deref_slot(slot); - - if (radix_tree_deref_retry(page)) { - slot = radix_tree_iter_retry(&iter); + xas_for_each(&xas, page, end - 1) { + if (xas_retry(&xas, page)) continue; - } - if (xa_is_value(page)) swapped++; if (need_resched()) { - slot = radix_tree_iter_resume(slot, &iter); + xas_pause(&xas); cond_resched_rcu(); } } -- 2.17.0 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot