From patchwork Thu Jan 12 08:30:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13097562 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 E2416C61DB3 for ; Thu, 12 Jan 2023 08:17:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E94D900003; Thu, 12 Jan 2023 03:17:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 19A538E0003; Thu, 12 Jan 2023 03:17:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB24A900005; Thu, 12 Jan 2023 03:17:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 778538E0003 for ; Thu, 12 Jan 2023 03:17:41 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 31EFB1204BD for ; Thu, 12 Jan 2023 08:17:41 +0000 (UTC) X-FDA: 80345443122.10.BD17C4C Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf02.hostedemail.com (Postfix) with ESMTP id B792A80014 for ; Thu, 12 Jan 2023 08:17:38 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1673511459; 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=rhxXxRerinKO8R0zStf2Cd5XszshE2EKPbc9CMcsJVk=; b=XUEQsta4ZYOFrHMplGahmgqR03d8zFg3muK0/h5u0vojucFUeoq7WcPS1MEw0d28RtQ0ka K8C28RfRcjSTZUHNbmIQFoUluQGjwZnJSxG23fEO4HC2zKFEV39vADcIrK0XjpUxA2n1G3 sXRe5qDQs91cO/0ryQjWSL2W+9JIXuE= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673511459; a=rsa-sha256; cv=none; b=W057LvQwNRTCXLge3UdDFE5g6ulOZG1qHX4mLBjVp5ZUgzU/h5kDpL4dMLjjGViPpayMIg cISbbh/bm8MX/ZiiVOn/fAohKFBW01bQKtQ+4XQFlz7HqxKQAcsy6VtAA4ybzK8KSbs+lR BLSoz2NO9jpcS+o2LEt6iJ5BRpTQK/I= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Nsy304mYVzqV9c; Thu, 12 Jan 2023 16:12:44 +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:31 +0800 From: Kefeng Wang To: , , CC: , Kefeng Wang Subject: [PATCH -next 1/7] mm: huge_memory: make __do_huge_pmd_anonymous_page() to take a folio Date: Thu, 12 Jan 2023 16:30:00 +0800 Message-ID: <20230112083006.163393-2-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: B792A80014 X-Stat-Signature: ea5txpnzq6x6yxafd1fyhy1m8bch6o8c X-Rspam-User: X-HE-Tag: 1673511458-163633 X-HE-Meta: U2FsdGVkX19y/ZgS9Gpk1fNr2/Xc2U7Nd740mI4RDdZ2XYNeJBBqXlxt61EHhLuU0ihg4vwMlh/78C/ywtlsGiw0iXL8fmDoaHi2075pBnr+anyZwxFR35e44xzmmwvHVNAQAn5vTcJbsMEG1qUwD6vpYDnd9qfPnT/Wd688NtI8+vZXSri7PE9334z+vimCw0rrk2hOy/v+anJLfngxkiLekYNk88I3YsKFLZxhs7Qi41UMT/e9WL8PE3X8zLlpDGOZngB0ELtiQzvdT7BAYKinMTs9M/nxcxZ5mA9pnrwFDa6jYOvd227Slflgdt9fdM5JIIWRS4XkZqCS5RHJbrTIXKnCghRR6mL2K0fX3/kO+GRo285jIGc56kzdJbD4NCwWPyO2sR5qkSdPfyyBAoEXsgsqeYKZ0AYtFvzy1b795N0UuhICg/za+uCTZiZCARBVbiiHYhhW9QQ70CXxAejhknK71a4pP9tUFVoj/5z6+7heTC1jsRtq8rPZB5qBj/fnEWaSiiGKGVBdq/TjekvMcg3it0YTdIETuJZrXxn2TFJTto9cM/LzQYNFuSm6nsuUZUD0sX+yFJ6ENRNEx470ngerUTnlbryWKEHAPkip3dPlZEqv7KWotVACQtR+D5sdBo7+VymyKmmwld32BZNsZqtLciOo+RHBWp7XBT4snnl+X5TiMLgN6mDtM15SCTAKvnup8ghkDWzOi7Rg3R0ocmM71/7aUqs0rIly2+ihYrBMCwD0kpv5gBRlxHDYU2ctJPt097qr93TPuOiL4xBaPbc9kk06fiav77UwXkMpvLQRbznc2cwNghKrRDKsSx0HXBbltSJV4ZIV2gqi65He//jMXrd/vHbw7/fNLJltewLno5tJvrXSrvfCpWF3ZMlxjuieaJbs/paEKnXggLuPtCvjjyWZ 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: Let's __do_huge_pmd_anonymous_page() take a folio and convert related functions to use folios. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index c13b1f67d14e..cb23b24e2eb8 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -650,22 +650,23 @@ unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr, EXPORT_SYMBOL_GPL(thp_get_unmapped_area); static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf, - struct page *page, gfp_t gfp) + struct folio *folio, gfp_t gfp) { struct vm_area_struct *vma = vmf->vma; + struct page *page = &folio->page; pgtable_t pgtable; unsigned long haddr = vmf->address & HPAGE_PMD_MASK; vm_fault_t ret = 0; - VM_BUG_ON_PAGE(!PageCompound(page), page); + VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); - if (mem_cgroup_charge(page_folio(page), vma->vm_mm, gfp)) { - put_page(page); + if (mem_cgroup_charge(folio, vma->vm_mm, gfp)) { + folio_put(folio); count_vm_event(THP_FAULT_FALLBACK); count_vm_event(THP_FAULT_FALLBACK_CHARGE); return VM_FAULT_FALLBACK; } - cgroup_throttle_swaprate(page, gfp); + folio_throttle_swaprate(folio, gfp); pgtable = pte_alloc_one(vma->vm_mm); if (unlikely(!pgtable)) { @@ -675,11 +676,11 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf, clear_huge_page(page, vmf->address, HPAGE_PMD_NR); /* - * The memory barrier inside __SetPageUptodate makes sure that + * The memory barrier inside __folio_mark_uptodate makes sure that * clear_huge_page writes become visible before the set_pmd_at() * write. */ - __SetPageUptodate(page); + __folio_mark_uptodate(folio); vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); if (unlikely(!pmd_none(*vmf->pmd))) { @@ -694,7 +695,7 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf, /* Deliver the page fault to userland */ if (userfaultfd_missing(vma)) { spin_unlock(vmf->ptl); - put_page(page); + folio_put(folio); pte_free(vma->vm_mm, pgtable); ret = handle_userfault(vmf, VM_UFFD_MISSING); VM_BUG_ON(ret & VM_FAULT_FALLBACK); @@ -704,7 +705,7 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf, entry = mk_huge_pmd(page, vma->vm_page_prot); entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); page_add_new_anon_rmap(page, vma, haddr); - lru_cache_add_inactive_or_unevictable(page, vma); + folio_add_lru_vma(folio, vma); pgtable_trans_huge_deposit(vma->vm_mm, vmf->pmd, pgtable); set_pmd_at(vma->vm_mm, haddr, vmf->pmd, entry); update_mmu_cache_pmd(vma, vmf->address, vmf->pmd); @@ -721,7 +722,7 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf, release: if (pgtable) pte_free(vma->vm_mm, pgtable); - put_page(page); + folio_put(folio); return ret; } @@ -834,7 +835,7 @@ vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf) count_vm_event(THP_FAULT_FALLBACK); return VM_FAULT_FALLBACK; } - return __do_huge_pmd_anonymous_page(vmf, &folio->page, gfp); + return __do_huge_pmd_anonymous_page(vmf, folio, gfp); } static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, 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; } 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; } From patchwork Thu Jan 12 08:30:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13097561 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 7C46AC54EBD for ; Thu, 12 Jan 2023 08:17:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECDCE8E0006; Thu, 12 Jan 2023 03:17:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DCE4C8E0003; Thu, 12 Jan 2023 03:17:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A74BE900004; Thu, 12 Jan 2023 03:17:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 807688E0006 for ; Thu, 12 Jan 2023 03:17:41 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5921D8038E for ; Thu, 12 Jan 2023 08:17:41 +0000 (UTC) X-FDA: 80345443122.12.BD1162F Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf08.hostedemail.com (Postfix) with ESMTP id E8BC0160003 for ; Thu, 12 Jan 2023 08:17:38 +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.187 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=1673511459; 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=vPWAoifsdZDSaIY3s2IrQdDt6yOwKVi4WGwzwvvUpwQ=; b=nV3mgWfzyLyqzqh/zzTm4WZiFPEGXZ5b4nx8a8QH2p1sVzzfhlE9J0L6D+xpabb5ekOsh3 GwEes8wcnD0eX6BV0ePi8yXcNPCSazaQ0pqOdRSuWv2a8vrSwmlBA0rLrmsILsWB0lEzY6 EjXJJ4eyXqmvb7p4vTQCzsrzJGLXzb0= 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.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673511459; a=rsa-sha256; cv=none; b=bmWRYy0ntXSe4kv0YQW6O0fAsBpETbX/g/9PtihCYFIhGfVGP0O/69qs4gwkMFtGjqEv/z D+82eqBtjG24RGi3qH8nA+NMnLiaVsGPnGMk67yg/YAW6uClDmG4lvGlyjl9Qp0gWAl7Ev qzj0djJpzZtfKRxsz0IAwqDtZ4/mSzI= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Nsy315qzgzqV8x; Thu, 12 Jan 2023 16:12:45 +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:33 +0800 From: Kefeng Wang To: , , CC: , Kefeng Wang Subject: [PATCH -next 4/7] mm: memory: convert page_copy_prealloc() to use a folio Date: Thu, 12 Jan 2023 16:30:03 +0800 Message-ID: <20230112083006.163393-5-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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E8BC0160003 X-Stat-Signature: n1sm3e8oaekiahmj1sg6k1cbjmk689dx X-HE-Tag: 1673511458-740604 X-HE-Meta: U2FsdGVkX1+0uZTWT5V1/nDIOisHp4XUKfuDyzfxckUIrJN8xFQMOQgD2e21wsT1zJiMA4/uykuc5LPQCj2UtWCBmzmxOl2ljpMcgyMS5/haldcE424eAdFTE71XV4dwwz89BWK5TgP1KqIF0PhUe4giY0ed7yh7ZnJWQrWzn0knllK99hn1S6Es/uiQB94Ba0CaqWgp6diocxp5guwNkdrBEQRfmDZJTVWRP06mvm0CbUImG8I7MXUOC5hLF0hYorymkUqf9TmWVlXFykX/+qxjnOYJc5rl3ImSpKLf0TB+x3Lmfsy5b9oLEGUGzGp3VCToIsRnws0N7vmRiFXl1psNKiLgxN+8hiT2SejkYVKaRQ3L/pSpDkakLY1mg3WzMzjU/UlRgoKiLzok32BUz4tko+AHin43cBj8s1EAf6xxcoFAzTCCx1TgN7LhSbPWQ7N90TWAwrAgt+VSKANLA5APnpBJRaY1rA6c+g2z7mBfB1XxzX8Tnj69m7T21msgOJed+jLSxxHkR/Lo7EFi8c4PgJix23KHXLn9oh8wN+G81drPe7Sdr+F5mf+J4BMh/jVnUp/f1leJFUEvYGfsANUqgBmpy9MjRXVF2oCdhu/0QPiiR01PYDzrhtm3IMXI3UHTsdcBrjY83QU1be6GyemTymF4PVSWiC6TmjkyQVhWhIpy4w7uynurIEoxvuVqDQGavOy3ygeI61vjqixsxUNJyNJZHmyaKCDw07P9732ImTjHw5+5j2YG0JhSRacbpkg6CgzTcobT63F/gu6l2ETvqNuyE6/SGugA11GTkhyASQeoF17kR/2WuB4dXcioNcScyZa3PN5VD6gVShkpDXv87lojdPb/K2k1Sm6QZGsPPXKfi4nSZGFJMS7EmAuZJQAZfrGMLO0KVFFTlGJrGl6euab2AApy 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 to folio functions in page_copy_prealloc(). 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 f29bca499e0d..b66c425b4d7c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -958,19 +958,19 @@ static inline struct page * page_copy_prealloc(struct mm_struct *src_mm, struct vm_area_struct *vma, unsigned long addr) { - struct page *new_page; + struct folio *new_folio; - new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, addr); - if (!new_page) + new_folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, addr, false); + if (!new_folio) return NULL; - if (mem_cgroup_charge(page_folio(new_page), src_mm, GFP_KERNEL)) { - put_page(new_page); + if (mem_cgroup_charge(new_folio, src_mm, GFP_KERNEL)) { + folio_put(new_folio); return NULL; } - cgroup_throttle_swaprate(new_page, GFP_KERNEL); + folio_throttle_swaprate(new_folio, GFP_KERNEL); - return new_page; + return &new_folio->page; } static int From patchwork Thu Jan 12 08:30:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13097560 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 0ADE6C61DB3 for ; Thu, 12 Jan 2023 08:17:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C29C48E0001; Thu, 12 Jan 2023 03:17:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D6F28E0008; Thu, 12 Jan 2023 03:17:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7654F8E0001; Thu, 12 Jan 2023 03:17:41 -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 62F6A8E0003 for ; Thu, 12 Jan 2023 03:17:41 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4074C1C2BC1 for ; Thu, 12 Jan 2023 08:17:41 +0000 (UTC) X-FDA: 80345443122.10.D24B729 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf03.hostedemail.com (Postfix) with ESMTP id 750D020009 for ; Thu, 12 Jan 2023 08:17:37 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673511459; a=rsa-sha256; cv=none; b=yC6+oqRKutUz7uNXVL9hSFMnyFsqlv8sETKkHzi8DztYYVqQU8kcd03izAJEO4r9jm+w0z 7sNU7C+0lhIrcwcUMwwKydy+OXyxjuhrYJ/LXiTX+K8s/1yebM47ESiBCZkH4IL0wNLoBF aUyfK24+gN8PwqSr2d27hltaQeJdhok= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673511459; 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=BI+GrC6ViWwQkI7N2V00Cjbe16xcRU3pJmqY+T7EhCQ=; b=Kg3/FJHrvjplwl/gBXyF2VQtRfZcsFExg4m5KBTBoR00weWEX1iTnTlLmRuo+zFuOfmeIH 2OIS6Rcxiro4nwFsNZ3XQ/j93nlmd+1X2wVCWpynf70V8L9XjV+qzFabotpYk+C8x0I3Fl +WALPc7VBHWFutQcyFB4X1cu9mH3LKk= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Nsy6j6Y2kz16Mkg; 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:33 +0800 From: Kefeng Wang To: , , CC: , Kefeng Wang Subject: [PATCH -next 5/7] mm: memory: convert wp_page_copy() to use folios Date: Thu, 12 Jan 2023 16:30:04 +0800 Message-ID: <20230112083006.163393-6-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-Rspam-User: X-Rspamd-Queue-Id: 750D020009 X-Rspamd-Server: rspam01 X-Stat-Signature: yuh847uqxsr731bh6kxtdibe7yxf9ibd X-HE-Tag: 1673511457-560125 X-HE-Meta: U2FsdGVkX1+C8GUuOBXnJ4zvJbgmncnkjccUyFOJuOgKfGoyj1eEzJ5IyPGazTzXVqSY254IsqBCZwqPvf6s9CfPmX0c5pKWceJkBFJr8tVzUOi5KtISzX5cD8Kns6TlvrIXVgYEC0eIVSErKQhd3LJVAbQhI1V0e0QzK3iv8rtQjSD1/2bz0uwVTnYBYyMCaWMLA20J0/rKsT3UGMoXPTdeCw8mi6EtEYKjQ1ebkwQIvVeLNQ7mSLszhZSutox7JOjdnYnFLqH+t2tDPMJWTScY68r2VIhYmc4q4aNxT6qFLDHGN4ALVr5tseuki+ssyIBmp5BPVWJrwiFqS/hJTuzvyPXP2YEl0Gunor6rpbUu0lQLLFpuIlGXYHNu9zbq+4suZgK6LVXOJ/gX7S5RHW+/gorQLSjVGVdlsBD7ezr8jUsdIQvfe9R0GJ1WUtyvEs4yvaELYpUxJsKcMyGWZoSWGp2W7nUtjoiUcu+FixI6YrsKHgx9fk1KOzt0CdceUIkeddTIQPu7pCN0cIxY16Bhj0UMWZ5YJ9N0vKG7gMu/bszoz0B48YOXei6/qroaMwtJ5rJPHG9GvAqrCn9VbDy5EnU3K/MflBZOZjRKicmvdGZS8JSjhBLGZ3ZDzuUnN/C7kjGVEll3bmzMM2Z3jX4dwX/a9zlP03dy1H2itMiDoZ+uaW95KoQjL9ToGPCLdqxgd4LIpimWD0+9V+01ifOXFqWN+bo6Yid2RnoMo6cCqW+3Cbe2+xvUYZxwdJ1LtXF1GfHgK7QRkcYE8JYolyY9B51AXYGVRQdEUK1eLK5rMlAV3kMl3f1J1BInRnqhft5CBm0bmHjMRLZc8nF09I8Cm6XbLPu+dtCW2knB0hFGab42subYVoE7YESHuYPRlZQS5K0Xh7wnC+9nmXy6gQ== 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 old_page/new_page are converted to old_folio/new_folio in wp_page_copy(), then replaced related page functions to folio functions. Signed-off-by: Kefeng Wang Tested-by: SeongJae Park --- mm/memory.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index b66c425b4d7c..746f485366e8 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3044,7 +3044,9 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) struct vm_area_struct *vma = vmf->vma; struct mm_struct *mm = vma->vm_mm; struct page *old_page = vmf->page; + struct folio *old_folio = page_folio(old_page); struct page *new_page = NULL; + struct folio *new_folio = NULL; pte_t entry; int page_copied = 0; struct mmu_notifier_range range; @@ -3060,12 +3062,13 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) vmf->address); if (!new_page) goto oom; + new_folio = page_folio(new_page); } else { - new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, - vmf->address); - if (!new_page) + new_folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, + vmf->address, false); + if (!new_folio) goto oom; - + new_page = &new_folio->page; ret = __wp_page_copy_user(new_page, old_page, vmf); if (ret) { /* @@ -3075,9 +3078,9 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) * from the second attempt. * The -EHWPOISON case will not be retried. */ - put_page(new_page); - if (old_page) - put_page(old_page); + folio_put(new_folio); + if (old_folio) + folio_put(old_folio); delayacct_wpcopy_end(); return ret == -EHWPOISON ? VM_FAULT_HWPOISON : 0; @@ -3085,11 +3088,11 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) kmsan_copy_page_meta(new_page, old_page); } - if (mem_cgroup_charge(page_folio(new_page), mm, GFP_KERNEL)) + if (mem_cgroup_charge(new_folio, mm, GFP_KERNEL)) goto oom_free_new; - cgroup_throttle_swaprate(new_page, GFP_KERNEL); + folio_throttle_swaprate(new_folio, GFP_KERNEL); - __SetPageUptodate(new_page); + __folio_mark_uptodate(new_folio); mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, mm, vmf->address & PAGE_MASK, @@ -3101,8 +3104,8 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) */ vmf->pte = pte_offset_map_lock(mm, vmf->pmd, vmf->address, &vmf->ptl); if (likely(pte_same(*vmf->pte, vmf->orig_pte))) { - if (old_page) { - if (!PageAnon(old_page)) { + if (old_folio) { + if (!folio_test_anon(old_folio)) { dec_mm_counter(mm, mm_counter_file(old_page)); inc_mm_counter(mm, MM_ANONPAGES); } @@ -3130,7 +3133,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) */ ptep_clear_flush_notify(vma, vmf->address, vmf->pte); page_add_new_anon_rmap(new_page, vma, vmf->address); - lru_cache_add_inactive_or_unevictable(new_page, vma); + folio_add_lru_vma(new_folio, vma); /* * We call the notify macro here because, when using secondary * mmu page tables (such as kvm shadow page tables), we want the @@ -3139,7 +3142,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) BUG_ON(unshare && pte_write(entry)); set_pte_at_notify(mm, vmf->address, vmf->pte, entry); update_mmu_cache(vma, vmf->address, vmf->pte); - if (old_page) { + if (old_folio) { /* * Only after switching the pte to the new page may * we remove the mapcount here. Otherwise another @@ -3166,14 +3169,14 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) } /* Free the old page.. */ - new_page = old_page; + new_folio = old_folio; page_copied = 1; } else { update_mmu_tlb(vma, vmf->address, vmf->pte); } - if (new_page) - put_page(new_page); + if (new_folio) + folio_put(new_folio); pte_unmap_unlock(vmf->pte, vmf->ptl); /* @@ -3181,19 +3184,19 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) * the above ptep_clear_flush_notify() did already call it. */ mmu_notifier_invalidate_range_only_end(&range); - if (old_page) { + if (old_folio) { if (page_copied) free_swap_cache(old_page); - put_page(old_page); + folio_put(old_folio); } delayacct_wpcopy_end(); return 0; oom_free_new: - put_page(new_page); + folio_put(new_folio); oom: - if (old_page) - put_page(old_page); + if (old_folio) + folio_put(old_folio); delayacct_wpcopy_end(); return VM_FAULT_OOM; From patchwork Thu Jan 12 08:30:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13097559 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 2EA32C54EBC for ; Thu, 12 Jan 2023 08:17:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96D898E0005; Thu, 12 Jan 2023 03:17:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 89F3B8E0007; Thu, 12 Jan 2023 03:17:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CAA28E0005; Thu, 12 Jan 2023 03:17:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5F20F8E0001 for ; Thu, 12 Jan 2023 03:17:41 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 36181C01F5 for ; Thu, 12 Jan 2023 08:17:41 +0000 (UTC) X-FDA: 80345443122.13.D68CB6C Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf28.hostedemail.com (Postfix) with ESMTP id 2C737C0008 for ; Thu, 12 Jan 2023 08:17:37 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673511459; a=rsa-sha256; cv=none; b=0DkyGxS/QwR6LW7xLqswe18WQmOea9skeF8qIZTpb37yVAgUqSVWoWdBtc3zetkrFoI0Z4 lKcdGilPJ2t4wsa4ShqwdLpLkFLO5/mgB+6lOaffzNzOEB5ycXOfh342qHwgptwR1jS+Q1 KmROQinBfoaCQ8/qYC1bJcm9B7nE4Lw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673511459; 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=Al8EKcnYAtYB1JWIzS1KLhE26inWUEAs3Hs0krdsZ4w=; b=SeA97kq23zsS+eaq1ZRxCqYx2SEAU0vOQNybLJ9tOMLDto8Pru6MYQT+1GvdGO8CDyi+te 7mPtTPZ6T3HHyHpvzimFRKFiF6W5LwhLntfCuLPS99TvX1bPrPuUFwBB4exnEs6MtaADwn +Hgxbvr6RokkBMcHHBcpieW/AIEqIx4= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Nsy324H2pzqV7h; Thu, 12 Jan 2023 16:12:46 +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:33 +0800 From: Kefeng Wang To: , , CC: , Kefeng Wang Subject: [PATCH -next 6/7] mm: memory: use folio_throttle_swaprate() in do_swap_page() Date: Thu, 12 Jan 2023 16:30:05 +0800 Message-ID: <20230112083006.163393-7-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-Rspam-User: X-Rspamd-Queue-Id: 2C737C0008 X-Rspamd-Server: rspam01 X-Stat-Signature: tjw1n7j8xc7um74emsafwneexjeoaih3 X-HE-Tag: 1673511457-151145 X-HE-Meta: U2FsdGVkX19Frwx+swMFp7FbdtfFDXwSno/3p430cKwRpNo9WYXOs2ObvmqRTUq2eYvYub1A85i7SJ0OYigIOqtucn+Jj1PPOpgdMxYYIPVyHIRUw9UvMpGKybL8JggDYH50urC3T3ueRr+AkdYL6i+6INCVYdw74WBjhVRoMBX3nwlXUl3l9F0XXv9HDxBdf1a5AUFT5SeVcilPbtMP5eoU5VkswEokqolQS3LLEZxtJaF7Yu1mSoIT2Fh+jf4ZoEnBa8LvNf7kbMzlvtRR8U5boMJZbzjBmDlcRyE6qpVHEPfP9Uk28HY4KIs0jowNpTyxsrGVhavTQ3A4fxKEoB8/8yEK0LsDuvnXgCTEueDsgelsJ+wSSeZK26YtnNdsfXIhM3HKMhi14g+si+gzZHvvA13KgPcKv/Rluj+bH5QMfDb4O+PLNoGOR2w9gZwUMBKOSvnRTyS+A0kjwLKheRQ3ek0+q+0SInEO/O+ipgPSLT61pfPL/zCi0Qr+930jW4N4CsC+ww4qb8HPPbAf6eAxvYIMhNbxDjgJxTujFr4AdtZudVWGZ4iRt83/OanvSbgdIYSKpqOaH9JZAhiEG4ZEIRSJtWmHIHNXvUR4vpNTq0XS7CU1RN/+uoG295PaQzIqkLhYl97Ye6rtg+epFu4HLiyJeIjKt26SfM+aijvNSG/+6Q8rV/hKXmSfMYByrkm7ldbMJbW5E1kSyqRGj+X+hc79bvIl5zbFpR4WeaZGPGAT9iZtYr7ahYQiXKwQUasYiuBurb7V5EqkQuMWufkpXpo3GMnLBW4XtwdBzsl9Ql6RJKDY5IIfa/4L2xSG84sU+66fIjqVGehxvRY4V2Xu/3nHcG1tpIhAPQAEno5D44OXzC4Yc/af1NkjH9ylZjvryUKXSYUFqbBxW7XuWhU/5euRM/Nr 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: Directly use folio_throttle_swaprate() instead cgroup_throttle_swaprate(). Signed-off-by: Kefeng Wang --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index 746f485366e8..abc4e606d8bc 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3839,7 +3839,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) lru_add_drain(); } - cgroup_throttle_swaprate(page, GFP_KERNEL); + folio_throttle_swaprate(folio, GFP_KERNEL); /* * Back out if somebody else already faulted in this pte. From patchwork Thu Jan 12 08:30:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13097563 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 5B2A6C54EBD for ; Thu, 12 Jan 2023 08:17:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 47C9B8E0003; Thu, 12 Jan 2023 03:17:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3EDAF900004; Thu, 12 Jan 2023 03:17:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0FC938E0007; Thu, 12 Jan 2023 03:17:41 -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 A404D900003 for ; Thu, 12 Jan 2023 03:17:41 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7420D12052A for ; Thu, 12 Jan 2023 08:17:41 +0000 (UTC) X-FDA: 80345443122.09.5413180 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf09.hostedemail.com (Postfix) with ESMTP id F136C140010 for ; Thu, 12 Jan 2023 08:17:38 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673511459; a=rsa-sha256; cv=none; b=Y6tSYeLIhXXGLu9LIcyym2DPpk501Fod4cRqX5fP6b22PEJzG6bo/nu7uN9KBQuuhaboJt eTB8cSSNVJ5iyr+VkpDVJz0beBWGXzGyEEka/AmiBiPY99x/q3lX5W1fDjkYYiiOm1ss+r Zl/LM03hlS1qOGg6P569q0jA/3kQlvc= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673511459; 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=+z4eofE9nff3vyL8ObJyK/MRgR2W0Z1B4DVPxEokq1E=; b=SRtmiTTYrUGV41nA99A3qiruBaWD87rGP7NbVH2nL+sSM9qleCcRrimeMAnEpu6AH0ZvAv RjleEz5OfuXe8Kril4p72mr8k+TACEkgHSfoFEF0MBhVl+AZy3wZgzLHsP17RXyjmvT+Iy xH79e3ezBuJqvK0bVSI+XAiqxgn845g= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Nsy6k50gwz16MZK; Thu, 12 Jan 2023 16:15:58 +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:34 +0800 From: Kefeng Wang To: , , CC: , Kefeng Wang Subject: [PATCH -next 7/7] mm: swap: remove unneeded cgroup_throttle_swaprate() Date: Thu, 12 Jan 2023 16:30:06 +0800 Message-ID: <20230112083006.163393-8-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-Rspam-User: X-Rspamd-Queue-Id: F136C140010 X-Rspamd-Server: rspam01 X-Stat-Signature: pioc81brk8f7i9n5x4h1jxf7ouej3nqa X-HE-Tag: 1673511458-860593 X-HE-Meta: U2FsdGVkX19omFgOBbHwoKfI4NZ9Rsysx1Xmp16oJ/HMhMCe/1qlDIWtGA03FqD4dTfYDPIqhzpssl/AnvsbH5nb2NI1CVh+IsHZVivqtFbQozWSES6kp5fNzvSbfU7Ar4YsWk96F3S53FE2o6pY7VPkr79v4v6XssEh6D/R1IA3W3t/rSAbURRgGniN6wuOJC9DgfBFUpbsjeqmhJulwXka7IkIwStrT5y8zGX4mA6X5yhuq9jjlcc+DzDvbtjLiZapZQge/w7Z3pW5er/WuS6INROqJD3rmQ4T+c5NPBDoia54LanXQZK6LmcgD9+VbmevBQ21j7cqgVnamCRPoMNk3bK6oJvHJVnrQULLZ/ORn1b6TgINeD5o1oScCIer8eXhTn/R/SCRYpg9ISeZi095hj3ptPA1LXEJ2DKbhMYj/A0r1odRHFwt/dHMjyVan2Gl5h4Lqbafjlv1K90osRsGLPxBc1rd8sT5QlfvZiSX1Hfy7GiZ1bOKQWRQa+VHgnhO8xUdjMa2sV4vjHI5ApPjlyt5naWhFLnr+jSBgoKbXCw091CD+kF3ttLkdatzIezfe+zrl7N452iYL0HXMbpdtDf5lIXaJ12lBg61QopxkphucSZ7tQu8Z93u7hGc/ESvAqKvj/wG58bJ6IOchD1DipDfAb3BbfcpVRR0TnBvjR8K/aSri1tfAFXQSu+CulQFWe2oTKc1lRwMEzYtoYVGj2nIQw+gpqYpdlaoHgdjLV2K45mzMCndW3u7FVNGsfUam/zg3P4jgfgLijobI38Vjqc7ZBJQSYsuHeM+0lGs4rasM2VSfarLxLyclTnIk7FVwl+bX2Fu1Cw7qDvmzF4tVZWQnYLqOIXMWoVcC44fdjN+0xPC1nNq39z8fy3705XsyrQXzvWydJIunumeL36miVJ0q2wA 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: All the callers of cgroup_throttle_swaprate() are converted to folio_throttle_swaprate(), so make __cgroup_throttle_swaprate() to take a folio, and drop unused cgroup_throttle_swaprate(). Signed-off-by: Kefeng Wang --- include/linux/swap.h | 12 ++++-------- mm/swapfile.c | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 209a425739a9..2674408e6d63 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -641,22 +641,18 @@ extern atomic_t zswap_stored_pages; #endif #if defined(CONFIG_SWAP) && defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP) -extern void __cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask); -static inline void cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask) +extern void __cgroup_throttle_swaprate(struct folio *folio, gfp_t gfp_mask); +static inline void folio_throttle_swaprate(struct folio *folio, gfp_t gfp_mask) { if (mem_cgroup_disabled()) return; - __cgroup_throttle_swaprate(page, gfp_mask); + __cgroup_throttle_swaprate(folio, gfp_mask); } #else -static inline void cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask) +static inline void folio_throttle_swaprate(struct folio *folio, gfp_t gfp_mask) { } #endif -static inline void folio_throttle_swaprate(struct folio *folio, gfp_t gfp) -{ - cgroup_throttle_swaprate(&folio->page, gfp); -} #if defined(CONFIG_MEMCG) && defined(CONFIG_SWAP) void mem_cgroup_swapout(struct folio *folio, swp_entry_t entry); diff --git a/mm/swapfile.c b/mm/swapfile.c index a5729273480e..3abf514c3f28 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3636,10 +3636,10 @@ static void free_swap_count_continuations(struct swap_info_struct *si) } #if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP) -void __cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask) +void __cgroup_throttle_swaprate(struct folio *folio, gfp_t gfp_mask) { struct swap_info_struct *si, *next; - int nid = page_to_nid(page); + int nid = folio_nid(folio); if (!(gfp_mask & __GFP_IO)) return;