linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tracing: Report wrong dynamic event command
@ 2025-11-08 10:56 Masami Hiramatsu (Google)
  2025-11-09 11:05 ` kernel test robot
  2025-11-09 13:27 ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Masami Hiramatsu (Google) @ 2025-11-08 10:56 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu
  Cc: Mathieu Desnoyers, linux-kernel, linux-trace-kernel

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

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
           ^
---

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 kernel/trace/trace_dynevent.c |   11 +++++++++--
 kernel/trace/trace_probe.h    |    3 ++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_dynevent.c b/kernel/trace/trace_dynevent.c
index d06854bd32b3..536a7704abfd 100644
--- a/kernel/trace/trace_dynevent.c
+++ b/kernel/trace/trace_dynevent.c
@@ -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;
 }
diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
index 591adc9bb1e9..e6e5c884e60a 100644
--- a/kernel/trace/trace_probe.h
+++ b/kernel/trace/trace_probe.h
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tracing: Report wrong dynamic event command
  2025-11-08 10:56 [PATCH] tracing: Report wrong dynamic event command Masami Hiramatsu (Google)
@ 2025-11-09 11:05 ` kernel test robot
  2025-11-09 13:27 ` kernel test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-11-09 11:05 UTC (permalink / raw)
  To: Masami Hiramatsu (Google), Steven Rostedt
  Cc: oe-kbuild-all, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel

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/202511091817.JzD0Zi0O-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 9.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251109/202511091817.JzD0Zi0O-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511091817.JzD0Zi0O-lkp@intel.com/

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'

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tracing: Report wrong dynamic event command
  2025-11-08 10:56 [PATCH] tracing: Report wrong dynamic event command Masami Hiramatsu (Google)
  2025-11-09 11:05 ` kernel test robot
@ 2025-11-09 13:27 ` kernel test robot
  2025-11-10  5:00   ` Masami Hiramatsu
  1 sibling, 1 reply; 4+ messages in thread
From: kernel test robot @ 2025-11-09 13:27 UTC (permalink / raw)
  To: Masami Hiramatsu (Google), Steven Rostedt
  Cc: oe-kbuild-all, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel

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/202511092149.N375MBPu-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251109/202511092149.N375MBPu-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511092149.N375MBPu-lkp@intel.com/

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	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tracing: Report wrong dynamic event command
  2025-11-09 13:27 ` kernel test robot
@ 2025-11-10  5:00   ` Masami Hiramatsu
  0 siblings, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2025-11-10  5:00 UTC (permalink / raw)
  To: kernel test robot
  Cc: Steven Rostedt, oe-kbuild-all, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel

On Sun, 9 Nov 2025 21:27:50 +0800
kernel test robot <lkp@intel.com> 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/202511092149.N375MBPu-lkp@intel.com/config)
> compiler: s390-linux-gcc (GCC) 8.5.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251109/202511092149.N375MBPu-lkp@intel.com/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 <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202511092149.N375MBPu-lkp@intel.com/
> 
> 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'

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,

> 
> 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	
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-10  5:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-08 10:56 [PATCH] tracing: Report wrong dynamic event command Masami Hiramatsu (Google)
2025-11-09 11:05 ` kernel test robot
2025-11-09 13:27 ` kernel test robot
2025-11-10  5:00   ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).