Received: by 10.213.65.68 with SMTP id h4csp350341imn; Tue, 13 Mar 2018 06:28:39 -0700 (PDT) X-Google-Smtp-Source: AG47ELvdR5BJfds8LDyZKsuh/LwnEQH3c5YsPk2bS4adrW54gZMQJ5OPRWgRL8VBXuYz7hLmA26+ X-Received: by 10.99.39.131 with SMTP id n125mr516988pgn.292.1520947718873; Tue, 13 Mar 2018 06:28:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520947718; cv=none; d=google.com; s=arc-20160816; b=0gizwgMKKxmOgxqz+4w0YP0sqzKcxJKmtNAT8XDPd7G29TNppfgJcdZ/5sUJAoovi8 BdYscH4UQwPFAs1P0SeT+2tYIxqptH7r9SifzwkKUZbBkvse81vtRF933JofjM1MWCRA qhV+hT8OnBAJKGzy0+k2i9YRLvN9nycNTzpGwMvSC2D3e7CEABEmlpXfgxHIjIz80DoE EzFTqDnbM7Z9WlDYlY9zdg+LQgPr8etRMH8YsdaY/adpvVhmxEwg4m2IHEoqtHKypOnB cjX+GowndeINx59XyhfvFEdi7zGQp0vc1jOg0RRBmJ87OlDzZ0yVW/f1SDExlZb413MK cOUg== 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=ilG1gJosbTyyuNQT1Kd+mdCYou0B9zfa+ME2Qhkq8Tw=; b=DjiYv6rHlB9q0EcZOYv8na0uWsF6ilJMJhbCzWNsFZjV8ivrFDy4UjqbwVlj6Vpo89 zJSebZji/SvlbSqArB6nPZDWNUsVb6bGg57PZOLxqRvuKFRvOFmDxNPxD6kh4zCkadx1 JQw1Hw+NhhIyPfEucnK+dvmfuRR/oV94cp2hqCagfYtE7upqonZNLeZc68L7PvXdFfiQ uzXRBJVXO/anQgKmei6TKv4x3Iirtk2VDOYQ3viB7S2qB9luYftT4kuRhFSDTi9w5W7Y l4rBDerTWF5bLDWwwwfHAmIEfrbSWkuFdjx5ZD96qVoBt9m5xWmdIEzmYnz2pganPuBn 7o1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=C5Kprbf/; 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 s11-v6si125250plj.701.2018.03.13.06.28.24; Tue, 13 Mar 2018 06:28:38 -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=C5Kprbf/; 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 S932763AbeCMN1L (ORCPT + 99 others); Tue, 13 Mar 2018 09:27:11 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35528 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932649AbeCMN1E (ORCPT ); Tue, 13 Mar 2018 09:27:04 -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=ilG1gJosbTyyuNQT1Kd+mdCYou0B9zfa+ME2Qhkq8Tw=; b=C5Kprbf/ZG+c2e/Icm+eTnpex l89PdwuyjRCbxU3uVSS6P+Wrh58LNoSluWS1sWTHH52MJTxgReD/snLk9d7oCsqtaLqBHN0BW+KuH c17fnhYAmoJg5MyDpZ9385aCK3AIc1Unr2zsGuvS9x8JEcbf/pr2c7FrDPh1Zz+S72zVrVmUZQ6Gu TVX51BcA1nh5plAI8hQAnso2T1vX9yrdZcjRw1CHjB6pRuOVGKZCZiSwnYQ4cQDuUJPtLecgIuOqA NUw1oBxpLdKxTiq4/+eCHijOaxbwPSF7W1w/yqF389cGV+OYYQnYyvlPlGimzOVJD6Fs/Wn17FQRq KLOHyg1lg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1evjxH-0004ku-GM; Tue, 13 Mar 2018 13:27:03 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Ryusuke Konishi , linux-nilfs@vger.kernel.org Subject: [PATCH v9 49/61] shmem: Convert shmem_partial_swap_usage to XArray Date: Tue, 13 Mar 2018 06:26:27 -0700 Message-Id: <20180313132639.17387-50-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313132639.17387-1-willy@infradead.org> References: <20180313132639.17387-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 cfbffb4b47a2..707430003ec7 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->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.1