2022-11-09 08:46:34

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v4 0/4] perf: Add more syscalls to benchmark

Tiezhu Yang (4):
tools x86: Keep list sorted by number in unistd_{32,64}.h
perf bench syscall: Introduce bench_syscall_common()
perf bench syscall: Add getpgrp syscall benchmark
perf bench syscall: Add execve syscall benchmark

tools/arch/x86/include/uapi/asm/unistd_32.h | 23 ++++++---
tools/arch/x86/include/uapi/asm/unistd_64.h | 23 ++++++---
tools/perf/bench/bench.h | 2 +
tools/perf/bench/syscall.c | 76 +++++++++++++++++++++++++++--
tools/perf/builtin-bench.c | 2 +
5 files changed, 108 insertions(+), 18 deletions(-)

--
2.1.0



2022-11-09 08:53:58

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v4 3/4] perf bench syscall: Add getpgrp syscall benchmark

This commit adds a simple getpgrp syscall benchmark, more syscall
benchmarks can be added in the future.

Signed-off-by: Tiezhu Yang <[email protected]>
---
tools/arch/x86/include/uapi/asm/unistd_32.h | 3 +++
tools/arch/x86/include/uapi/asm/unistd_64.h | 3 +++
tools/perf/bench/bench.h | 1 +
tools/perf/bench/syscall.c | 11 +++++++++++
tools/perf/builtin-bench.c | 1 +
5 files changed, 19 insertions(+)

diff --git a/tools/arch/x86/include/uapi/asm/unistd_32.h b/tools/arch/x86/include/uapi/asm/unistd_32.h
index 4d8873a..2bcf47f 100644
--- a/tools/arch/x86/include/uapi/asm/unistd_32.h
+++ b/tools/arch/x86/include/uapi/asm/unistd_32.h
@@ -2,6 +2,9 @@
#ifndef __NR_getppid
#define __NR_getppid 64
#endif
+#ifndef __NR_getpgrp
+#define __NR_getpgrp 65
+#endif
#ifndef __NR_gettid
#define __NR_gettid 224
#endif
diff --git a/tools/arch/x86/include/uapi/asm/unistd_64.h b/tools/arch/x86/include/uapi/asm/unistd_64.h
index e29038a..5472203 100644
--- a/tools/arch/x86/include/uapi/asm/unistd_64.h
+++ b/tools/arch/x86/include/uapi/asm/unistd_64.h
@@ -2,6 +2,9 @@
#ifndef __NR_getppid
#define __NR_getppid 110
#endif
+#ifndef __NR_getpgrp
+#define __NR_getpgrp 111
+#endif
#ifndef __NR_gettid
#define __NR_gettid 186
#endif
diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h
index 6cefb43..7ccc021 100644
--- a/tools/perf/bench/bench.h
+++ b/tools/perf/bench/bench.h
@@ -34,6 +34,7 @@ int bench_numa(int argc, const char **argv);
int bench_sched_messaging(int argc, const char **argv);
int bench_sched_pipe(int argc, const char **argv);
int bench_syscall_basic(int argc, const char **argv);
+int bench_syscall_getpgrp(int argc, const char **argv);
int bench_mem_memcpy(int argc, const char **argv);
int bench_mem_memset(int argc, const char **argv);
int bench_mem_find_bit(int argc, const char **argv);
diff --git a/tools/perf/bench/syscall.c b/tools/perf/bench/syscall.c
index 746fd71..2b89884 100644
--- a/tools/perf/bench/syscall.c
+++ b/tools/perf/bench/syscall.c
@@ -46,6 +46,9 @@ static int bench_syscall_common(int argc, const char **argv, int syscall)
case __NR_getppid:
getppid();
break;
+ case __NR_getpgrp:
+ getpgrp();
+ break;
default:
break;
}
@@ -58,6 +61,9 @@ static int bench_syscall_common(int argc, const char **argv, int syscall)
case __NR_getppid:
name = "getppid()";
break;
+ case __NR_getpgrp:
+ name = "getpgrp()";
+ break;
default:
break;
}
@@ -100,3 +106,8 @@ int bench_syscall_basic(int argc, const char **argv)
{
return bench_syscall_common(argc, argv, __NR_getppid);
}
+
+int bench_syscall_getpgrp(int argc, const char **argv)
+{
+ return bench_syscall_common(argc, argv, __NR_getpgrp);
+}
diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index 334ab89..20ca4ac 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -52,6 +52,7 @@ static struct bench sched_benchmarks[] = {

static struct bench syscall_benchmarks[] = {
{ "basic", "Benchmark for basic getppid(2) calls", bench_syscall_basic },
+ { "getpgrp", "Benchmark for getpgrp(2) calls", bench_syscall_getpgrp },
{ "all", "Run all syscall benchmarks", NULL },
{ NULL, NULL, NULL },
};
--
2.1.0


2022-11-09 09:11:47

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v4 1/4] tools x86: Keep list sorted by number in unistd_{32,64}.h

