Message ID | 20221027085343.2388485-1-suagrfillet@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp115687wru; Thu, 27 Oct 2022 02:03:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6KnRC67t29Myemdp2OQqG74mPxm5CP6/qfrMaPwm7bKLVkUtg5i9sP/L39/3YxLhQ92Cb6 X-Received: by 2002:aa7:ccd2:0:b0:462:73bd:3acb with SMTP id y18-20020aa7ccd2000000b0046273bd3acbmr5436134edt.378.1666861403320; Thu, 27 Oct 2022 02:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666861403; cv=none; d=google.com; s=arc-20160816; b=u5n008PmM1SQNQFvQSncFU2VFOQjP2PSd9GDh+djszF0Mf54NSzTx7nDg2SNYKXhli yYHrsS5QxNtg035WRnEDXEHsLT5Rw5EF5r/JtJSCWILJOsGGhu3BAfAUzgHLQv4ld2UQ Mw1+crl/o5W+YM9/o5Rr04I39Hjb9PkSv6/JbwGR6sn1dleDsZiF9pfi6EwxSf7jdMFA ClUTiBJ2uwwqCYVKFWXpipymKpchrZCkNJzMOKV1E/FxIhTUGkVyUlEIGAix4SStAaB6 PbaI+dHzIa9RHa2M+3TwRWYzazUAgLxIaLvaM2cgRSYzqslrSg1+8KFcxNbZOB/J3aik 0BAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=rxILUEhhuIRRDXNGGTClKXs5A57MKkYLhJBHPtEVeMk=; b=tlYUNdHEZkspWDxh3Ncr48ZQ2zl0XAUko2YC0Go2uhLcrHGWJyzdqaJedvDzKzIyBf GeT9V4KCFyd+AF+IsECF1TT9YHFeVWdgZEXRgYyp7zAGs//XJQ9FCLXW4IqtDS+DclJ4 5Rus4Y5nG33BpjcE20v9w6XZ3sTp7qyPpnWE5OOzlF/8x9Nc9cG28rTsoVMrt6htyIo9 lTTLihUM5wYnvgcb7yQlcKv2zN23YwGaG0LnzcwLAUkf5F5BcDRXlPOvG86eO3MoC2iJ NhgZdofmamo+/4VT+WpHtwc4t2VXHEhBk8+gp/57oUF8NQks0c8BKfKnUO/xqqOttmFw /eQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZYH3ZRbJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o10-20020a170906974a00b0072ef52514f6si1069692ejy.629.2022.10.27.02.02.58; Thu, 27 Oct 2022 02:03:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZYH3ZRbJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234748AbiJ0Ixy (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Thu, 27 Oct 2022 04:53:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233295AbiJ0Ixw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 27 Oct 2022 04:53:52 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4903F15D0AA for <linux-kernel@vger.kernel.org>; Thu, 27 Oct 2022 01:53:52 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id r61-20020a17090a43c300b00212f4e9cccdso5608899pjg.5 for <linux-kernel@vger.kernel.org>; Thu, 27 Oct 2022 01:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rxILUEhhuIRRDXNGGTClKXs5A57MKkYLhJBHPtEVeMk=; b=ZYH3ZRbJiHV4047FALOjGhndjJy9T8t65dSVQn/JOmOW2sm1HNdoKsxcTrqkqqU7+C VkJHoKNVr43ZIY0pEdWsfzXhUb0CyvZY739xAeDrC+A4wm67MUuVHcV/mhuwCrWrX/8T L4VwIGzT3KGYXTB5mvEjb47ReZSQg4L71Pags/pUwr+Xybpd/Axm/HyOmN758pvna57e OPaieyXaNhxM15T3Jsy2BZ7GZE6JiZpG8/8v4PyD1Ey8bVHqrUutUSB9IVh4ELTx3Ziu IqT9dyugY6GhU7pnNrpiFZlnqoFBUbX0aD6w/5koYBgyrCHXauNG5YADjr45xvSItIyH 5xkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rxILUEhhuIRRDXNGGTClKXs5A57MKkYLhJBHPtEVeMk=; b=UaHbYHe3w6k9sKA6yA4n2bSrAxCWZMKnHeFgTwYTtVRiwr99L3NkQZ8TEW5fl8QR5j 8OFd4vu+KntReXmNvqDv9AVRDU0xie40A4GF8RSueu2qmdoKAUOo+pGbU5dRM0rmpp2c K87c+yuUbTFsioIo+yT5z0SLJHC4iPhAevgrd7BnT6DaZMKoAXNvQj3Gmkiyb6we9d8Z s4uFLlX1mcofZuW2qEWsOESymIZWQfj8mrUhASpzKvrwA6Ue1K24zhRcqJGcqdelGvxZ qc6x2dfcXj82cerHMsGm/UmkEpLoYOr8VX+wPmRGVK8ZaiYEpC4EQ8jNrnoUe6f0yxW4 cTbg== X-Gm-Message-State: ACrzQf10OL6qsdnTNZrmzgSXKlvzgVWsQJOQ2G8M7uBAm7QCGo6nMbW3 L6sf53tJ91Tk1t56eb1ZX3KUZoDVLlpNOQ== X-Received: by 2002:a17:90b:1806:b0:20d:3256:38 with SMTP id lw6-20020a17090b180600b0020d32560038mr8727249pjb.94.1666860831788; Thu, 27 Oct 2022 01:53:51 -0700 (PDT) Received: from localhost.localdomain ([221.226.144.218]) by smtp.gmail.com with ESMTPSA id u1-20020a17090a1d4100b0020dda7efe61sm2314581pju.5.2022.10.27.01.53.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 01:53:51 -0700 (PDT) From: Song Shuai <suagrfillet@gmail.com> To: rostedt@goodmis.org, mingo@redhat.com Cc: linux-kernel@vger.kernel.org, Song Shuai <suagrfillet@gmail.com> Subject: [PATCH] ftrace: fix static function tracer not working Date: Thu, 27 Oct 2022 16:53:43 +0800 Message-Id: <20221027085343.2388485-1-suagrfillet@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747830862749430093?= X-GMAIL-MSGID: =?utf-8?q?1747830862749430093?= |
Series |
ftrace: fix static function tracer not working
|
|
Commit Message
Song Shuai
Oct. 27, 2022, 8:53 a.m. UTC
Setting kernel command line parameter ftrace=function shows
nothing on the kernel built with static ftrace.
In static ftrace, ftrace_nodyn_init should be executed before
initializing tracers. While this commit `dbeafd0d6131` brings
the initialization of function tracer forward from core_initcall
where ftrace_nodyn_init still remains.
This patch puts ftrace_nodyn_init and ftrace_init together and
makes function tracer works in static ftrace.
Fixes: dbeafd0d6131 ("ftrace: Have function tracing start in early boot up")
Signed-off-by: Song Shuai <suagrfillet@gmail.com>
---
include/linux/ftrace.h | 6 ++++++
init/main.c | 1 +
kernel/trace/ftrace.c | 4 +---
3 files changed, 8 insertions(+), 3 deletions(-)
Comments
Hi Song, Thank you for the patch! Yet something to improve: [auto build test ERROR on rostedt-trace/for-next] [also build test ERROR on linus/master v6.1-rc2 next-20221027] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Song-Shuai/ftrace-fix-static-function-tracer-not-working/20221027-165526 base: https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git for-next patch link: https://lore.kernel.org/r/20221027085343.2388485-1-suagrfillet%40gmail.com patch subject: [PATCH] ftrace: fix static function tracer not working config: arc-defconfig compiler: arc-elf-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/44eabe3b35e870ebfd71d4bae0ebe371b305f042 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Song-Shuai/ftrace-fix-static-function-tracer-not-working/20221027-165526 git checkout 44eabe3b35e870ebfd71d4bae0ebe371b305f042 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): arc-elf-ld: init/main.o: in function `start_kernel': >> main.c:(.init.text+0x7e2): undefined reference to `ftrace_nodyn_init' >> arc-elf-ld: main.c:(.init.text+0x7e2): undefined reference to `ftrace_nodyn_init'
On Thu, 27 Oct 2022 16:53:43 +0800 Song Shuai <suagrfillet@gmail.com> wrote: > Setting kernel command line parameter ftrace=function shows > nothing on the kernel built with static ftrace. > > In static ftrace, ftrace_nodyn_init should be executed before > initializing tracers. While this commit `dbeafd0d6131` brings > the initialization of function tracer forward from core_initcall > where ftrace_nodyn_init still remains. > > This patch puts ftrace_nodyn_init and ftrace_init together and > makes function tracer works in static ftrace. Sorry but NACK. Static ftrace only exists for helping new architectures get dynamic ftrace working. It is not, and never will be, considered the end product. Really, I only keep it around as a stepping stone for full dynamic ftrace, otherwise I would have removed it along time ago. No generic code should ever be modified to satisfy static ftrace. Please get dynamic ftrace functional, as that could be used in production environments. -- Steve
Hi Song,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on rostedt-trace/for-next]
[also build test ERROR on linus/master v6.1-rc2 next-20221027]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Song-Shuai/ftrace-fix-static-function-tracer-not-working/20221027-165526
base: https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git for-next
patch link: https://lore.kernel.org/r/20221027085343.2388485-1-suagrfillet%40gmail.com
patch subject: [PATCH] ftrace: fix static function tracer not working
config: csky-randconfig-r026-20221027
compiler: csky-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/44eabe3b35e870ebfd71d4bae0ebe371b305f042
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Song-Shuai/ftrace-fix-static-function-tracer-not-working/20221027-165526
git checkout 44eabe3b35e870ebfd71d4bae0ebe371b305f042
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=csky SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
csky-linux-ld: csky-linux-ld: DWARF error: could not find abbrev number 10698
init/main.o: in function `start_kernel':
main.c:(.init.text+0x7d6): undefined reference to `ftrace_nodyn_init'
>> csky-linux-ld: main.c:(.init.text+0x9c4): undefined reference to `ftrace_nodyn_init'
Hi, Steve: Thank you for your time and attention. The static ftrace is exactly overridden by dynamic ftrace in most architectures when selecting Kconfig. I'll throw this patch to trash. BTW, can you help me review this [thread][1] which hasn't been checked for about a week. [1]: https://lore.kernel.org/linux-kernel/20221026132039.2236233-1-suagrfillet@gmail.com/ -- Song Shuai
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 0b61371e287b..4bdab0461b10 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -978,6 +978,12 @@ extern void ftrace_init(void); static inline void ftrace_init(void) { } #endif + +#ifndef CONFIG_FTRACE_MCOUNT_RECORD +extern void ftrace_nodyn_init(void); +#else +static inline void ftrace_nodyn_init(void) { } +#endif /* * Structure that defines an entry function trace. * It's already packed but the attribute "packed" is needed diff --git a/init/main.c b/init/main.c index 91642a4e69be..ebf8136e828a 100644 --- a/init/main.c +++ b/init/main.c @@ -986,6 +986,7 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void) trap_init(); mm_init(); + ftrace_nodyn_init(); ftrace_init(); /* trace_printk can be enabled here */ diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 56b1a42e1937..40325ae575a5 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -7454,12 +7454,10 @@ struct ftrace_ops global_ops = { FTRACE_OPS_FL_PID, }; -static int __init ftrace_nodyn_init(void) +void __init ftrace_nodyn_init(void) { ftrace_enabled = 1; - return 0; } -core_initcall(ftrace_nodyn_init); static inline int ftrace_init_dyn_tracefs(struct dentry *d_tracer) { return 0; } static inline void ftrace_startup_all(int command) { }