Skip to contentSkip to conversation

tracing: Report wrong dynamic event command

PATCH Superseded Masami Hiramatsu (Google) 2 participants 4 messages Nov 8, 2025 – Nov 10, 2025 Tracing

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Masami Hiramatsu (Google)

author maintainer
#0 lore raw

PATCH 1/1 tracing: Report wrong dynamic event command

From: Masami Hiramatsu (Google) <[email protected]>

Report wrong dynamic event command via error_log.
---

 # echo "z hoge" > /sys/kernel/tracing/dynamic_events
 sh: write error: Invalid argument
 # cat /sys/kernel/tracing/error_log
 [   73.371714] dynevent: error: Invalid dynamic event command
  Command: z hoge
           ^
---
---
 kernel/trace/trace_dynevent.c |   11 +++++++++--
 kernel/trace/trace_probe.h    |    3 ++-
 2 files changed, 11 insertions(+), 3 deletions(-)
kernel/trace/trace_dynevent.c +9 -2
index d06854bd32b3..536a7704abfd 100644
@@ -14,6 +14,7 @@
 
 #include "trace.h"
 #include "trace_output.h"	/* for trace_event_sem */
+#include "trace_probe.h"
 #include "trace_dynevent.h"
 
 DEFINE_MUTEX(dyn_event_ops_mutex);
@@ -144,9 +145,15 @@ static int create_dyn_event(const char *raw_command)
 		if (!ret || ret != -ECANCELED)
 			break;
 	}
-	mutex_unlock(&dyn_event_ops_mutex);
-	if (ret == -ECANCELED)
+	if (ret == -ECANCELED) {
+		/* Wrong dynamic event. Leave an error message. */
+		trace_probe_log_init("dynevent", 1, &raw_command);
+		trace_probe_log_err(0, BAD_DYN_EVENT);
+		trace_probe_log_clear();
 		ret = -EINVAL;
+	}
+
+	mutex_unlock(&dyn_event_ops_mutex);
 
 	return ret;
 }
kernel/trace/trace_probe.h +2 -1
index 591adc9bb1e9..e6e5c884e60a 100644
@@ -567,7 +567,8 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,
 	C(BAD_ACCESS_FMT,	"Access memory address requires @"),	\
 	C(BAD_ACCESS_TYPE,	"Bad memory access type"),	\
 	C(BAD_ACCESS_LEN,	"This memory access length is not supported"), \
-	C(BAD_ACCESS_ADDR,	"Invalid access memory address"),
+	C(BAD_ACCESS_ADDR,	"Invalid access memory address"),	\
+	C(BAD_DYN_EVENT,	"Invalid dynamic event command"),
 
 #undef C
 #define C(a, b)		TP_ERR_##a
#1 lore raw
kernel test robot noticed the following build errors:

Hi Masami,

kernel test robot noticed the following build errors:

