Received: by 10.223.185.116 with SMTP id b49csp4135829wrg; Mon, 19 Feb 2018 11:48:29 -0800 (PST) X-Google-Smtp-Source: AH8x224kz2EL6qVLmTXlqqoyBzF5OiIBFJrS7l3dFdKS4gyHyEcmnuyB3sv0/fnvxhMCVRKZWnSH X-Received: by 2002:a17:902:c81:: with SMTP id 1-v6mr4550940plt.205.1519069709707; Mon, 19 Feb 2018 11:48:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519069709; cv=none; d=google.com; s=arc-20160816; b=aii4argX8m3NfvnAraIkaG0e/EF3rn4LxZM+Y8Tlcqg2B8tExVLlVzRONhQHG67FrT GydCIpGU3e+FZgM4PuQFQ/PlQGYuU5G4N9k47mOemtEqbi+/D2CTiWUJHBi7piy1w2aD mB7PntniQJN13frTqxCEfdfSU73X/GRe3lKPO6Lmg9b5fFdlBJeREDwTTKrrhm+SfZen wkx6RQ5afhU88HWu0otmSAkd0yzm5Ce9KJxeVqMzOuEd4ru1Ko3mp+x9+lbp1ikMcFMy 0Nq0SUdWKz2US2ega/xJixWU2H0GZGQ9VFK9GXhqLSVw36f8ps9AzGu/4CP36562+4cZ yGBA== 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=Zv7TOAdMSkAdgcZeYdIAoFRWLnOw/ZVDVF39MgffUEQ=; b=n4XbJ6hPXARiMaype2JVIH01asLWHUbruRGDqH4tGb0FdntblFLR7Jigp/GJi91R2F 1UixlAiANzaHWdePiS9Q7HR8lNVf0NwO+F9fgvz3xLZOODam8fYXOJja1LTBnebkCbJ7 nj575YskYfrDi3SqCCRgi+328n/W+DY66J9XcCWsUcJqoLY+4Wc2yxsYTBxYwjjVmTHn wQW0je/DbHxixXTqK56D9GUgpJ8hQUqXZe3EyasNWWJz6SdtqXeIwlyzFOEcqC3CW22C 3xxLw7TO2kbGDX86wzqjfDCgekAergPIUxQChyfGghNq2/yGxyoKiTqzFC4HQW8DRsoK rorA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ChCPAtHQ; 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 5-v6si4540031plx.742.2018.02.19.11.48.15; Mon, 19 Feb 2018 11:48:29 -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=ChCPAtHQ; 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 S932113AbeBSTqi (ORCPT + 99 others); Mon, 19 Feb 2018 14:46:38 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:45028 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753678AbeBSTq3 (ORCPT ); Mon, 19 Feb 2018 14:46:29 -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=Zv7TOAdMSkAdgcZeYdIAoFRWLnOw/ZVDVF39MgffUEQ=; b=ChCPAtHQ9WJAQxv2KHE7OWWHz bpc/tbB279pJxRDEiFu0m7i1nK7dHd8RyyjJh5dVwG9MdQQ1JpNYZc0Gh8DS5eBsR97uV+lp4TUzc 1t74XzWfEphHC6pM0ObAkq54oVNoG3sBurXCCTr0JmiBB/eSdq+fFo6anfXgaANJk8l+o7i0Sa+3+ 2BOMXNAG4/zXp6kCyjhUUzwa1soSZP6huCq5S6fwv5wkJkSvs7ccTAIneUf39hbZ350OzGCCcJEev KXz0iyeM0XDeixg1A3LE8tPt4FUXsGOG0n5LfC092acxZ1H4mLj1JkqYFZQNnrfGU7mGarq4k7d2x mHCG8DbJg==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1enrOO-0001w5-4m; Mon, 19 Feb 2018 19:46:28 +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 52/61] shmem: Convert shmem_partial_swap_usage to XArray Date: Mon, 19 Feb 2018 11:45:47 -0800 Message-Id: <20180219194556.6575-53-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 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 a7931660897d..c24c4cb76c43 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -658,29 +658,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->pages, start); struct page *page; unsigned long swapped = 0; rcu_read_lock(); - - radix_tree_for_each_slot(slot, &mapping->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.1