From: James Clark <james.clark@linaro.org>
To: Chun-Tse Shao <ctshao@google.com>
Cc: wy.shih90@gmail.com, Ian Rogers <irogers@google.com>,
peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
namhyung@kernel.org, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
adrian.hunter@intel.com, kan.liang@linux.intel.com,
tmricht@linux.ibm.com, leo.yan@arm.com,
atrajeev@linux.vnet.ibm.com, linux-perf-users@vger.kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] perf test: Replace grep perl regexp with awk
Date: Mon, 23 Jun 2025 15:12:00 +0100 [thread overview]
Message-ID: <e8c28a7e-bc08-4c50-96ca-afe62cfcf9fd@linaro.org> (raw)
In-Reply-To: <20250620174034.819894-1-ctshao@google.com>
On 20/06/2025 6:40 pm, Chun-Tse Shao wrote:
> perl is not universal on all machines and should be replaced with awk,
> which is much more common.
>
> Before:
> $ perf test "probe libc's inet_pton & backtrace it with ping" -v
> --- start ---
> test child forked, pid 145431
> grep: Perl matching not supported in a --disable-perl-regexp build
>
> FAIL: could not add event
> ---- end(-1) ----
> 121: probe libc's inet_pton & backtrace it with ping : FAILED!
> After:
> $ perf test "probe libc's inet_pton & backtrace it with ping" -v
> 121: probe libc's inet_pton & backtrace it with ping : Ok
>
> Suggested-by: Ian Rogers <irogers@google.com>
> Signed-off-by: Chun-Tse Shao <ctshao@google.com>
> ---
> tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
> index c4bab5b5cc59..aaa5ee06ae18 100755
> --- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
> +++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
> @@ -23,7 +23,8 @@ event_pattern='probe_libc:inet_pton(\_[[:digit:]]+)?'
> add_libc_inet_pton_event() {
>
> event_name=$(perf probe -f -x $libc -a inet_pton 2>&1 | tail -n +2 | head -n -5 | \
> - grep -P -o "$event_pattern(?=[[:space:]]\(on inet_pton in $libc\))")
> + awk -v ep="$event_pattern" -v l="$libc" '$0 ~ ep && $0 ~ \
> + ("\\(on inet_pton in " l "\\)") {print $1}')
>
> if [ $? -ne 0 ] || [ -z "$event_name" ] ; then
> printf "FAIL: could not add event\n"
> --
> 2.50.0.rc2.701.gf1e915cc24-goog
>
Minor nit: the underscore in event_pattern (not shown in the diff) never
needed to be escaped.
But now we're using awk it gives a warning so we should remove it in
case anyone is searching through the output:
awk: warning: escape sequence `\_' treated as plain `_'
Reviewed-by: James Clark <james.clark@linaro.org>
next prev parent reply other threads:[~2025-06-23 14:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 17:40 Chun-Tse Shao
2025-06-23 14:12 ` James Clark [this message]
2025-06-24 17:56 ` Namhyung Kim
2025-06-25 18:04 ` Namhyung Kim
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=e8c28a7e-bc08-4c50-96ca-afe62cfcf9fd@linaro.org \
--to=james.clark@linaro.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=ctshao@google.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=leo.yan@arm.com \
--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=tmricht@linux.ibm.com \
--cc=wy.shih90@gmail.com \
/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®