Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4250784imm; Mon, 11 Jun 2018 09:15:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI15d6jVC3LRvZKX/pN/tUGd23MajogiciriROKivBBBImeZUoTDRbiBaHjGavlREBv55h6 X-Received: by 2002:a17:902:2f43:: with SMTP id s61-v6mr19184114plb.274.1528733702723; Mon, 11 Jun 2018 09:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528733702; cv=none; d=google.com; s=arc-20160816; b=nTZuAGdqReI2K5v3WoikU382ATUfIv6rJy2yQVJqhE4jugJiG2snYEaWJAGpUgP7WP PU2K1ywwiDStN0YUrGF2yE3JA8hCUHaLLpwcqmpBL8XhQyCU2LYWSXxzL3UuI/BTuEP9 0fvhEhsUu4zEQYu7JcHlC67sb36cFyHW7cSXWXRsuRdrre+vDh2xFTKDx8+B6OEDWuFr VvNN0d2ugbfZPssucAyKxjuXxMVb1/iu9m+G0x4N4MVYdV9wKeUYBqZm3EZNTGlX5GnZ ImmGT3Nv+Vz7hd5WLLBjChndVloDh0PSXgzBhnFgFF3sj3VFzN0NvS0Zux8K1ZbiULOD +PIA== 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=0EjsrGiMt0AMBHCpmZhDE2s/mYuVDVXAXqW03asYwq0=; b=UPMpGRJAFvEigT7IctrNXiwct8jaQYaelED4IvRxk7tX2lhwGoa+bLBzVS6d9FzWvH fKR3E9h/VvXtvyry8ls1s8Ocst6D8B90mlJw35SpK4d/DM/BVk4BIcwCefvILFQ/rCvD C3d2V24gLXhicsGJVh2mCHxC/rA8ucdin1tBoPEa+z/5CW7BJ34DroinAcHOzh6HFR5a W9gwWXRHyank3hp8lRmGQRe8k70nlqVkKoynBjYGZrofIIzVsr1rCAA1RQm+r5C5qOm9 OQQ/uHhq+P3LaHzAGPjUEP5vjpZH5qt57NhuMhm+oyMCtIP6I9J2iKTTFMvMx2LYDUt0 HToQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=jq8BOrbU; 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 60-v6si35048657ple.65.2018.06.11.09.14.48; Mon, 11 Jun 2018 09:15:02 -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=jq8BOrbU; 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 S934054AbeFKOQS (ORCPT + 99 others); Mon, 11 Jun 2018 10:16:18 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45924 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933558AbeFKOHA (ORCPT ); Mon, 11 Jun 2018 10:07: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=0EjsrGiMt0AMBHCpmZhDE2s/mYuVDVXAXqW03asYwq0=; b=jq8BOrbUjd88V+j+k026qIkdn iSyF90b76zY7jssORf8MpW1fP1/GPaH7/EJv9cUywaRdzjCYreCKUcZAb3IVbiqK+0XQ0p7oZBFSZ eaMxqjlmHIqLnx+J1k4VBbBtux2xXQHA533229i/CEitjmcjF9PkgUhitcEcp3OOZTsCl7v7tNYfi 4nELIbDLMnbTtCwHeIYXMiL/1q4ZERTpbjET/A9atIxATtrzSK/C7NMCSLK94CGoMjUcLkiXteooK xGYb6AeKysRK9DqOM06pJyRz8hL4LEuzKIRpITsZrYqP4VhWEmeCp7llRjokOfUj5LpBwih29byI0 T/erpetLQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNTH-0004oe-FF; Mon, 11 Jun 2018 14:06:59 +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 43/72] mm: Convert khugepaged_scan_shmem to XArray Date: Mon, 11 Jun 2018 07:06:10 -0700 Message-Id: <20180611140639.17215-44-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 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 43598cc5998b..28579ad0c5fe 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1538,8 +1538,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; @@ -1548,17 +1547,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; @@ -1597,7 +1590,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.17.1