2023-05-30 10:06:30

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v3 0/5] perf tools: Modify mksyscalltbl

Thanks Alexander, Leo and Ian for your reviews and suggestions.

v3:
-- Add a new patch to declare syscalltbl_*[] as const for all archs,
suggested by Ian.
-- Add a new patch to use max_nr to define SYSCALLTBL_ARM64_MAX_ID.

v2:
-- Add a new patch to rename create_table_from_c()
to create_sc_table(), suggested by Leo.
-- Simplify the shell script, suggested by Alexander.

Tiezhu Yang (5):
perf tools: Declare syscalltbl_*[] as const for all archs
perf arm64: Rename create_table_from_c() to create_sc_table()
perf arm64: Handle __NR3264_ prefixed syscall number
perf arm64: Use max_nr to define SYSCALLTBL_ARM64_MAX_ID
perf LoongArch: Simplify mksyscalltbl

tools/perf/arch/arm64/entry/syscalls/mksyscalltbl | 17 ++++-----
.../arch/loongarch/entry/syscalls/mksyscalltbl | 40 +++++++---------------
tools/perf/arch/mips/entry/syscalls/mksyscalltbl | 2 +-
.../perf/arch/powerpc/entry/syscalls/mksyscalltbl | 2 +-
tools/perf/arch/s390/entry/syscalls/mksyscalltbl | 2 +-
tools/perf/arch/x86/entry/syscalls/syscalltbl.sh | 2 +-
tools/perf/util/syscalltbl.c | 14 ++++----
7 files changed, 32 insertions(+), 47 deletions(-)

--
2.1.0



2023-05-30 10:11:38

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v3 1/5] perf tools: Declare syscalltbl_*[] as const for all archs

syscalltbl_*[] should never be changing, let us declare it as const.

Suggested-by: Ian Rogers <[email protected]>
Signed-off-by: Tiezhu Yang <[email protected]>
---
tools/perf/arch/arm64/entry/syscalls/mksyscalltbl | 2 +-
tools/perf/arch/loongarch/entry/syscalls/mksyscalltbl | 2 +-
tools/perf/arch/mips/entry/syscalls/mksyscalltbl | 2 +-
tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl | 2 +-
tools/perf/arch/s390/entry/syscalls/mksyscalltbl | 2 +-
tools/perf/arch/x86/entry/syscalls/syscalltbl.sh | 2 +-
tools/perf/util/syscalltbl.c | 14 +++++++-------
7 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
index 22cdf91..4edcdf6 100755
--- a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
+++ b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
@@ -34,7 +34,7 @@ create_table_from_c()
create_table()
{
echo "#include \"$input\""
- echo "static const char *syscalltbl_arm64[] = {"
+ echo "static const char *const syscalltbl_arm64[] = {"
create_table_from_c
echo "};"
}
diff --git a/tools/perf/arch/loongarch/entry/syscalls/mksyscalltbl b/tools/perf/arch/loongarch/entry/syscalls/mksyscalltbl
index c52156f..5fb83bd 100755
--- a/tools/perf/arch/loongarch/entry/syscalls/mksyscalltbl
+++ b/tools/perf/arch/loongarch/entry/syscalls/mksyscalltbl
@@ -50,7 +50,7 @@ create_table_from_c()

