* [PATCH v1] perf test: Replace grep perl regexp with awk
@ 2025-06-20 17:40 Chun-Tse Shao
2025-06-23 14:12 ` James Clark
2025-06-25 18:04 ` Namhyung Kim
0 siblings, 2 replies; 4+ messages in thread
From: Chun-Tse Shao @ 2025-06-20 17:40 UTC (permalink / raw)
To: linux-kernel
Cc: wy.shih90, Chun-Tse Shao, Ian Rogers, peterz, mingo, acme,
namhyung, mark.rutland, alexander.shishkin, jolsa, adrian.hunter,
kan.liang, james.clark, tmricht, leo.yan, atrajeev,
linux-perf-users
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1] perf test: Replace grep perl regexp with awk
2025-06-20 17:40 [PATCH v1] perf test: Replace grep perl regexp with awk Chun-Tse Shao
@ 2025-06-23 14:12 ` James Clark
2025-06-24 17:56 ` Namhyung Kim
2025-06-25 18:04 ` Namhyung Kim
1 sibling, 1 reply; 4+ messages in thread
From: James Clark @ 2025-06-23 14:12 UTC (permalink / raw)
To: Chun-Tse Shao
Cc: wy.shih90, Ian Rogers, peterz, mingo, acme, namhyung,
mark.rutland, alexander.shishkin, jolsa, adrian.hunter, kan.liang,
tmricht, leo.yan, atrajeev, linux-perf-users,
linux-kernel@vger.kernel.org
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] perf test: Replace grep perl regexp with awk
2025-06-23 14:12 ` James Clark
@ 2025-06-24 17:56 ` Namhyung Kim
0 siblings, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2025-06-24 17:56 UTC (permalink / raw)
To: James Clark
Cc: Chun-Tse Shao, wy.shih90, Ian Rogers, peterz, mingo, acme,
mark.rutland, alexander.shishkin, jolsa, adrian.hunter, kan.liang,
tmricht, leo.yan, atrajeev, linux-perf-users,
linux-kernel@vger.kernel.org
Hello,
On Mon, Jun 23, 2025 at 03:12:00PM +0100, James Clark wrote:
>
>
> 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>
Thanks for your review. I'll fold the below change.
---8<---
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 aaa5ee06ae1833de..9bdf47aabe9d738b 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -18,7 +18,7 @@
libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1/g')
nm -Dg $libc 2>/dev/null | grep -F -q inet_pton || exit 254
-event_pattern='probe_libc:inet_pton(\_[[:digit:]]+)?'
+event_pattern='probe_libc:inet_pton(_[[:digit:]]+)?'
add_libc_inet_pton_event() {
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1] perf test: Replace grep perl regexp with awk
2025-06-20 17:40 [PATCH v1] perf test: Replace grep perl regexp with awk Chun-Tse Shao
2025-06-23 14:12 ` James Clark
@ 2025-06-25 18:04 ` Namhyung Kim
1 sibling, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2025-06-25 18:04 UTC (permalink / raw)
To: linux-kernel, Chun-Tse Shao
Cc: wy.shih90, Ian Rogers, peterz, mingo, acme, mark.rutland,
alexander.shishkin, jolsa, adrian.hunter, kan.liang, james.clark,
tmricht, leo.yan, atrajeev, linux-perf-users
On Fri, 20 Jun 2025 10:40:09 -0700, 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
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-25 18:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-20 17:40 [PATCH v1] perf test: Replace grep perl regexp with awk Chun-Tse Shao
2025-06-23 14:12 ` James Clark
2025-06-24 17:56 ` Namhyung Kim
2025-06-25 18:04 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).