From patchwork Thu Apr 11 16:00:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13626222 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 3E78CC4345F for ; Thu, 11 Apr 2024 16:03:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C00D96B00AC; Thu, 11 Apr 2024 12:03:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB13B6B00AD; Thu, 11 Apr 2024 12:03:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2B0A6B00AE; Thu, 11 Apr 2024 12:03:58 -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 82F986B00AC for ; Thu, 11 Apr 2024 12:03:58 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 54CD4140C68 for ; Thu, 11 Apr 2024 16:03:58 +0000 (UTC) X-FDA: 81997722156.06.7957D76 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 8A3922001C for ; Thu, 11 Apr 2024 16:03:51 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KWHNNAcI; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf03.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=1712851431; 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=43XC4vW3C9EMzl2QgJ3oj/sFfpbUSDLKB3H0nJ6PbwQ=; b=1XRB0Y9lUtnxGujl68TdlPdg4v1ia80x/q4+TUfcuZXdu5XTavHGHA8q/1xJRmrtSH0HD1 Trl9tvYGquQPP4Y7qLrkXy9aGN0za/gibPj/BBoqTUO0BMDCg1DLr627mZ9Wd0vwXKY6cn JVo8gWf91yT/5CER8k6EudFJtuoHOFs= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KWHNNAcI; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf03.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=1712851431; a=rsa-sha256; cv=none; b=3vKmnkm4ZnucJzs0+8cmGBHhUavCjs0PXHhZ2sEXi4BrHO1JH8VFvVI7sUeRidtQu0WA40 cAjeqJxOeYVNmyEEbmlFhpefFem7bY+Dt5BP/T1CcTy9HZxkgZOisvKCS1pDXAvKl5YtCi W9tb/4e//kkJHhw72I+V0H5OGpOxUW0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D4525620DF; Thu, 11 Apr 2024 16:03:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B264BC072AA; Thu, 11 Apr 2024 16:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712851430; bh=tleyEU1lUC0BC39QIzg11FQLbY7rS2GjqFF25yuhwvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KWHNNAcIx/mLULvyCHWFsS1YLjSZIaezlJX+m72pGZE/RNEbdBx5UBl+FwhfwbSxC fdiUBt+vEpaP3R/bm42w8LxmAlAgfVm0TZBD86qoaEKsjkv1HZ/9uJh3DXf39hjl+Z S/10ZwZSzTC3Znq9H07mRCjK8broyIQBbWWLJf3tk8B+pnbnTfmsA14YuXJlRy7DTL I6xnz4e0u5vePgQqBHaVpuuAl5Img7qwFaNWAmNczEjvOPFISuS2S3W3ypFIfEcoS8 gbo3+vyOWtGb9NM4v6WJPlqh5O74/8/XHwwwKYKPbAH9YXX8m9nHRw7GlWJhdO6RJ+ v5BXTq7XKxO3A== 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 , Michael Ellerman , Mike Rapoport , Nadav Amit , Palmer Dabbelt , Puranjay Mohan , Rick Edgecombe , Russell King , 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 v4 12/15] x86/ftrace: enable dynamic ftrace without CONFIG_MODULES Date: Thu, 11 Apr 2024 19:00:48 +0300 Message-ID: <20240411160051.2093261-13-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411160051.2093261-1-rppt@kernel.org> References: <20240411160051.2093261-1-rppt@kernel.org> MIME-Version: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JLVDui6sBp9X5dwlbotp+8 I+0l7p6j eW1GkxiECEfjSaYsdfsOcuAp60MS7+fKkX2/qpkp2xk7C8eKE2ToyqOq2AdfxBLgH2eVlzmMU24QVeaEaUHrb4nVSVLjAi2ybVYEktBTdhUs5dkYiCzIkvYzZOT+tozXYs4oyQN4Hbc38/ZtxQuziqRBEqK32vuLf4unUbiZ4DJP1r4XBrG+axvGx3Z62UPK6EQcUMSm9vLgNsn7UiBtwKZTYExQ1ppwkAkb6PCAuh9zR4ubhJrcaXVH0bwZFurLlqKkEuEoAw2ji6KJXCDyk4HJsP9sSn+9rqn54JOliHSbAsNMdbaKblbpxeB6rEJzFM74bQ/hB0neq3FL6EqDWMKLymZ/T02O7u7gWsK2Eiw4c5TQ= 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 e87ddbdaaeb2..5100a769ffda 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);