From patchwork Sat Apr 9 08:54:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 12807751 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D1BEBC433FE for ; Sat, 9 Apr 2022 08:57:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=CEBVCS0q1N0SFIEyQASpseKRfMSmCZCzVFe/2ooYASk=; b=09bbb5Bp0vwzV7 SSH1ke1mMzqv84UvslCDI+dvd7JPHB96oj4MHJL3uHohkdjErkBwU3lpqcAgZWtW3QxzZTaQUuNUY GjypE8FebESlNX5qmBiSGDn7u6ZDvwqCbBghUg05yQF+gKCOsP38bB+G8isODf0c679GjSkVt7dzn 1DhKA07JDF7WWrufQBzh27eqXiSEOi4hPUPXeGHdYkS5buIFknyvE9ilIXcm1rZIlFReuoApVWAbA r4R7TU87vlNc/qNVpUI8QQRFIs6kAObCy0O1TgeOh/QETdyF4qEGBsmRByLfHXeQrhuUf/UTngljw 5Ss8H4i8c8Z9I4slx8Zw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nd6sW-002cya-Np; Sat, 09 Apr 2022 08:55:32 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nd6sR-002cyC-6l for linux-arm-kernel@lists.infradead.org; Sat, 09 Apr 2022 08:55:31 +0000 Received: by mail-pl1-x632.google.com with SMTP id c23so9933797plo.0 for ; Sat, 09 Apr 2022 01:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7HV1je4u5Ps2cjIZaWTRdZP2wZij+4hAKWpeqsFhAYA=; b=bcxFfwZMolC4nUg0WowB0NHBwGnR5c3yV2aW2R/N9dCtkb6t35Wd0tC7Pq7ArzSk4e fBYz6wcSdqSA1NyJP8DcFFwgHiJYuHKIbq+ieNf3gVCkYYdEBLbvcyK2GXuJzHoppAFP C5JVsKbKOSYmE/f7USfgc+GVR4giVMD2nmr0kzOqcxqSQocxKOIsXukfEGQtKXANx2+M EEgnL0XNrnvIOyz5s1RQD7ONMMsb/A5qzNi1Uo2H+4MVC8RnS6sUHL1EgcXzYw0JRk4g lUejvKgvTP2LjcWdim/+bndMLyV53A0MW/89XWVPEcqjVvFQYW5ZoBJOB6gsfbno41YH 3aGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7HV1je4u5Ps2cjIZaWTRdZP2wZij+4hAKWpeqsFhAYA=; b=ujBygA57CT/fHFwGj7FEPpnIduGhpl4h0jJdSmg+IavAaH4R6izwJlKZN4uKpEO8n0 +Cl+/Q+tCk/D4WDNUsfs7AvNfTebGVW2LoCTg37ZaHqxkEC3WWSuYNlnuR8mfCggPGBi 6AJIpTNZ0Wko5bwKoRoA8w8CzM2trQr9VCS7GQ0DXxxZH78pUH5BEz5hwKRmKlZxKqzi LOpg9efGzC0VctXsuA33kCQO6lLo9eAIWo5jP88OaemA5Zk8G4XLSDYj9uyXVVZM1LGz 092YnhrL8XIBcJn0Pe+I8l+h//wKHdqITpIHlLofMJjJ5AUL3+/E9Yr8kVZA78e/S8uX 1cTw== X-Gm-Message-State: AOAM531MB6R2eYp7zQ22/r6E1dW93BRUx1qUiQ1HOUPSq+TBqkFwnPz3 aahlOY0Ge7wAmlNUcJsLT6MO+w== X-Google-Smtp-Source: ABdhPJw/1U1aSHZo/9aCtqEnmz2T1/PqhEfq3BRGeyZsXATl15zYpTaJzxxbAs1pvsCt15Z7SVhYRA== X-Received: by 2002:a17:902:db0e:b0:154:8682:c1db with SMTP id m14-20020a170902db0e00b001548682c1dbmr23053611plx.128.1649494524777; Sat, 09 Apr 2022 01:55:24 -0700 (PDT) Received: from localhost.localdomain ([2409:8a28:e6c:f010:3c21:7dc2:3a08:b6bc]) by smtp.gmail.com with ESMTPSA id f192-20020a636ac9000000b0039836edcf42sm24460806pgc.85.2022.04.09.01.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Apr 2022 01:55:23 -0700 (PDT) From: Chengming Zhou To: rostedt@goodmis.org, mingo@redhat.com, catalin.marinas@arm.com, will@kernel.org, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, broonie@kernel.org, mark.rutland@arm.com, ardb@kernel.org, zhouchengming@bytedance.com, linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, songmuchun@bytedance.com Subject: [PATCH RESEND v3 1/2] ftrace: cleanup ftrace_graph_caller enable and disable Date: Sat, 9 Apr 2022 16:54:59 +0800 Message-Id: <20220409085500.4549-1-zhouchengming@bytedance.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220409_015529_346692_3D3796C6 X-CRM114-Status: GOOD ( 13.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The ftrace_[enable,disable]_ftrace_graph_caller() are used to do special hooks for graph tracer, which are not needed on some ARCHs that use graph_ops:func function to install return_hooker. So introduce the weak version in ftrace core code to cleanup in x86. Signed-off-by: Chengming Zhou --- v3: - consolidate two #if into a single #if, suggested by Steve. Thanks. --- arch/x86/kernel/ftrace.c | 17 ++--------------- kernel/trace/ftrace.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 1e31c7d21597..b09d73c2ba89 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c @@ -579,9 +579,7 @@ void arch_ftrace_trampoline_free(struct ftrace_ops *ops) #ifdef CONFIG_FUNCTION_GRAPH_TRACER -#ifdef CONFIG_DYNAMIC_FTRACE - -#ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS +#if defined(CONFIG_DYNAMIC_FTRACE) && !defined(CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS) extern void ftrace_graph_call(void); static const char *ftrace_jmp_replace(unsigned long ip, unsigned long addr) { @@ -610,18 +608,7 @@ int ftrace_disable_ftrace_graph_caller(void) return ftrace_mod_jmp(ip, &ftrace_stub); } -#else /* !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */ -int ftrace_enable_ftrace_graph_caller(void) -{ - return 0; -} - -int ftrace_disable_ftrace_graph_caller(void) -{ - return 0; -} -#endif /* CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */ -#endif /* !CONFIG_DYNAMIC_FTRACE */ +#endif /* CONFIG_DYNAMIC_FTRACE && !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */ /* * Hook the return address and push it in the stack of return addrs diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 4f1d2f5e7263..30622c755c77 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -2721,6 +2721,26 @@ int __weak ftrace_arch_code_modify_post_process(void) return 0; } +#ifdef CONFIG_FUNCTION_GRAPH_TRACER +/* + * archs can override this function if they must do something + * to enable hook for graph tracer. + */ +int __weak ftrace_enable_ftrace_graph_caller(void) +{ + return 0; +} + +/* + * archs can override this function if they must do something + * to disable hook for graph tracer. + */ +int __weak ftrace_disable_ftrace_graph_caller(void) +{ + return 0; +} +#endif + void ftrace_modify_all_code(int command) { int update = command & FTRACE_UPDATE_TRACE_FUNC;