From patchwork Mon Apr 29 12:16:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13646781 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 64447C25B10 for ; Mon, 29 Apr 2024 12:19:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3A186B0098; Mon, 29 Apr 2024 08:19:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EEA6C6B0099; Mon, 29 Apr 2024 08:19:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD9476B009A; Mon, 29 Apr 2024 08:19:12 -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 C19FC6B0098 for ; Mon, 29 Apr 2024 08:19:12 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8AB7A121AEA for ; Mon, 29 Apr 2024 12:19:12 +0000 (UTC) X-FDA: 82062474144.04.0C20C0D Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf23.hostedemail.com (Postfix) with ESMTP id 424B6140017 for ; Mon, 29 Apr 2024 12:19:09 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SPgdaeYp; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714393151; 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=3EwmMTzC/Bj192d/Pf4YlDIL18YUY1OyNaj/+CH2hNSRRXhRkZMT28wCqd+WKYtMncFzcE PYw27g+ncHRd5eWCSd+42tbPUhG95kqw4r4NAF5R9qJih90Qg/jXT0bhz3vM/ljUx+Sg94 eiVDf3Aly3EVXXIlTmQpG7hd+RcuhTc= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SPgdaeYp; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714393151; a=rsa-sha256; cv=none; b=ielU1/CZlRtKVvXduEmC8sPAACBohHnBJWLe7qndf2l7l0UBjOc6tAcOE5tobjrZx+4i/0 qpJOzhq+FuGd30Rz+2654pN5WsyCrcUae+fMej9OScDaD1YuY1CE6TIUMSExf6qfhgbmrC YHLEL8z0tejxjcDNtZU/AJIPPVZkCrc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 596BDCE0B62; Mon, 29 Apr 2024 12:19:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6B74C4AF51; Mon, 29 Apr 2024 12:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714393146; bh=IjQRyjekukMjpd5h0+fXfebHcomYxPC0ei8vi/yCB1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SPgdaeYpabv0yHFmtuafEHgxX9ZhBEqjRbAHz/5OrYvplh1qL2PD46cmSJh5suetN MkVsDxw/Td7Y1re0PavY5BxsYWOYTVZ0toQRjMjgfi7wJUrE/gCo65MYq9y2mAmpuA dN1l/5M0x7M6kCdxTVfIdYgmZwlVZOFC2YnDZ6ehAMmmVizJWt+EyHyMrGsVUN5Mg2 RChPQ3gUYMGrhlVhXxe/Xqs3QcR5pvQ58YzMpD6UiLTiYy1Edv1UnecuUBwzl1Q0EA Pf9ONvjqTVc5Y9+LcfGa4WNrm/awTw0lvt7VBnXpkuN+acRAs394j6dfq2cKDLhnUf vkdtS4dR7I3og== 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 , =?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 v7 13/16] x86/ftrace: enable dynamic ftrace without CONFIG_MODULES Date: Mon, 29 Apr 2024 15:16:17 +0300 Message-ID: <20240429121620.1186447-14-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240429121620.1186447-1-rppt@kernel.org> References: <20240429121620.1186447-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 424B6140017 X-Stat-Signature: 3e978k13bkae49dhx3psoyqmiu8aktck X-Rspam-User: X-HE-Tag: 1714393149-824251 X-HE-Meta: U2FsdGVkX1/hPjM9XpepYy7U0AnLhnLHfaifKhVVb1Hr/F6wrIR0bXrCS4lLBoE5mi7hQoRcXruw4VAR3YiYUVLIT+tFRM5ndnmCb/O3XWcuheQ4K6Jk0dzDRJ3tE48427ExW4B3aSLg65hXCAxyT38fFWcosiNRXODQjW0XTtxaA4D/Nzl8YFQbTffNN1ZRDQIv/zTx2JW/ku5EB1od6wHfxpPsMVx4BTYZBED5lVljGzdmrJRjOsp+14neC6R+G7fJNGNdJwGV6Y8Xfdkx8oiaeEdLsJwFb1cbGj3hm5o+S+fm2gGlway9BwXk3cfRU3TMPucUJsZZkMPOUcCFrvBMuMy2MMu/v2yaXY2x8fnV1Wc+Q1C4XguOyRiIZ2IzKpgB89mquqcFcdElWv2vIGQcjaxNWuLPg8bPm007+cre32KPesE7kW4az4tmZ9ggghCN3sz6r3St5pTY2okB68V+PrvXMgKrwhNmsh48ILw+xcx428v8LzQH1yVAb1th6a1dqRge1juK8if5ZrSZbtvgh+FrBC+pQlhNwn0m42YPnDhZRpCq/NllCxHMcm87vS6g4GZ7fuQkqCklVXQh5ELCuGr6uD7ISpFiTrgjlXjrtdUbKvk6D1a6Ql6Ly6Z+eGXzdkURjLQzHGs5Ts6+SpJjvUKlXRVSGdHlAKnlUuhoNC5G0Cq2JSI9WbTBzVSIypL96bbN/WYc9PJLsm+RvbBfSIHclVdFOmJD0ueQuXYY025Z18B4P/yxvysj4FNU9ea7RP/bXUDORrFqcqbghXvc5uQ4XLc4pv5xWWSJFlI1DAe+G2CyqBNFCtgdgVKnCsBJsIAWIyjU/IfEQeLhwr20k1vxWnRnZrFKmSpQuc3ksHY4rgoImSquB3al19/Z3WBS9oyHLPhSiNAytrYLj2/PgGr76J/EB1H8XXmA3eJtin2R4xJPCu2TvUshqlE7sY6VRGcnNpJU8ee0yV/ 4lC0sSdx +4D4AGeBzxFK4JiZku3SrQzChRLM9TqK9X+ffd8M68/kq8ZBRd3bWCVYMu9tKtJ1bVrO9JF27lp1HT/WvX1LyQpTfpsJq7mCqmvfyjOEGcJpTH8LYsz5RS/FiWaVueihiOrjZC6V6ikOPKTvsfPUNMzSh67gF+leBLXUoVy/HYez8FEm2KZjdTZmDs5phsSfoo+hlLCQxXTp9Y0KH4S4fY6VuIdghUP2Sk+Dw87scMz2qRlP+L6lnAmFToBEBMlzrddcSZm562ra8gyWIGK6brKydRPrGNHDM2eRsvj7FPT/SY64PvpvHiYzhz3GOCvyG11L9OI2us3E5FZLfLwrlAWAvOUUh6jS2renme2n1JtqsIhH5mHgzYtaS/B4mpNRwcQLfW1fHsr0imZ+QYJIP/VY9/B8f/um7gNYU23+ygJdNZxiC9mITs9YwgQ== 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 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);