From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] perf bench syscall: Add close syscall benchmark
Date: Tue, 6 Sep 2022 11:06:16 +0800 [thread overview]
Message-ID: <1662433577-23266-3-git-send-email-yangtiezhu@loongson.cn> (raw)
In-Reply-To: <1662433577-23266-1-git-send-email-yangtiezhu@loongson.cn>
This commit adds a simple close syscall benchmark, more syscall
benchmarks can be added in the future.
Here are the test results:
[loongson@linux 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@linux 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@linux 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@linux 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@loongson.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
next prev parent reply other threads:[~2022-09-06 3:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-06 3:06 [PATCH 0/3] perf: Add more syscalls to benchmark Tiezhu Yang
2022-09-06 3:06 ` [PATCH 1/3] perf bench syscall: Introduce bench_syscall_common() Tiezhu Yang
2022-09-20 7:44 ` [perf bench syscall] 30463f9f35: perf-test.perf.make_fail kernel test robot
2022-09-06 3:06 ` Tiezhu Yang [this message]
2022-09-06 3:30 ` [PATCH 2/3] perf bench syscall: Add close syscall benchmark David Laight
2022-09-06 4:27 ` Tiezhu Yang
2022-09-06 3:06 ` [PATCH 3/3] perf bench syscall: Add execve " Tiezhu Yang
2022-09-28 1:06 ` [PATCH 0/3] perf: Add more syscalls to benchmark Tiezhu Yang
2022-09-28 14:15 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1662433577-23266-3-git-send-email-yangtiezhu@loongson.cn \
--to=yangtiezhu@loongson.cn \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).