From patchwork Thu Dec 19 16:44:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13915289 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 DA422E77184 for ; Thu, 19 Dec 2024 16:46:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D3AB6B0085; Thu, 19 Dec 2024 11:46:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 65BE16B008C; Thu, 19 Dec 2024 11:46:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AE866B0092; Thu, 19 Dec 2024 11:46:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 28B4A6B0085 for ; Thu, 19 Dec 2024 11:46:22 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C436D1C8A41 for ; Thu, 19 Dec 2024 16:46:21 +0000 (UTC) X-FDA: 82912285932.11.872A44B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf02.hostedemail.com (Postfix) with ESMTP id AB5028000D for ; Thu, 19 Dec 2024 16:45:16 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf02.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=1734626765; 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=PwcZYQebHQhJI8S2XCpqJM+lG6xJt9XpWgsLOxw4To8=; b=A6SDRSNRGLSH122FDaEqe4xe6DSEurwOPclC4Bm6joizRb8DoacmFfiRtF6YsI/OJ1hYWf s5+bwje+V8MIkz8AQ5SUjmnl/ZUgsj1r64W6Qe4xsiclApnOtRJMtzyy8n2yG7QLCN9KeA IeRazwz1aMysBQBK6lRLECEx7reTMj0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf02.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=1734626765; a=rsa-sha256; cv=none; b=jU8jvF/ArRTIHY+KsIVMA3hDPIR7jJwRsQgSpRWWv4NHRfZfAv4lJQu7ysoPRgbkbLUyaw D/ZdOKqp0HearZJ8LwaoScGsBm6rjk69okEFAvyXZqRGsMqbk98vsUdLHooTyZr4ihBJ9T SiyXGeYf8QhrDzqotRPGJ/jqJnyamao= 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 90DDF1480; Thu, 19 Dec 2024 08:46:47 -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 90EAC3F58B; Thu, 19 Dec 2024 08:46:15 -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 , 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 02/10] parisc: mm: Ensure pagetable_pmd_[cd]tor are called Date: Thu, 19 Dec 2024 16:44:17 +0000 Message-ID: <20241219164425.2277022-3-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219164425.2277022-1-kevin.brodsky@arm.com> References: <20241219164425.2277022-1-kevin.brodsky@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: AB5028000D X-Stat-Signature: 74rtipxxiwnqwqzrccf99qzqga49k47y X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734626716-584929 X-HE-Meta: U2FsdGVkX18jQruJWpBqauFV6fPhdvWjMgTrQwEadP7kvFQvCiTSEb01hMxMKA2F/BLc3MDeCb/nob9BNC+EGHaRc8WOJtqMoWmz6ngDE5q29IMMy2QpYU+c6dSjvjcvGJx9nnwZuOUvI8nkObGViKN11NHpZCvook208Z2fnBSxx/9w803JPORdZxSS1PxOStF2zSf5swtrAzhFd2Ds9JWtuK4Qpk+9N2srWdRmV6ikQiyo9CbOa5ATqKzq9NyjbX5WofR+4l2pduIQl9CcChqae5RHE5pgakRX/F6HJvvJp2OBIGPAoZ/dnRYV3E9AVGiFHJDHGHTnRxtgc9cKDY7pxksLHaeRtHcfh0Tl6vaV4q9H5Wn2VKdsTsi0EU3ahd59aIy9Opzk7oGIEQ4rGwNucxnQBKvLZPY1mIYEWEYqacMzcchHuAx6IE40gsFwkDBigW0Fqb6NkNhwypUjeTYQJEuQitmyS2ihcfL8LHg+UVIMBHw/4cfcs8r9yjomOFGtUF75hOtw1XWPxB0At/xt9Ndj6qVszMXl9yU5ls2J0RHTM6R548rhltxfTYYjsGl+v7GR1l75osSuYkg37TyhWIB5yXBqifxJj/xadP+Z7zPg0iko6awkBkOZac3JlcIO4N0kZTTnpAv+MkLM51T/xZUDZt9j9iWasD6cX5O5LKLzYZ6iSjPcgnyV36FKboy6YtWQfY/XPrEulo7TiheaRg88GBXdVvv2krkhaRdU9a7oXpZw8CNtfeZ7pSZuX2ZBE8LGwySUf4mQErOLVxFiP548NO/bbCNhusHhSxRtqeEHxheatwZJ+m2PQT9VjOj2SSKBjz3Lh3aZnJBr5dlCDECh8M4rgJyEezJ7kzqdeRXzNMeq+EID+Ysqx/3WSGplg7YovmRIsjfauQ8QY0CpgaacPKTd7WA9s/kAChJqCtSpmsjnXST/86qSOAyAJBlN39PGxg0z97YNw/M bGYQJuGJ jPDtu28Mu2RVwW2Nfb3SxEXBN7CpgslNZbGEzPBgyjmUmoWSxH2qpvyLEbqqYMfMHmo0qWBvTHgbE4qS3zwXKVYCwk+WrXbasoQOnRSVKfWXIBKp9a+x2EWN+/24MMH+Jdu84XUJcdkciInNac25d29MmA1zSsQSsczcK1T4DqEKHPAvY6bG7tK03uou+OBCHLbcLZpGKFOT5iFdEuyvIATKtU3Kk7IN7aBlfu17Tubvw/3+V//BJNlPPUDfS6qWlLUdBlBKyEpMjtArcE2djkxKj6DDjvQ2biPgP4IZWfK3p5qYPqHiuEsCG/+rVlPQUva5Q 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. 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