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: 161316 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1056459vqu; Fri, 3 Nov 2023 07:05:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWrMVo291Z6iqJc9vN2iFnmvqWEjX/1sW3EulrpkrVWlaKFs+eewUOlcWxBWkQdB8J5lta X-Received: by 2002:a17:902:ec91:b0:1cc:3bfc:69b1 with SMTP id x17-20020a170902ec9100b001cc3bfc69b1mr16410308plg.24.1699020303524; Fri, 03 Nov 2023 07:05:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020303; cv=none; d=google.com; s=arc-20160816; b=E2XiNpE4yXoSEmeSfDvh3fm7NSqUDvn8r1KNnmzaElBu53u5JQlqIXRmhygVQBzuft fu1ulZMmTqHAwuu4oWSazspN9CphM7vUXau2fRxkyL12VTYXjauOEKG3E+e9bvjmHXH0 D0wlvZakVsZ6eGn0NgbTPkNH+i8ElfS/xja+k50vJf8Wtw8YUV09g72K/mEyPDQyzD41 Ae7c+0R8XaC9EeOywc8hVXloeyoj/luDnxQ2/4Kq29klsuR1Kg1KMpLUg5jU+wYQVWpR +rrPDvgm/+cO2E0uUVM4jfk5WHJCxau/VdW013gltV7W5sLhnYQjAe0yjBSqtCy2jGgN 9ehA== 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:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id w2-20020a170902c78200b001cc2a6624e5si1503872pla.307.2023.11.03.07.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:05:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id A1EF6829F1EA; Fri, 3 Nov 2023 07:04:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377862AbjKCOEJ (ORCPT + 36 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 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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:04:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781551913988676957 X-GMAIL-MSGID: 1781551913988676957 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