From patchwork Mon Apr 22 09:44:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13638154 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F42FC4345F for ; Mon, 22 Apr 2024 09:46:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vMB1lz8p28aa0smBKInmRfZK/8xPkb3oc/9SEyJE8aw=; b=BAWFnv0xsOMqld z+Ugom5BjY9vdY6W/9FnaM0iwa7ChERM7Iy6ynSezA044uGdRGM4GU3kDVHpFR76Wty92+RFHcyG6 Nip6gzUkcIBZShjSTElyqsYYJRVlgMpDVXMjTv+8W2Yc59hfhv0GnQ9bBjd89YedBKBkKH6aQJCes gTI3u8cDU9+H/tZ/YDxuIe9tENpbw+Z9thCe3+DnjBoyzg9QhAst++4VQwsq3mRvx73ADztaVGJ9r XF4V2OhqOhvxhXD7wKFBAx/SPCcbPS8kBSYQJK6D+XVri/dMPFdb5ZMSkCkiyRiBUwjjYZgLZY4x5 TTxzhhGicC0YFyCl2ANQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryqFb-0000000CzCI-0Eos; Mon, 22 Apr 2024 09:46:15 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryqF6-0000000CynO-3dDm; Mon, 22 Apr 2024 09:45:50 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E0ECC60C2D; Mon, 22 Apr 2024 09:45:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 524EBC3277B; Mon, 22 Apr 2024 09:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713779143; bh=jgYZaFJ37N18LMQ1WJO1fYtb83p+Fzz2HBcTxrLBVpQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pTzYnfXhpjxu83nQPuEnNLRgHVoQQroHJiCpAQ3Za0sQG/dZMmhg1H4T+YOmcaqe0 W8/nK7bnWno/TQVlwkLSwhtUciMpaWbLG3k8baDb1t4dhUQEhwC+fZNZZ0aP4Ff0FA SK4hqgU6ME9logSwScvy01bmqFt0tlL8NIeHoaBIScIM5cBVNPh0LPNAEBVoxt0wq7 oM8kmGLxHnFtdLfcWmNBGVpaFk4UBmZXcVCJSKD0K7oqah6ftCD+6zrI0vZpt/vIt5 RvttqW0vSfXuroC5zmudSNEVC7fM/Am2IbPF+1+Ac1O0Hpgj2CFEzW94QP2gWq+6bd J5GXrq3B+u2Ig== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexandre Ghiti , Andrew Morton , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Donald Dutile , Eric Chanudet , Heiko Carstens , Helge Deller , Huacai Chen , Kent Overstreet , Luis Chamberlain , Mark Rutland , Masami Hiramatsu , Michael Ellerman , Mike Rapoport , Nadav Amit , Palmer Dabbelt , Peter Zijlstra , Rick Edgecombe , Russell King , Sam Ravnborg , Song Liu , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , Will Deacon , bpf@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v5 04/15] sparc: simplify module_alloc() Date: Mon, 22 Apr 2024 12:44:25 +0300 Message-ID: <20240422094436.3625171-5-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422094436.3625171-1-rppt@kernel.org> References: <20240422094436.3625171-1-rppt@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_024545_168001_F270F123 X-CRM114-Status: GOOD ( 12.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: "Mike Rapoport (IBM)" Define MODULES_VADDR and MODULES_END as VMALLOC_START and VMALLOC_END for 32-bit and reduce module_alloc() to __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END, ...) as with the new defines the allocations becames identical for both 32 and 64 bits. While on it, drop unsed include of Suggested-by: Sam Ravnborg Signed-off-by: Mike Rapoport (IBM) Reviewed-by: Sam Ravnborg --- arch/sparc/include/asm/pgtable_32.h | 2 ++ arch/sparc/kernel/module.c | 25 +------------------------ 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h index 9e85d57ac3f2..62bcafe38b1f 100644 --- a/arch/sparc/include/asm/pgtable_32.h +++ b/arch/sparc/include/asm/pgtable_32.h @@ -432,6 +432,8 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma, #define VMALLOC_START _AC(0xfe600000,UL) #define VMALLOC_END _AC(0xffc00000,UL) +#define MODULES_VADDR VMALLOC_START +#define MODULES_END VMALLOC_END /* We provide our own get_unmapped_area to cope with VA holes for userland */ #define HAVE_ARCH_UNMAPPED_AREA diff --git a/arch/sparc/kernel/module.c b/arch/sparc/kernel/module.c index 66c45a2764bc..d37adb2a0b54 100644 --- a/arch/sparc/kernel/module.c +++ b/arch/sparc/kernel/module.c @@ -21,35 +21,12 @@ #include "entry.h" -#ifdef CONFIG_SPARC64 - -#include - -static void *module_map(unsigned long size) +void *module_alloc(unsigned long size) { - if (PAGE_ALIGN(size) > MODULES_LEN) - return NULL; return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END, GFP_KERNEL, PAGE_KERNEL, 0, NUMA_NO_NODE, __builtin_return_address(0)); } -#else -static void *module_map(unsigned long size) -{ - return vmalloc(size); -} -#endif /* CONFIG_SPARC64 */ - -void *module_alloc(unsigned long size) -{ - void *ret; - - ret = module_map(size); - if (ret) - memset(ret, 0, size); - - return ret; -} /* Make generic code ignore STT_REGISTER dummy undefined symbols. */ int module_frob_arch_sections(Elf_Ehdr *hdr,