diff mbox series

[v5,21/22] tracing/boot: Add function tracer filter options

Message ID 157736928302.11126.8760178688093051786.stgit@devnote2 (mailing list archive)
State New, archived
Headers show
Series tracing: bootconfig: Boot-time tracing and Extra boot config | expand

Commit Message

Masami Hiramatsu (Google) Dec. 26, 2019, 2:08 p.m. UTC
Add below function-tracer filter options to boot-time tracing.

 - ftrace.[instance.INSTANCE.]ftrace.filters
   This will take an array of tracing function filter rules

 - ftrace.[instance.INSTANCE.]ftrace.notraces
   This will take an array of NON-tracing function filter rules

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 0 files changed

Comments

kernel test robot Dec. 26, 2019, 6:05 p.m. UTC | #1
Hi Masami,

I love your patch! Yet something to improve:

[auto build test ERROR on trace/for-next]
[also build test ERROR on lwn/docs-next linus/master v5.5-rc3]
[cannot apply to tip/perf/core next-20191220]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Masami-Hiramatsu/tracing-bootconfig-Boot-time-tracing-and-Extra-boot-config/20191227-002009
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git for-next
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 7.5.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.5.0 make.cross ARCH=xtensa 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from kernel/trace/trace_boot.c:9:0:
>> include/linux/ftrace.h:719:50: error: expected identifier or '(' before '{' token
    #define ftrace_set_filter(ops, buf, len, reset) ({ -ENODEV; })
                                                     ^
>> kernel/trace/trace_boot.c:249:12: note: in expansion of macro 'ftrace_set_filter'
    extern int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
               ^~~~~~~~~~~~~~~~~
   include/linux/ftrace.h:720:51: error: expected identifier or '(' before '{' token
    #define ftrace_set_notrace(ops, buf, len, reset) ({ -ENODEV; })
                                                      ^
>> kernel/trace/trace_boot.c:251:12: note: in expansion of macro 'ftrace_set_notrace'
    extern int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
               ^~~~~~~~~~~~~~~~~~
--
   In file included from kernel//trace/trace_boot.c:9:0:
>> include/linux/ftrace.h:719:50: error: expected identifier or '(' before '{' token
    #define ftrace_set_filter(ops, buf, len, reset) ({ -ENODEV; })
                                                     ^
   kernel//trace/trace_boot.c:249:12: note: in expansion of macro 'ftrace_set_filter'
    extern int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
               ^~~~~~~~~~~~~~~~~
   include/linux/ftrace.h:720:51: error: expected identifier or '(' before '{' token
    #define ftrace_set_notrace(ops, buf, len, reset) ({ -ENODEV; })
                                                      ^
   kernel//trace/trace_boot.c:251:12: note: in expansion of macro 'ftrace_set_notrace'
    extern int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
               ^~~~~~~~~~~~~~~~~~

vim +/ftrace_set_filter +249 kernel/trace/trace_boot.c

   246	
   247	#ifdef CONFIG_FUNCTION_TRACER
   248	extern bool ftrace_filter_param __initdata;
 > 249	extern int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
   250				     int len, int reset);
 > 251	extern int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
   252				      int len, int reset);
   253	static void __init
   254	trace_boot_set_ftrace_filter(struct trace_array *tr, struct xbc_node *node)
   255	{
   256		struct xbc_node *anode;
   257		const char *p;
   258		char *q;
   259	
   260		xbc_node_for_each_array_value(node, "ftrace.filters", anode, p) {
   261			q = kstrdup(p, GFP_KERNEL);
   262			if (!q)
   263				return;
   264			if (ftrace_set_filter(tr->ops, q, strlen(q), 0) < 0)
   265				pr_err("Failed to add %s to ftrace filter\n", p);
   266			else
   267				ftrace_filter_param = true;
   268			kfree(q);
   269		}
   270		xbc_node_for_each_array_value(node, "ftrace.notraces", anode, p) {
   271			q = kstrdup(p, GFP_KERNEL);
   272			if (!q)
   273				return;
   274			if (ftrace_set_notrace(tr->ops, q, strlen(q), 0) < 0)
   275				pr_err("Failed to add %s to ftrace filter\n", p);
   276			else
   277				ftrace_filter_param = true;
   278			kfree(q);
   279		}
   280	}
   281	#else
   282	#define trace_boot_set_ftrace_filter(tr, node) do {} while (0)
   283	#endif
   284	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
Masami Hiramatsu (Google) Dec. 27, 2019, 2:56 a.m. UTC | #2
Oops, the ftrace_set_filter/notrace_filter depend on CONFIG_DYNAMIC_FTRACE, not CONFIG_FUNCTION_TRACER

Thanks, I'll fix it.

On Fri, 27 Dec 2019 02:05:11 +0800
kbuild test robot <lkp@intel.com> wrote:

