[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1662433577-23266-3-git-send-email-yangtiezhu@loongson.cn>
Date: Tue, 6 Sep 2022 11:06:16 +0800
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
To: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>
Cc: linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 2/3] perf bench syscall: Add close syscall benchmark
This commit adds a simple close syscall benchmark, more syscall
benchmarks can be added in the future.
Here are the test results:
[loongson@...ux perf]$ ./perf bench syscall
# List of available benchmarks for collection 'syscall':
basic: Benchmark for basic getppid(2) calls
close: Benchmark for close(2) calls
all: Run all syscall benchmarks
[loongson@...ux perf]$ ./perf bench syscall basic
# Running 'syscall/basic' benchmark:
# Executed 10000000 getppid() calls
Total time: 1.956 [sec]
0.195687 usecs/op
5110201 ops/sec
[loongson@...ux perf]$ ./perf bench syscall close
# Running 'syscall/close' benchmark:
# Executed 10000000 close() calls
Total time: 6.302 [sec]
0.630297 usecs/op
1586553 ops/sec
[loongson@...ux perf]$ ./perf bench syscall all
# Running syscall/basic benchmark...
# Executed 10000000 getppid() calls
Total time: 1.956 [sec]
0.195686 usecs/op
5110232 ops/sec
# Running syscall/close benchmark...
# Executed 10000000 close() calls
Total time: 6.302 [sec]
0.630271 usecs/op
1586619 ops/sec
Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
---
tools/perf/bench/bench.h | 1 +
tools/perf/bench/syscall.c | 11 +++++++++++
tools/perf/builtin-bench.c | 1 +
3 files changed, 13 insertions(+)
diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h
index 6cefb43..916cd47 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_close(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..058394b 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_close:
+ close(dup(0));
+ 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_close:
+ name = "close()";
+ 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_close(int argc, const char **argv)
+{
+ return bench_syscall_common(argc, argv, __NR_close);
+}
diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index 334ab89..b63c711 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 },
+ { "close", "Benchmark for close(2) calls", bench_syscall_close },
{ "all", "Run all syscall benchmarks", NULL },
{ NULL, NULL, NULL },
};
--
2.1.0
Powered by blists - more mailing lists