Re: [PATCH v2] perf ftrace: Detect whether ftrace is enabled on system
From: Arnaldo Carvalho de Melo
Date: Wed Sep 11 2024 - 08:34:09 EST
On Wed, Sep 11, 2024 at 11:15:19AM +0100, James Clark wrote:
> On 11/09/2024 11:01, Changbin Du wrote:
> > To make error messages more accurate, this change detects whether ftrace is
> > enabled on system by checking trace file "set_ftrace_pid".
<SNIP>
> > @@ -1583,6 +1601,11 @@ int cmd_ftrace(int argc, const char **argv)
> > if (!check_ftrace_capable())
> > return -1;
> > + if (!is_ftrace_supported()) {
> > + pr_err("ftrace is not supported on this system\n");
> > + return -ENOTSUP;
> > + }
> > +
> > ret = perf_config(perf_ftrace_config, &ftrace);
> > if (ret < 0)
> > return -1;
>
> Reviewed-by: James Clark <james.clark@xxxxxxxxxx>
Applied and added these comments:
Committer testing:
Doing it in an unprivileged toolbox container on Fedora 40:
Before:
acme@number:~/git/perf-tools-next$ toolbox enter perf
⬢[acme@toolbox perf-tools-next]$ sudo su -
⬢[root@toolbox ~]# ~acme/bin/perf ftrace
failed to reset ftrace
⬢[root@toolbox ~]#
After this patch:
⬢[root@toolbox ~]# ~acme/bin/perf ftrace
ftrace is not supported on this system
⬢[root@toolbox ~]#
Maybe we could check if we are in such as situation, inside an
unprivileged container, and provide a HINT line?
Reviewed-by: James Clark <james.clark@xxxxxxxxxx>
Signed-off-by: Changbin Du <changbin.du@xxxxxxxxxx>
Tested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>