From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox Subject: [PATCH v10 42/62] shmem: Convert shmem_partial_swap_usage to XArray Date: Thu, 29 Mar 2018 20:42:25 -0700 Message-ID: <20180330034245.10462-43-willy@infradead.org> References: <20180330034245.10462-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=OMuHyRUoxlrZNQGgjGAHfNtlOqEqeMYPkHfN4y+9u3w=; b=SWN9QROTzC+5VVw8HMFWgZ485T I7TPBqWXLaa8QMu1/a5WvunN7fsmP/KV1Gfscz2a/1IGHKPeznHq2ekrci/do6Ed19VTWVvIWJUdI bdPWiuFG4X7A86+0Ga2NIVFoGZsgmJgcHLcMG1f45nMz+49qzIjPl9AcMb31k1VTa/yQ=; 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=OMuHyRUoxlrZNQGgjGAHfNtlOqEqeMYPkHfN4y+9u3w=; b=eHROVmFfQ+8qfnIgC0vp3hb1sp hRJAJGPI7AbFfhlg6ihe/ZEsGZCaWpEd38u8NJ3zSVK3FR5GStztMitcBbDVNU+DdKsrHrlqomJEC TqtPwSlKpIIYKvwiW34ArxzeST2n937Frn2+FKRfokLB0+pZdYGPFMwLRlxptNz4jW0A=; 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=OMuHyRUoxlrZNQGgjGAHfNtlOqEqeMYPkHfN4y+9u3w=; b=sZMSUk4kOuGsj3HvDhm8dQ7bL 0hsJnI8u6kbk3yll/NDyPx7qU6S3vBhyrZcFzrNpOBjw55nKTdHqE2wSTqMMrwPR0b1MTOTNsV+yI MengXQK++wBIAdPLlcIS91JxZv47rxBkbt78jDS+B+IIWvQX7S9TECjnV2d6X6rOnRiIeZVrNunu0 BS/Y+OsSGmF+Er0JOMoIyiEUz0B4T1S8ja70ZibnR1oB+Sbi/LaBafyg3m9Lag+U9rotlnz+KShsV Cvh48qnOw1EIP8PskWZQtqnq3mjqrk2hkAQBA8gKIzhfCoKjVeggU3QZrA2b9Yt9YAqS2zPT2KuFU Rggihfjlg==; In-Reply-To: <20180330034245.10462-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, 3 insertions(+), 15 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index be8c6d43b4aa..cffb3b6294b7 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -667,29 +667,17 @@ 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); - continue; - } - + xas_for_each(&xas, page, end - 1) { if (xa_is_value(page)) swapped++; if (need_resched()) { - slot = radix_tree_iter_resume(slot, &iter); + xas_pause(&xas); cond_resched_rcu(); } } -- 2.16.2 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot