From patchwork Thu Sep 21 07:44:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13393709 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 02FA4CD342E for ; Thu, 21 Sep 2023 07:46:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C0A16B0188; Thu, 21 Sep 2023 03:46:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 597EE6B018A; Thu, 21 Sep 2023 03:46:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 486886B0192; Thu, 21 Sep 2023 03:46:37 -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 37A026B0188 for ; Thu, 21 Sep 2023 03:46:37 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 07A1B1A10C3 for ; Thu, 21 Sep 2023 07:46:37 +0000 (UTC) X-FDA: 81259822434.17.7623141 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf10.hostedemail.com (Postfix) with ESMTP id BA2DBC0002 for ; Thu, 21 Sep 2023 07:46:34 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695282395; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ok1PI54IQsKeQymGDTd8xDFL/XYgPYhYno6RdRByNRM=; b=InzfldM2yxxWybZllMWvL5/mSykHPWHfUexi9ctKpK7D+rB7SPrmSWzOOPKHBKQn3sCf2x gjVEwEE2VtJLjh6RJ2h+lNZOHc1+cstL+synxQzWaRwTL/b7O3R3eQXz378RG/cV67s8Kp LtynTf3C8oXUzVBYLBjb6limbfI19Wc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695282395; a=rsa-sha256; cv=none; b=wfMh1GXv7CrdJgwVGDNZHjkwVcPCHEa+KNIuu3q/uCjH926Jknl4eZo/HRJVvmR2sOIKdh qakMoo2YKlSOd7Tpl9iYkv/nBxEwQ9fRlrP4qrq1g+zmWJX8FjKGg9a8oR4PomJOmVVdxD 5Vo99q8RElQZwVzM7Ghirgbt9cQyay8= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RrnTK2HcnzrSxT; Thu, 21 Sep 2023 15:43:49 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 21 Sep 2023 15:45:56 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 2/6] mm: huge_memory: use a folio in do_huge_pmd_numa_page() Date: Thu, 21 Sep 2023 15:44:13 +0800 Message-ID: <20230921074417.24004-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230921074417.24004-1-wangkefeng.wang@huawei.com> References: <20230921074417.24004-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: BA2DBC0002 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: r964m3hf1syhhdrwtj6bk9fdnwa5geta X-HE-Tag: 1695282394-534739 X-HE-Meta: U2FsdGVkX1/8PgQsxmVmXWsA4E8Jqy/oqI1+ueGOdmVDtEJtmQtifRo9i5Ea38Sv9EgOP4m2hzoQoLz3e3a/H0JG68bAu66OV2Ugqt29+4/V46uk1WOlOJItCyeBNtvjwTzJu0DiQdprZ7eQlGe9sVfXrmnnBY3w4ZT1HrKW6rKt7JGOF0X/N1WK3/JP7OqKxbkT0lZzO3aLCcsp/wZIZODVgmTNhVUIsu5P4YypFhPdkm3Y9CyKraboft+R/8Mr5d5hyWD2yEco431iJ6RunlsZvp9NXeMAAfD7ZEupN1fUW9VF5Gc+GCuaXmIruikaJwmqOuLIp5r57vgxp2fQuWWGX75IF1mjUoknfM2ym2OSDTV2w/XWAYwbRutWOEqN0Of8FCR2kOlOt4zBag3fC1yv+L/Nnri/KzmM6sXKYVuxv7yFaojoE2w703usRQmodiODFzbI8yfJAahmEXoIjY+9nU3cJYGKlIljY3vuUQyx9Wnznw4HHoCoJovE5ihvUjojxYyDKGkhGGYWi/Cz2lsepcND9cbWr8+jSFWY7a+KcO1wJR4TrVI/EyybRb6ptg9QC/sCo6TCSlUtro/zFdzYy+Zb3gag2hIBFDEfSk8xCwO4KiWwTDZsV7Afjr68XgPXu3Jr81D2RVUbQ+yguHaR1mCllajwTmft3kN8hZFjn/Kl0f1IFeQbtV8HEQwU5QTy3UAObHgr67A1xRevOabJqsqpl/vDFpxd4z94T0RZbDbx0tJm0Pw55vB51hsiPAK8s9olKd/SmhkAB6JYMBAZuDOtJtg31JwrPFIQoVCqR3tqf4Qbg7bRYBHbYugGwhEvJwtBZsNDBmj909rZmmwmasMBmef1zt1x+A1Bf+ry/vCtZpJoQV3KMlT3ZqCjULgr4I+mgTihmde3f8RHSkrsgIo5Vvv5kxQ+V+xzrSuIRToPZkqSuiEuSjtSf/4CR87DwYHzyK9uRL1ruXj ZYCKz9BE AkeY/FAxSF421LtAsP1iKvdM5antbQPiewcqQTDT6pf+q9GP63rPTZ5rnsT0yJB+bpTFwCuYZhJDfMnE3+mCR7z4b74fmlwpIKF0nwFgmEAYSWpHPmtUMnyrM44/P3jok3ezl3Zqpl6ccoVe0KyblBtaawPEtlWHtxx9BKwLWEPRk11DBRDt76hVTl9NYRM/0eU1/ 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: Use a folio in do_huge_pmd_numa_page(), reduce three page_folio() calls to one, no functional change intended. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 0da653080d8c..53472e34a761 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1517,9 +1517,9 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) struct vm_area_struct *vma = vmf->vma; pmd_t oldpmd = vmf->orig_pmd; pmd_t pmd; - struct page *page; + struct folio *folio; unsigned long haddr = vmf->address & HPAGE_PMD_MASK; - int page_nid = NUMA_NO_NODE; + int nid = NUMA_NO_NODE; int target_nid, last_cpupid = (-1 & LAST_CPUPID_MASK); bool migrated = false, writable = false; int flags = 0; @@ -1541,36 +1541,34 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) can_change_pmd_writable(vma, vmf->address, pmd)) writable = true; - page = vm_normal_page_pmd(vma, haddr, pmd); - if (!page) + folio = vm_normal_folio_pmd(vma, haddr, pmd); + if (!folio) goto out_map; /* See similar comment in do_numa_page for explanation */ if (!writable) flags |= TNF_NO_GROUP; - page_nid = page_to_nid(page); + nid = folio_nid(folio); /* * For memory tiering mode, cpupid of slow memory page is used * to record page access time. So use default value. */ - if (node_is_toptier(page_nid)) - last_cpupid = page_cpupid_last(page); - target_nid = numa_migrate_prep(page, vma, haddr, page_nid, - &flags); - + if (node_is_toptier(nid)) + last_cpupid = page_cpupid_last(&folio->page); + target_nid = numa_migrate_prep(&folio->page, vma, haddr, nid, &flags); if (target_nid == NUMA_NO_NODE) { - put_page(page); + folio_put(folio); goto out_map; } spin_unlock(vmf->ptl); writable = false; - migrated = migrate_misplaced_folio(page_folio(page), vma, target_nid); + migrated = migrate_misplaced_folio(folio, vma, target_nid); if (migrated) { flags |= TNF_MIGRATED; - page_nid = target_nid; + nid = target_nid; } else { flags |= TNF_MIGRATE_FAIL; vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); @@ -1582,9 +1580,8 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) } out: - if (page_nid != NUMA_NO_NODE) - task_numa_fault(last_cpupid, page_nid, HPAGE_PMD_NR, - flags); + if (nid != NUMA_NO_NODE) + task_numa_fault(last_cpupid, nid, HPAGE_PMD_NR, flags); return 0;