From patchwork Tue Jul 30 06:46:58 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: 13746742 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 5FD41C3DA61 for ; Tue, 30 Jul 2024 06:43:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1F6D6B0096; Tue, 30 Jul 2024 02:43:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA72D6B0098; Tue, 30 Jul 2024 02:43:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFA526B0099; Tue, 30 Jul 2024 02:43:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id ABB806B0096 for ; Tue, 30 Jul 2024 02:43:48 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 44A7B16012B for ; Tue, 30 Jul 2024 06:43:48 +0000 (UTC) X-FDA: 82395478536.24.8CCB3DF Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf11.hostedemail.com (Postfix) with ESMTP id ED61F4000E for ; Tue, 30 Jul 2024 06:43:45 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pCvcQ31O; spf=pass (imf11.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=eEZqGNYKfJ/GBCgkce7J5DoxDjOh5psUFb8RKdEH3ds=; b=buebSzpnwSLRIVoClo43eVsRx/vz2KtaqzjydiovPjPPySMedLpTyx+8a00zb2SgVbFamL isNgZJt66QCRTfl9Neti8RTbCrp19CpKBjYqT92DPAzx2xK1aqxL4h0Solb2JkQg3loIID fuTjLRj/uCafZOsACcZC9DnarmLspdI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pCvcQ31O; spf=pass (imf11.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722321799; a=rsa-sha256; cv=none; b=dvuH1Yj0tji9u0VyJVWjTzAOBzUmkW6Gkp492GlfVY17HOPtVuYaHKZfMCzJyja1NYFLYE NI178vB6ymOvj+kTquwtoUiqeUgsSJBse9E++H/Ir7oyF5eY0oISfvkjci70LAktsdVO8+ u3fxTYbNIetgTgVlfhrlJKXBoJ/5kzM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 6F0E4CE0EB9; Tue, 30 Jul 2024 06:43:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BACF0C4AF0F; Tue, 30 Jul 2024 06:43:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722321821; bh=0HxdBM1LE6ysqiZRX6SJTg2axmKV4cup3qnH1WxeykQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pCvcQ31Oh/rZrX6vYGdEMdYSwjAA1+34RzrEr/t9o7MT5D+PNTa7YGGRObsY3Vj9J MUxGysHSwKrQcTkpl2SvBl6MqrXIGFBmI4eQ8UJaSIMIEoLnBkMvA28EEmbuYs8lJK mCDTcdUtjWr6glb6vgLgL4UY0BRUmhgrr7fA+xoTqQOS70P7y/nWIOhbfFqpU6R5sg QonRXyIz/vNUbS7vAW+pLYDApyNCiOl6Tc9/c2usw+ur/OSWJW0zIG0rK19z5A7Fpr j1UM3Hg0YFwY8/lXeCo/dTo4rnWTG7ZllMILNLVedgbzdeKrt+O1TPgn6MC8iP/Fif 4XWWZnrr+crcw== 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 04/18] mm/thp: use ptdesc pointer in __do_huge_pmd_anonymous_page Date: Tue, 30 Jul 2024 14:46:58 +0800 Message-ID: <20240730064712.3714387-5-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-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: ED61F4000E X-Stat-Signature: pn1yzh73yr1o3rxqffuiijpg8ur6doww X-HE-Tag: 1722321825-28968 X-HE-Meta: U2FsdGVkX1/r9sDtQP27mmxX3ARkFZH7pGdBOiGniwYo8L+ogx/syyezXPHz0dNfGrSM6AdI8JLOb0ZgdGgDqSnEwf5ZNL9ul7/7ONFbytZTrxgvuWBAeAjfpnZwGFYLgGqRhcdmm4Zd8KRx4a7xhRanKUveGmRA1ZlvHgSFKwQzgs6iWq4xLPUeeGGmB0gPudSzAzHSQBgKurVTPk4ILlQmaiL/cgGqKk2LVoUHrhCXLof2Hs7No4PFcDgWlg+Wf4Ec2eWDasN/Q++gKKX0mq7UO0eIyeFx+SAYd7FOtdiR0YFWLEdS7kMXCTwgEf6BA5EWPz4UJpOZ7fVeiV36k59FS45oyaECwYKI8vCutoSToC79IUbhEzNs9YBPCRbWgzfOJlx56gy1pzXwPkY2eFrYxd2BY6NnnHLpAiMxn5LPym9SjuN89eAKbOitsI5U14aozfgR0p7YNWwSkS30BBckW7HOE1Xvrs8xam8aw6595AjNqT2CfXnp91xTVlg38bjsLRyYYvXGdWhIxJXk/TBG0ptSzPb9gQq6eUimnJgNINpYaZLbE5SfgZM+atCUu/uJHL/Heqmdb+QB7+Kw4Q361xAI45H1PPg5NTKPsafzzXJ+QEgf6wHTtbLH7H3/SXvGDd0FmE3K0OzqD5Qwvjq32j87Kh7JuL372fX+mmCMn2tGN21hv6HuRZ+YtcPjRyLFWisTXsSGbryoFYVKgntswBqT05d2ERSXvTM1uSSGnPAKlTBrKpzMB5SsWnVe0zlWPjjO3bCMRrooBYi7yEpU3iolwi4nZ1jO7+8RGxVT8GUlkC+pjs/7h5U4PuEZjLxSA1z1bXXpKR5tyFwKAzMORD4yKviTO1HHmrucY1rUb6G77KDqwFm1c7QPd3ENWSf2m6TF76vEV3Dieky5V+oVJ7phjMLlrc7CF92VtgJAHk6NxoDpB3f6gCRIMrV1A+1HZjTn/v+uotLmJGZ bhDQX4fA a+jVyV4SiWV7pzvd38N6GefDNLURkes30mp8/OVI4ezko0h2ocImYveycEyqE01mlODyE1KlAshC5zRTKcIDClDqreC92cLXlpfAGuPCmv4msCWqL3+8MUEWnSPqSdLhENs41r78RFcscB3SX5ap+ZynZtKTM1op7BdWeIQ4+grgod6CUqR9faGeKGdfoSCG79Elwt2UwxdXFIZFgJYXzInXZRDHGMGLtMbFOFe6Ya21s+SrEwngbS7P2wyT/3dP8i5aaosI3NcVBzbmdu3NNT4V8lMyyzzNizGkczWKbzxUzQxyAYOoeBagfORapPjpqKri5tnysUQkRo1k1Eeb6o0BOsc5cpiKZ0ftI8orwnJ9ffC77FH4M6QqembEZEBgMgOabEZBvXRVBP+BFqCzTToGm/DVzphMSBUuEvaehOy+iKJyFHonl5qEkuU6bzasgdKAtMlmgdDIaoVoqmrxq1uZbqw== 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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 0167dc27e365..0ee104093121 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -943,7 +943,7 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf, { struct vm_area_struct *vma = vmf->vma; struct folio *folio = page_folio(page); - pgtable_t pgtable; + struct ptdesc *ptdesc; unsigned long haddr = vmf->address & HPAGE_PMD_MASK; vm_fault_t ret = 0; @@ -959,8 +959,8 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf, } folio_throttle_swaprate(folio, gfp); - pgtable = pte_alloc_one(vma->vm_mm); - if (unlikely(!pgtable)) { + ptdesc = page_ptdesc(pte_alloc_one(vma->vm_mm)); + if (unlikely(!ptdesc)) { ret = VM_FAULT_OOM; goto release; } @@ -987,7 +987,7 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf, if (userfaultfd_missing(vma)) { spin_unlock(vmf->ptl); folio_put(folio); - pte_free(vma->vm_mm, pgtable); + pte_free(vma->vm_mm, ptdesc_page(ptdesc)); ret = handle_userfault(vmf, VM_UFFD_MISSING); VM_BUG_ON(ret & VM_FAULT_FALLBACK); return ret; @@ -997,7 +997,7 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf, entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); folio_add_new_anon_rmap(folio, vma, haddr, RMAP_EXCLUSIVE); folio_add_lru_vma(folio, vma); - pgtable_trans_huge_deposit(vma->vm_mm, vmf->pmd, pgtable); + pgtable_trans_huge_deposit(vma->vm_mm, vmf->pmd, ptdesc_page(ptdesc)); set_pmd_at(vma->vm_mm, haddr, vmf->pmd, entry); update_mmu_cache_pmd(vma, vmf->address, vmf->pmd); add_mm_counter(vma->vm_mm, MM_ANONPAGES, HPAGE_PMD_NR); @@ -1012,8 +1012,8 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf, unlock_release: spin_unlock(vmf->ptl); release: - if (pgtable) - pte_free(vma->vm_mm, pgtable); + if (ptdesc) + pte_free(vma->vm_mm, ptdesc_page(ptdesc)); folio_put(folio); return ret;