From patchwork Mon Apr 22 08:50: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: 13638048 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 BE749C4345F for ; Mon, 22 Apr 2024 08:51:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58B746B00B4; Mon, 22 Apr 2024 04:51:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 53A9A6B00B5; Mon, 22 Apr 2024 04:51:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 402E16B00B6; Mon, 22 Apr 2024 04:51:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 20DBB6B00B4 for ; Mon, 22 Apr 2024 04:51:16 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D41911C1046 for ; Mon, 22 Apr 2024 08:51:15 +0000 (UTC) X-FDA: 82036548510.12.3C0DF74 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 3059E1C0002 for ; Mon, 22 Apr 2024 08:51:14 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sO4wTbB+; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 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=1713775874; 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=keoPmlRYBC8gJHWQFpPxOF4zc+hg0eChP9iHcJnehgVo+vuoJ3yHu3nF8dao1BawuP/Apn I4AWqeXqv3JDwy9nHggQ/7073qnEnKB38G4hh4D3l741f0yjV33Qg8u5oMa9r707CblEsD 4vack6rOQpnj4K1+8omq1bACKvfhmV4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sO4wTbB+; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713775874; a=rsa-sha256; cv=none; b=gdBxB34TuWv4wj6ZoTEvbcNBWxXNv0fSOF9a76upYkFWLgbuW2TZ9bPOS8Xoq0Mdq7M6cZ IH2d4t8YIxeggEAUtZFD7GELI5f9wkEkzTQmp6S+NFSLiwAuVHmh1cmTC9XKPUy5kV/kc5 O5cy1PMcsi9SkqDczMtIgi1iqd6DGJU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 661C260D39; Mon, 22 Apr 2024 08:51:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D54B0C113CC; Mon, 22 Apr 2024 08:51:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713775873; bh=lHpN+d0QRuUVXJIB1eReja4FWUfXvpd+hME9aJI8tNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sO4wTbB+Milo3xS+lLBG3XWGzAtuQNj9vPNus4JsUmgfbe8gEP4GhjKuaPghll8ad AIL4PHWve7PCKN2gpwuzIrT1A0qMYLaMmX9Mbk5GP1i+0ImBflhvG/HDKJ89MJLS7C NSegGqr+fYAhlsYGHPsTd4qCsBTID69/OIaM+hwcwpdK/vdai/Cmc3WZQUIwFKMf2l sH+rF9Y+jCRKBnnUGS6fxPjHVdYE9oR4TuuD1NzcbrL1Uo008iZkwtxC47vH1y20ws N/AdwVXRGgfWFdYdBbqVwJ9sHu6lojECBJYUuES8MHpkRwaKf/ofhZDClHBd2mup1e zf4ynpfxlW1VA== 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 11:50:25 +0300 Message-ID: <20240422085028.3602777-3-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422085028.3602777-1-rppt@kernel.org> References: <20240422085028.3602777-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3059E1C0002 X-Stat-Signature: knxdceyhip8kqagka8qhhhz9m1a7rzet X-HE-Tag: 1713775874-380270 X-HE-Meta: U2FsdGVkX1+7SA9zNNwMMB0gVjQsn6KR4Ge5CNM9DvlDFkJM8RKK++xwpNhjWDrdHBKVXLrjZVMvjjypdleIUzySRai3kPojjGa7glQwpUOHhktU7b7hnUnbnIJ2iZ7JatjZgHc0usqszaKpWIALjdpn7bHUPzUh5bBsBLeuuBKSoUVtUqXCi36dQUaEQq4LHssffmKS61tAPe7ss53O4NxbtcFOUrMxHOiRuUCxqvr5G+7dXz5gRG4a1gVwtqcsL1M5pwcx4Yc5Z+vD8/aEASfFfE8aDJmJvhMgsBV3JJnyjp2PdU5nbPiqY8jzp0NvPfoerJ2aTAwg2O8bCzqqgz+0KHQCsOk+k6LOPtOpVxT/Fl9ruTAcKD787lT25haVf9vj8L7jGRIpLPNNYe1ObCVpVxsl5yLVN5xuWMV7JG28Jac1tu2GP4sS/aCJUhZGb57tD3YN5uMlzd3a5iKRIC3QavpF4FNbDyebNj2aPdqwCPfPX1l1me4C/uPdrLRrzQD3lqFnN6TfKvnOYbTrIKVxgBcId7az+m+HRQ/8NbsvV4LbU+g9Ze23KfRL725JsayaXwSnwx3mtuRmdYk2+KPnBPz+PYZmN56j0XeEAiV0Likh44BoNq/Et/9aes4PDWhzHVrdsa5N/GQDwSJ8mKCVIMRGdIM2YvmF+j/tkRkWvs5gHVb0mEKq0hGQ9NGpA6S4QCrSB060ygJXa2iiB3WuFmUo8fAngDDNiYK6IwJ56If68MwvCT3HLHxa4B2qfah1m48TXvKfjgUlCrly69i7MuSMitc/g56aJUjKWCkAO65kUdYmeQaFH/NxMnQeQgsi27Ei7pVr+VWeE59KphtdY7d2wfgrDU3hNAOIU/TcRNCx8RhhedsU5jbU6SZHH+g+D6dt33n6YBq+qqK6RGnkklzufdx1vjfUrcT0UGxotzgFYtKv5a3cmA/V/AuRLKsAuPGkfVrgfIgy1BT 1F+2wbCC UdZ41PzzSj7+MNq6848eo5xIy2UNyXTGsuie/hL+PAiA9PbRC8CBqX4VnrCazyqkKX+kwPYc2zRvxkgQ4PW2Bmdz5U6kNLbKctcQTWyYL9XQmsSwqwTi/Zfmc+A+xlnw8y7noQSAdfIJIVcCraKxMD4pLxlzbxOVdeSbzUCaO7hO1BJ3qfRBzSOzCsFZaUVUUBddLB6Rg+BOhnzSNOCn+KC39SOcWj6z2VFtQsPFIGMCTVFqluXha5Urhpm8d2s92n2hA9wKP8hQK54IvR1jAyGKYT7FShC5eEzZ96epVPmjFsLurpF+TmMEJGuUqXeCztmEC03+6EHcfQZ4DFxeNeVr73gTujADvOfeSxp+P5nipMVo= 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);