From patchwork Sun Jun 17 02:00:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10468247 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 03204603B4 for ; Sun, 17 Jun 2018 02:02:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E54CC28BFA for ; Sun, 17 Jun 2018 02:02:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA2DD28C08; Sun, 17 Jun 2018 02:02:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7151728BFA for ; Sun, 17 Jun 2018 02:02:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B89D26B027C; Sat, 16 Jun 2018 22:01:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id ACBF26B0279; Sat, 16 Jun 2018 22:01:09 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 902F36B027C; Sat, 16 Jun 2018 22:01:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id 3CF226B0279 for ; Sat, 16 Jun 2018 22:01:09 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id q18-v6so7729888pll.3 for ; Sat, 16 Jun 2018 19:01:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=OoAF9vwIWIQcgx5UcrxtXLEzDcPJ64kC3chNz+6Igus=; b=BcRI8lh3wt5kLH7A0sDj5KPTetMzEbLatXLwrzqV23A3+Tope2TLTHJTvd/qdckHR0 EHLmITy8q+8vrldiF7/oS/7HfR8Tj6NDCLzAk4XHfqC6gEaNoCgVn3gfKM1YaUjJ3ZGP DcJ0QLvO9qaNp6EsMuGL6aiDWWzpAbkGKxjxEN9/0RKaLFeDm/G7UxWrskeM8CA675lm Dj9xfQEzzpPaE0V6vH4r8HDJrSrLFPtCeMolQ5qhh8IYvtxhEoHQbYDoKmXcC41Yg+rK QCqhBXwe2RArN8eQNiWQEp2GXb4+D+UC36Jn99ZNGMKsro5QDg62467COwhx50lNuK53 tjog== X-Gm-Message-State: APt69E1McE8JjFrvEHm765tWePlchrYa5jIxyM9N5cAR7sEbq+3JW8RD kq+6+CVjoKaD9INBp61HmimBHxAfMSLXS3qJmjS14VvKWqj4qlfQUDlk9MabKfqLMlJdFtxRUe4 N2CwIfrhMmF4YEviRp8M8lkFAL672j1+pJJV9VDNFvN94A0ZWKW8MVY9nICGbzoUxEA== X-Received: by 2002:a63:3115:: with SMTP id x21-v6mr6524729pgx.373.1529200868921; Sat, 16 Jun 2018 19:01:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL7PJKsysUbr43WtqHVBRgVHya+GUH7gTKLEXanjh4x0GVdIK95pu09ZXp0gS9gZAkUHl5p X-Received: by 2002:a63:3115:: with SMTP id x21-v6mr6524707pgx.373.1529200868169; Sat, 16 Jun 2018 19:01:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529200867; cv=none; d=google.com; s=arc-20160816; b=bqHY6KP2F/aP5+XMorbi6ytuN9lFO/wyFji64BeXwdZdsoClmW0bS+lR5gTtHCDfXV qYtisVZkfgCmkQR5lUpjibn7C8JQ8qOmoMJ4VWEtwIWSeRk+2ZymWIQHt6lTVQkZyGUx dbhD3u27H3HCWtusg6e9sRQTZ4i0P500SxHehP25NbDH+5hnfRZqnyX9m7nEL21L0Eg1 mdsDgTyCPMUTeayskufiEHf9HHY8q43wbvk8OEAgoedOBHGprXun2+fSYT6r8NDycqmF HEVRISHFmQC2vO1VR2udq/TSqUlBBiK5u0UeP2wty36yShiY9voJ3TfzT96v+bp5ON0A r5vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=OoAF9vwIWIQcgx5UcrxtXLEzDcPJ64kC3chNz+6Igus=; b=gLzYlzfuo6MIIpO42tW21d67RaR+Ecq3eQRMp7vqhHod5IkEAyD+twAVlj0gX7rvcf 42Rwj5lfWpCz8oW/in54wKf3tx2fxmzYdv+DQWj9v8ZZlAPHs5HTSb6y5A44jc4bUdgf w8CW333pBjaCEVyQych1rZbqTRheISe4MDZEqlH1A4TZOC/lyW3KxRadApxJTh+ftkjh 7ln9mJhOvMvsB+ec65VGnWNjnxLe2sDECedHsp4scbS3IYJiemQUeLnufGfW1VBTH6Zp Cme+98SmRzFJ56a/H5DO10qm3Kt6eBXKEyexVz1jprC/zhbEBCb7L5nnSxVkLgMFhbSi Heag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=NLAHcQX2; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id v5-v6si11616911plo.166.2018.06.16.19.01.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 16 Jun 2018 19:01:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=NLAHcQX2; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org 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=OoAF9vwIWIQcgx5UcrxtXLEzDcPJ64kC3chNz+6Igus=; b=NLAHcQX2xmKLG2q0l7Ph4IHHm g0dEUPNrCaenU+lq87ESTTrwADiCa8xM5oRjWIVJ+7YkfBybIlAWnbCl+jH/o2Y+IdFCZiLrG2AG9 0BNiquc4siOPFazZEM1SHpoBt3BdOZstGZ8OBusQ6XVYZCfxk6dW5KRQ5Ls8GGM+9us0jiPXtGsfO ikd1RanlULfRVaw2LMW3x6eHAq6CgI3JzpkRPnh/WshmSHVIIbU986JVIJGiJOajtlXyyEhbi2PGT jhKLJrA6inLPl39kDSaq/wHd7/Mdbl+cn3tqvBRxBTewQvURXHCqyOf08obk1THt5DKWx25I6fYkB G4kGuI8ig==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUN06-0001Mp-NJ; Sun, 17 Jun 2018 02:01:06 +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 44/74] mm: Convert khugepaged_scan_shmem to XArray Date: Sat, 16 Jun 2018 19:00:22 -0700 Message-Id: <20180617020052.4759-45-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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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(); } }