[auto build test ERROR on trace/for-next]
[also build test ERROR on next-20251107]
[cannot apply to linus/master v6.18-rc4]
[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/Masami-Hiramatsu-Google/tracing-Report-wrong-dynamic-event-command/20251108-185823
base:   https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link:    https://lore.kernel.org/r/176259938768.261465.10714633393722227911.stgit%40devnote2
patch subject: [PATCH] tracing: Report wrong dynamic event command
config: parisc-randconfig-001-20251109 (https://download.01.org/0day-ci/archive/20251109/[email protected]/config)
compiler: hppa-linux-gcc (GCC) 9.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251109/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

hppa-linux-ld: kernel/trace/trace_dynevent.o: in function `create_dyn_event':

>> (.text+0x610): undefined reference to `trace_probe_log_init'
>> hppa-linux-ld: (.text+0x61c): undefined reference to `__trace_probe_log_err'
>> hppa-linux-ld: (.text+0x624): undefined reference to `trace_probe_log_clear'
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#2 lore raw
In reply to Masami Hiramatsu (Google)
kernel test robot noticed the following build errors:

Hi Masami,

kernel test robot noticed the following build errors:

[auto build test ERROR on trace/for-next]
[also build test ERROR on next-20251107]
[cannot apply to linus/master v6.18-rc4]
[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/Masami-Hiramatsu-Google/tracing-Report-wrong-dynamic-event-command/20251108-185823
base:   https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link:    https://lore.kernel.org/r/176259938768.261465.10714633393722227911.stgit%40devnote2
patch subject: [PATCH] tracing: Report wrong dynamic event command
config: s390-randconfig-002-20251109 (https://download.01.org/0day-ci/archive/20251109/[email protected]/config)
compiler: s390-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251109/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

s390-linux-ld: kernel/trace/trace_dynevent.o: in function `create_dyn_event':

>> kernel/trace/trace_dynevent.c:150: undefined reference to `trace_probe_log_init'
>> s390-linux-ld: kernel/trace/trace_dynevent.c:151: undefined reference to `__trace_probe_log_err'
>> s390-linux-ld: kernel/trace/trace_dynevent.c:152: undefined reference to `trace_probe_log_clear'

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for I2C_K1
Depends on [n]: I2C [=y] && HAS_IOMEM [=y] && (ARCH_SPACEMIT || COMPILE_TEST [=y]) && OF [=n] Selected by [y]:
- MFD_SPACEMIT_P1 [=y] && HAS_IOMEM [=y] && (ARCH_SPACEMIT || COMPILE_TEST [=y]) && I2C [=y]

vim +150 kernel/trace/trace_dynevent.c

133
134 static int create_dyn_event(const char *raw_command)
135 {
136 struct dyn_event_operations *ops;
137 int ret = -ENODEV;
138
139 if (raw_command[0] == '-' || raw_command[0] == '!')
140 return dyn_event_release(raw_command, NULL);
141
142 mutex_lock(&dyn_event_ops_mutex);
143 list_for_each_entry(ops, &dyn_event_ops_list, list) {
144 ret = ops->create(raw_command);
145 if (!ret || ret != -ECANCELED)
146 break;
147 }
148 if (ret == -ECANCELED) {
149 /* Wrong dynamic event. Leave an error message. */

 > 150			trace_probe_log_init("dynevent", 1, &raw_command);
 > 151			trace_probe_log_err(0, BAD_DYN_EVENT);
 > 152			trace_probe_log_clear();

153 ret = -EINVAL;
154 }
155
156 mutex_unlock(&dyn_event_ops_mutex);
157
158 return ret;
159 }
160

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#3 lore raw
Quoted 19 lines · On Sun, 9 Nov 2025 21:27:50 +0800 kernel test robot <[email protected]> wrote:

Hi Masami,

kernel test robot noticed the following build errors:

[auto build test ERROR on trace/for-next]
[also build test ERROR on next-20251107]
[cannot apply to linus/master v6.18-rc4]
[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/Masami-Hiramatsu-Google/tracing-Report-wrong-dynamic-event-command/20251108-185823
base:   https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link:    https://lore.kernel.org/r/176259938768.261465.10714633393722227911.stgit%40devnote2
patch subject: [PATCH] tracing: Report wrong dynamic event command
config: s390-randconfig-002-20251109 (https://download.01.org/0day-ci/archive/20251109/[email protected]/config)
compiler: s390-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251109/[email protected]/reproduce)
Quoted 11 lines

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

s390-linux-ld: kernel/trace/trace_dynevent.o: in function `create_dyn_event':

Quoted 3 lines
Quoted 3 lines

kernel/trace/trace_dynevent.c:150: undefined reference to `trace_probe_log_init'
s390-linux-ld: kernel/trace/trace_dynevent.c:151: undefined reference to `__trace_probe_log_err'
s390-linux-ld: kernel/trace/trace_dynevent.c:152: undefined reference to `trace_probe_log_clear'

Oops, it is because CONFIG_DYNAMIC_EVENTS=y but CONFIG_PROBE_EVENTS=n. Hmm, it seems better to make "trace_probe_log.{c,h}" for this purpose.

Thank you,

Quoted 42 lines

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for I2C_K1
Depends on [n]: I2C [=y] && HAS_IOMEM [=y] && (ARCH_SPACEMIT || COMPILE_TEST [=y]) && OF [=n] Selected by [y]:
- MFD_SPACEMIT_P1 [=y] && HAS_IOMEM [=y] && (ARCH_SPACEMIT || COMPILE_TEST [=y]) && I2C [=y]

vim +150 kernel/trace/trace_dynevent.c

   133	
   134	static int create_dyn_event(const char *raw_command)
   135	{
   136		struct dyn_event_operations *ops;
   137		int ret = -ENODEV;
   138	
   139		if (raw_command[0] == '-' || raw_command[0] == '!')
   140			return dyn_event_release(raw_command, NULL);
   141	
   142		mutex_lock(&dyn_event_ops_mutex);
   143		list_for_each_entry(ops, &dyn_event_ops_list, list) {
   144			ret = ops->create(raw_command);
   145			if (!ret || ret != -ECANCELED)
   146				break;
   147		}
   148		if (ret == -ECANCELED) {
   149			/* Wrong dynamic event. Leave an error message. */
Quoted 3 lines

150 trace_probe_log_init("dynevent", 1, &raw_command);
151 trace_probe_log_err(0, BAD_DYN_EVENT);
152 trace_probe_log_clear();

   153			ret = -EINVAL;
   154		}
   155	
   156		mutex_unlock(&dyn_event_ops_mutex);
   157	
   158		return ret;
   159	}
   160	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>