> Hi Masami,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on trace/for-next]
> [also build test ERROR on lwn/docs-next linus/master v5.5-rc3]
> [cannot apply to tip/perf/core next-20191220]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system. BTW, we also suggest to use '--base' option to specify the
> base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
> 
> url:    https://github.com/0day-ci/linux/commits/Masami-Hiramatsu/tracing-bootconfig-Boot-time-tracing-and-Extra-boot-config/20191227-002009
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git for-next
> config: xtensa-allyesconfig (attached as .config)
> compiler: xtensa-linux-gcc (GCC) 7.5.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         GCC_VERSION=7.5.0 make.cross ARCH=xtensa 
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
> 
> All error/warnings (new ones prefixed by >>):
> 
>    In file included from kernel/trace/trace_boot.c:9:0:
> >> include/linux/ftrace.h:719:50: error: expected identifier or '(' before '{' token
>     #define ftrace_set_filter(ops, buf, len, reset) ({ -ENODEV; })
>                                                      ^
> >> kernel/trace/trace_boot.c:249:12: note: in expansion of macro 'ftrace_set_filter'
>     extern int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
>                ^~~~~~~~~~~~~~~~~
>    include/linux/ftrace.h:720:51: error: expected identifier or '(' before '{' token
>     #define ftrace_set_notrace(ops, buf, len, reset) ({ -ENODEV; })
>                                                       ^
> >> kernel/trace/trace_boot.c:251:12: note: in expansion of macro 'ftrace_set_notrace'
>     extern int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
>                ^~~~~~~~~~~~~~~~~~
> --
>    In file included from kernel//trace/trace_boot.c:9:0:
> >> include/linux/ftrace.h:719:50: error: expected identifier or '(' before '{' token
>     #define ftrace_set_filter(ops, buf, len, reset) ({ -ENODEV; })
>                                                      ^
>    kernel//trace/trace_boot.c:249:12: note: in expansion of macro 'ftrace_set_filter'
>     extern int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
>                ^~~~~~~~~~~~~~~~~
>    include/linux/ftrace.h:720:51: error: expected identifier or '(' before '{' token
>     #define ftrace_set_notrace(ops, buf, len, reset) ({ -ENODEV; })
>                                                       ^
>    kernel//trace/trace_boot.c:251:12: note: in expansion of macro 'ftrace_set_notrace'
>     extern int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
>                ^~~~~~~~~~~~~~~~~~
> 
> vim +/ftrace_set_filter +249 kernel/trace/trace_boot.c
> 
>    246	
>    247	#ifdef CONFIG_FUNCTION_TRACER
>    248	extern bool ftrace_filter_param __initdata;
>  > 249	extern int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
>    250				     int len, int reset);
>  > 251	extern int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
>    252				      int len, int reset);
>    253	static void __init
>    254	trace_boot_set_ftrace_filter(struct trace_array *tr, struct xbc_node *node)
>    255	{
>    256		struct xbc_node *anode;
>    257		const char *p;
>    258		char *q;
>    259	
>    260		xbc_node_for_each_array_value(node, "ftrace.filters", anode, p) {
>    261			q = kstrdup(p, GFP_KERNEL);
>    262			if (!q)
>    263				return;
>    264			if (ftrace_set_filter(tr->ops, q, strlen(q), 0) < 0)
>    265				pr_err("Failed to add %s to ftrace filter\n", p);
>    266			else
>    267				ftrace_filter_param = true;
>    268			kfree(q);
>    269		}
>    270		xbc_node_for_each_array_value(node, "ftrace.notraces", anode, p) {
>    271			q = kstrdup(p, GFP_KERNEL);
>    272			if (!q)
>    273				return;
>    274			if (ftrace_set_notrace(tr->ops, q, strlen(q), 0) < 0)
>    275				pr_err("Failed to add %s to ftrace filter\n", p);
>    276			else
>    277				ftrace_filter_param = true;
>    278			kfree(q);
>    279		}
>    280	}
>    281	#else
>    282	#define trace_boot_set_ftrace_filter(tr, node) do {} while (0)
>    283	#endif
>    284	
> 
> ---
> 0-DAY kernel test infrastructure                 Open Source Technology Center
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
diff mbox series

Patch

diff --git a/kernel/trace/trace_boot.c b/kernel/trace/trace_boot.c
index 81d923c16a4d..57274b9b3718 100644
--- a/kernel/trace/trace_boot.c
+++ b/kernel/trace/trace_boot.c
@@ -244,11 +244,51 @@  trace_boot_init_events(struct trace_array *tr, struct xbc_node *node)
 #define trace_boot_init_events(tr, node) do {} while (0)
 #endif
 
+#ifdef CONFIG_FUNCTION_TRACER
+extern bool ftrace_filter_param __initdata;
+extern int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
+			     int len, int reset);
+extern int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
+			      int len, int reset);
+static void __init
+trace_boot_set_ftrace_filter(struct trace_array *tr, struct xbc_node *node)
+{
+	struct xbc_node *anode;
+	const char *p;
+	char *q;
+
+	xbc_node_for_each_array_value(node, "ftrace.filters", anode, p) {
+		q = kstrdup(p, GFP_KERNEL);
+		if (!q)
+			return;
+		if (ftrace_set_filter(tr->ops, q, strlen(q), 0) < 0)
+			pr_err("Failed to add %s to ftrace filter\n", p);
+		else
+			ftrace_filter_param = true;
+		kfree(q);
+	}
+	xbc_node_for_each_array_value(node, "ftrace.notraces", anode, p) {
+		q = kstrdup(p, GFP_KERNEL);
+		if (!q)
+			return;
+		if (ftrace_set_notrace(tr->ops, q, strlen(q), 0) < 0)
+			pr_err("Failed to add %s to ftrace filter\n", p);
+		else
+			ftrace_filter_param = true;
+		kfree(q);
+	}
+}
+#else
+#define trace_boot_set_ftrace_filter(tr, node) do {} while (0)
+#endif
+
 static void __init
 trace_boot_enable_tracer(struct trace_array *tr, struct xbc_node *node)
 {
 	const char *p;
 
+	trace_boot_set_ftrace_filter(tr, node);
+
 	p = xbc_node_find_value(node, "tracer", NULL);
 	if (p && *p != '\0') {
 		if (tracing_set_tracer(tr, p) < 0)