Received: by 10.213.65.68 with SMTP id h4csp357697imn; Tue, 13 Mar 2018 06:41:06 -0700 (PDT) X-Google-Smtp-Source: AG47ELv6dyBZ8BnTWndyk0fvmeI+EVadZHdj9n6juf4XCPBUMPep8PhNrk01Gpbampr5AQb9da97 X-Received: by 10.101.66.193 with SMTP id l1mr538954pgp.57.1520948465984; Tue, 13 Mar 2018 06:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520948465; cv=none; d=google.com; s=arc-20160816; b=FSdf+H8LWVUtgpwlSeroe7JhpCeuHoScd625xl6OVLx/w+zGqZZ0gJywVPH9iljb50 0cqlQ7+nOSX4hmS7lDQH4JR0TUbl97lrcVaFMn+h0hjexl2yqwjVKot4N+0mejahIvso IoRLORCoHYo0B4y2BnT4WoD1fW0HtnyPHBb08TjVw0TdhPaxRrgfRUv1Syoih7JHnYeZ la9jyL7J8BjpTaD/QwIxdxagvktXwUGQINvhuQCOJ6tX3osetHS7jtmlC0SsJF64CtWr sqY9kuYp7Opp6vzeyMT7NrTnl88hOj8g9XDk0/trof8a+c+QwtTDxJUFZT/OmVg3Wf8U X5TA== 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=fMGveMqJ+AfhMwu7w/CIfEaV6iAA+0Ik35yRaUfo3/M=; b=gl42tW2FxEVDID/8LT9hKcKHupOp/EmaqGqe0En5NBdJ4tIzBiSp1oqod3NmULuiBS 6qU2EgWE6kU2mzea0vhLGGSqVxH7MxPV+tDLx7seVfk4LNXAc+rXqvo9BpqgiWFzKkHk VliqD/IG0sH4LOBEGIxjr9h0j3KLlnPUhCpCmAS4ES0x3EdrQ/fIxRYP6D0AJ6Vp1jpU UZLf1lTW+1atSSgi0ro+Y+iiQvMk8m9nZwS7QbPRLCSUxHPdB5ILh9oKOo7nLAXRruPU qUtD1bpiKDu4jZDzSNSiEkkC5dzthImz3iWbI8Y3mRM/qhGzC0N3FDAhB+zAjOXYPhfS VMmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=SRr/BE8G; 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 b1-v6si131339plr.335.2018.03.13.06.40.51; Tue, 13 Mar 2018 06:41:05 -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=SRr/BE8G; 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 S932930AbeCMNjB (ORCPT + 99 others); Tue, 13 Mar 2018 09:39:01 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35408 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932568AbeCMN1A (ORCPT ); Tue, 13 Mar 2018 09:27:00 -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=fMGveMqJ+AfhMwu7w/CIfEaV6iAA+0Ik35yRaUfo3/M=; b=SRr/BE8GLJxqx0I3nGvrZKAa+ 60m+TCC/6bJNOYAJy2HAULPF0+RekBS21OmNSpL03z625N22Hb8g3wisnV8rHCKY9q757ChIWRqY4 c5dgy8KhulqEareeQfzekK4DR4grjsiOwvpp2arWKX8kPLNNJvrwtrKxmRytUQKkAZ49IjiFxrYwO K/I8YzOHA6/04wx52KfeJizzuLIe1W5YCEhSqDj2WMou8+V12R4Kdh4/LRYkwA+kizGYUG7XF6HoE 7E7wD1nMH8Sc2hAGwOO2I7llLq89IB/mOK+tEGQUL9Aa9qARWuakHJfks3xYrVHVGyewfSsxGvGxa pQ2GlPTlw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1evjxD-0004jA-Lt; Tue, 13 Mar 2018 13:26:59 +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 41/61] mm: Convert khugepaged_scan_shmem to XArray Date: Tue, 13 Mar 2018 06:26:19 -0700 Message-Id: <20180313132639.17387-42-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 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 3685c8e2b3dc..39e260a0639c 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->i_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->i_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