From patchwork Fri Nov 3 14:01:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444573 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 A4F7DC4332F for ; Fri, 3 Nov 2023 14:04:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 38FD7280028; Fri, 3 Nov 2023 10:04:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FBF928001D; Fri, 3 Nov 2023 10:04:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19DAC280028; Fri, 3 Nov 2023 10:04:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 09C8C28001D for ; Fri, 3 Nov 2023 10:04:24 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A240AB6176 for ; Fri, 3 Nov 2023 14:04:23 +0000 (UTC) X-FDA: 81416812806.10.B6B814E Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf22.hostedemail.com (Postfix) with ESMTP id 1FBF5C0010 for ; Fri, 3 Nov 2023 14:04:04 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699020245; 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=ecal4P50fwrAghsjzr7+jLbx0qZqwlf5MiupE4LTgsU=; b=LWqY3SDseDEVPbzZlgHGlvFSrjSOBBY0uNm6dcfNY3Gw2+FLNbz+OROoVcb9uqkFKbZFPP zyR8io4aQtUptHE7SM1IJCbI8jmSsjmmm1OPhXa24RQiawC4tVBxId8bBbsuIOOu8xEuUe hJnWrCBcmqm3WT21hbbR8ytyZh5ud4I= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020245; a=rsa-sha256; cv=none; b=yNlx1ZU6wqmjPGGmuR6m1tPXi0uUCsU2zCyKhazV0r+HRE8Z0YozT1CEeeL8AR/hsiQN0r ArXJY+cyAAoDlxjEiPRDBKe35g79zsUBs4gPz4a8X4EGw6WNmzxbv8EWBiB0ybTVJi7zdv +QBarLPMZJEFch6SIViDK1s+3kN5244= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ1c3mz1P7ph; Fri, 3 Nov 2023 22:00:46 +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; Fri, 3 Nov 2023 22:03:49 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 15/18] mm: memory: use a folio in copy_nonpresent_pte() Date: Fri, 3 Nov 2023 22:01:16 +0800 Message-ID: <20231103140119.2306578-16-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 1FBF5C0010 X-Stat-Signature: xmr7h746z563qtpz1pzwj9zfj5h4rpqq X-Rspam-User: X-HE-Tag: 1699020244-466378 X-HE-Meta: U2FsdGVkX1/5U7V8CIUbeEw9IV0MccInjXsDVMdCVAzJZx0hvsYZlSWC6pMDTAbSlvEgHN3/2mB3ifmBN7kKGZEicqiDJe7sORTi9GlcB3V22z6eqeATUv9JIN/nO4A/ZVEa1B1GVvG2NAp/iXX4XHvtZKU4eqI5aC70qYm2ca5xojqpz4eisDYMBi6wnyvLEkIbm4XWRLLIaDwR9nowco4TkCGRkUKjCLruYxzs/XloCYA+UPFHgbiYLCnZzK6ODFtdgWQ88pTD2YGnRPAQ89zdDFLmb0xP+SVtV1q8L3ATmVgVF3styhcG0V2TPxUob6pv3PzaKj/K9YVmEVfgFJZhgQ6Nw+4eUI+ULATucLJQ7ddkLvyVapz68bVxEHgNXRbRXkXWpxJ0qDgBLM/sNxl2QI+h4k0omzlqR2iJZFEBgTtOC8SdkYpz7/B0R1qGQ6z6RYLD6uMprRULjUzgT1HZxt/v8HAs7jLjNviuEda0GBZTrntFVIJ9Tw8stnrJAruoLrCTI5uCbk0WXkdzX7mH8f4vwMWwjxNo2Y0BYBk8wbkQ5gfsHrv+IYI6KZaH7gLpPE4MWWN+bQ4JBZU43BWD4Sx+9rbDj2NwxgezsSKkzaMC/1Iwa1dJGGG7jcvatDPN3stuf+UXOcdpLeNb2yTpiK/6xEvayvg+RcYj6w9SWsWFLBEgqBHiHuFE8yVEUCgSnZgqa8JFR5gDk24p6FMp4IE0417NXtQibgf7PfZzQo2IEiyS2lr+H03XNXb9e2xxQnvsayCsF/V0Li1H/EeKG7yFnP7ysIkeTQUSEdWQE9+fF/K9y9vdRklRfw5AACcn/xB9ogmmZaQID+dCBQy6nV5/hF58bE3y3jbbC5csGlLFX4gDWwnvhnWX4QAyLfbKWrOlKfIXnO06sLgEVG/mSzAGmq/+KWQd3aAsd91j0urifmMJRsPJKRwxvDS6zpJJzzANwmcxFpVDLFi LX/J8u22 WwwiyBzT+IaicDNeukEg6h27V5sa3akTtfZvyfYNORjqz65zhSPcvVvvimS1tgDalg8FXnXEB+yHsVayYPP+lBf4lDHJbuN6sjpjDbtnEoA9fPzKzdE4Uc7hs6E95cqcnB684vnTw3+s+j7DK199OtSDaTmnDL3TJMGEDCdCZs2y0ngGza/15IGxxtGiWIPo/Dh9x 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: List-Subscribe: List-Unsubscribe: Use a folio in copy_nonpresent_pte() to save one compound_head() call. Signed-off-by: Kefeng Wang --- mm/memory.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 584fe9a550b9..fcc04dce8e8a 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -779,7 +779,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, unsigned long vm_flags = dst_vma->vm_flags; pte_t orig_pte = ptep_get(src_pte); pte_t pte = orig_pte; - struct page *page; + struct folio *folio; swp_entry_t entry = pte_to_swp_entry(orig_pte); if (likely(!non_swap_entry(entry))) { @@ -801,9 +801,9 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, } rss[MM_SWAPENTS]++; } else if (is_migration_entry(entry)) { - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_to_folio(entry); - rss[mm_counter(page)]++; + rss[mm_counter_folio(folio)]++; if (!is_readable_migration_entry(entry) && is_cow_mapping(vm_flags)) { @@ -822,7 +822,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, set_pte_at(src_mm, addr, src_pte, pte); } } else if (is_device_private_entry(entry)) { - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_to_folio(entry); /* * Update rss count even for unaddressable pages, as @@ -833,10 +833,10 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, * for unaddressable pages, at some point. But for now * keep things as they are. */ - get_page(page); - rss[mm_counter(page)]++; + folio_get(folio); + rss[mm_counter_folio(folio)]++; /* Cannot fail as these pages cannot get pinned. */ - BUG_ON(page_try_dup_anon_rmap(page, false, src_vma)); + BUG_ON(page_try_dup_anon_rmap(&folio->page, false, src_vma)); /* * We do not preserve soft-dirty information, because so