Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4240860imm; Mon, 11 Jun 2018 09:06:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLWIsLXwtnfXo7djxvo2kCUw4Utcb7mEyyPaexHcaN8yv2zWPlpTyQvmLrJ5JgfxL72Y0zQ X-Received: by 2002:a62:642:: with SMTP id 63-v6mr18400068pfg.222.1528733195842; Mon, 11 Jun 2018 09:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528733195; cv=none; d=google.com; s=arc-20160816; b=d7LU+9SRmZ01oiAGyKGd4R24nbuZzbJ/ZFSX7Gi9vEd+1rWtoyKlIpFe4Gtw/RAhZb 5cTyULkboh984oLjkiqh0WG1qUeiWpyrn0c7JuHMFcgATOGQ4bk7k1gyvReJyefCGMce XeGSeG6OnNoag8n+Er30ceRsiGL7G840k4apO2GHnXsXk2KzjTpXchyJ7f4+Xb57S3pP pPeMBpyXX99gpic7qU8Ltzudn1ZAcRj80TgynMZVVRq3rQ7WilmMhPZklDfpVDGpLuIV 38nroyOQSniUddkjfPrOWqJ9ph3txo23b0VscJBOZpbgndAJ0rv3B71iVqZvfKzT8A+p P+Mg== 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=oTHiFdNe4Vn6UitekWmDmg9p/jcGgir3VQorWtPf2OU=; b=uij2HeDK2Mk6ehK8LpCcLEWMoGWd++MAGbbfbKNNl0ZzAgrCOSm5w71cVQ40AMtQSf GwV2PRsWJfQ/f3E8/T4dYeu2bh4yFQgoA85vMRyPd41ouchXVOhYFnoULvZzRXDKvcpv SYsh5D59F9vLdXFQK7l7hadDgb9F2h13Sb4IkFAF+LD0pfBoLH2x290V9Q/EXNMCUZ/i 8maUXmtf6abE3aED5Ha6WYZ+wNQYusdloa1htNrMhOp7VBr0Ua1Z3lt0fHUBfmxH8Phm dd0C0/KqPrw7aL5QbUnV3rEDVoOdCeYiVMgmx7P81dCIZ4uTDDfshTv50tXGPIfRwlaS N8fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Voy8qDga; 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 m1-v6si20679247pfk.56.2018.06.11.09.06.21; Mon, 11 Jun 2018 09:06:35 -0700 (PDT) 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=Voy8qDga; 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 S933963AbeFKOLm (ORCPT + 99 others); Mon, 11 Jun 2018 10:11:42 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:46254 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933616AbeFKOHG (ORCPT ); Mon, 11 Jun 2018 10:07:06 -0400 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=oTHiFdNe4Vn6UitekWmDmg9p/jcGgir3VQorWtPf2OU=; b=Voy8qDgaiHz4YuIZATm3+m9j7 VmoYUsTWRN+oCLYOpbsfoZuvK6VneyZOgM2YrCokdEjf93cHQtIVgby73oscjYMUVTwJPLKkbMu+Y zNt3zh/2KJBq/JTnmrU3M10/+qZmD5RegS7dqd4un7dYmw7qraGg0o/YpHHHg2BcBuwPQbAwNOIqZ kBgLCBE4UZ+msZFEle9AfKaZlGfsRH2GEkT4zwfj/1EYM+lvcfGy9Jt/UKMmEfftW8HYTuZWuVNoX D35yUymwUPu9MoAAXUgPj49FeRr1nJCRtspS0LtgqpinlxDdPBIYXxQNt9EOW6/7cG+cPc5mPr7Yp C37CYV7Vg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNTN-0004uW-69; Mon, 11 Jun 2018 14:07:05 +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 52/72] shmem: Convert shmem_partial_swap_usage to XArray Date: Mon, 11 Jun 2018 07:06:19 -0700 Message-Id: <20180611140639.17215-53-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> 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, 4 insertions(+), 14 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 9dbbdd5dee30..bffb87854852 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -679,29 +679,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 __rcu **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.1