From patchwork Thu Jan 12 08:30:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13097565 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 F2A4EC54EBC for ; Thu, 12 Jan 2023 08:17:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F3A28E0007; Thu, 12 Jan 2023 03:17:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 67ACC900004; Thu, 12 Jan 2023 03:17:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CE9D8E0009; Thu, 12 Jan 2023 03:17:43 -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 3EE078E0007 for ; Thu, 12 Jan 2023 03:17:43 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1899DAAC59 for ; Thu, 12 Jan 2023 08:17:43 +0000 (UTC) X-FDA: 80345443206.29.AB6F549 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf08.hostedemail.com (Postfix) with ESMTP id 040F016000E for ; Thu, 12 Jan 2023 08:17:40 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1673511461; 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=EWkJujdwo//0sP1d8/c4d92QJNqcyfaKcDeRJS35TxY=; b=pyRn6Jhr5276Fa933PLKEbuq2uc1IOKFHfFhMsYGyIbgbd4foMAyYyQuUBfGh/IKoYgI2n vsI79uvHd47FuSlWKvZo8Zvkz+9uD3Rul4OSeqxfSXF1YSyfGHrI0c64yjZ+o0421Kma5v 4sxVwouXhuphKE0UY5X1KWsZ8vqKcc0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673511461; a=rsa-sha256; cv=none; b=6O8G1ImP+kg1eDeGvIGssaum2QHFo5A6K8OFaCMMM9b/RXS0IRA6GQaa80ODGiLn8UKBJj hhVvsT1HqfyPXxAsOPcVKSClleU4zy4JyeOFkBPyXGUc2AuCKnS1i8+EJ6ciPCQ9hq3r18 D/UEKXKLdyi1XtkPT72BiJKJVCZ0pLY= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Nsy6j12wLz16MkP; Thu, 12 Jan 2023 16:15:57 +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 3/7] mm: memory: convert do_cow_fault to use folios Date: Thu, 12 Jan 2023 16:30:02 +0800 Message-ID: <20230112083006.163393-4-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: rspam05 X-Rspamd-Queue-Id: 040F016000E X-Stat-Signature: m15543xj9dn4gmopgy65xd9bd7itjrcx X-Rspam-User: X-HE-Tag: 1673511460-621913 X-HE-Meta: U2FsdGVkX18cV6+qkSkpNG87T/GmxS6XK4sgIGSrLETfzZzIwGq9kYkaJWHM8HAP+6fKpIARJNGbdoYzNBFeSWyKuXCuP6Gp7JNgSrP8vOY8wiOup5gGSt72Ai94C47Uz/s9N5+jtpsdCnicPDYLN31NKtf4Ry9aDmYtplxPEcI57we1qtXk3vfBvX0hA0BmPuqmzcAbP34LGI4uQKF0nujaePEgbx7f2APNYgytBycIU+QxsLkOg+aBjuFv/JGgBsRQE9D5mcH6/wMc2wSym2DAhuyrtKUR23q540idaeY6T6uAL9MnNk18oY2PfFDSslmCcd1j85tljreSv2b6VlapWuybomCLsWwDLIfMQTrhm9Uhn31psD2vjgconOk6XVc7/Bi1cWGdPDdIyiR3KEDII3xtfL74wg8OAXEPeu8g7jJBtM2M9/fs1EDmN3aZxIGRetQRJqCDOhKq0onegY9ZDNFtz6DHNRyu0IRFTJBY12zRLSaYPclmj3IxkPN6I6LqG6W102/HcqcnWsZCrvT2IRoTBD/k0dLsNlz+wkyxvfgtvYENFO+SNSnRbNpnZRrgWDhVbwB3tWOgazjA0ci7ACLSxRaxWLdIaUy0mkYNzJ6sc8YZQAaaioybf/Gt3dkhYbJmM7EkUA/AHM0EngzAgv7TDoWfvuRfwTJEXBSBYBpT/oX0DKPo5EfUP+QKEBnyPjFxoBBmlQmxOs0t4xn7MIeI4xs/94a74iS1mhw4j83v4BsXvhKAK7h+w8Rg5o9pPz4MYPmt8jZHrt4vZlrSHgCQNsoe5sE3VVCreVy+ZmVpwQCRqMmHyXCsGwTACp6fGkSp1ww9r3tHp769+ZgfiEmBfU23M++OMCYMhBlRQi5WwfyCi2rapsD3UOSNpT+/KHruxtHrb9Pkdt1qDH6kOfuFiXv5 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: The page functions are converted to corresponding folio functions in do_cow_fault(). Signed-off-by: Kefeng Wang --- mm/memory.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 1cfdb0fd8d79..f29bca499e0d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4507,22 +4507,24 @@ static vm_fault_t do_read_fault(struct vm_fault *vmf) static vm_fault_t do_cow_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; + struct folio *cow_folio, *folio; vm_fault_t ret; if (unlikely(anon_vma_prepare(vma))) return VM_FAULT_OOM; - vmf->cow_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, vmf->address); - if (!vmf->cow_page) + cow_folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, vmf->address, + false); + if (!cow_folio) return VM_FAULT_OOM; - if (mem_cgroup_charge(page_folio(vmf->cow_page), vma->vm_mm, - GFP_KERNEL)) { - put_page(vmf->cow_page); + if (mem_cgroup_charge(cow_folio, vma->vm_mm, GFP_KERNEL)) { + folio_put(cow_folio); return VM_FAULT_OOM; } - cgroup_throttle_swaprate(vmf->cow_page, GFP_KERNEL); + folio_throttle_swaprate(cow_folio, GFP_KERNEL); + vmf->cow_page = &cow_folio->page; ret = __do_fault(vmf); if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY))) goto uncharge_out; @@ -4530,16 +4532,17 @@ static vm_fault_t do_cow_fault(struct vm_fault *vmf) return ret; copy_user_highpage(vmf->cow_page, vmf->page, vmf->address, vma); - __SetPageUptodate(vmf->cow_page); + __folio_mark_uptodate(cow_folio); ret |= finish_fault(vmf); - unlock_page(vmf->page); - put_page(vmf->page); + folio = page_folio(vmf->page); + folio_unlock(folio); + folio_put(folio); if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY))) goto uncharge_out; return ret; uncharge_out: - put_page(vmf->cow_page); + folio_put(cow_folio); return ret; }