It is better to keep list sorted by number in unistd_{32,64}.h,
so that we can add more syscall number to a proper position.

This is preparation for later patch, no functionality change.

Signed-off-by: Tiezhu Yang <[email protected]>
---
tools/arch/x86/include/uapi/asm/unistd_32.h | 16 ++++++++--------
tools/arch/x86/include/uapi/asm/unistd_64.h | 16 ++++++++--------
2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/tools/arch/x86/include/uapi/asm/unistd_32.h b/tools/arch/x86/include/uapi/asm/unistd_32.h
index 60a89db..e1cc62d 100644
--- a/tools/arch/x86/include/uapi/asm/unistd_32.h
+++ b/tools/arch/x86/include/uapi/asm/unistd_32.h
@@ -1,16 +1,16 @@
/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __NR_perf_event_open
-# define __NR_perf_event_open 336
+#ifndef __NR_gettid
+#define __NR_gettid 224
#endif
#ifndef __NR_futex
-# define __NR_futex 240
-#endif
-#ifndef __NR_gettid
-# define __NR_gettid 224
+#define __NR_futex 240
#endif
#ifndef __NR_getcpu
-# define __NR_getcpu 318
+#define __NR_getcpu 318
+#endif
+#ifndef __NR_perf_event_open
+#define __NR_perf_event_open 336
#endif
#ifndef __NR_setns
-# define __NR_setns 346
+#define __NR_setns 346
#endif
diff --git a/tools/arch/x86/include/uapi/asm/unistd_64.h b/tools/arch/x86/include/uapi/asm/unistd_64.h
index cb52a3a..ce8b7ab 100644
--- a/tools/arch/x86/include/uapi/asm/unistd_64.h
+++ b/tools/arch/x86/include/uapi/asm/unistd_64.h
@@ -1,16 +1,16 @@
/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __NR_perf_event_open
-# define __NR_perf_event_open 298
+#ifndef __NR_gettid
+#define __NR_gettid 186
#endif
#ifndef __NR_futex
-# define __NR_futex 202
-#endif
-#ifndef __NR_gettid
-# define __NR_gettid 186
+#define __NR_futex 202
#endif
-#ifndef __NR_getcpu
-# define __NR_getcpu 309
+#ifndef __NR_perf_event_open
+#define __NR_perf_event_open 298
#endif
#ifndef __NR_setns
#define __NR_setns 308
#endif
+#ifndef __NR_getcpu
+#define __NR_getcpu 309
+#endif
--
2.1.0


2022-11-09 18:36:21

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH v4 0/4] perf: Add more syscalls to benchmark

Hello,

On Wed, Nov 9, 2022 at 12:29 AM Tiezhu Yang <[email protected]> wrote:
>
> Tiezhu Yang (4):
> tools x86: Keep list sorted by number in unistd_{32,64}.h
> perf bench syscall: Introduce bench_syscall_common()
> perf bench syscall: Add getpgrp syscall benchmark
> perf bench syscall: Add execve syscall benchmark

Have you tested it on non-x86 too? It seems you only added the syscall
numbers to x86.

Thanks,
Namhyung


>
> tools/arch/x86/include/uapi/asm/unistd_32.h | 23 ++++++---
> tools/arch/x86/include/uapi/asm/unistd_64.h | 23 ++++++---
> tools/perf/bench/bench.h | 2 +
> tools/perf/bench/syscall.c | 76 +++++++++++++++++++++++++++--
> tools/perf/builtin-bench.c | 2 +
> 5 files changed, 108 insertions(+), 18 deletions(-)
>
> --
> 2.1.0
>

2022-11-10 03:15:07

by Tiezhu Yang

[permalink] [raw]
Subject: Re: [PATCH v4 0/4] perf: Add more syscalls to benchmark



On 11/10/2022 02:15 AM, Namhyung Kim wrote:
> Hello,
>
> On Wed, Nov 9, 2022 at 12:29 AM Tiezhu Yang <[email protected]> wrote:
>>
>> Tiezhu Yang (4):
>> tools x86: Keep list sorted by number in unistd_{32,64}.h
>> perf bench syscall: Introduce bench_syscall_common()
>> perf bench syscall: Add getpgrp syscall benchmark
>> perf bench syscall: Add execve syscall benchmark
>
> Have you tested it on non-x86 too? It seems you only added the syscall
> numbers to x86.
>

Hi Namhyung,

Thank you for your reply.

I tested only on x86, when build on arm64, there exists
the following build error:

error: ‘__NR_getpgrp’ undeclared (first use in this function)

this is because __NR_getpgrp is deprecated on some archs.

Sorry for that, let me use getpgid, I will test on x86_64, arm64,
mips64 and loongarch64, and then send v5, thank you.

Thanks,
Tiezhu