Received: by 10.223.185.116 with SMTP id b49csp4140061wrg; Mon, 19 Feb 2018 11:54:13 -0800 (PST) X-Google-Smtp-Source: AH8x2272QuM41T58SrIRrMKnMdFOJ/jVKhWjcAnmezNQIreZY/8rvZEWieBO9cwGiTn6hSqkBTNg X-Received: by 10.99.55.1 with SMTP id e1mr13136141pga.237.1519070053765; Mon, 19 Feb 2018 11:54:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519070053; cv=none; d=google.com; s=arc-20160816; b=nn9AIIUdEJC/xgaT1Qb/4YFENNWbb7h2PPxpVGD6n0VA+ALas+WyiP2XIrzgdqDPAu w9hX/N5ZaGncctAs6SEoFmoU0gbHd9uWKW3Ot++Pur4tVt0nmHJrZDSq+VJJ6b4FSjmA 0cgjN9Z49ykR7UHm3inXPIcsi8bMQ97sOTMRM0IVSRWfbrHsU+t/u7yiHod3PzAlGTmt 4uFDBcskh1aRLONY/dTQb1p5db6HK5gpzv+rfcV4NsbHWbmc+xdgJ5/aYGNpcZVXxfy/ 6lpK/QJp9as/5eu5PlDzQIz03GkwBK/3ouaiexjMviwGznFdILCNHwN29fK2NXfR+p34 etkQ== 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=znnkj54K1cHajMb3zL66mVbKGuTCfd12e/IuDRr6Hr8=; b=RNisIdcGx/CPrN/lISze7G7uJubfyd5qA+H0mKQh1WSb0RrGeyRLPj2sbzHAe9A4dY 7wCYPLcyzmDpnxcOEfQ0ILA1yM/XEWYrZWXwNxtSwY8bXcZNnlnv/Lpxcr8quBq6nrMG wVW3gsZip/hU65EcqnAlBswIo4eg8VVpKrNuKuq0WqdVxWwVAW6dua3nLQ6s7u0zwPBu F1eANzHPMeK3B/GwKrUtSAkZYB6ycpwfxpwXWgO9INTiPKXh6wfPr5+kG6joMHKo0LxQ EyBzB89owPgseB6ncKhzm8N001Oo66zljXf+A9d5jvNWJm3XTwXbR9dkozJi8ELIGYcB u3NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=QK6dqy2f; 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 y16-v6si7805186pll.696.2018.02.19.11.53.59; Mon, 19 Feb 2018 11:54:13 -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=QK6dqy2f; 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 S932068AbeBSTwX (ORCPT + 99 others); Mon, 19 Feb 2018 14:52:23 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:44934 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753689AbeBSTqZ (ORCPT ); Mon, 19 Feb 2018 14:46:25 -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=znnkj54K1cHajMb3zL66mVbKGuTCfd12e/IuDRr6Hr8=; b=QK6dqy2f4xQqQBMifeKL4QqU7 wB91gtdoFztM0KQpEQN3wVG4tk/Y+N60Hg35GZqnXldZ4bv9aNWgBqDXtyCoSLgBhozD6mOpiuumi SL43cgRzq+MB3i6/OyloNtlJVYGwSJLhg0u4NSBhFIpR1MQR0yOmCTbv1spX1R+alJt/bOqt+Fife yl8m5ExcU0nOGlEl+b1KyUqWCvYlEn+DV/HH4MJ76UaRwha5sBnerUN5gCyY6qSMp6eOJqhEoEMij TESONQmD4KoneVrUv/REkxPDvxJZdFvF2zd3inOuuG47GTNQbc7xcDOytvch4FBTYdo3E0qwfZgvo hXZdf/HuA==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1enrOJ-0001sw-EU; Mon, 19 Feb 2018 19:46:23 +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 42/61] mm: Convert khugepaged_scan_shmem to XArray Date: Mon, 19 Feb 2018 11:45:37 -0800 Message-Id: <20180219194556.6575-43-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 Slightly shorter and easier to read code. Signed-off-by: Matthew Wilcox --- mm/khugepaged.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index a1b1a714aff9..5c96452090ec 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1533,8 +1533,7 @@ static void khugepaged_scan_shmem(struct mm_struct *mm, pgoff_t start, struct page **hpage) { struct page *page = NULL; - struct radix_tree_iter iter; - void **slot; + XA_STATE(xas, &mapping->pages, start); int present, swap; int node = NUMA_NO_NODE; int result = SCAN_SUCCEED; @@ -1543,17 +1542,11 @@ static void khugepaged_scan_shmem(struct mm_struct *mm, swap = 0; memset(khugepaged_node_load, 0, sizeof(khugepaged_node_load)); rcu_read_lock(); - radix_tree_for_each_slot(slot, &mapping->pages, &iter, start) { - if (iter.index >= start + HPAGE_PMD_NR) - break; - - page = radix_tree_deref_slot(slot); - if (radix_tree_deref_retry(page)) { - slot = radix_tree_iter_retry(&iter); + xas_for_each(&xas, page, start + HPAGE_PMD_NR - 1) { + if (xas_retry(&xas, page)) continue; - } - if (radix_tree_exception(page)) { + if (xa_is_value(page)) { if (++swap > khugepaged_max_ptes_swap) { result = SCAN_EXCEED_SWAP_PTE; break; @@ -1592,7 +1585,7 @@ static void khugepaged_scan_shmem(struct mm_struct *mm, present++; if (need_resched()) { - slot = radix_tree_iter_resume(slot, &iter); + xas_pause(&xas); cond_resched_rcu(); } } -- 2.16.1