create_table()
{
- echo "static const char *syscalltbl_loongarch[] = {"
+ echo "static const char *const syscalltbl_loongarch[] = {"
create_table_from_c
echo "};"
}
diff --git a/tools/perf/arch/mips/entry/syscalls/mksyscalltbl b/tools/perf/arch/mips/entry/syscalls/mksyscalltbl
index fb1f494..c0d93f9 100644
--- a/tools/perf/arch/mips/entry/syscalls/mksyscalltbl
+++ b/tools/perf/arch/mips/entry/syscalls/mksyscalltbl
@@ -18,7 +18,7 @@ create_table()
{
local max_nr nr abi sc discard

- echo 'static const char *syscalltbl_mips_n64[] = {'
+ echo 'static const char *const syscalltbl_mips_n64[] = {'
while read nr abi sc discard; do
printf '\t[%d] = "%s",\n' $nr $sc
max_nr=$nr
diff --git a/tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl b/tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl
index 6c58060..0eb316f 100755
--- a/tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl
+++ b/tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl
@@ -23,7 +23,7 @@ create_table()
max_nr=-1
nr=0

- echo "static const char *syscalltbl_powerpc_${wordsize}[] = {"
+ echo "static const char *const syscalltbl_powerpc_${wordsize}[] = {"
while read nr abi sc discard; do
if [ "$max_nr" -lt "$nr" ]; then
printf '\t[%d] = "%s",\n' $nr $sc
diff --git a/tools/perf/arch/s390/entry/syscalls/mksyscalltbl b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl
index 72ecbb6..52eb88a 100755
--- a/tools/perf/arch/s390/entry/syscalls/mksyscalltbl
+++ b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl
@@ -18,7 +18,7 @@ create_table()
{
local max_nr nr abi sc discard

- echo 'static const char *syscalltbl_s390_64[] = {'
+ echo 'static const char *const syscalltbl_s390_64[] = {'
while read nr abi sc discard; do
printf '\t[%d] = "%s",\n' $nr $sc
max_nr=$nr
diff --git a/tools/perf/arch/x86/entry/syscalls/syscalltbl.sh b/tools/perf/arch/x86/entry/syscalls/syscalltbl.sh
index 029a72c..fa526a9 100755
--- a/tools/perf/arch/x86/entry/syscalls/syscalltbl.sh
+++ b/tools/perf/arch/x86/entry/syscalls/syscalltbl.sh
@@ -18,7 +18,7 @@ emit() {
syscall_macro "$nr" "$entry"
}

-echo "static const char *syscalltbl_${arch}[] = {"
+echo "static const char *const syscalltbl_${arch}[] = {"

sorted_table=$(mktemp /tmp/syscalltbl.XXXXXX)
grep '^[0-9]' "$in" | sort -n > $sorted_table
diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
index 313ecce..63be7b5 100644
--- a/tools/perf/util/syscalltbl.c
+++ b/tools/perf/util/syscalltbl.c
@@ -17,31 +17,31 @@
#if defined(__x86_64__)
#include <asm/syscalls_64.c>
const int syscalltbl_native_max_id = SYSCALLTBL_x86_64_MAX_ID;
-static const char **syscalltbl_native = syscalltbl_x86_64;
+static const char *const *syscalltbl_native = syscalltbl_x86_64;
#elif defined(__s390x__)
#include <asm/syscalls_64.c>
const int syscalltbl_native_max_id = SYSCALLTBL_S390_64_MAX_ID;
-static const char **syscalltbl_native = syscalltbl_s390_64;
+static const char *const *syscalltbl_native = syscalltbl_s390_64;
#elif defined(__powerpc64__)
#include <asm/syscalls_64.c>
const int syscalltbl_native_max_id = SYSCALLTBL_POWERPC_64_MAX_ID;
-static const char **syscalltbl_native = syscalltbl_powerpc_64;
+static const char *const *syscalltbl_native = syscalltbl_powerpc_64;
#elif defined(__powerpc__)
#include <asm/syscalls_32.c>
const int syscalltbl_native_max_id = SYSCALLTBL_POWERPC_32_MAX_ID;
-static const char **syscalltbl_native = syscalltbl_powerpc_32;
+static const char *const *syscalltbl_native = syscalltbl_powerpc_32;
#elif defined(__aarch64__)
#include <asm/syscalls.c>
const int syscalltbl_native_max_id = SYSCALLTBL_ARM64_MAX_ID;
-static const char **syscalltbl_native = syscalltbl_arm64;
+static const char *const *syscalltbl_native = syscalltbl_arm64;
#elif defined(__mips__)
#include <asm/syscalls_n64.c>
const int syscalltbl_native_max_id = SYSCALLTBL_MIPS_N64_MAX_ID;
-static const char **syscalltbl_native = syscalltbl_mips_n64;
+static const char *const *syscalltbl_native = syscalltbl_mips_n64;
#elif defined(__loongarch__)
#include <asm/syscalls.c>
const int syscalltbl_native_max_id = SYSCALLTBL_LOONGARCH_MAX_ID;
-static const char **syscalltbl_native = syscalltbl_loongarch;
+static const char *const *syscalltbl_native = syscalltbl_loongarch;
#endif

struct syscall {
--
2.1.0


2023-05-30 10:11:39

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v3 3/5] perf arm64: Handle __NR3264_ prefixed syscall number

After commit 9854e7ad35fe ("perf arm64: Simplify mksyscalltbl"),
in the generated syscall table file syscalls.c, there exist some
__NR3264_ prefixed syscall numbers such as [__NR3264_ftruncate],
it looks like not so good, just do some small filter operations
to handle __NR3264_ prefixed syscall number as a digital number.

Without this patch:

[__NR3264_ftruncate] = "ftruncate",

With this patch:

[46] = "ftruncate",

Suggested-by: Alexander Kapshuk <[email protected]>
Signed-off-by: Tiezhu Yang <[email protected]>
Reviewed-by: Leo Yan <[email protected]>
---
tools/perf/arch/arm64/entry/syscalls/mksyscalltbl | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
index 84976dc..0bcd64a 100755
--- a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
+++ b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
@@ -40,6 +40,7 @@ create_table()
}

$gcc -E -dM -x c -I $incpath/include/uapi $input \
- |sed -ne 's/^#define __NR_//p' \
- |sort -t' ' -k2 -n \
+ |awk '$2 ~ "__NR" && $3 !~ "__NR3264_" {
+ sub("^#define __NR(3264)?_", "");
+ print | "sort -k2 -n"}' \
|create_table
--
2.1.0


