From patchwork Thu Jan 12 08:30:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13097566 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 28531C61DB3 for ; Thu, 12 Jan 2023 08:17:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D0A58E000A; Thu, 12 Jan 2023 03:17:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 481B48E0009; Thu, 12 Jan 2023 03:17:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C10B900004; Thu, 12 Jan 2023 03:17:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0C62C8E0009 for ; Thu, 12 Jan 2023 03:17:46 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D474E1A014C for ; Thu, 12 Jan 2023 08:17:45 +0000 (UTC) X-FDA: 80345443290.15.ADC1686 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf04.hostedemail.com (Postfix) with ESMTP id 73BE940015 for ; Thu, 12 Jan 2023 08:17:42 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1673511463; 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=f410hYM6HfpdiyxHhhDFQuD0DaLql9Gj21P5cfv/VWA=; b=4jZ1mLz/jKqdCk2KV/mvEeOc0luKnx4ahVEQwNJxkC7GMROxBNQUiz/7U610qcuXVCRtyD gIaiQTaNYiHGHpkFzq+B7GJwWzKhqddGbNwdGOxjHN9OyVWetRWlYFH4v3NcZwze72C6Cg oyRYbAnNJ4yzgPbYUglA79xgkiggtT8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673511463; a=rsa-sha256; cv=none; b=QGRvgfRdGsagp7YGqgnnJBZ1ThxzHSCJoKDaVcH4lxxXebWIFnPrDcKrgf/Eqm0NACGUSb QB3FfPKZU3PdhxeY0TloOUF/KER5NbR6oMED1bhsgzmbL130qKkm8kZ8IUqENoaEgANbJU zCd1S3cwAs8EVvOzEHfXyv8zoZUre2U= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Nsy3m238PzJq98; Thu, 12 Jan 2023 16:13:24 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 12 Jan 2023 16:17:32 +0800 From: Kefeng Wang To: , , CC: , Kefeng Wang Subject: [PATCH -next 2/7] mm: memory: convert do_anonymous_page() to use a folio Date: Thu, 12 Jan 2023 16:30:01 +0800 Message-ID: <20230112083006.163393-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230112083006.163393-1-wangkefeng.wang@huawei.com> References: <20230112083006.163393-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 73BE940015 X-Rspam-User: X-Stat-Signature: gdx8du9ib8yraod67fgmhgotc98467qn X-HE-Tag: 1673511462-425007 X-HE-Meta: U2FsdGVkX19luovOCd86bdsv9p17tiSrkpR+dAmLTiI281Zq5Tc7Nl/fryquTtBkoIdcFFxDVgTh7iLG0pQJPiSySAo0MJIP3OUmsU1U3He5SJtZ1nH8+6mpPq0VVVrnhmcMGkIKrWC+MI8H39BEPaY8jqLpjmowd1e6XbD8ayYK9klLBr1X/Hw6lPp6RBtm+t93kVVEQAhr9vJ/kIzM8KaYYNSBhzmaXDSsQ0hhK+fLwFFEwJqQIddcZP7pEWv9UMAX/G0aUVDVpwmAvQt9itygFN4teckhxYHTbxunHy+luVHOcttbphgp9BFHeGOmMKLwXm9zHIbmYO7vYwuoAHtOiFi1hfCBmCoVLclaZW8OtWC3UikrUajQkBuSqmQhVB+EcG79/zpuwwU6EHBGyre7sbwaIV0/FNSFQxqVkmJqzPNOoiJAJcjR4cyOvqXg18Y3xxFVnoxCaLdtsVQri/BJ6SCddgqTX1PoXldmVQg9kip+wJfvxLpIrv/K6KSQ+KYDm77HClKpvAKDbmKLy6yKnbBbbYm895gxfHKgwXAWqv31O1nTVAF/zalzv7fgGGZ4ft4UaXDfrPi2rotjyM3w0AZ0PDSM8Xvcu6CS+rDgHhMrY6p1X0aKzALayi7oDjpJi3U3jcW0qJnnC0DP/j4kK25K+0aXM8Cy+DJ7oUBMoYiKTJxQdeGW/lQZTqkv8p1T3KESCz/220xsMUlQjqnHlekWdsMQN7WHKgMMkMe3VKz7OesGxaGmiWTWIwPhtomZlAvGMgTcF8yhthxnMQ8MUOWcRsFfzVeA5lFoIN4NlO847fX6dKOOWulN+j8/U70XpVOWS7P7C7l1rI6OF18s3DdiaEMwMTZq5vEsYboYCOPEpSJAFXWqaYQ5C5g/RwzHDoFsKGQdzL14Y8TT2QOGgEIKHC4l 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: Convert do_anonymous_page() to use a folio and replace related functions to folio functions. Signed-off-by: Kefeng Wang --- mm/memory.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 56b571c83a0e..1cfdb0fd8d79 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4002,6 +4002,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; struct page *page; + struct folio *folio; vm_fault_t ret = 0; pte_t entry; @@ -4055,16 +4056,17 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) if (!page) goto oom; - if (mem_cgroup_charge(page_folio(page), vma->vm_mm, GFP_KERNEL)) + folio = page_folio(page); + if (mem_cgroup_charge(folio, vma->vm_mm, GFP_KERNEL)) goto oom_free_page; - cgroup_throttle_swaprate(page, GFP_KERNEL); + folio_throttle_swaprate(folio, GFP_KERNEL); /* - * The memory barrier inside __SetPageUptodate makes sure that + * The memory barrier inside __folio_mark_uptodate makes sure that * preceding stores to the page contents become visible before * the set_pte_at() write. */ - __SetPageUptodate(page); + __folio_mark_uptodate(folio); entry = mk_pte(page, vma->vm_page_prot); entry = pte_sw_mkyoung(entry); @@ -4085,13 +4087,13 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) /* Deliver the page fault to userland, check inside PT lock */ if (userfaultfd_missing(vma)) { pte_unmap_unlock(vmf->pte, vmf->ptl); - put_page(page); + folio_put(folio); return handle_userfault(vmf, VM_UFFD_MISSING); } inc_mm_counter(vma->vm_mm, MM_ANONPAGES); page_add_new_anon_rmap(page, vma, vmf->address); - lru_cache_add_inactive_or_unevictable(page, vma); + folio_add_lru_vma(folio, vma); setpte: set_pte_at(vma->vm_mm, vmf->address, vmf->pte, entry); @@ -4101,10 +4103,10 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); return ret; release: - put_page(page); + folio_put(folio); goto unlock; oom_free_page: - put_page(page); + folio_put(folio); oom: return VM_FAULT_OOM; }