From patchwork Fri Jan 3 18:44:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13925791 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 43627E77188 for ; Fri, 3 Jan 2025 18:44:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B10B96B008C; Fri, 3 Jan 2025 13:44:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AC17F6B0095; Fri, 3 Jan 2025 13:44:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E0A06B0096; Fri, 3 Jan 2025 13:44:40 -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 8102A6B008C for ; Fri, 3 Jan 2025 13:44:40 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 337B1160A2B for ; Fri, 3 Jan 2025 18:44:40 +0000 (UTC) X-FDA: 82967016720.08.47A6268 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf12.hostedemail.com (Postfix) with ESMTP id 9065340006 for ; Fri, 3 Jan 2025 18:44:38 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf12.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735929878; 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; bh=/ZOoCqxUOeXyIAoNGnuNc/b+IIwNReB87jcTC0KeBzY=; b=YZvxIavV6amSsnI6AL3l/mB4B0EVFXg5S3wbiudI1b7Nh6IZIQr7E0PvwzXFkK9GwWTm2C GStBPjp+he21gCPuuHKuoDJAuam7En35JGpdCUS4vl/Wxxpfxua2D9zrbuAG4bZsvwyfiD cvBia0l9d0qxTPWYaECtWxnx7P+idcA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf12.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735929878; a=rsa-sha256; cv=none; b=RklmVuvA8vxJMj9sEcFBGuNABazSeB855Fupsl875fN66yn7LsdTxJVNW0B+Q+bGnfUwSP If5UMeflSw/43WOeKHpVtFElqayoXsPVfQ4eIpOL/d7HTVtKE98+8qZFKi51YeLin+rVou pG/w8DhIc0jnG0/04cBipHBdj79M9zc= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ED50C1C14; Fri, 3 Jan 2025 10:45:05 -0800 (PST) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B7C5C3F673; Fri, 3 Jan 2025 10:44:33 -0800 (PST) From: Kevin Brodsky To: linux-mm@kvack.org Cc: Kevin Brodsky , Andrew Morton , Catalin Marinas , Dave Hansen , Linus Walleij , Andy Lutomirski , Peter Zijlstra , "Mike Rapoport (IBM)" , Ryan Roberts , Thomas Gleixner , Will Deacon , Matthew Wilcox , Qi Zheng , linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-um@lists.infradead.org, loongarch@lists.linux.dev, x86@kernel.org Subject: [PATCH v2 2/6] parisc: mm: Ensure pagetable_pmd_[cd]tor are called Date: Fri, 3 Jan 2025 18:44:11 +0000 Message-ID: <20250103184415.2744423-3-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250103184415.2744423-1-kevin.brodsky@arm.com> References: <20250103184415.2744423-1-kevin.brodsky@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9065340006 X-Stat-Signature: 83t3hfyy6ica618cyekd6urxakwmf78q X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1735929878-632087 X-HE-Meta: U2FsdGVkX197/nHKEgNW3CHWLfixj4qCbQbyF2mDRY8xMqbmLg2ql0ixfZCSC5eYL6HnaqwVY+InhkZynNIkd0fjDXYTHwkYEZPDgKgnOEfYjEhKulr0mD/s8/n30OaXjQsFtXJUYmL9EqeZ6pN0VTfEim66/zKihUbuoWmAx0XSpeKiuLZP7E5lWrEHY2g00udGtJfQ9wZW/h88o4sYfpT3ZsZwCPOprcgP1rflxXjVJvP5/8wmR590f012BorKz7aZJ4hSBnNDNTIGYHlO+JkFqAAu7Wr4nN0SVqT9uUf9jPMl8nhSzg359xdNSjT53ZSCYdOTCVTyYyl6Lz6mk7txHK+jvKLKQ24hV7BoJhypDgKLAClPKzHqKJZ3JT4UDR34GPGEOracHkRQNnmeVLSnbPj0KnkAUSLFn4z/wCaEtAcmWrxSXIDnfYAjPMZvz9H3zxGU5W8mpOx9/McHL0ef4JKEHhyB5Qj1+aQLNIDDkF78v+dQ2s9K4wLyMFIZA4YAkq8olN8whaZCrjyghorYQ0XktV9kd8yA2C0UW30HKtf3cxe2RvNF+ZD/S8DPO+9QS4OCDMgEcHUsfxeg0clNzeSr0lIjOZdStFiGr9+yusZbDQAWubXyVGzb/tLAEbgoVFq2SiKDP6t5/ot7wp5UFoWLWYVgW61Wejo4Um48HAGH4sF7vaZgAycSEizi1isg7Ve/E3NLZ5XlIQDG4GAd7wZUQG2Gr6B86ODyvp2bc+yhLApYsVFeEhpvjTS7+qTa8wQwapiju8XZXbQxrKraGAHv1C6juisT9dHLsetF5dAzOUy8UDSusebuqGQHzEy22j7TUY/RTZVQA3sKMF529rDdeDHQ0Rh0p/cw342sVIPQF7nop+4IsMSXSept0GIYd9aKGYwkg10J38T0vm05bVvWhJEimGEGrqrK/ny6l59K/YJov3tRIF2kX8yM8OPFBkaaetPZAqKgv2n OIMHTIjG XH+AI5/u2CfLFVHiV01P5l9kAPmugrxvjYe8N7Edaenmuo7FghCPwH/ehw/Dp6Ss9ByQqAL4hrnAHj57auSzvIhf3J5k2DPNlD7VpDj/Qzx4Ujo2sLLeMys3aTxys3r9R4pZPOH9qOSN3QersswCTKkKgoNnSUVrVa6xxiy8XAqWFv4WCkX4ejNV+7tMAvH6hHD+fkGFAXYvHUlk9iqiYxThy4YwtIebSgjcS 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: The implementation of pmd_{alloc_one,free} on parisc requires a non-zero allocation order, but is completely standard aside from that. Let's reuse the generic implementation of pmd_alloc_one(). Explicit zeroing is not needed as GFP_PGTABLE_KERNEL includes __GFP_ZERO. The generic pmd_free() can handle higher allocation orders so we don't need to define our own. These changes ensure that pagetable_pmd_[cd]tor are called, improving the accounting of page table pages. Acked-by: Dave Hansen Signed-off-by: Kevin Brodsky --- arch/parisc/include/asm/pgalloc.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h index e3e142b1c5c5..3e8dbd79670b 100644 --- a/arch/parisc/include/asm/pgalloc.h +++ b/arch/parisc/include/asm/pgalloc.h @@ -11,7 +11,6 @@ #include #define __HAVE_ARCH_PMD_ALLOC_ONE -#define __HAVE_ARCH_PMD_FREE #define __HAVE_ARCH_PGD_FREE #include @@ -46,17 +45,19 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) { - pmd_t *pmd; + struct ptdesc *ptdesc; + gfp_t gfp = GFP_PGTABLE_USER; - pmd = (pmd_t *)__get_free_pages(GFP_PGTABLE_KERNEL, PMD_TABLE_ORDER); - if (likely(pmd)) - memset ((void *)pmd, 0, PAGE_SIZE << PMD_TABLE_ORDER); - return pmd; -} - -static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) -{ - free_pages((unsigned long)pmd, PMD_TABLE_ORDER); + if (mm == &init_mm) + gfp = GFP_PGTABLE_KERNEL; + ptdesc = pagetable_alloc(gfp, PMD_TABLE_ORDER); + if (!ptdesc) + return NULL; + if (!pagetable_pmd_ctor(ptdesc)) { + pagetable_free(ptdesc); + return NULL; + } + return ptdesc_address(ptdesc); } #endif