2023-05-30 10:14:20

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v3 2/5] perf arm64: Rename create_table_from_c() to create_sc_table()

After commit 9854e7ad35fe ("perf arm64: Simplify mksyscalltbl"),
it has been removed the temporary C program and used shell to
generate syscall table, so let us rename create_table_from_c()
to create_sc_table() to avoid confusion.

Suggested-by: Leo Yan <[email protected]>
Signed-off-by: Tiezhu Yang <[email protected]>
---
tools/perf/arch/arm64/entry/syscalls/mksyscalltbl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
index 4edcdf6..84976dc 100755
--- a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
+++ b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
@@ -19,7 +19,7 @@ if ! test -r $input; then
exit 1
fi

-create_table_from_c()
+create_sc_table()
{
local sc nr last_sc

@@ -35,7 +35,7 @@ create_table()
{
echo "#include \"$input\""
echo "static const char *const syscalltbl_arm64[] = {"
- create_table_from_c
+ create_sc_table
echo "};"
}

--
2.1.0


2023-06-01 00:08:47

by Leo Yan

[permalink] [raw]
Subject: Re: [PATCH v3 0/5] perf tools: Modify mksyscalltbl

Hi Tiezhu,

On Tue, May 30, 2023 at 05:51:00PM +0800, Tiezhu Yang wrote:

[...]

> Tiezhu Yang (5):
> perf tools: Declare syscalltbl_*[] as const for all archs
> perf arm64: Rename create_table_from_c() to create_sc_table()
> perf arm64: Handle __NR3264_ prefixed syscall number
> perf arm64: Use max_nr to define SYSCALLTBL_ARM64_MAX_ID
> perf LoongArch: Simplify mksyscalltbl

Either in my mail inbox or on lore site [1], it only shows up 3 patches
but not the 5 patches. Please consider to resend the series.

Thanks,
Leo

[1] https://lore.kernel.org/lkml/[email protected]/

2023-06-01 03:13:24

by Tiezhu Yang

[permalink] [raw]
Subject: Re: [PATCH v3 0/5] perf tools: Modify mksyscalltbl



On 06/01/2023 07:55 AM, Leo Yan wrote:
> Hi Tiezhu,
>
> On Tue, May 30, 2023 at 05:51:00PM +0800, Tiezhu Yang wrote:
>
> [...]
>
>> Tiezhu Yang (5):
>> perf tools: Declare syscalltbl_*[] as const for all archs
>> perf arm64: Rename create_table_from_c() to create_sc_table()
>> perf arm64: Handle __NR3264_ prefixed syscall number
>> perf arm64: Use max_nr to define SYSCALLTBL_ARM64_MAX_ID
>> perf LoongArch: Simplify mksyscalltbl
>
> Either in my mail inbox or on lore site [1], it only shows up 3 patches
> but not the 5 patches. Please consider to resend the series.

Here is the complete patchset:

[PATCH RESEND v3 0/5] perf tools: Modify mksyscalltbl
https://lore.kernel.org/linux-perf-users/[email protected]/

Thanks,
Tiezhu