From patchwork Mon Sep 18 07:29:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13388980 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 A9C69C46CA1 for ; Mon, 18 Sep 2023 07:32:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4311E6B028D; Mon, 18 Sep 2023 03:32:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BBE46B0290; Mon, 18 Sep 2023 03:32:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2369A6B0291; Mon, 18 Sep 2023 03:32:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0E7A46B028D for ; Mon, 18 Sep 2023 03:32:05 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DA1A9A0C3B for ; Mon, 18 Sep 2023 07:32:04 +0000 (UTC) X-FDA: 81248899368.29.190210F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id 11C6C80005 for ; Mon, 18 Sep 2023 07:32:02 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jOnWnURB; spf=pass (imf30.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695022323; a=rsa-sha256; cv=none; b=oF5PQWxiOsBsodkxoxwc8D44wQAqcMaaxx6y3VVvDKBJdv9Ehtgdr/wNlrhzNS/M19/2PV zRwMMLx+sZ0jKSZ0E4DiFbGs8HOOisM6Coyt9xrKLn4yaMQ21vtxL8OoJe4zDt6Fv+CYWe pLhFPl7nMD2LCnbx+mJAV1Gxsj59szg= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jOnWnURB; spf=pass (imf30.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=1695022323; 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=pZR7i50VIMpGPwB+fYLRiSUppIV7vmV9jffC49cC9qk=; b=rgp2S2YSPD3MX7j3qYeVMqVBWUxZZN0YOI76i9VPqJ9+G4agQnjtn/Y/Dski4Ch2QsFiIj wMRvVTyhPVWpF3KeD1PPEmM+J2r35nFux3UhQeXs7LOiwwBWy/jWWUF9+eYHFwSFeOD/SR bQBfcvmJ9Yi8V3CaxgIFad3QXFFLS6I= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6804C60FA1; Mon, 18 Sep 2023 07:32:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE792C433BC; Mon, 18 Sep 2023 07:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695022322; bh=1UL8tl9eANdNOFG3ZTSYgBTww7VCSn8pNWCEuJfnTK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jOnWnURBWcrt92iQ1E5Vr3mXWyQ6RAJ4i9B8tsY7FXOUVwWaNtFLbRVsEzVfJ0Nfg zcF2T76bilI3SPkaUjpMzEfs1sQN/JzTRMR83DnXh+Ov+MJ2AuKwZwF8Fnu/AObC0k QAdcrio7/1JZevOAFEj9aMF9cUGQUD6UCX9K1G2jVF2I2HWuIYbnj0wy/Rm4EXVNom HeAH3TaXGuMZDe4Y3BnUwv/DnuIZbNW8G+v45crhACvScxYPJb49nAjf6MNnqIIZFe chFFMgGweSzKG7hh/3g3keI9zbSw1HmwgbPcUexA3rwgKV2tInhKeo5IsMuopaavQ2 VqOvvHTW8VtZw== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Andrew Morton , =?utf-8?b?QmrDtnJuIFTDtnBl?= =?utf-8?b?bA==?= , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Heiko Carstens , Helge Deller , Huacai Chen , Kent Overstreet , Luis Chamberlain , Mark Rutland , Michael Ellerman , Mike Rapoport , Nadav Amit , "Naveen N. Rao" , Palmer Dabbelt , Puranjay Mohan , Rick Edgecombe , Russell King , Song Liu , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , Will Deacon , bpf@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 v3 11/13] x86/ftrace: enable dynamic ftrace without CONFIG_MODULES Date: Mon, 18 Sep 2023 10:29:53 +0300 Message-Id: <20230918072955.2507221-12-rppt@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230918072955.2507221-1-rppt@kernel.org> References: <20230918072955.2507221-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 11C6C80005 X-Stat-Signature: yk81k8wp5mdygpcw4kio6arwf53o1kyc X-Rspam-User: X-HE-Tag: 1695022322-329436 X-HE-Meta: U2FsdGVkX199awmVAgTGJQUqJgtqiVJOWjxScekzMVGUi/YT3Hc+LKamIKXLXnhUHQhof4u0X6+lMUGP0R7zFcB1pQhXCC+OW59ClLBqgcPpu8qdlqOVZeCiJdFUpUYppXeo1HPmBVNLtjWCEaXG5uVzqa9VYLn6UPXN9VMI3pzvX/u5xx1frkZk43uOujc0oNmsHlRydJYm7W3ytBpo3T78zNN3nl2CETHYq0BROtwE6HBjPe3QOWpc0CZPUIauQ5feMRwq3S6WpmfdfJhfPfZ4NvVUPRg8m41suoPqHRldxk20pDj4MqOFI2ILawGkewqEcyd1T1G450SR6mEI+U9JpRk/P8G9DEgx5KzlegfZmbEp8DwFMyYzGQhoc6sse/w1tPVRortOSbuFPMFTDaI6u0VMXrMCH/tf66ONkW9y42lVwx7R4ZebRmuBwQcqt+XHbv3Jtm/U/9h1X0uEcfq76hcIQ7f41gmrcIeph1ExTYgUfDIr8RZmFsjj0eoE+pXmWDqnK1zcR18lrOq98QXor2JE/52fgjtEqo791dC8AvIDOJdXy7SEuJn07KZZ3WZFouF5gwGTdkXdbssWGUknJ/hE/wQmRAwIP9FrzteT78dnkq+UuORnvPPVEpiimkUj+2FNV+nhd9V2a8ESJBk5nyeuAQJAbIirHPZ2QTyDHACCqryfTkomDP07Mjcgee3e49JI/Sd8mAm6F36vTQl3r8Nlw3Iwy64wR2pdSOhSDcuErw6lNX644WkSgb3kAC8i5N3ltASBufOGbvNO+iHLo9qwiulxbTeRzqz+ieNNudTf+8cEdBTB7WHfpf6+9VTni5aL+ExZDNRIhyzSyF4Dk2Vv+tujurUNzcWOAQqyo4yssudCOKk+3xrWvA19oy0wsGOCiUSArl7TBRUsFX5CQJUDNkCbusCP8X/g6INw8I8HlJK2cLlSf2/nWW8lyaQuw2T0EpDT1ySxOSA 9DXMHxiP FiqvNCWF7ltLNxctv7ARoNvWu81ikTVrmVrdy8f3W3AetXUhPHTMZa7d2J7JEUj/iMJDZ/43nT4SskASNu3u+9IYKR8HPPQp4pmsfCnF2bcFqCYty5gGbDSdJmeu23op38vJdWJLUAoXKsgnp2tg7MjrLw+smvXdbYXHKRzEhlvnKtnOvs0OhsHbHLBTVMiujrfJngsJJHdzMVtwY8rkCYlRqvCkI4Y+vaBsvp7XmjgtKm3dz26phUCkwPzCwCh7qwvQebbnCYR0BhmaLZL26ex4BDKmuhHwJ4ZPkQfZp/O3q+9VsK8RZiwq23V//48tOkwy6vYoNvXHCTK/08tkbfmJxNcv8Y4GO7oASonXhiPdE55DhtPACRlVClixwaBpeWaw09Le09YexfhIc8RgKmuyXwOLGkGkDvVN4kF5MX1un++KduI320syIrbrvNhEjsMSN93sxyt+HlDA= 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: 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 982b777eadc7..cc7c4a0a8c16 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -35,6 +35,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 ae56d79a6a74..7ed7e8297ba3 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_text_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);