[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241014112443.97b129e774d9f313dc32568e@kernel.org>
Date: Mon, 14 Oct 2024 11:24:43 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Leo Yan <leo.yan@....com>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim
<namhyung@...nel.org>, Mark Rutland <mark.rutland@....com>, Alexander
Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa
<jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>, Adrian Hunter
<adrian.hunter@...el.com>, "Liang, Kan" <kan.liang@...ux.intel.com>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 3/3] perf probe: Improve log for long event name
failure
On Sat, 12 Oct 2024 21:47:25 +0100
Leo Yan <leo.yan@....com> wrote:
> If a symbol name is longer than the maximum event length (64 bytes), the
> perf tool reports error:
>
> # perf probe -x test_cpp_mangle --add "this_is_a_very_very_long_print_data_abcdefghijklmnopqrstuvwxyz(int)"
> snprintf() failed: -7; the event name nbase='this_is_a_very_very_long_print_data_abcdefghijklmnopqrstuvwxyz(int)' is too long
> Error: Failed to add events.
>
> An information is missed in the log that the symbol name and the event
> name can be set separately. Especially, this is recommended for adding
> probe for a long symbol.
>
> This commit refines the log for reminding event syntax.
>
> After:
>
> # perf probe -x test_cpp_mangle --add "this_is_a_very_very_long_print_data_abcdefghijklmnopqrstuvwxyz(int)"
> snprintf() failed: -7; the event name 'this_is_a_very_very_long_print_data_abcdefghijklmnopqrstuvwxyz(int)' is too long
> Hint: Set a shorter event with syntax "EVENT=PROBEDEF"
> EVENT: Event name (max length: 64 bytes).
> Error: Failed to add events.
>
Nice!
Acked-by: Masami Hiramatsu (Google) <mhiramat@...nel.org>
Thank you,
> Signed-off-by: Leo Yan <leo.yan@....com>
> ---
> tools/perf/util/probe-event.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 224ec6818803..2a2fc5e78c5c 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -2760,7 +2760,10 @@ static int get_new_event_name(char *buf, size_t len, const char *base,
> /* Try no suffix number */
> ret = e_snprintf(buf, len, "%s%s", nbase, ret_event ? "__return" : "");
> if (ret < 0) {
> - pr_warning("snprintf() failed: %d; the event name nbase='%s' is too long\n", ret, nbase);
> + pr_warning("snprintf() failed: %d; the event name '%s' is too long\n"
> + " Hint: Set a shorter event with syntax \"EVENT=PROBEDEF\"\n"
> + " EVENT: Event name (max length: %d bytes).\n",
> + ret, nbase, MAX_EVENT_NAME_LEN);
> goto out;
> }
> if (!strlist__has_entry(namelist, buf))
> @@ -2780,7 +2783,10 @@ static int get_new_event_name(char *buf, size_t len, const char *base,
> for (i = 1; i < MAX_EVENT_INDEX; i++) {
> ret = e_snprintf(buf, len, "%s_%d", nbase, i);
> if (ret < 0) {
> - pr_debug("snprintf() failed: %d\n", ret);
> + pr_warning("Add suffix failed: %d; the event name '%s' is too long\n"
> + " Hint: Set a shorter event with syntax \"EVENT=PROBEDEF\"\n"
> + " EVENT: Event name (max length: %d bytes).\n",
> + ret, nbase, MAX_EVENT_NAME_LEN);
> goto out;
> }
> if (!strlist__has_entry(namelist, buf))
> --
> 2.25.1
>
--
Masami Hiramatsu (Google) <mhiramat@...nel.org>
Powered by blists - more mailing lists