From patchwork Sat Nov 4 03:55:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13445391 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 7BE1DC4167B for ; Sat, 4 Nov 2023 03:56:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13ECF8D00D9; Fri, 3 Nov 2023 23:56:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C9168D00D5; Fri, 3 Nov 2023 23:56:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF86E8D00D9; Fri, 3 Nov 2023 23:56:19 -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 DFC058D00D5 for ; Fri, 3 Nov 2023 23:56:19 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BEA8A120CAB for ; Sat, 4 Nov 2023 03:56:19 +0000 (UTC) X-FDA: 81418909278.02.60ABF4F Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf25.hostedemail.com (Postfix) with ESMTP id 5BAD3A000B for ; Sat, 4 Nov 2023 03:56:16 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.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=1699070177; 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=YGSXYmu+7g7unSHUX92KPz3ikmxmm44e+0Bb9DZZSLk=; b=glrfE8O+lfsIIdXSfr7ARvyLoxDzuXPMC1qdtN9InxEGrQIy7XjVCAwA0CLyUqFpM1TSuW 6B8L1YvntddjF3XIJXLypU4FG/YwjHRiLCnqa5938elImnGSEWmQj2kjhdDhA3bT9yrXna SZblrZRnUUMvw+ZEA84YkZbO8Zqke9U= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.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=1699070177; a=rsa-sha256; cv=none; b=h1aZ9dV3lbvtKJ/wkoQfVKV/PCuMgYfqYzE183G0DyEOCkLjwRVRix02svE9ZKvLDp2JqI rnEWyUmwNg0PAVzTFAHMNuo3Hn/T0ulALzRstyNKcF2DgTSMdcSL/4xGHt1Z0jgRLH+x+X Bzx3T9OU42W4PGAN+zdU/RC5LSUFbP0= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMkGG17Kyz1P7rh; Sat, 4 Nov 2023 11:52:38 +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; Sat, 4 Nov 2023 11:55:42 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH v2 05/10] mm: memory: use a folio in copy_nonpresent_pte() Date: Sat, 4 Nov 2023 11:55:17 +0800 Message-ID: <20231104035522.2418660-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> References: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5BAD3A000B X-Stat-Signature: jkufya7swdozf4cosbby4g6un7jzgkyw X-HE-Tag: 1699070176-204614 X-HE-Meta: U2FsdGVkX19ccHrPvuNuBLggzzXs7w6cVMa9LyPMkMT0qqqlJxyvoWcmtdrO/zbHRPiUuQ+W2QYbsRmAVekuA58BCRpD6WewT608IYvHmx+ltD8o+DwV+SidrzNke4/DEoalW5wHyXYiVuJCHve7Jz0qid+7wjPC9eEA+OFm7W3MjHorkeF23AzpsIa1A1OM4Q79OLzq4q9d/grtIveVxEHXz9ktE32JdkvDlE6PF4vzpD7NbvzlBep2qHrHNuXqT9sHxJpLXQ96vmn8nov7S8zdsMYttxoLfSwgwLQ/TCFKMopnlGp5Q42TcbY6gZSHvNu6V7PjuSoo8e1uXT3/E5725RwX7RGZsvl7a+DTt9edcuEHHAve9DVDX+2UkSjIn7Kij3on20H9R8B1lSG6PpJymqSQcgqfSaW0+TKWh/aulouCLrnCE6GVfcQpFaYw5gckrB5ACFrFdWJZR15nRFmSONIKvkYraYAl0fRbbMSM4abKOSma1C6K5AQlh4OJ9+TxBFzVDX7NiBneU0xldKEVeG9d8/p8+Av9u2FQHilwlxMCVA3iSLVkhHxblSyyuHVw5yMBznd1w1R6i0x1nAT/74PdbsXxswMjqx2Iv8+VBYnCLYyWzQqv8vhjyaM3U2ir7b/w92sU6CRdMxI33oG+iu6zZ+TEHcRbpP/kElvW6VzBs4G08wKmnz3EXyyCPeSIanG4pIZJUmdD4YkwlKwTOpHLiiqUtnYWNR74NbdCCK0lhAMYnbjU8GhiOdfEmyyA02M/3oUr76kPxiR1mVH8tV9HK4rxIdLBBbO9Bb4CeOLxYp8EJTP2ofxqZaatD7+N5n6tysL9zOwGrU/kOBKONXLuDBJ0is0YX4k0EPu0PMF/CrzQRezKEQqLhez/fReX0oAbqUhc9Ud7z1Pzi03xfUR7MbyS6bJbKnHYHhGpCHadrRcCkTbdLAjrTLYwF9iKIKyzaRaT1F6TvoN Lye13epN /VvodunSTy0UEZBEKE0vCP/hv6QrAIeH/uwR9FqcGO6cDVkqb1qlrx99EMxbwjmQjGZZnfMQbOIMgZJ6kqhx6+uYjp2Vn0PbaeLzwz/sIg/LalB9sxPYAXBHZ5VH90qK6Ai3hjU32jGwufetpxWdakaQS9I5kEdDvK4dhszj69OrqgCU6UfJ3KPE3CqQqM1em62VF 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 1f18ed4a5497..d9314dee355e 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->page)]++; 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->page)]++; /* 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