From patchwork Sun May 5 14:25:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13654324 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 398C6C25B10 for ; Sun, 5 May 2024 14:29:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0D746B00A8; Sun, 5 May 2024 10:29:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B96826B00A9; Sun, 5 May 2024 10:29:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A11326B00AA; Sun, 5 May 2024 10:29:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7DA6C6B00A8 for ; Sun, 5 May 2024 10:29:04 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 49BC5A149B for ; Sun, 5 May 2024 14:29:04 +0000 (UTC) X-FDA: 82084574208.20.04A6C98 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf23.hostedemail.com (Postfix) with ESMTP id 0C6E714000C for ; Sun, 5 May 2024 14:29:01 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cuVFtupf; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 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=1714919342; 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=bP6HuoUMXi9ivDdJhuywQ3Y30eb1dSG7Z8hyYP5sWNc=; b=ev14nMITAhhWgbYohmNrBDlVMtOTCU5bv0GmvFL0cHQZvwXg2cf5XIBBw4WIjko/bJBDal 9IUWYWRGqdNUtAhRg7yEull6qbBNnpUZ5xYvXgy9UL1fuNGNFdpjGhpvOPC4FqJMt3iVpY TQ3vUGZzIAjSOiJukLRjKVUFHAPM9oM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714919342; a=rsa-sha256; cv=none; b=JFZXw8wkhBpqj1RCBPlDh6+oMjV8/GK0H5zXqzpVAcvZ4ziH/zSz8h3VCiyP0g9tkXagtt OWE5C/I3hcZiwLfljGO/h2JSbRH7ePgPyBzJvdP1WVdWFgP8J3YUFw1aa4rm6iEMK0sIdW 7sP6ZEiQefvlCQhx7v5JzXDMLp8bwr0= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cuVFtupf; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 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 sin.source.kernel.org (Postfix) with ESMTP id E3BA9CE0A4B; Sun, 5 May 2024 14:28:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B27BEC4DDE7; Sun, 5 May 2024 14:28:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714919338; bh=IjQRyjekukMjpd5h0+fXfebHcomYxPC0ei8vi/yCB1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cuVFtupflLG9foxMymnTpolKk/M8bZjmlvoz/5eAdj/Z7jQ3VoLWttmwQjjfF7k6F gVRucLz5J7TjB0oz3lKSXF/Qfgn4YfiKtiBaspHSER9pRgodxhwQaBwBBlZJXEAbx3 itoCIx+2aKqrcMnxllqD/Xqq15d6gfl6nRuhpfksLTuLH3EHuWQluNRdW0IvqIbrxN zgi4oer7nSTtlhcycRpg75sJg7UMeotCvpnVKznt18uUIrjjgHbOqf1KjIF6aonw37 +sBXk1tkpAP2cobOwC0+bu9JCS4gou7ZT1EdLfDoRt1l+1jvKZ4OXqqsn3wKoXCOZa 26OgeAK2La2gg== 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 , Liviu Dudau , Luis Chamberlain , Mark Rutland , Masami Hiramatsu , Michael Ellerman , Mike Rapoport , Nadav Amit , Palmer Dabbelt , Peter Zijlstra , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , 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 v8 13/17] x86/ftrace: enable dynamic ftrace without CONFIG_MODULES Date: Sun, 5 May 2024 17:25:56 +0300 Message-ID: <20240505142600.2322517-14-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240505142600.2322517-1-rppt@kernel.org> References: <20240505142600.2322517-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: ukyede6bk169g7cjma8p7dwf6fhoyhwi X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 0C6E714000C X-HE-Tag: 1714919341-70804 X-HE-Meta: U2FsdGVkX19hkfFm190nE+ABJRAx+x2jqYQi5n3Rhiks4ri05Wlncw8Oy019M4ijP33EDsgiu3WcG6buNFDbIZ+tXuYuPCfx4BLC+47vvbtKdMsJ8g+S+QOc3xQ6DQQlQGY1cM9TC+j0xw6lZP0FMWddS5wyu1sUCNEzXDm4h+6GRzr2LudoVzM7XtKHyQeQLN4SKRHJebSEW7iGXo4h4WzHhA4MXNMSS3U5hRJvpGjYbEqGZrAepBxZnWL/Y5uFVngdwDHvgkF0lRGCKOYRuYjzDRukh7TJE7jjaN5/CYrKIiuwJxBFyVhVWEimkczKrvgVxIgVKrOxTcvQeAS5orbKpDo3d/x9/NBd6i0fP0ippYYTduW36rcG4ucANjV0VZPKwQ8zsTriwPiLgCUdxr9JEw/FIWs+vXHdbXe8XhQSh/Y+Gh+tEgHfGvinNzgbwFdm4rlFA+AaJmJlLwF0xCLnZOccHsGax6dZZ1YF57UPF+xcZZDLL+ParjlaR/bKyyG+tksEjzAfGFlG10J+4ahkaxvOghUlGjPwL2UFF/VbuarwqJ7A8SCDYkRc+LwYfhtwTh3FNBr1L0uC4W98rwqA1138xoVt6kgoQ5GnxoqSahSwEpdcBOZf0LxCctoxypYmS2TSdAUIWB3uxtr44psBIwsa5fNQNI7Uq+8GgPvIJQcT+1ejBNPYyFTcc6JDWpq1LgLYPGv2gRcthwJSjrMoV/+/bDcsF0wdq4vEsW1sUKWkasln1jdyr8SxT9pS6EBOUQ2Aoq1lFcMfiAn6NnqvrZSNF1Kqlli8HaAFr9UN24bFP0widq6bc46XVfb86nhgxlaajaE1rCV+xpVRXBNJYoA/ZoX5IVLzIPdbj0GEzjFDNHY2y9VWMfdwBAKw8QotWRF7BHe05706SSmuRfTYlwD2rod+RWZFOwHhfsH/X9f53obZf+7bCQFWKbpOaIjBTVXfJFDTLud1mJP OWwSYpup 1XfhwM4PvVkzvarEsx1COz0VgCd89z8/z8lb2obWt1R7zMnHmjyrdRSize9ubj2ADiAixYnVnQsjOzr9ncNUKw8BlT8geKraDOzlFC+6HFCMqvldnJqoudRy68q2c+NJ1gJcO2ELjH5yWy9xnttsqoeODCiXYUZpclnSPYMKIIQmBO98WmVSkfJNKo/DQuouQ/7O/5bYuzJz/rfvvdrX6mQRhRBBzNPYInwbMUONMqcmD2PsU0C4yHeUHjec0IuMnB56NvIWtzWeG7e9c68EUF/EEsZhdDjptvaSAJd3MYjxz8KowHXUpxikocA8s2UFLOIvpAGSVVypDFUPmpgH0ByzCwz+MEr5/5kuGrHXnY3FzXcEW1dDVwRmdK2FqAt4WfSlcniF2RrkrpIYISU7w6FeZlQIxTdbnM/V25JOpYni//QifJlWvd4MRyw== 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) Reviewed-by: Steven Rostedt (Google) --- 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 4474bf32d0a4..f2917ccf4fb4 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);