Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp896404rdf; Fri, 3 Nov 2023 20:56:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEM2u3vv8zNys+iik4uqjTYVpasSzQTwsdsL3DVNzyr6c/ZY41vtjell79AbDrarWNWhqrn X-Received: by 2002:a05:622a:612:b0:41c:dd0a:6f66 with SMTP id z18-20020a05622a061200b0041cdd0a6f66mr26058133qta.46.1699070195685; Fri, 03 Nov 2023 20:56:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699070195; cv=none; d=google.com; s=arc-20160816; b=bmePry3wg0XbcFQk3oA+IdYSIE4rIPdsG3FmviX98Zr9DMIg7JtHNHDj1YTWIKapCV XMws8fkdHptu4/63XbRozBSJFKxx5dt8F1sF63Q12trsFVCQODqQddNP/QwUbhvW5Xyv f36jJCIZRy6jWWiy5U397PUHEuY89/xIOAcFu6EcT4G53p/i76pTU+6pW8vljfNeqSf3 7oW8jTtsDMTJJkuYVRTJ3pk25vIEHapiRpY73gv47ShsTX5z/dykQQmvEvSQX5pAwRiJ MFGW4u6B4ofYgL/7FExp45H+6Y6eHrDTA/7IcJ830h0jzeeG/DeaKDnfgSKNoenXYL30 XV/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=YGSXYmu+7g7unSHUX92KPz3ikmxmm44e+0Bb9DZZSLk=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=UJwjQjl4YqE9qnoTZ1uw0xCK/1MLwFMRcWzEXJ3IXZpPJnHE2RpXL/OJNdhvD+9dxF NTqqe3tXURuTHa7YpvVS78+/w9VledI+YVQsQbGhhPx5zHik4abn+qgv14E39VSCG6q1 2YKyHhHw9fC0W5rNumDJSIrvETWwzRgZaXI4mXkB5qo0jF1m5iO0KyrRDEJBc7FqWv6m T1vKtxE5/90nmzovea3+JL5OGgnAL503+ST6uPhzOyGg9THfkPL9jBTz14AGSIVkZkq9 CpQEilI+PwMedVCe7jaYIJvI/xvL0Kyfk/SYAE0JwN/4ztzu1AKzuptVqgkOUzUydSXW buuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id eg7-20020a056a00800700b006c31254aadbsi3026584pfb.90.2023.11.03.20.56.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 20:56:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 7534581F473C; Fri, 3 Nov 2023 20:56:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378059AbjKDD4O (ORCPT + 99 others); Fri, 3 Nov 2023 23:56:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234331AbjKDDzs (ORCPT ); Fri, 3 Nov 2023 23:55:48 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C57E6D50; Fri, 3 Nov 2023 20:55:44 -0700 (PDT) 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 03 Nov 2023 20:56:30 -0700 (PDT) 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 -- 2.27.0