Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2451881imm; Sat, 16 Jun 2018 19:10:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKDQDXOlTVwTb8U+m+qehqSurybGHyCnMnQeKoq0Z8inJXMJPWr0NQuXRmOVbaYtasKzSrT X-Received: by 2002:a63:7741:: with SMTP id s62-v6mr6745291pgc.103.1529201417069; Sat, 16 Jun 2018 19:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529201417; cv=none; d=google.com; s=arc-20160816; b=ZYblwAtkCtLVXjUzI50ASS8phZic4JscSECmQLnPS5Z7e4v1Yx2bMwRsVo9XMNmRsI Exjyc2ADDYgRdhedqF3wxekhHLLcUE0aHqgjhgt8UMiHkgMfSMaklctByylptqu4Rka6 QTEaP/kHFI7OWo9COSK0LGM4F1l2ecIjLwUuTJNc9zJFYiO00Ofrak0KEQeyk6LsmhyX YAqSYXaTn7ruwSWZ8oGGA3arzeVYEumbVAnCYL3upzBaPh0GsRNqIC96rZ29ylHjVf4Y +F6m9C7C/qcPmL/pgrzwp7c9o0DIxsl/O+rqLjmsfV+h3zmiIt3ATAqh3Hy4otCXQU7C YErw== 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=cG68gKkTs5UYbRuctTjnA5DJ1Hlo3K420tinQxGQS78=; b=WlW6MLPGj1MUa3bueW868HUr+d2hhYxHIfZtZe39Jl8MZdc8UJwuMSKA3FOY07BK/f Z56tcnqgdX2+/CTphBAqtDy9FPiV8iG0+kJDzuJm6mgfFTtLYmZmdQAXP+XhQ2EYQr4k EZ52Vb4p4nUCvvFl9bio5Uds2TTAnb/SkpNKAx3lajIzjtzL6XyA/sjxBdD0i2K2numh uQnPjoIoAMF6Ag9DXqJaXrFNoSbdRcUOz5b3gBkkHYNgRkEQQp8tNy0wREwUVPZ5OrZW brTLcGoDproLI+n6RLLaeiT76IMGxAv8MLiqaszJafSTnLBlKJ3A/gPKDxkpawP+l6Er YJOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=c0oiJt9v; 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 d66-v6si9397624pgc.141.2018.06.16.19.10.02; Sat, 16 Jun 2018 19:10:17 -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=c0oiJt9v; 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 S934351AbeFQCH4 (ORCPT + 99 others); Sat, 16 Jun 2018 22:07:56 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:59384 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934003AbeFQCBM (ORCPT ); Sat, 16 Jun 2018 22:01:12 -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=cG68gKkTs5UYbRuctTjnA5DJ1Hlo3K420tinQxGQS78=; b=c0oiJt9vr2RZyOX28lNA3rwqz hfl0ZlZ1FzLhhgLV2vmQ8nMAwdBeCTtb407HvZsHcqTrxzUmLBQZQOJx4krdvm2WgkVITInaNjBHY ERaYaqnG7/RdpnjAHCbd/CxaHCW+SVYrn+TTmqHwAFR4Fm3ABpaPnXTz23OZJC5pZmwHanqPFfcUo Sy821ttd2CNHL6cP8VgmTa2apeymy6o5svDu6t6LdzkzjgphePdD7GnKn7E1ZbLWs+UN0hoKbLwjz 3J7v3MaN5L18L5SmElcIUL9730UmvnMVistmH0+Dwaq4gbFpeqjWynYFS2tjfoaKG21GwWnCQ06CE 7FldP2KrA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUN0B-0001QJ-Py; Sun, 17 Jun 2018 02:01:11 +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 53/74] shmem: Convert shmem_partial_swap_usage to XArray Date: Sat, 16 Jun 2018 19:00:31 -0700 Message-Id: <20180617020052.4759-54-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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