From patchwork Mon Jun 11 14:06:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10457961 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 A4CBD601A0 for ; Mon, 11 Jun 2018 14:09:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91E392835B for ; Mon, 11 Jun 2018 14:09:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8640028451; Mon, 11 Jun 2018 14:09:42 +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 2407D2835B for ; Mon, 11 Jun 2018 14:09:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 948EE6B028A; Mon, 11 Jun 2018 10:07:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8CF8B6B028B; Mon, 11 Jun 2018 10:07:02 -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 6FB6E6B028C; Mon, 11 Jun 2018 10:07:02 -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 0E9E86B028A for ; Mon, 11 Jun 2018 10:07:02 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id i1-v6so12148855pld.11 for ; Mon, 11 Jun 2018 07:07:02 -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=0EjsrGiMt0AMBHCpmZhDE2s/mYuVDVXAXqW03asYwq0=; b=eoGIdhcsjdyud4TzbthWsY7RxPFeDLKG6L4taPHNM9wxy5B4zb9X5uC/yYfPxtRY3o l8C2o8CViBUXqol36ToP8NUxg3vkk+Ih5rJjA7oeuyM3nu1DEP5kCIwJfXpVMk/9Whot sE4TMz2iutMO1bVo2vuDmIxTA+yiJ439xxHSCHd6GglunSs/plPhtYq0O2Q9t1D8iobQ Ey3STo8s9/GYjZITzZbGOPTWCdJe4LwCItMPydRs4bsMz23nnilNXDtuhCrTSw+A8Awn yseoLb+c6zgCMAqh//toyDC7FQdiyqPbG6LHw1JP29T1LOHtrM/PHZPOI4540xkdfdMC bgaQ== X-Gm-Message-State: APt69E1MHVyeWm/Ws8+h+lG3QF4WQs3+oCOah/3L46MDYYfemtex+DcM SWjzt2XZJv95tFI4W4WtCWmpsYlQQghxL35uX/tV3KCx45txaBtWk5XFZhSk7iyCPnUKX2zGdyS oa2y+EU9miOgc6VyuFR3YNdGOk1qalQ/opGxv6C7tDAbFZLll90D8SYOeaTFlsK+BrQ== X-Received: by 2002:a65:5686:: with SMTP id v6-v6mr15122690pgs.141.1528726021759; Mon, 11 Jun 2018 07:07:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKItY9Jkio4XBzXjd9u1vh/YFJd6LFz6q5y6vWo5s904CweIA5qqsug/TiteOv+KmoKIEvF5 X-Received: by 2002:a65:5686:: with SMTP id v6-v6mr15122632pgs.141.1528726020681; Mon, 11 Jun 2018 07:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528726020; cv=none; d=google.com; s=arc-20160816; b=UExhFOHveYt9Z65dRigkS1tdMn7KWH6+izKGnD7SEnkK/lxR/hSmITlGLI/fXi1r2g Nq1LIOSCjBcSXMlE4gvqpZR5DQzFpKZR+pYJlBVMV2sha+tkPjKw8eMARD5Kx+Bko48M LjDDLQvlzglr7WrvpGgT3/4VVowEouCJ+OivZWpQDgRTDOMp83eK/9YHEq28zV9Rb71t fi9J7xz5jGn37W36EvTpGMEHycEBkQ2yJvnmuj8mDCM3DodpQsuixfhUR0BFEZN7A1PN zkZpGTO5A5QX6y+IG9lwt2lOAnLq+PXrteCHNBgUFg6GsU1Rh50RGtZkf4p+dqgGYyyK iswA== 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=0EjsrGiMt0AMBHCpmZhDE2s/mYuVDVXAXqW03asYwq0=; b=M1aHz/Hf3sIaS26ysMJRmsSb9gt+g0GYom1FjZRUq1FUhtwee+MzPEXIn7HLCS2UY2 r2APuOf78EcH80vLSgOzJ+vIJZA4hAJhvaFOWS08BOMT03G+VNHwKS44iUjOzf1HuU8l 33PDkZgc0V0oSvKjXAXooi+cJ80SMtvxPE+k8v4n11aCZ4shAJ6VnaeHd2lyLe2BL5HE aPH9rLJFAXGmAWLJSneXMoZRSpareiiAL/d/38uwGzlDGHhyBNEJKJFtmdxJxRMsPVKD eAACy3hX2krey904gypndqO1sADcaPZ1pJBLsgM52I8JZ4v21NaYyVH+Y+cIGIfDhsYm rh4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=jq8BOrbU; 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 a19-v6si31270158pgv.47.2018.06.11.07.07.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 07:07:00 -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=jq8BOrbU; 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=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> 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 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(); } }