* [PATCH v2] perf beauty: Fix fsconfig generator
@ 2021-04-14 18:27 Vitaly Chikunov
2021-04-14 19:08 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: Vitaly Chikunov @ 2021-04-14 18:27 UTC (permalink / raw)
To: linux-kernel, Arnaldo Carvalho de Melo; +Cc: Dmitry V. Levin, Vitaly Chikunov
After gnulib update sed stopped matching `[[:space:]]*+' as before,
causing the following compilation error:
In file included from builtin-trace.c:719:
trace/beauty/generated/fsconfig_arrays.c:2:3: error: expected expression before ']' token
2 | [] = "",
| ^
trace/beauty/generated/fsconfig_arrays.c:2:3: error: array index in initializer not of integer type
trace/beauty/generated/fsconfig_arrays.c:2:3: note: (near initialization for 'fsconfig_cmds')
Fix this by correcting the regular expression used in the generator.
Also, clean up the script by removing redundant egrep, xargs, and printf
invocations.
Fixes: d35293004a5e4 ("perf beauty: Add generator for fsconfig's 'cmd' arg values")
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
---
tools/perf/trace/beauty/fsconfig.sh | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/tools/perf/trace/beauty/fsconfig.sh b/tools/perf/trace/beauty/fsconfig.sh
index 83fb24df05c9f..bc6ef7bb7a5f9 100755
--- a/tools/perf/trace/beauty/fsconfig.sh
+++ b/tools/perf/trace/beauty/fsconfig.sh
@@ -10,8 +10,7 @@ fi
linux_mount=${linux_header_dir}/mount.h
printf "static const char *fsconfig_cmds[] = {\n"
-regex='^[[:space:]]*+FSCONFIG_([[:alnum:]_]+)[[:space:]]*=[[:space:]]*([[:digit:]]+)[[:space:]]*,[[:space:]]*.*'
-egrep $regex ${linux_mount} | \
- sed -r "s/$regex/\2 \1/g" | \
- xargs printf "\t[%s] = \"%s\",\n"
+ms='[[:space:]]*'
+sed -nr "s/^${ms}FSCONFIG_([[:alnum:]_]+)${ms}=${ms}([[:digit:]]+)${ms},.*/\t[\2] = \"\1\",/p" \
+ ${linux_mount}
printf "};\n"
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] perf beauty: Fix fsconfig generator
2021-04-14 18:27 [PATCH v2] perf beauty: Fix fsconfig generator Vitaly Chikunov
@ 2021-04-14 19:08 ` Arnaldo Carvalho de Melo
2021-04-14 19:14 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-04-14 19:08 UTC (permalink / raw)
To: Vitaly Chikunov; +Cc: linux-kernel, Dmitry V. Levin
Em Wed, Apr 14, 2021 at 09:27:23PM +0300, Vitaly Chikunov escreveu:
> After gnulib update sed stopped matching `[[:space:]]*+' as before,
> causing the following compilation error:
>
> In file included from builtin-trace.c:719:
> trace/beauty/generated/fsconfig_arrays.c:2:3: error: expected expression before ']' token
> 2 | [] = "",
> | ^
> trace/beauty/generated/fsconfig_arrays.c:2:3: error: array index in initializer not of integer type
> trace/beauty/generated/fsconfig_arrays.c:2:3: note: (near initialization for 'fsconfig_cmds')
>
> Fix this by correcting the regular expression used in the generator.
> Also, clean up the script by removing redundant egrep, xargs, and printf
> invocations.
>
> Fixes: d35293004a5e4 ("perf beauty: Add generator for fsconfig's 'cmd' arg values")
> Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
> Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
> ---
> tools/perf/trace/beauty/fsconfig.sh | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/trace/beauty/fsconfig.sh b/tools/perf/trace/beauty/fsconfig.sh
> index 83fb24df05c9f..bc6ef7bb7a5f9 100755
> --- a/tools/perf/trace/beauty/fsconfig.sh
> +++ b/tools/perf/trace/beauty/fsconfig.sh
> @@ -10,8 +10,7 @@ fi
> linux_mount=${linux_header_dir}/mount.h
>
> printf "static const char *fsconfig_cmds[] = {\n"
> -regex='^[[:space:]]*+FSCONFIG_([[:alnum:]_]+)[[:space:]]*=[[:space:]]*([[:digit:]]+)[[:space:]]*,[[:space:]]*.*'
> -egrep $regex ${linux_mount} | \
> - sed -r "s/$regex/\2 \1/g" | \
> - xargs printf "\t[%s] = \"%s\",\n"
> +ms='[[:space:]]*'
> +sed -nr "s/^${ms}FSCONFIG_([[:alnum:]_]+)${ms}=${ms}([[:digit:]]+)${ms},.*/\t[\2] = \"\1\",/p" \
> + ${linux_mount}
> printf "};\n"
It continues working:
[acme@five perf]$ tools/perf/trace/beauty/fsconfig.sh
static const char *fsconfig_cmds[] = {
[0] = "SET_FLAG",
[1] = "SET_STRING",
[2] = "SET_BINARY",
[3] = "SET_PATH",
[4] = "SET_PATH_EMPTY",
[5] = "SET_FD",
[6] = "CMD_CREATE",
[7] = "CMD_RECONFIGURE",
};
[acme@five perf]$
Cool, this is on f33, lemme see on some other distro:
perfbuilder@fd2d918f35e1:/git/perf$ sed --version | head -1
sed (GNU sed) 4.2.2
perfbuilder@fd2d918f35e1:/git/perf$ cat tools/perf/trace/beauty/fsconfig.sh
#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1
if [ $# -ne 1 ] ; then
linux_header_dir=tools/include/uapi/linux
else
linux_header_dir=$1
fi
linux_mount=${linux_header_dir}/mount.h
printf "static const char *fsconfig_cmds[] = {\n"
ms='[[:space:]]*'
sed -nr "s/^${ms}FSCONFIG_([[:alnum:]_]+)${ms}=${ms}([[:digit:]]+)${ms},.*/\t[\2] = \"\1\",/p" \
${linux_mount}
printf "};\n"
perfbuilder@fd2d918f35e1:/git/perf$ tools/perf/trace/beauty/fsconfig.sh
static const char *fsconfig_cmds[] = {
[0] = "SET_FLAG",
[1] = "SET_STRING",
[2] = "SET_BINARY",
[3] = "SET_PATH",
[4] = "SET_PATH_EMPTY",
[5] = "SET_FD",
[6] = "CMD_CREATE",
[7] = "CMD_RECONFIGURE",
};
perfbuilder@fd2d918f35e1:/git/perf$
[perfbuilder@five sisyphus]$ dsh alt:sisyphus
sh-4.4# bash
[root@6db6d5ad9661 /]# cat /etc/redhat-release
ALT Sisyphus Sisyphus (unstable) (sisyphus)
[root@6db6d5ad9661 /]# cd /git
[root@6db6d5ad9661 git]# cd perf
[root@6db6d5ad9661 perf]# cat tools/perf/trace/beauty/fsconfig.sh
#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1
if [ $# -ne 1 ] ; then
linux_header_dir=tools/include/uapi/linux
else
linux_header_dir=$1
fi
linux_mount=${linux_header_dir}/mount.h
printf "static const char *fsconfig_cmds[] = {\n"
ms='[[:space:]]*'
sed -nr "s/^${ms}FSCONFIG_([[:alnum:]_]+)${ms}=${ms}([[:digit:]]+)${ms},.*/\t[\2] = \"\1\",/p" \
${linux_mount}
printf "};\n"
[root@6db6d5ad9661 perf]# tools/perf/trace/beauty/fsconfig.sh
static const char *fsconfig_cmds[] = {
[0] = "SET_FLAG",
[1] = "SET_STRING",
[2] = "SET_BINARY",
[3] = "SET_PATH",
[4] = "SET_PATH_EMPTY",
[5] = "SET_FD",
[6] = "CMD_CREATE",
[7] = "CMD_RECONFIGURE",
};
[root@6db6d5ad9661 perf]#
So I guess we can sweep thru tools/perf/trace/beauty/*.sh and simplify
things in other table generators?
Please consider this.
Thanks, applied.
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] perf beauty: Fix fsconfig generator
2021-04-14 19:08 ` Arnaldo Carvalho de Melo
@ 2021-04-14 19:14 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-04-14 19:14 UTC (permalink / raw)
To: Vitaly Chikunov; +Cc: linux-kernel, Dmitry V. Levin
Em Wed, Apr 14, 2021 at 04:08:12PM -0300, Arnaldo Carvalho de Melo escreveu:
> [root@6db6d5ad9661 perf]# tools/perf/trace/beauty/fsconfig.sh
> static const char *fsconfig_cmds[] = {
> [0] = "SET_FLAG",
> [1] = "SET_STRING",
> [2] = "SET_BINARY",
> [3] = "SET_PATH",
> [4] = "SET_PATH_EMPTY",
> [5] = "SET_FD",
> [6] = "CMD_CREATE",
> [7] = "CMD_RECONFIGURE",
> };
> [root@6db6d5ad9661 perf]#
>
> So I guess we can sweep thru tools/perf/trace/beauty/*.sh and simplify
> things in other table generators?
>
> Please consider this.
>
> Thanks, applied.
Its in my tmp.perf/core branch, will go to the main one after what is in
there passes my longish regression test suite,
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-14 19:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-14 18:27 [PATCH v2] perf beauty: Fix fsconfig generator Vitaly Chikunov
2021-04-14 19:08 ` Arnaldo Carvalho de Melo
2021-04-14 19:14 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.