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: 13447141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D30F1C4332F for ; Mon, 6 Nov 2023 15:50:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BB168D0028; Mon, 6 Nov 2023 10:50:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 26B9A8E0001; Mon, 6 Nov 2023 10:50:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E3BE8D0029; Mon, 6 Nov 2023 10:50:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EA4B08D0028 for ; Mon, 6 Nov 2023 10:50:13 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C6FA7140774 for ; Mon, 6 Nov 2023 15:50:13 +0000 (UTC) X-FDA: 81427965906.06.B7E41C6 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf29.hostedemail.com (Postfix) with ESMTP id 93CF0120009 for ; Mon, 6 Nov 2023 15:50:11 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699285812; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S/5dklcr5ixKzN/mRuVptDUFzLJu2EfnoxXfaOnnEM4=; b=wmTy9YAvW3oZZr2Vz7UeJwakhafYitrHk7+kJEWy40BDLvLdW1zuBR4mAY8m4REvOi3j6B ychgNdA+CYr9PwR2kguILbOx+VUcjRic/82vYoGmpiWTkwh+NCuF+Eq9t79wiOlUmIhDdO dwixcBBjpDeKqXTCVEWYdm+2enXV/mY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699285812; a=rsa-sha256; cv=none; b=aVREa6eaSZoV5X71MeWGIfhN2/E9pQoGEtcQ6Q6w7hLE5k+w+e6vsNAHGBRc3yDzlNQaSJ pDr++v9hTMQI1grkEBbqWPcug+Xx6pG4fpLiRUxwIRswAdVxxMPWLW65UPuqsAibKHBaWO RVVz7zyL5KRsEvC6vDQEC1Zk9lMAjuI= 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-Rspamd-Queue-Id: 93CF0120009 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 3b4ypkxjz4fq9zkbigphhwkpakzhxdsd X-HE-Tag: 1699285811-660564 X-HE-Meta: U2FsdGVkX1+zxTIm56tumGVM0kXtkVVXOeW685tHht11WLHzHaslXnhi/crIXgVStJ3E5V3YaUVt0V/qSOu+F4vw10CzSkyXCthkl+mRjLk+L44Df12/UVNVw8Q5B0HeDAGG6VwyC6xJ1Nm2dlewbWQ8kLZkwqvpIAHC+CZ5ORZcFPZJK9j5I4ytZIiUWxDKKCrvOz5d3EtyhoReP9pOOV7tsbVcDbl4tNcixtkBDUk2PORgudkpzBeovlOLZ3yDmO5uRD1O33tKzj+x+j7kplo9fCZGhotzOPyCnE0uJFVB0rLpVaeVHV3V4d0Dro26+TfYDl2AXDPH83fWpreUz3zv6OnxpBxaOoD6ahiMXIVYHFFgTUJXUzqPwbM7gq6FFKHT2yVTDfNVdXAyrzs9CtyRpDxsGgc6XFHR5Ks71l20TM0TZnROqgP86imByqJfboJdfI9ioH6NA/KtC372nEILCXItOTNfMCNbzHQD6cxagNmHsyoPT52nMRLZKLGURdrTk1EOT+yDFBjUzWvkf50mUPcrHFD45q+yncLAqmfS8CX9lI6pvX+KQ6oaf7MYmlNc2xhXSRlk0DGmxgjtYZo+SERyPSMsgReDH8+Xo5hl3a4uJv+ktFyfMj/JnkhB02qRcaXKQdxGfO5Q76coP4sfrUHHR1qbVq49fu9gyNdD0qmqsLCzrSjwZ6rUf+/0qD9fa+COq+oLmbqgenwLU9CZdNerm9UrfJZccpRZOVBbOfQKbmpFOi4ZTDeIRAkj8uA3MAkNUvxSD9nkayTbUDSFVVAuvBmZlAPHFmab7i4xR+mDIphydwb8oe5B25JGUGpLd30mnJ0hPCyoZg4XhTQ6qMDvanWtsgT9rECfqQfmOrzl4fZffVgHqcDsxQKC9kRB2zAmzNzF/IJbgtHHY7NQfBR9/D5Qj/7pydlZBvevDJePDArv/D3Qw08IVUOkNRDRn2IoFFmAtNQ21+M k6yQn3Dw WT2XvGT3PM+/Brw6w8zC9VciGsCZUFSXbzCEoVEBMl5InAJFv+lptks/kZq9/rcRfr9a+cHnf4RpWfmYCAhaCaMMFA3HhgrKHynfvKjU2miGjFKGXRO7t+oAjnWRSsHbj/SHrL+4Ee2M1UEhdHnXg4EWwrc3liusQYyZoeMDp90nSczzSmHsJoRWfT+6Pby7UXvyY X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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));