From patchwork Fri Oct 20 18:33:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13431018 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB1B6C0032E for ; Fri, 20 Oct 2023 18:33:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 74954800BB; Fri, 20 Oct 2023 14:33:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F90280044; Fri, 20 Oct 2023 14:33:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54A96800BB; Fri, 20 Oct 2023 14:33:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4914D80044 for ; Fri, 20 Oct 2023 14:33:48 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1AB5C1401B6 for ; Fri, 20 Oct 2023 18:33:48 +0000 (UTC) X-FDA: 81366688536.05.492F0EE Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf29.hostedemail.com (Postfix) with ESMTP id 4BD11120002 for ; Fri, 20 Oct 2023 18:33:46 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YNQnSr8C; spf=pass (imf29.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697826826; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kOxvYaksrDFINgvTHvg7i3BLH6nikNi8tBwFFhT4+xI=; b=qEAoaivB8GGXxVdfu1ftS0P3zBcR3kYjhNpg42SDraRtr1TlqASfzWC6jQuGUgpllc1yaJ PGUM3GxmzDxt+5Wj/9ZYxXk/fpcslswtpK2jMk1Wz03QAWK455xhR1wGLKWASjiHXoagdr j6shtsVVu6BpGY58PdouPgPl9oKapMU= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YNQnSr8C; spf=pass (imf29.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697826826; a=rsa-sha256; cv=none; b=lZSdOtoi4LjRMIVjikwiqKUguUEIUno85FAit5N9L3SlcrLnrbP2YZ5tquqDV72r/omeFs CGMFlv1DSKoexcqy3r4VYgqG72h6PNwcdxG+TV3Y5mxaOQgKNLkCUb2G4CJB2nXfJYxJo+ PjBBH4nWT5ebBqCwSAqYFmvtyvHiFIk= Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6b3c2607d9bso1064067b3a.1 for ; Fri, 20 Oct 2023 11:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697826825; x=1698431625; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kOxvYaksrDFINgvTHvg7i3BLH6nikNi8tBwFFhT4+xI=; b=YNQnSr8CL3EdAaBELXCWS+6jaR2jZ36riGWOLpY6pFKbDYrZAU+20pMxKWD82EK9aD +/gXWI3feFZlHxUibQCbiK9Sr+Z2nDHnAHAVZicF1rJbZ59pKKJV1JjllGV9LZCH8AuS mZ4fC7DUYbELduqbbufEEy2R5qFHTnvmF6+lDoiIT1IR0Y9DpDTJUVYt7h0muNFUHa/B OWybA+MwMDyLIhkiHEe8D0qffVfXww7bJpF+nTvazLsQJJcxqqY7asjpHW0cujuWz0XV Nd1cfFxkeHN/QBuysp0NjdBIRzK0zSNnMNoFVvFY7XnFjccBS5TBU6QIm3XhDxaSq0tk 1JKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697826825; x=1698431625; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kOxvYaksrDFINgvTHvg7i3BLH6nikNi8tBwFFhT4+xI=; b=pXeb4doTvhP+a8o7H4bdR0vBbz+uDGrVVB0b3I4vr2SGi2cCNK0VmUQDFKIiLp4+0J ADaQX80qSmptGoKPuXVo/AwZBYapxZ8TqustRqXfXca4TFuuHTHNgFupjHYPAe6108WC TVl6Y/tjfqcZMr+KCbdPKExkxsHH6AnOOrrSEFnpKoGNb0KqOcUhqy03XdAbLPmTiNTY EHeVWYf0AA9fu7u+tvQFcW2obSTW3qLib9ZQE0AAVjFFjdgaU7cnNY1MDhunOIveQ074 3r7WrlRAZMKX9XT6ch83Qiol7EfuCAQdaq2HBrhdvMDXYMTL8EhIUkyQYJwENlBPVEv9 nwSw== X-Gm-Message-State: AOJu0YwJbxXTyr8zJecvm8LbXsHU2ujWPJwMuf0c17tVeYb5yDBseAej i5Dn3PJzG5bCRouCQWPh+s4M+QGiRIo= X-Google-Smtp-Source: AGHT+IGjvWBVIPvS8d/Tp9SPsRWhqao+5hgFvjwUvgPczwPUlTiLiRzRdGbqQM/sCIzdkV5OmPNgVQ== X-Received: by 2002:a05:6a00:1393:b0:6bc:62d0:fffd with SMTP id t19-20020a056a00139300b006bc62d0fffdmr2943268pfg.15.1697826824857; Fri, 20 Oct 2023 11:33:44 -0700 (PDT) Received: from fedora.. (c-73-170-51-167.hsd1.ca.comcast.net. [73.170.51.167]) by smtp.googlemail.com with ESMTPSA id z14-20020aa7990e000000b006b4ac8885b4sm1911345pff.14.2023.10.20.11.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 11:33:44 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, "Vishal Moola (Oracle)" Subject: [PATCH v3 2/5] mm/khugepaged: Convert hpage_collapse_scan_pmd() to use folios Date: Fri, 20 Oct 2023 11:33:28 -0700 Message-Id: <20231020183331.10770-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231020183331.10770-1-vishal.moola@gmail.com> References: <20231020183331.10770-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4BD11120002 X-Rspam-User: X-Stat-Signature: dhbym7hgkzcwrd37zgemthwceb6exk6t X-Rspamd-Server: rspam01 X-HE-Tag: 1697826826-382685 X-HE-Meta: U2FsdGVkX1+dSeFXQzr6HHgPbbW0KEKEUcsiOvTCDlyR500KJ4ZOlImr5k7weQes68dKzmLsMzfS9vXy6Gm7wBtqMWUlWYxJTS6TLBeAjp5FhU02UtP0VY5DBiyN86saGkrAG2Jvci/Vb+JWd9h2FNu+eB8tfiiX/F6Bs3QjKBFr1j0Xjr1NpvV7zXgy0fT9/SPn/XOKnsKoz8rn2ojIpBN+91GXzAFmL2XoloulweV1ffAUx3XqrxoQRNeMudb6zwjSuXC4Kl4CE0t6zr4/+YU495EWWTpG6EhB5W1F2GnvZscT8GdkNl6DNd/Xfw4H8Hjx7ZiZXRbjPHTMbSJ/L244NJLJCYKts8voZQ0kIuSZ2Du8xIAar1mBa0LlO3q/ltsIpl6UeOvGDb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0CyeoXeOlTLtzi+rzmWmtirAm73RfJoXW7J+vI1dhloLRuX0uD/ck/NSZlsCaU0uQdCfYNM003Ls+Esw8sUkmu9GfY4ZJRQ1oaSTAKzOQLTRnLQw== 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: Replaces 5 calls to compound_head(), and removes 1385 bytes of kernel text. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Rik van Riel Reviewed-by: Yang Shi --- mm/khugepaged.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 500756604488..6c4b5af43371 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1248,6 +1248,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm, int result = SCAN_FAIL, referenced = 0; int none_or_zero = 0, shared = 0; struct page *page = NULL; + struct folio *folio = NULL; unsigned long _address; spinlock_t *ptl; int node = NUMA_NO_NODE, unmapped = 0; @@ -1334,29 +1335,28 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm, } } - page = compound_head(page); - + folio = page_folio(page); /* * Record which node the original page is from and save this * information to cc->node_load[]. * Khugepaged will allocate hugepage from the node has the max * hit record. */ - node = page_to_nid(page); + node = folio_nid(folio); if (hpage_collapse_scan_abort(node, cc)) { result = SCAN_SCAN_ABORT; goto out_unmap; } cc->node_load[node]++; - if (!PageLRU(page)) { + if (!folio_test_lru(folio)) { result = SCAN_PAGE_LRU; goto out_unmap; } - if (PageLocked(page)) { + if (folio_test_locked(folio)) { result = SCAN_PAGE_LOCK; goto out_unmap; } - if (!PageAnon(page)) { + if (!folio_test_anon(folio)) { result = SCAN_PAGE_ANON; goto out_unmap; } @@ -1371,7 +1371,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm, * has excessive GUP pins (i.e. 512). Anyway the same check * will be done again later the risk seems low. */ - if (!is_refcount_suitable(page)) { + if (!is_refcount_suitable(&folio->page)) { result = SCAN_PAGE_COUNT; goto out_unmap; } @@ -1381,8 +1381,8 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm, * enough young pte to justify collapsing the page */ if (cc->is_khugepaged && - (pte_young(pteval) || page_is_young(page) || - PageReferenced(page) || mmu_notifier_test_young(vma->vm_mm, + (pte_young(pteval) || folio_test_young(folio) || + folio_test_referenced(folio) || mmu_notifier_test_young(vma->vm_mm, address))) referenced++; } @@ -1404,7 +1404,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm, *mmap_locked = false; } out: - trace_mm_khugepaged_scan_pmd(mm, page, writable, referenced, + trace_mm_khugepaged_scan_pmd(mm, &folio->page, writable, referenced, none_or_zero, result, unmapped); return result; }