All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf timechart: Fail IO recording when no syscall tracepoint is available
@ 2026-10-21  2:56 ` Hang Zhengyang
  0 siblings, 0 replies; 3+ messages in thread
From: Hang Zhengyang via B4 Relay @ 2026-10-21  2:56 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, James Clark, Stanislav Fomichev
  Cc: linux-perf-users, linux-kernel, Hang Zhengyang

From: Hang Zhengyang <hang.zhengyang1010@gmail.com>

'perf timechart record -I' skips the syscall tracepoints that are not
available.  When none is, e.g. tracefs is not readable or the kernel lacks
CONFIG_FTRACE_SYSCALLS, perf record falls back to its default event and
succeeds, and 'perf timechart' later fails with a misleading message:

  No trace sample to read. Did you call 'perf timechart record'?

Fail at record time instead, reporting why like parse_events() does.

Fixes: b97b59b93d10 ("perf timechart: Implement IO mode")
Assisted-by: LLM
Signed-off-by: Hang Zhengyang <hang.zhengyang1010@gmail.com>
---
Found because the IO-only case of 'perf test timechart' fails as a
normal user; it is now skipped.  Tested as a normal user and as root
(all three cases pass).  The fix and changelog were drafted with an AI
assistant; I reproduced the issue, reviewed and tested the change.
---
 tools/perf/builtin-timechart.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 9eb335d9db16..69cc89232d6c 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -9,8 +9,10 @@
  */
 
 #include <errno.h>
+#include <fcntl.h>
 #include <inttypes.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "builtin.h"
 #include "util/color.h"
@@ -28,6 +30,7 @@
 #include "util/header.h"
 #include <subcmd/pager.h>
 #include <subcmd/parse-options.h>
+#include <api/fs/tracing_path.h>
 #include "util/parse-events.h"
 #include "util/event.h"
 #include "util/session.h"
@@ -1793,6 +1796,30 @@ static int timechart__tui(struct timechart *tchart)
 	return ret;
 }
 
+/*
+ * None of the syscall tracepoints can be used: find out why from the
+ * syscalls event directory and explain it the way parse_events() does.
+ */
+static void timechart__io_record_error(void)
+{
+	char errbuf[BUFSIZ];
+	char *path = get_events_file("syscalls");
+	int err = ENOENT;
+	int fd;
+
+	if (path) {
+		fd = open(path, O_RDONLY | O_DIRECTORY);
+		if (fd < 0)
+			err = errno;
+		else
+			close(fd);
+		put_events_file(path);
+	}
+
+	tracing_path__strerror_open_tp(err, errbuf, sizeof(errbuf), "syscalls", NULL);
+	pr_err("No syscall tracepoints available to record IO events\n%s", errbuf);
+}
+
 static int timechart__io_record(int argc, const char **argv, const char *output_data)
 {
 	unsigned int rec_argc, i;
@@ -1922,6 +1949,14 @@ static int timechart__io_record(int argc, const char **argv, const char *output_
 		*p++ = filter;
 	}
 
+	/* With no event, perf record would silently use its default one */
+	if (p == rec_argv + common_args_nr) {
+		timechart__io_record_error();
+		free(rec_argv);
+		free(filter);
+		return -1;
+	}
+
 	for (i = 0; i < (unsigned int)argc; i++)
 		*p++ = argv[i];
 

---
base-commit: 1c90f0a3c8a1c4e38f9edd97af9e20848805a7fb
change-id: 20261021-timechart-io-no-tp-4137ca738c92

Best regards,
-- 
Hang Zhengyang <hang.zhengyang1010@gmail.com>



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

* [PATCH] perf timechart: Fail IO recording when no syscall tracepoint is available
@ 2026-10-21  2:56 ` Hang Zhengyang
  0 siblings, 0 replies; 3+ messages in thread
From: Hang Zhengyang @ 2026-10-21  2:56 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, James Clark, Stanislav Fomichev
  Cc: linux-perf-users, linux-kernel, Hang Zhengyang

'perf timechart record -I' skips the syscall tracepoints that are not
available.  When none is, e.g. tracefs is not readable or the kernel lacks
CONFIG_FTRACE_SYSCALLS, perf record falls back to its default event and
succeeds, and 'perf timechart' later fails with a misleading message:

  No trace sample to read. Did you call 'perf timechart record'?

