From patchwork Wed Oct 18 20:32:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13427841 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 19293CDB47E for ; Wed, 18 Oct 2023 20:33:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 243338001D; Wed, 18 Oct 2023 16:33:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A57C8D0016; Wed, 18 Oct 2023 16:33:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E75798001D; Wed, 18 Oct 2023 16:33:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C9EF58D0016 for ; Wed, 18 Oct 2023 16:33:11 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9F5891A0393 for ; Wed, 18 Oct 2023 20:33:11 +0000 (UTC) X-FDA: 81359731782.08.5057E31 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf27.hostedemail.com (Postfix) with ESMTP id A7F2640027 for ; Wed, 18 Oct 2023 20:33:09 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JUTVa4Ry; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697661189; 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=ZHDPDftTEQo9Y69vRL/FtBiIRsSHxpRY5W6+bGGWNnJaISMtMlriAmwQ2HJYuwmzMqPvwb 77Xzgl3vrIBe54xbVxrKspt8uNtyUeZzVrj0OskNUt4GEmCSJGrUB76vp3aJ6ri0njHNZg /pV5e4kxCkn2NiWAJICY7pbzGnX0jW0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JUTVa4Ry; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697661189; a=rsa-sha256; cv=none; b=XxFgV3cMls5ULSLVy8FAjE5Gc51r006piM0RvzeVo2OZEWDyrUm4GlAOpi/j19fBTT7f3i PYpPHSYL3cIh27DnpcChqWwkV3RUKl/10yk+3KQtWHkOSQAbs/UbOvOpUN9b7Ig8bMG5+P ROP6KmYd68cF/VWU/I0rLy5K48ZuwM0= Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6b9af7d41d2so3913528b3a.0 for ; Wed, 18 Oct 2023 13:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697661188; x=1698265988; 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=JUTVa4RybRF/6beipfKFSMgzntSc+ea1docrmpP7g8H6z07i7WMNudFG/P8tbtufDt RYC8vFctryn3WD0T5FHxxLIh6r2CFzsgqbXB5jqiWWg7itny4Xq3wY7dlxfv69S7FzLM Wz78wTuDWjsB25POzSJGrkXI83eVidYngHqt7YcdarjRVg4f6QUluMjA4jqcsC3hUt/Z Gks2ZjwrC7+HL8TWy1ujvdR7SldZD1p1/qlxFCNnsbPJ7n4cHEF2Pdj95/lfDBGmAPNc JFVtHnqGfH6NKrl4FikX1dA6NE9SVnRC1t4+Dxhy6oPFfY9QH4wrbvLuUjf2ChjBKIYC KtTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697661188; x=1698265988; 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=tzZT4Vg4oq8GG7xn8Qfi+ECHihlFlNuUXHiAs26iznN3SuwWgxoGJzeyR3YI/CNk4j cHOZBlCmuPQqYOLPKYyaJulc9py8CPB/NOjUYDbaTf2xBRatD8o/s2CQ+Yr8KcPHtTFn hfcgcDk8xinLZwaST8Q77ZLPc3rc63XRkbrlLvHwgvSmgtKHIW4yK4r4qrvxNqQMRZli HRrtJGgOskcDkNJyjX73Ipp2zNKPunr/pFPaWvTQvc6l/q4g/s/oRYPJsYb84FVhT4/H 1nMAJSQZBaJkfGpOfI//c/GwVe+134DzAaJXx02NEcQSez4vXQ6+QY9OhfmOmLOOelXG xVnw== X-Gm-Message-State: AOJu0YxM/8BInDeNjizWsCeY1GuV1S+IeXpfuFWkjTJlKHnu89QWxZBn N4M9wm0fnlvU1iBrP3JbCLWHeLULqHk= X-Google-Smtp-Source: AGHT+IGSy+gf+h7WIcfgpR19k4aoWiTB0tv72CZNC2cmYBpamwb6VVIlhQcsy15b27bnd2RjKzzbdg== X-Received: by 2002:a05:6a21:6d99:b0:14c:d494:77d1 with SMTP id wl25-20020a056a216d9900b0014cd49477d1mr327396pzb.10.1697661188209; Wed, 18 Oct 2023 13:33:08 -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 w12-20020a170902d3cc00b001c61e628e9dsm354412plb.77.2023.10.18.13.33.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 13:33:07 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, shy828301@gmail.com, "Vishal Moola (Oracle)" Subject: [PATCH v2 2/5] mm/khugepaged: Convert hpage_collapse_scan_pmd() to use folios Date: Wed, 18 Oct 2023 13:32:10 -0700 Message-Id: <20231018203213.50224-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018203213.50224-1-vishal.moola@gmail.com> References: <20231018203213.50224-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A7F2640027 X-Stat-Signature: xthyfektzzhym59jx69zt1gyif5bd5hz X-Rspam-User: X-HE-Tag: 1697661189-655181 X-HE-Meta: U2FsdGVkX1+VpDOE36H//rQOn6lgrLiQrr+uPxkKceE+a61gKu5QJ878zl2cP5OI44R7Ic0VN5B/EVkalJwix7vBE4TOu/SSgr1DqtuWPf+Q5ct/xmpNbN7PnmKCA7c8U1NiMcrU4AekwxOGT59pcQgQoyg8SfEMCNBHJVIq5V4fHq542W86MHYExyFafOw9jjXfgzO8AjQwSgfl3vVCgMvO6x5IQgg07xh8k+tRamZc5Vjw5I8f/6HZoWJZ2J5ifgdqYPxnytmu/YOK6ZAh8lL7TbG47Jt1ljxCyMtlK0qMDEjw5mwULUSmfH0/1QB0pfha2sXxQuB7UWxMngPKbHZlXURY/5oGsbJOYUtZNID37KT2F5DWzJOyiZ8aYjpD/V71h8kaxRyGji8pjA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8rTlgXIQOEf+GcPPIMhshvx/YQGRizzVgVgO6va89+5rL9QfhoKLUPYzapJvWD2wh8kYyRS+UytVubLolDmHnHYvvmSV/lg== 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) --- 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; }