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: 161527 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1451028vqu; Fri, 3 Nov 2023 20:56:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2HzElPfZP42TolpS9NtMDTmKyPotsgDnoex0OZXyYpL/QWJfUtOFnWxnXRBN3xuznwGwD X-Received: by 2002:a9d:65d4:0:b0:6b7:5687:8a9e with SMTP id z20-20020a9d65d4000000b006b756878a9emr24403619oth.15.1699070214631; Fri, 03 Nov 2023 20:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699070214; cv=none; d=google.com; s=arc-20160816; b=04F7yT9IJfmqzZuDzK9iEKIBeJkWW4HUHLlgGdIqfppfJWPmG7c6wb6IrWDw5kDD6U OrkWKNAkX0i1zfJ8c4MoyaVnB9wmM71viYHOatx2pVC2cSIhbjIXMkg0Q2N639yqIZzw LfduY08SJe3TJaqESwWGckKJ37DK/N+UuN/F7meaN5lqjvpNNmNHwYNsh6R6gqBYWJmS B8typhwF9cspknxcAwGtrn86RjN2ZXoFj536uXuF2yYQqZrnPkjQCKnvr09qmXOOl08E ZnsnZEkoelSeT1mz0tdft5/nDQPu4+thSolH8mqsS9nPu0giNQCOZ7mmZHOKO81N9XCT S91Q== 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 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id t2-20020a17090aba8200b002804438ebcfsi2965339pjr.171.2023.11.03.20.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 20:56:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 94C5881F8FEB; Fri, 3 Nov 2023 20:56:51 -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 S1378139AbjKDD4O (ORCPT + 35 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 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:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781604248887285529 X-GMAIL-MSGID: 1781604248887285529 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