Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp503507rdf; Fri, 3 Nov 2023 07:04:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZCngOdoU0VvIxUwftaqd5NL3UzKmnGbjqTVvU77cRZi4I/qK/CL+R9J/1eZVw1WJECW+e X-Received: by 2002:a05:6870:3d86:b0:1e9:a70c:1323 with SMTP id lm6-20020a0568703d8600b001e9a70c1323mr28375385oab.39.1699020290835; Fri, 03 Nov 2023 07:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020290; cv=none; d=google.com; s=arc-20160816; b=up+YzDw9niPQV2sGOZLCoSjpjDOehpXS46vJYdtxfLgsI8Hm2IA+7AtOCa9Dz+4f2E aKYtttNSVrRVFTFBXrIyt0iLCabyMawjoKzt4oe3BT91EVcte/mqRCuNxAMA6M0UKwXZ 5GB4ZmacA6DeHBfgQJXu4VO9oVLYYATC8BypRAzZkCzyrCLrFXwBW82nr7e5aGajRq/e 8faUDaNvbt95dvA2s8fUgX+XaQHXv/uDarj5fnpdoYp2OGN/hvxI40Ld29EuRAdqn+cM s6D/UPSSuuSJaMgkv9vh6egP+BBDSpmbH3uSJUsUO/fjuAG0Sqbl+IQ0HacWDvSTWYrD oSmQ== 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=ecal4P50fwrAghsjzr7+jLbx0qZqwlf5MiupE4LTgsU=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=OeiS88RyFv4w5ClJESt+g5VvTAW1jEMRwq6PmPdmaa3rNmBnuLLlHWKW/jS23Xhwwi pPHFIsws3tFn5gKTilbyoEg95huvgfmVXf7xKA+2+WrI52Gef6dOAe+dAgvy+CeL4iH6 vgMargpn9MCS3tuTT+ESMjHOwvP+tNM8byY3SEcuyZ991uqHfzXN3TtfgszjnBBGT7y+ WSaZ73q1VbgIsG1CafZ4vqSAvN5fLVyTt5gd3Bli4JRa6z/64oGpEAzlYeMNOHH3GrJj FHs30n0Y6M11pnMRn09LY2DTcZhzEtn6Mp7aYbeiNwMpH5/7KKUdUnpLA4Bx+GxFQNuG 5UIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id hm4-20020a0568701b8400b001efadf550absi692747oab.322.2023.11.03.07.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:04:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id E3CDC82F3069; Fri, 3 Nov 2023 07:04:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377863AbjKCOEJ (ORCPT + 99 others); Fri, 3 Nov 2023 10:04:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377779AbjKCOD6 (ORCPT ); Fri, 3 Nov 2023 10:03:58 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61057D4B; Fri, 3 Nov 2023 07:03:55 -0700 (PDT) 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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-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 groat.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 (groat.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:04:42 -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 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 -- 2.27.0