mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hang Zhengyang via B4 Relay <devnull+hang.zhengyang1010.gmail.com@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	 Arnaldo Carvalho de Melo <acme@kernel.org>,
	 Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	 Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	 Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	 Adrian Hunter <adrian.hunter@intel.com>,
	 James Clark <james.clark@linaro.org>,
	Stanislav Fomichev <sdf@fomichev.me>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Hang Zhengyang <hang.zhengyang1010@gmail.com>
Subject: [PATCH] perf timechart: Fail IO recording when no syscall tracepoint is available
Date: Wed, 21 Oct 2026 10:56:19 +0800	[thread overview]
Message-ID: <20261021-timechart-io-no-tp-v1-1-71779e7db01e@gmail.com> (raw)

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>



                 reply	other threads:[~2026-10-21  2:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261021-timechart-io-no-tp-v1-1-71779e7db01e@gmail.com \
    --to=devnull+hang.zhengyang1010.gmail.com@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=hang.zhengyang1010@gmail.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sdf@fomichev.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®