From patchwork Fri Apr 26 08:28:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13644310 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 9B911C4345F for ; Fri, 26 Apr 2024 08:31:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3245A6B00B0; Fri, 26 Apr 2024 04:31:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D1D16B00B1; Fri, 26 Apr 2024 04:31:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 14BCD6B00B2; Fri, 26 Apr 2024 04:31:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E69816B00B0 for ; Fri, 26 Apr 2024 04:31:41 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A31A3160735 for ; Fri, 26 Apr 2024 08:31:41 +0000 (UTC) X-FDA: 82051014402.15.CDEEBE5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 2DD9216000A for ; Fri, 26 Apr 2024 08:31:40 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LA0moLCc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.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=1714120300; 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=psLFo6TbUqfvrSKPfWSlG05Is5yttHhilYZp+m5QpUEQpQLYhd/wIaDRjJXCn9p2h8EBAG voiP/gFa/X2PrkOLCqo//hvvMAEEulUk+69NuuPOSQb58bdV7N/htLFNnJ5VujNwgZ5j6G NVK/6I9XzQIq1nL/H5JDMZQC/d2FxZo= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LA0moLCc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.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=1714120300; a=rsa-sha256; cv=none; b=LSTFrQ5Yl8H2vHz+EkVb3xJ/nTruUQNTc7H1YgHe8264jZZ5MXQersBXSGfKwGtNRIAfjY QRV7pON/cQ2GA4qAvYGPC3x0bRu2BFcyPw2bpMF0urVXRYjT050iPiJf0qeKFfhLWw2ICt BaHkfz6deZAjXk5hiHKTi1/wpFvQw2M= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5A6E762012; Fri, 26 Apr 2024 08:31:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DA85C113CE; Fri, 26 Apr 2024 08:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714120299; bh=IjQRyjekukMjpd5h0+fXfebHcomYxPC0ei8vi/yCB1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LA0moLCc1XyAaxAPTvc2WyIttGhEB1PUkRgD8LjafqmW1PC2dnh9KEdiQSzuSb0T4 YpX/elYXFX8hxPbLkyV1qqjNauUZIgcZg3kzBpvpU6/SKuLo4yitJSpCtiFIFbCwVb ORmYodfdLWjNxtFIjvgEYglV8iMV/tWBwtMAZsyEEgjuUyNZeEVpzh+A6GJki4rfG/ DhmPLsgQ0pxg/0E49LfmzQ/p9zYIhFidW2Xoh1epuanPXsEfkllchRca++MFsCY3GX XMZ71Es0P9TwVba3X9SadBYfOb5dasZkd5McPlM57jv3qH/9znon6bHqyIjzUQqGd4 sYSWwWhOXkvXQ== 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 v6 13/16] x86/ftrace: enable dynamic ftrace without CONFIG_MODULES Date: Fri, 26 Apr 2024 11:28:51 +0300 Message-ID: <20240426082854.7355-14-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240426082854.7355-1-rppt@kernel.org> References: <20240426082854.7355-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2DD9216000A X-Rspam-User: X-Stat-Signature: o9dxwknadi4pxmhui9ozgg9co9sre71i X-HE-Tag: 1714120300-670319 X-HE-Meta: U2FsdGVkX1+By5duOWFhGjLTJNl8XVs7s9Oat74gEmAxWsMkhha46nzZRnAsIowwgPz3HgGgkrR1Nsto4h6ihuADHbwvs5eulpSiINYm9JjUVWkG/BsS6dOtCeQiCZMPvlsDRdQ1aznsOUYgqtf0bTx0fcM+qlaRAUkNbguZzpcnOpgXQJkLN5CgkIgmJB5IMojly+q3e2vtWGpNQBUCJHf1O1nndb5ixGZl1EdW5R5534rqQk2u+ZE/xBHz3g+vKYL8Qw4+tce1lAMxErhTmbP03AeHDWjefLnrFRB6GrA8o1kl2FY45U6WSBuXFzLf1+63UX63/KLfK2V1Hw4eptm1JYOrrze+3gePHkugBr2qdMX7QRH6X/+5e2Qv+xuwet+m7j4yhY0/XX0q8MnwJDZANUPCR/yHY88Fu3sfj2I9Hq4zSucn5aMGO++mTsxqzpIgVtxE+o0OOTaPP/7bkwcm29Iz6l37GCGZXpvDKQvLXIn1pdZBG3mHQ/5Tu6mrDbqWVHiQmnkGJnr68SCwU2QxG5s5iTRodzddf3VQAq8VqM/Co8wlLrsbj9LxGMKvZrtBCZU6TbpLoAwIIDPRZlbDANkXdnLYFd24wMfydzG+JgQNjsmyFdWgjTSVykcySXAK2ffUX0zXNQxYtqyP1FOHig7pfEfc+bh/NyY2y4UFr5f6HKnZtCJKU8gWxC2ctfz5vqwyrSFe/Eg2brxYIsC6yzFl0oiAuZFEhlfk/7+Gm1NbFGBDQmjTXMRsbR6ldTZ2J0cHxzRq4YSceGgrmkfCRSZ0Yt6fQwmkU/rJ85AAOAwntwhGW4lPQAgqFhrJWNpLP3LXV8cYr+7aEbqa09iipovoePuora8qtlXpuUmFd7pKlAi3NLKYNJvDIaCXB09Nabde/Ry5emK97snNlBpJrGmZTZM3H5mTx/hTldRciWLBlin6Y4kzLNv1Z+qaToTxkJJPw0m0Qi9T4FC PEdqfRSP QbpbnDSTX5jbL65ISdJrKlYF9ZkLiwtOt0C+E2BEaU89odgdbnDz1PLuUI9HzJV+FN4BCALGd0ZnmmJ0l6bdh0gVTYkpTJ3AMaKDwkPPjMP/BYrK/1LPxqtUKRIVe36xbRwr5mRA74INvDaY2af3XTjSnqQ== 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);