* [PATCH] selftests/powerpc: Import Anton's mmap & futex micro benchmarks
@ 2016-06-02 12:02 Michael Ellerman
2016-06-02 12:05 ` Michael Ellerman
2016-07-05 14:10 ` Michael Ellerman
0 siblings, 2 replies; 3+ messages in thread
From: Michael Ellerman @ 2016-06-02 12:02 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Anton Blanchard
These are useful little loops for smoke testing performance.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
.../selftests/powerpc/benchmarks/.gitignore | 2 ++
.../testing/selftests/powerpc/benchmarks/Makefile | 2 +-
.../selftests/powerpc/benchmarks/futex_bench.c | 42 ++++++++++++++++++++++
.../selftests/powerpc/benchmarks/mmap_bench.c | 41 +++++++++++++++++++++
4 files changed, 86 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/powerpc/benchmarks/futex_bench.c
create mode 100644 tools/testing/selftests/powerpc/benchmarks/mmap_bench.c
diff --git a/tools/testing/selftests/powerpc/benchmarks/.gitignore b/tools/testing/selftests/powerpc/benchmarks/.gitignore
index 6fa673316ac2..bce49ebd869e 100644
--- a/tools/testing/selftests/powerpc/benchmarks/.gitignore
+++ b/tools/testing/selftests/powerpc/benchmarks/.gitignore
@@ -1,2 +1,4 @@
gettimeofday
context_switch
+mmap_bench
+futex_bench
\ No newline at end of file
diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
index 912445ff7ce7..579cc63e6f19 100644
--- a/tools/testing/selftests/powerpc/benchmarks/Makefile
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -1,4 +1,4 @@
-TEST_PROGS := gettimeofday context_switch
+TEST_PROGS := gettimeofday context_switch mmap_bench futex_bench
CFLAGS += -O2
diff --git a/tools/testing/selftests/powerpc/benchmarks/futex_bench.c b/tools/testing/selftests/powerpc/benchmarks/futex_bench.c
new file mode 100644
index 000000000000..f7ba806ddcec
--- /dev/null
+++ b/tools/testing/selftests/powerpc/benchmarks/futex_bench.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2016, Anton Blanchard, Michael Ellerman, IBM Corp.
+ * Licensed under GPLv2.
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <sys/syscall.h>
+#include <time.h>
+#include <unistd.h>
+#include <linux/futex.h>
+
+#include "utils.h"
+
+#define ITERATIONS 100000000
+
+#define futex(A, B, C, D, E, F) syscall(__NR_futex, A, B, C, D, E, F)
+
+int test_futex(void)
+{
+ struct timespec ts_start, ts_end;
+ unsigned long i = ITERATIONS;
+
+ clock_gettime(CLOCK_MONOTONIC, &ts_start);
+
+ while (i--) {
+ unsigned int addr = 0;
+ futex(&addr, FUTEX_WAKE, 1, NULL, NULL, 0);
+ }
+
+ clock_gettime(CLOCK_MONOTONIC, &ts_end);
+
+ printf("time = %.6f\n", ts_end.tv_sec - ts_start.tv_sec + (ts_end.tv_nsec - ts_start.tv_nsec) / 1e9);
+
+ return 0;
+}
+
+int main(void)
+{
+ return test_harness(test_futex, "futex_bench");
+}
diff --git a/tools/testing/selftests/powerpc/benchmarks/mmap_bench.c b/tools/testing/selftests/powerpc/benchmarks/mmap_bench.c
new file mode 100644
index 000000000000..02bb711f84b0
--- /dev/null
+++ b/tools/testing/selftests/powerpc/benchmarks/mmap_bench.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2016, Anton Blanchard, Michael Ellerman, IBM Corp.
+ * Licensed under GPLv2.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <time.h>
+
+#include "utils.h"
+
+#define ITERATIONS 5000000
+
+#define MEMSIZE (128 * 1024 * 1024)
+
+int test_mmap(void)
+{
+ struct timespec ts_start, ts_end;
+ unsigned long i = ITERATIONS;
+
+ clock_gettime(CLOCK_MONOTONIC, &ts_start);
+
+ while (i--) {
+ char *c = mmap(NULL, MEMSIZE, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ FAIL_IF(c == MAP_FAILED);
+ munmap(c, MEMSIZE);
+ }
+
+ clock_gettime(CLOCK_MONOTONIC, &ts_end);
+
+ printf("time = %.6f\n", ts_end.tv_sec - ts_start.tv_sec + (ts_end.tv_nsec - ts_start.tv_nsec) / 1e9);
+
+ return 0;
+}
+
+int main(void)
+{
+ return test_harness(test_mmap, "mmap_bench");
+}
--
2.5.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/powerpc: Import Anton's mmap & futex micro benchmarks
2016-06-02 12:02 [PATCH] selftests/powerpc: Import Anton's mmap & futex micro benchmarks Michael Ellerman
@ 2016-06-02 12:05 ` Michael Ellerman
2016-07-05 14:10 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2016-06-02 12:05 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Anton Blanchard
On Thu, 2016-06-02 at 22:02 +1000, Michael Ellerman wrote:
> +
> +int test_futex(void)
> +{
> + struct timespec ts_start, ts_end;
> + unsigned long i = ITERATIONS;
> +
> + clock_gettime(CLOCK_MONOTONIC, &ts_start);
> +
> + while (i--) {
> + unsigned int addr = 0;
> + futex(&addr, FUTEX_WAKE, 1, NULL, NULL, 0);
> + }
Ugh, I can't even ..
Obviously I'll fix up the whitespace before committing.
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: selftests/powerpc: Import Anton's mmap & futex micro benchmarks
2016-06-02 12:02 [PATCH] selftests/powerpc: Import Anton's mmap & futex micro benchmarks Michael Ellerman
2016-06-02 12:05 ` Michael Ellerman
@ 2016-07-05 14:10 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2016-07-05 14:10 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev; +Cc: Anton Blanchard
On Thu, 2016-02-06 at 12:02:01 UTC, Michael Ellerman wrote:
> These are useful little loops for smoke testing performance.
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Applied to powerpc next.
https://git.kernel.org/powerpc/c/0c63e8b7b97fb72ef38c8edbfb
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-05 14:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-02 12:02 [PATCH] selftests/powerpc: Import Anton's mmap & futex micro benchmarks Michael Ellerman
2016-06-02 12:05 ` Michael Ellerman
2016-07-05 14:10 ` Michael Ellerman
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).