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,