Fail at record time instead, reporting why like parse_events() does.

Fixes: b97b59b93d10 ("perf timechart: Implement IO mode")
Assisted-by: LLM
Signed-off-by: Hang Zhengyang <hang.zhengyang1010@gmail.com>
---
Found because the IO-only case of 'perf test timechart' fails as a
normal user; it is now skipped.  Tested as a normal user and as root
(all three cases pass).  The fix and changelog were drafted with an AI
assistant; I reproduced the issue, reviewed and tested the change.
---
 tools/perf/builtin-timechart.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 9eb335d9db16..69cc89232d6c 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -9,8 +9,10 @@
  */
 
 #include <errno.h>
+#include <fcntl.h>
 #include <inttypes.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "builtin.h"
 #include "util/color.h"
@@ -28,6 +30,7 @@
 #include "util/header.h"
 #include <subcmd/pager.h>
 #include <subcmd/parse-options.h>
+#include <api/fs/tracing_path.h>
 #include "util/parse-events.h"
 #include "util/event.h"
 #include "util/session.h"
@@ -1793,6 +1796,30 @@ static int timechart__tui(struct timechart *tchart)
 	return ret;
 }
 
+/*
+ * None of the syscall tracepoints can be used: find out why from the
+ * syscalls event directory and explain it the way parse_events() does.
+ */
+static void timechart__io_record_error(void)
+{
+	char errbuf[BUFSIZ];
+	char *path = get_events_file("syscalls");
+	int err = ENOENT;
+	int fd;
+
+	if (path) {
+		fd = open(path, O_RDONLY | O_DIRECTORY);
+		if (fd < 0)
+			err = errno;
+		else
+			close(fd);
+		put_events_file(path);
+	}
+
+	tracing_path__strerror_open_tp(err, errbuf, sizeof(errbuf), "syscalls", NULL);
+	pr_err("No syscall tracepoints available to record IO events\n%s", errbuf);
+}
+
 static int timechart__io_record(int argc, const char **argv, const char *output_data)
 {
 	unsigned int rec_argc, i;
@@ -1922,6 +1949,14 @@ static int timechart__io_record(int argc, const char **argv, const char *output_
 		*p++ = filter;
 	}
 
+	/* With no event, perf record would silently use its default one */
+	if (p == rec_argv + common_args_nr) {
+		timechart__io_record_error();
+		free(rec_argv);
+		free(filter);
+		return -1;
+	}
+
 	for (i = 0; i < (unsigned int)argc; i++)
 		*p++ = argv[i];
 

---
base-commit: 1c90f0a3c8a1c4e38f9edd97af9e20848805a7fb
change-id: 20261021-timechart-io-no-tp-4137ca738c92

Best regards,
-- 
Hang Zhengyang <hang.zhengyang1010@gmail.com>


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

* Re: [PATCH] perf timechart: Fail IO recording when no syscall tracepoint is available
  2026-10-21  2:56 ` Hang Zhengyang
  (?)
@ 2026-10-21  3:00 ` sashiko-bot
  -1 siblings, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-10-21  3:00 UTC (permalink / raw)
  To: Hang Zhengyang; +Cc: linux-perf-users

> From: Hang Zhengyang <hang.zhengyang1010@gmail.com>
> 
> 'perf timechart record -I' skips the syscall tracepoints that are not
> available.  When none is, e.g. tracefs is not readable or the kernel lacks
> CONFIG_FTRACE_SYSCALLS, perf record falls back to its default event and
> succeeds, and 'perf timechart' later fails with a misleading message:
> 
>   No trace sample to read. Did you call 'perf timechart record'?
> 
> Fail at record time instead, reporting why like parse_events() does.
> 
> Fixes: b97b59b93d10 ("perf timechart: Implement IO mode")
> Assisted-by: LLM
> Signed-off-by: Hang Zhengyang <hang.zhengyang1010@gmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261021-timechart-io-no-tp-v1-1-71779e7db01e@gmail.com?part=1


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

end of thread, other threads:[~2026-10-21  3:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-21  2:56 [PATCH] perf timechart: Fail IO recording when no syscall tracepoint is available Hang Zhengyang via B4 Relay
2026-10-21  2:56 ` Hang Zhengyang
2026-10-21  3:00 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.