From patchwork Tue Jul 30 06:47:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexs@kernel.org X-Patchwork-Id: 13746744 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 75C13C3DA61 for ; Tue, 30 Jul 2024 06:44:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 115556B009B; Tue, 30 Jul 2024 02:44:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C5406B009C; Tue, 30 Jul 2024 02:44:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E81246B009D; Tue, 30 Jul 2024 02:44:15 -0400 (EDT) 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 C75196B009B for ; Tue, 30 Jul 2024 02:44:15 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 747E140103 for ; Tue, 30 Jul 2024 06:44:15 +0000 (UTC) X-FDA: 82395479670.08.E53B2DE Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf20.hostedemail.com (Postfix) with ESMTP id 153F91C0002 for ; Tue, 30 Jul 2024 06:44:12 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZEtbsRJn; spf=pass (imf20.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722321799; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZliMR338dlO8O0967TFppwWn8Gn2cTZOIlU7WLGfCDU=; b=Ws5R4G8ArufKOUFAtKgjtdUFMIAeQhaNba/PKmfTVbRGRxRFl1BYzti1IlZvwdKYlu//Cn tZNzSVZjtSgvjRYNOAC5HoZ11ZweWT7EX7uYPYd9VykRxnFNpwS0V6po3a9XZetILRUk8a GYspXWFhsS3UOkbWcexUoD92H/T4J6k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722321799; a=rsa-sha256; cv=none; b=hG9dVMoxHPvpdqc9b5vAIFCXRk1uYZ7cnQF0IdaoBhTLGZpdTwCQLKqooiTdbyFw5bL98b 8+N4rRHqOiZD4Jz/F3TJAiILT2NQpUiT3h2Nbr3ZQi8SSZ2NnDU45EIs5qQ24wsr859rOK ZYmoEUJl7m7TnZESm11tmYu4EkaVgQw= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZEtbsRJn; spf=pass (imf20.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 83232CE0E51; Tue, 30 Jul 2024 06:44:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1846C4AF11; Tue, 30 Jul 2024 06:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722321848; bh=PV8eOJ4vyzS4FxAkaZ5NDLLSz9ktugALPQl2HkO57GQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZEtbsRJnMf7Ux0oUP43wBe2ysz4FoXhhZTuwRiPtnQvwBzcF04hW3I71Xi5W3eYCz vb88N88O7flGQsN6anDDUISBm6/xyE43fRkDhAbxLnCjDlVv82fGw6FotjAYvt6GYX QFHcPrRinsx/+c7KPzDEsLxpolwpWompiMzb0pXGb0blFP07SEq1UyKFHAQv8XC/pa pwgu/eKYgUvwjUgeNQmkj2V0n+sfCR/zx78ePeUsj8CmLWrWcX3OzbvvjpOQap3f7i 4IH69bYV6ej5Ph0nh99eBqc8supUb+vBuZOERYMAwubQqITEfEu+UKFYgdgEO9AhVB gqDximJu4aCiQ== From: alexs@kernel.org To: Will Deacon , "Aneesh Kumar K . V" , Nick Piggin , Peter Zijlstra , Russell King , Catalin Marinas , Brian Cain , WANG Xuerui , Geert Uytterhoeven , Jonas Bonn , Stefan Kristiansson , Stafford Horne , Michael Ellerman , Naveen N Rao , Paul Walmsley , Albert Ou , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Andy Lutomirski , Bibo Mao , Baolin Wang , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-openrisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Qi Zheng , Vishal Moola , "Aneesh Kumar K . V" , Kemeng Shi , Lance Yang , Peter Xu , Barry Song , linux-s390@vger.kernel.org Cc: Guo Ren , Christophe Leroy , Palmer Dabbelt , Mike Rapoport , Oscar Salvador , Alexandre Ghiti , Jisheng Zhang , Samuel Holland , Anup Patel , Josh Poimboeuf , Breno Leitao , Alexander Gordeev , Gerald Schaefer , Hugh Dickins , David Hildenbrand , Ryan Roberts , Matthew Wilcox , Alex Shi , Andrew Morton Subject: [RFC PATCH 06/18] mm/thp: convert insert_pfn_pmd and its caller to use ptdesc Date: Tue, 30 Jul 2024 14:47:00 +0800 Message-ID: <20240730064712.3714387-7-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240730064712.3714387-1-alexs@kernel.org> References: <20240730064712.3714387-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 153F91C0002 X-Stat-Signature: uyd8zft6sh4i3nb691aamc3rzprw6iia X-HE-Tag: 1722321852-493744 X-HE-Meta: U2FsdGVkX181lwyyvfRNndixwadi9PGbK0Mq4pxe+MUtGNcUgAlNUmbSMOx14llgIbYQkaAMt0mi78ax4mvrJyKsnD4+YkHUVDIgC0wrZkFFQYI1/k8tK3Fw8jU21g5BmTweECAzO5T9Luw4s5elfrm/eFZzBj2iVywrutdgt/KDjk7k5bsJlpqw6MKbOnlnVfxQ+0V0fBeSLFkQfBLfidtqadT3iTW3v/vef1+aJGywnCdC+JtmqQla598AEEkEzGw8FbJ0xdk4O6sgPPYDwT3JAcQIc2wCskzF/tUWAMnv/Tc7dGCZAEPM1TuWpJCrTEuqVnGq6/ZcWGDiJf4nRJsJ+Rtl/As4q8keJLyVGa9T1bx8VG621KKeFgWBPOw8QkMi3xUvFu5kqgPyWh3pKBsmbRlbjDGJtZKIcEks6xAqSqi83eYrqMsH5fhquAmZs/uB2YT/S6m8VlG7sUhNOXtcPB7uvtyFPi/4lX1845VXplcCS25m5gOub/yUNrWF2c9NlKcUG4z6ljQJAp+40MW8oT2D9IbXfxrQCE50aOf1iqugWE5WGpsgZkBjWN4SeHvLvaFZ+D9AhZYyHUZCbfMbaIf/GWHu5Xgtb0C70ch8DarRBTDOoV71GE07M0JuV3ZTSZK8gdsPs5egsTYeKm+mreOXzgzmafJmkPW/exQEAUrNM2ZqVjZRquvKMHT8wgsU9o7XiJg3ixv2hvP68RMpVmBnPjkwnV/VPj4jDvy5uxYtlDsLdjP3+xCBApKwziYCJ/Mhh3edCdkgKNM5j1I0ORmdHnZNQUARUFCjWTiF9MrFB3IaVt14hIe7nGbUES6Du4q/L8nhKP6hTfrPDRzjrmAOxv8cHkvvd9dImN0d8FTHHWjeS1p9BEJQ+maRXgo4Fc01V2DrFdtuLPbXQaIAUPYbtpedmn2D2MGD+cEEHeUj63nM/Osd+6yLsjzZeRIoNyiCzNF67oVMeSS mtfbk3RB sCDYR+yfJD5h0Bi0ZcVP6eq5kc6b3L/lt4XO8q6RGIiriuEe60xwAz9FgFGqgWD1bdgOJc/nxGXCCHtg/GCXNt1smpAxGSFHJImaDAxOqhB5WWz8Iyxr6nHDPSBA945UMy+X30KOlskgnA+538lN77gkeLasq2um4DPiVY/JWcf+CJLi5h7963grmwm+OcEYY0rRApnOZfQ3Bb2ZLTkXYPPoNUyZEKksk2/EX83r6O6Rmis88Z7TUaR3sIofTkHUscscMPstjEitZr61vdSbgA3YHRMXj+f/Iqr30osSjPr0zfm629duNjexXQYPgubvO7S0ZqGesxUgnLkYO8/acdDqmu+I9DK6OPdBgQAJ/cUu5QHwOi/jyc1XMas65BsxDp1FoUVp93nom7Bn1mMTKMsVKx8SVOGAproawqgG8Dfixu5iXdKz0iKoUQ/JUzatOrpN139dNrNlKK9CJT+/1Xdv0Hw== 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: From: Alex Shi Since we have ptdesc struct now, better to use replace pgtable_t, aka 'struct page *'. It's alaos a preparation for return ptdesc pointer in pte_alloc_one series function. Signed-off-by: Alex Shi Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org Cc: Andrew Morton --- mm/huge_memory.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index d86108d81a99..a331d4504d52 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1136,7 +1136,7 @@ vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf) static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, pmd_t *pmd, pfn_t pfn, pgprot_t prot, bool write, - pgtable_t pgtable) + struct ptdesc *ptdesc) { struct mm_struct *mm = vma->vm_mm; pmd_t entry; @@ -1166,10 +1166,10 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, entry = maybe_pmd_mkwrite(entry, vma); } - if (pgtable) { - pgtable_trans_huge_deposit(mm, pmd, pgtable); + if (ptdesc) { + pgtable_trans_huge_deposit(mm, pmd, ptdesc_page(ptdesc)); mm_inc_nr_ptes(mm); - pgtable = NULL; + ptdesc = NULL; } set_pmd_at(mm, addr, pmd, entry); @@ -1177,8 +1177,8 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, out_unlock: spin_unlock(ptl); - if (pgtable) - pte_free(mm, pgtable); + if (ptdesc) + pte_free(mm, ptdesc_page(ptdesc)); } /** @@ -1196,7 +1196,7 @@ vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write) unsigned long addr = vmf->address & PMD_MASK; struct vm_area_struct *vma = vmf->vma; pgprot_t pgprot = vma->vm_page_prot; - pgtable_t pgtable = NULL; + struct ptdesc *ptdesc = NULL; /* * If we had pmd_special, we could avoid all these restrictions, @@ -1213,14 +1213,14 @@ vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write) return VM_FAULT_SIGBUS; if (arch_needs_pgtable_deposit()) { - pgtable = pte_alloc_one(vma->vm_mm); - if (!pgtable) + ptdesc = page_ptdesc(pte_alloc_one(vma->vm_mm)); + if (!ptdesc) return VM_FAULT_OOM; } track_pfn_insert(vma, &pgprot, pfn); - insert_pfn_pmd(vma, addr, vmf->pmd, pfn, pgprot, write, pgtable); + insert_pfn_pmd(vma, addr, vmf->pmd, pfn, pgprot, write, ptdesc); return VM_FAULT_NOPAGE; } EXPORT_SYMBOL_GPL(vmf_insert_pfn_pmd);