From patchwork Mon Oct 16 20:05:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13424038 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 52476CDB474 for ; Mon, 16 Oct 2023 20:07:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E61218D00C1; Mon, 16 Oct 2023 16:07:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC3128D00BA; Mon, 16 Oct 2023 16:07:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0A118D00C1; Mon, 16 Oct 2023 16:07:01 -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 AD5EE8D00BA for ; Mon, 16 Oct 2023 16:07:01 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8ADD0120ACD for ; Mon, 16 Oct 2023 20:07:01 +0000 (UTC) X-FDA: 81352408242.22.A9A3EA0 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf02.hostedemail.com (Postfix) with ESMTP id A6F1A80003 for ; Mon, 16 Oct 2023 20:06:59 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Q/XXFvhL"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697486819; a=rsa-sha256; cv=none; b=6HSIeJqC7N4QDPwswlRm61727JrtQRKYWwUmgz7pNEXL2dmHXg/dhZ79ebafsK/dpPNTF+ iZoPiRQOuvlhANAtwGXPWrBjapAFK3fqHjqx50xyj2X43XXTBZMXB94TgechZrHgpFvzWx NiWViKd72z71ojTytLcKHDBP+jVkEKM= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Q/XXFvhL"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.43 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=1697486819; 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=vjFYTTptetyjp2cWLw2h5u7A70TW4Bkl9MqEU9zvv1g=; b=yleNn+3aQ4K9JxIsz4WhfehOYIgaI4aW9P08U2aQdJKFt4PCtymk6sUha7/wJnu5AlrLPg A7Ws5Bj+wpkfMVRkObdb30X7TYDEil5EnKBo14w4qtnlrKPxDqtUjuLZiHuHzhb0hIwi2J C23kf2JWzxDDm8h198zRZb7tL4mifJU= Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-27d18475ed4so3662613a91.0 for ; Mon, 16 Oct 2023 13:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697486818; x=1698091618; 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=vjFYTTptetyjp2cWLw2h5u7A70TW4Bkl9MqEU9zvv1g=; b=Q/XXFvhL4uKp9PaNHioE6gmShZLAI9CymahXsE97BGn4JlWCyYPytvTOaU+7K/TrXE WyzHdbOOWvfluqxQhCZZmp6UpAw7oWMlDWqrqlfm/u/Y8J7k8oX6ZxKaqfF0A0VHKa4J Rwj0sW+miHl/s0q3rR6/vggfLpoPCmQhQPsD3hR0cmuwCibNH5lzl/1jF9K1/J5IJh2V Os7Ms/WSRB6FgZTitZmOKbNAQuohazFZiLNGuFGffxHV0weFnTza5iQ8AktQHvdyg05Q r0PDKSuY+pDLuMD0Ey5UkoZ5OZYoc1DwmkwJkiegxc0zYOmcY2B/RQx0rXv9yppzZJds LSSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697486818; x=1698091618; 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=vjFYTTptetyjp2cWLw2h5u7A70TW4Bkl9MqEU9zvv1g=; b=vOFZX1eufDoqlzoV/iuy3G4P+hbIX6AtTkdzaPbCQadlMxIWFE7l1xMEFZhLt+tQnX zxLju/u5Fks1+C4Kl+k45j2wAE5dm2EJezjawV1qImibElwdwOrer0qAu+hGb5ht4EbT GGYM8OUkik3fYfmIfBhdybao0Pv+ypvoo/HpZMNwTWbGbuBPAubMz2XB+b19BtxYNZ94 AJeyzdx063L0atUvdZrviL+7JNSiIK+56LH13O5Qm1aXbCy7M816WJhLLQMfd91ndfSN 6NwbC1T8YgZkmZMCRkcTSa+hqn1pJWOdW7kyKBThbuiO7IF7eSxfMIbNRsssVIuKsGaI Tu6g== X-Gm-Message-State: AOJu0YzhH9NQA6U1fP868ueah1nunJh+asj9IPEY9jKKiNpH4KabC0A2 ERHPM1xfVDH4Joe4rsi5Ho6B3B8d55I= X-Google-Smtp-Source: AGHT+IGtbGzgcQz/00iryQWZ82rvlGPg9aar7vEHyd9Xs5MULzqeh3bW4EbQYfV2V5h2DPzj6QHTog== X-Received: by 2002:a17:90a:eb09:b0:27c:fc09:401d with SMTP id j9-20020a17090aeb0900b0027cfc09401dmr179801pjz.38.1697486818298; Mon, 16 Oct 2023 13:06:58 -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 t16-20020a17090b019000b002772faee740sm5162367pjs.5.2023.10.16.13.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 13:06:58 -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 3/5] mm/khugepaged: Convert is_refcount_suitable() to use folios Date: Mon, 16 Oct 2023 13:05:08 -0700 Message-Id: <20231016200510.7387-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231016200510.7387-1-vishal.moola@gmail.com> References: <20231016200510.7387-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: A6F1A80003 X-Stat-Signature: 3sdg44th8jts48qqku59gex4px3npq7a X-HE-Tag: 1697486819-331524 X-HE-Meta: U2FsdGVkX1/FnsnRN2doeK1KSZNtcYr8K1Fw0YaL0F3EkhQ4nS/I1UjKJA+IPjdXpG9gyf4PXbgsOAjbWl6FgqOoHSU9jBTCkfVtDEGqz45dqh8QGySiI7DA3/IzBpmXC4HKIEHKyVe4cmFtTqE98tVdQS1R8RIp6X6X7Qel9UQCmkTG9cQfwI2FqZiLwpeG+LItEXq9UPMc6hl6ORWZ7UA7qcS3fcn7slCIEOExb/UMjxS67vUFA6BoGhFENYvSMSxYmXGW4GdyYISI8lY/prBWZkRmcBMb9++rPh6f5MQLx4EuX9DWrdqJZIcKFvvAmKgGeYqyyqL3ldIDEj4p91TyYYLadmfgfSp5fn3CCvFjv70D5OVDjxCH300EmHG8ibWGHCwV9gALz29wHJxcJa16sC7w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uTCrFaOWMwSCV2TiQwH9ez7h2OBFOjrTgAPzUYHyB1JC8PDGzhYwiM4kVPg9fN2cccb9Xq2LcGFrQ== 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: Both callers of is_refcount_suitable() have been converted to use folios, so convert it to take in a folio. Both callers only operate on head pages of folios so mapcount/refcount conversions here are trivial. Removes 3 calls to compound head, and removes 315 bytes of kernel text. Signed-off-by: Vishal Moola (Oracle) --- mm/khugepaged.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 67aac53b31c8..fa21a53ce0c0 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -524,15 +524,15 @@ static void release_pte_pages(pte_t *pte, pte_t *_pte, } } -static bool is_refcount_suitable(struct page *page) +static bool is_refcount_suitable(struct folio *folio) { int expected_refcount; - expected_refcount = total_mapcount(page); - if (PageSwapCache(page)) - expected_refcount += compound_nr(page); + expected_refcount = folio_mapcount(folio); + if (folio_test_swapcache(folio)) + expected_refcount += folio_nr_pages(folio); - return page_count(page) == expected_refcount; + return folio_ref_count(folio) == expected_refcount; } static int __collapse_huge_page_isolate(struct vm_area_struct *vma, @@ -623,7 +623,7 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, * but not from this process. The other process cannot write to * the page, only trigger CoW. */ - if (!is_refcount_suitable(&folio->page)) { + if (!is_refcount_suitable(folio)) { folio_unlock(folio); result = SCAN_PAGE_COUNT; goto out; @@ -1367,7 +1367,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(&folio->page)) { + if (!is_refcount_suitable(folio)) { result = SCAN_PAGE_COUNT; goto out_unmap; }