From patchwork Mon Apr 22 09:44:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13638189 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 92A75C4345F for ; Mon, 22 Apr 2024 09:47:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 280906B00CE; Mon, 22 Apr 2024 05:47:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 207D86B00CF; Mon, 22 Apr 2024 05:47:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05AAC6B00D0; Mon, 22 Apr 2024 05:47:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D65D26B00CE for ; Mon, 22 Apr 2024 05:47:21 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8EF95160AF4 for ; Mon, 22 Apr 2024 09:47:21 +0000 (UTC) X-FDA: 82036689882.04.CB3D191 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id D64251C000A for ; Mon, 22 Apr 2024 09:47:19 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lqvQCRbS; spf=pass (imf18.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@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=1713779239; 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=QHQKLhCRCq0jN6F1p3Q02RhJGLvwNvE4h4Z8DKx5n6s=; b=5Fmk5zxbIHmBaBuXXoVfp7W/us9DNmglc4LPqj32dQ7uJCmjlSsdrLdGt/G3TMrr7M6USE fmNhpjx1jQLggj36LQBHHWElZaF+tIAFoULrdYGMCi0JwDHF2bXUeSTdj/5E05kwNgID36 OBFIfrLI55jo7IS3C48a7Fgmg0UW+Y8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713779239; a=rsa-sha256; cv=none; b=TK+sM62FyClfpc9Ou28GwfzTY7Pqqzkzu4omrYy7DTVrcLs/sTlBFuiL/XRMXdoIouz3Lv mt3DatU2I2mGR3/wUGCMqcYNKUn3U8wXt7LIN5oWRBxMbET5DCa/tz7R5bx5eOVEu+JiGj NJ9VAXqdD3nO6QbfidSabv6nPK1/bhQ= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lqvQCRbS; spf=pass (imf18.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 06CEC60D42; Mon, 22 Apr 2024 09:47:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C049C4AF07; Mon, 22 Apr 2024 09:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713779238; bh=lHpN+d0QRuUVXJIB1eReja4FWUfXvpd+hME9aJI8tNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lqvQCRbSgOtByDX5V7X7Bw0Q6Xg/6rK2dK+e7xdmVuh3CxXahd5fkRnnV4/E1mgFv MnpJiS6k7qsv4Cv9yrxpVrkgPtBTgXqv6snY5o+VvaMzmB+dgrrgTWs6Fk2xCb4cbk clpfBZgcTEXi+sDhCAuvAiBk/RZJQ1ExQR6SIQ0XaYWNYv8ggZmdP6DnkyauN/SN5i PgKK3IY72GlYAysRAMEAsjNSAyfQ8xL5gQVlm2N6nJvIJ2embrZ+O9iEk9WZVsoBfo Jyo9Tu1EKGZ/sy2vEM8dORmBr0c+/aSvnlpUXttLCMWeOso2IBKsjBwFUVDAnUIytk rvIzl/f//U9QA== 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 12/15] x86/ftrace: enable dynamic ftrace without CONFIG_MODULES Date: Mon, 22 Apr 2024 12:44:33 +0300 Message-ID: <20240422094436.3625171-13-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-Stat-Signature: abt3d56mrfgnwatq3ra5ayc5rdb3mmui X-Rspamd-Queue-Id: D64251C000A X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1713779239-978738 X-HE-Meta: U2FsdGVkX184fjBCUEROWCCiiU0buJcauz5/CmiBRRgAyZU2GafzpTb/Y3SynCGOj9Zj9/9Bi0CvtRvXIvLb2PnHLZLORlpEVr8W19IYmtH8mT5JQhNndKWMdHwZHafWUnwOo/sCbFYZ4E0TsqWwWYf1w2LsBOzHQI7HZk9Esl66MZgjl34J0INDb27LRDJTRnt3WS4fWFKCQMi+XFTFRoNtxgMtL+LONi74jlNZVoIMHgQXT089DOZfXoC4rmhgWI8GmcrZTvfZhT/c7+uROZ3kBanYh7Z5Z7A7+j0wKivVuwIaXyrw07644aZZOOPMYXr7aLly7kTul+CtU4661iqZX5qtHXOAEEeUDrUwBpbUEzAdedGWyhYkgJqaRLtswm+xOZoqSTAqsLsuHcgaEVGM6AvX50wXQiHNonJlSGqw06EEa3RGIeN7N9IAThDorGqvo30f27NgtTyA7mxNQYyG+LibDrOE7MlFB7K4ervPEsl+tCTMkmJz5y/0gRkATN3w1R6xTudwVH4fAviOWCGyCPktZp6dH9gnXFdv2TEucq6Sbu7xrWxrLsJf/RrY8pXi8ke+GD1EGd/DL/V8Nl6CHl9l0X6iODsPeAXNDIlXBVR80ZtJNeWA1yO2btdSy7ZA5rOEr3NAJMPzrPYRUMSt+3BjhutHDM8yCQnPez446dNW+xzhlMAz/Uo1xbvxDktkeMJG1dthPtPQ839yjgiIOzPxNDArWAaHonoSbc+BGyN3MyCOvgOIvxQ9V4pVCoC3zZQb8R/D2hA2rid3HWxvj7mA67l16pTKFH/av2GaMyGwHKxnyw0c+FxmYx/kK9SuZu5ylTye39PY00kxtoFiJcNmkVDwakO1eu2pEYLsviMVrH/MQVs1yQnUgdW3c/dT7Torkb/VYR1EGrTxC9bm+Pm7+fPIFHwGoq9cKLNijkYRTJ3q3TlZt3hPokmpHRDaRyVGIPtxsDPXIp+ BpV4Zsas j+sMmBvmSjwYptsyBestr2bYe0kcCnSevECztvEH6qIo+aRwdSai1K16HnIvUth0sT+1mGQKncWWLoN6FOKpSUct4Tf5+YaK/MnZh6At4mVrDU3P6BlYNdPKEvuJWSLDKS+HUEuPcZxX3Uim3DLG8Vkb3ybjoSk7d9Bgsr7A5+HzGUwMUkJoQ96U1OCUnHNcSa66lXIfSnVRguAZlNO1zVXmdHW7t9aqI8qrrWsCOJ+0FmwM6aLiwY4FkIJ3uX8ALWokoaqFdn9RRReayU6nfFiBy4CYl9b3cLh9nKhxvwb9znAn1ReNyRAdUmOkfG66Q+AfcfppELSk/ybKhDdix67yN4O6IhtHRaaH9Tdc9irSiGTg= 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: "Mike Rapoport (IBM)" Dynamic ftrace must allocate memory for code and this was impossible without CONFIG_MODULES. With execmem separated from the modules code, execmem_text_alloc() is available regardless of CONFIG_MODULES. Remove dependency of dynamic ftrace on CONFIG_MODULES and make CONFIG_DYNAMIC_FTRACE select CONFIG_EXECMEM in Kconfig. Signed-off-by: Mike Rapoport (IBM) --- arch/x86/Kconfig | 1 + arch/x86/kernel/ftrace.c | 10 ---------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 3f5ba72c9480..cd8addb96a0b 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -34,6 +34,7 @@ config X86_64 select SWIOTLB select ARCH_HAS_ELFCORE_COMPAT select ZONE_DMA32 + select EXECMEM if DYNAMIC_FTRACE config FORCE_DYNAMIC_FTRACE def_bool y diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index c8ddb7abda7c..8da0e66ca22d 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c @@ -261,8 +261,6 @@ void arch_ftrace_update_code(int command) /* Currently only x86_64 supports dynamic trampolines */ #ifdef CONFIG_X86_64 -#ifdef CONFIG_MODULES -/* Module allocation simplifies allocating memory for code */ static inline void *alloc_tramp(unsigned long size) { return execmem_alloc(EXECMEM_FTRACE, size); @@ -271,14 +269,6 @@ static inline void tramp_free(void *tramp) { execmem_free(tramp); } -#else -/* Trampolines can only be created if modules are supported */ -static inline void *alloc_tramp(unsigned long size) -{ - return NULL; -} -static inline void tramp_free(void *tramp) { } -#endif /* Defined as markers to the end of the ftrace default trampolines */ extern void ftrace_regs_caller_end(void);