From patchwork Sun May 5 16:06: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: 13654475 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 D846EC4345F for ; Sun, 5 May 2024 16:09:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6944B6B0092; Sun, 5 May 2024 12:09:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 644EE6B00A6; Sun, 5 May 2024 12:09:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E5716B00A7; Sun, 5 May 2024 12:09:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 30A2C6B0092 for ; Sun, 5 May 2024 12:09:25 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E0934C0313 for ; Sun, 5 May 2024 16:09:24 +0000 (UTC) X-FDA: 82084827048.06.BF40251 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id 3B34718000F for ; Sun, 5 May 2024 16:09:23 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=T7Y2tIoI; spf=pass (imf16.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=1714925363; 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=BahXYWLskul0BYODfxozKoAHG+VjNURddCetUsFj2diQY3H6AttBG7OnAONCk2HFEKQHia c8LUuy1JGJzpf496rnjY6aFdagimXbZaRKDZ7KwTFiPHbQLBAMXbl5Z/4PN8iP8S9yDTv3 CMwFoUCPHRTQdNqtCRub2v24VTeGg24= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=T7Y2tIoI; spf=pass (imf16.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=1714925363; a=rsa-sha256; cv=none; b=zEJJfYmAlvaB+bLWaPxoVomdYE92RvvEsKvX3+j3fsCkv9PiSKczjht16VYagWyppM/8s6 8P4UfZaG+yDIdCKDY+ME6ZuiL+7Q6U4DhRoLYftaZTuNJRd4SoBB8AftXbxO/deY0JzTni b6XeEXAG4GAbtRewrd1XkbRySQgyowU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5F1AC60CEE; Sun, 5 May 2024 16:09:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC4ABC113CC; Sun, 5 May 2024 16:09:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714925362; bh=IjQRyjekukMjpd5h0+fXfebHcomYxPC0ei8vi/yCB1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T7Y2tIoI+ouDiNcQpQ86aQxIzvrgfLXieAAtowk4KtTkMUCc8jxPAWO18JJ7SD9Xt UGr6EXLLow4ZiiZ9f1+fF0t/CKI95SkQ5wNiCan6darR1D58vauIEK88aQiX0uY+yK fFic9b/6Dr9IMMoO9aumzLI/hH0HrlsLDUsj4bpN4eBOrAuFq5d4d7SBei5FXxjNvb Qcolv2fZ6kgJVW4Pl5ylISFS6jnJLMVovlleGEduKhjiJeQ2hBhy43GrygVJ8E5Xuh cAZFS/Jh3HvrD6rXC8n01vsku8OgU0v1fZ9t/8pvT0jjsUQjs6FrZnrM7QlqVnOESq LuLV4gmANK50Q== 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 RESEND v8 13/16] x86/ftrace: enable dynamic ftrace without CONFIG_MODULES Date: Sun, 5 May 2024 19:06:25 +0300 Message-ID: <20240505160628.2323363-14-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240505160628.2323363-1-rppt@kernel.org> References: <20240505160628.2323363-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: whep7s6infyz1o4zdpo3ta8676g6hk86 X-Rspam-User: X-Rspamd-Queue-Id: 3B34718000F X-Rspamd-Server: rspam05 X-HE-Tag: 1714925363-277540 X-HE-Meta: U2FsdGVkX19J0yce4UjIfRMmWwRutAE0hFjJgkNzi7Vwn7OZx/a3/PzXsHiQvTrg9bYHfunLPFHgajjCBKgIlRSUZZoE9JFAO77PIaGIT2UE8W95mIencLhsTZDnGfi5GtGQjxTXVw6B2m0UssdGJRIevHgx9fQ1RbnihPBieOs+48OvdIz0Vq47iF6wANWfnjb4sh158q6e39z748MMvLrOZpsnw2HqnLx1y/acynerplcs0S6yySOD+DhVj+hULk3BvzeGlD+JNnZWO4cLqumHbnLR4ZLzi5u41WLmyn4CNXZ54E1c0QB0HDD6hYzrVycrCoIm4Rik+xYZl9OU+ywDin4gJmcrg1DUqby07s2aeij7BB5x8Nz09yH2MLwxYL3tPGWrFgtDlSC58QZaN++SGXzFwqReqUU67NsxzYIi8B94CEPHhSLgaB61Gsh7iaTsD7VWoyzdT2lOe5AC2BV0t9U5qdbHEVNekSSiDYYLJe0crwg835Cgo7SV+v1UM+U+3pLthGNfeFQP6jo6SALquWo9x6KKua0OUievvLqSYgJWdLX7qeNjkPvBGZOioLHpu3nSq3/O/bdg0JGK4su6nKuNSj62BXYqPfZEHMdHE1bRWmMYCSSmUSenxb3R8UK5IeNKKf2yAGR7FnNTd6oAJECeiA0yKUFYMtAKH2ohVKstX63jgrN8ZpsIz4WkPslHJR1A+mwnkcVZov6M4b65j0qD8qr5HiRiqb+NRWR+1QnoZdeiWdLQkiA0GWkvyM+EIU3lOaCGJ5ZYlyBYk01E4Z0OlzJkdw3ctM4wUt2LdRm7J7ZSlABPxWh1V2+eeBGZIKtV77Pgb+mCADDtqVVSVDYEliRhPPbFFT86SsmtIFFKtqJBw5kBRN23YlvhPDaGwvDb8gK2i0fNEz6nwQmaikjrHHNK5LnPojnaQaFuGB1f+MHkq0+lMc+GlBMa/t6cgULwYnDdcRR34qf QFsg6C/V aN9K0R9GzDFWJakgYQjCYWKvD/mbS0vXfujBJE1KsYxHl18BRDUM7lABKNC+S6CcSZJG3MMpHlGP8dVP5N7p/DsD7tDYDwOzfOrCIhmgVBTfhK8CXVU/586mfCsowdwm5hqQDtnbsUW/YhntzXmTnMdHR+ywU6330Qb3oXVrTkM5+tQcpRDeorUyyyjb2ZvrO29AI2tftrgDRVGwK4wcIsMkSuLJbbhEZFJwqhnuHyGPU1ONM/j6wMEJDD/E7sQj94zA+Rd/KjWRQfJr/GmfD4u4wXnrDiyiXAvdfsJtxWMC0uAmfj0apkpYOX6Fapf7j3oNoxtlRBws4HDuMlFHa9i3BngOsoJrid9QzFm/g2DYW8j1RAFVz3KHZooQ3/ChDqUpS9QR4aFE65BHZ+zu2e8xj2+05ymWGniXRfn4qi009+J7GwTeY7gu1+g== 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);