From patchwork Mon Nov 6 15:49:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 162061 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2750292vqu; Mon, 6 Nov 2023 07:51:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVZm2d0TOt2oewudSBIPhNlExoWqSs+99JDziK1CREP/ysvJLqxJkx2dhNuuYEIdtsn2gw X-Received: by 2002:a17:902:c401:b0:1cc:e36a:8bb with SMTP id k1-20020a170902c40100b001cce36a08bbmr1403811plk.25.1699285890178; Mon, 06 Nov 2023 07:51:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699285890; cv=none; d=google.com; s=arc-20160816; b=rRysDSMWTpL5gKgALNsm3ZV6PpMXl16KkQ6hjCsSbFnYmDnxG4sCpQd/4/vtcZx5+9 SBAScczdFKGMBHi3CuxY9y0Rmi8f/n2GjhAEjgWCDCSgGBvpkhspgnbq4bQqKuAKN4kZ 6b4w9JCpKqIIfOrzSr2dYMrwdvKVUr7QgwwDWXffF/4Yvq9l6UvTumZnHZgYSn8dWbaH Ewk3oWqeoCQUZDt9otRqoznx5HMmu5QizR8MXrHrxvE6R8BcQOMChagzw2S3TUz8qeJB wmZFV+luNeHpl6n70F3/pe3y5Y6BURdNBnWrd7/JJqSpjhFOG1YCB8eIzcqJkz4l3j2f N64Q== 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=S/5dklcr5ixKzN/mRuVptDUFzLJu2EfnoxXfaOnnEM4=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=mLBEOMiSzfBQh34nZCN31VdPN2JE3+2IkLNjsKmTVjA/oeYTD0RCcIOcs88xtvvnA8 WcqmgrXV7MIO58ZyPY6EDKtxhpL8Cak7NMNVmrdiuwnPcEabLBfI6RLCHLw713+oFKUS eayFCnSC15Xyv+uN4hA5pIblcVxR68zvA54DSNBQpKQKtka20i2boA225jjtzRyvoG/b vyfXHl7ZNte6wXTo5BrP3/FDuxJ/0dqvMXhon0ACmQaAZt+mRWcoOou2Ec86KEzWXA+E MXqnFb0xDi74ql4VQi2NkcB8xu/JMLSQv5sCvLw1/1eXZPYb4bk5ATPSMqIs/avfx6Vg l6HQ== 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:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id l8-20020a170903120800b001b801044467si8770249plh.3.2023.11.06.07.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 07:51:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 7EDD980963A9; Mon, 6 Nov 2023 07:50:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232326AbjKFPuR (ORCPT + 35 others); Mon, 6 Nov 2023 10:50:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232348AbjKFPuF (ORCPT ); Mon, 6 Nov 2023 10:50:05 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACBBB191; Mon, 6 Nov 2023 07:50:02 -0800 (PST) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SPG4v34Z0zVlpd; Mon, 6 Nov 2023 23:49:51 +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; Mon, 6 Nov 2023 23:50:00 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 05/10] mm: memory: use a folio in copy_nonpresent_pte() Date: Mon, 6 Nov 2023 23:49:45 +0800 Message-ID: <20231106154950.3399469-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231106154950.3399469-1-wangkefeng.wang@huawei.com> References: <20231106154950.3399469-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 06 Nov 2023 07:50:55 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781830401507563778 X-GMAIL-MSGID: 1781830401507563778 Use a folio in copy_nonpresent_pte(), which is a preparetion for converting mm counter functions to take a folio. Signed-off-by: Kefeng Wang --- mm/memory.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 1f18ed4a5497..914353d1c7f1 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,8 +822,9 @@ 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); + struct page *page = pfn_swap_entry_to_page(entry); + folio = page_folio(page); /* * Update rss count even for unaddressable pages, as * they should treated just like normal pages in this @@ -833,7 +834,7 @@ 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); + folio_get(folio); rss[mm_counter(page)]++; /* Cannot fail as these pages cannot get pinned. */ BUG_ON(page_try_dup_anon_rmap(page, false, src_vma));