diff mbox

[v2,1/2] powerpc/selftest: Add gettimeofday() benchmark

Message ID 1443153700-15395-2-git-send-email-mikey@neuling.org (mailing list archive)
State Accepted
Headers show

Commit Message

Michael Neuling Sept. 25, 2015, 4:01 a.m. UTC
This adds a benchmark directory to the powerpc selftests and adds a
gettimeofday() benchmark to it.

Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 tools/testing/selftests/powerpc/Makefile           |  2 +-
 .../testing/selftests/powerpc/benchmarks/Makefile  | 12 +++++++++
 .../selftests/powerpc/benchmarks/gettimeofday.c    | 31 ++++++++++++++++++++++
 3 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/powerpc/benchmarks/Makefile
 create mode 100644 tools/testing/selftests/powerpc/benchmarks/gettimeofday.c

Comments

Arnd Bergmann Sept. 25, 2015, 7:39 a.m. UTC | #1
On Friday 25 September 2015 14:01:39 Michael Neuling wrote:
> This adds a benchmark directory to the powerpc selftests and adds a
> gettimeofday() benchmark to it.
> 
> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> 

Any reason for keeping this powerpc specific? It seems generally useful.
and portable.

	Arnd
Denis Kirjanov Sept. 25, 2015, 9:28 a.m. UTC | #2
On 9/25/15, Arnd Bergmann <arnd@arndb.de> wrote:
> On Friday 25 September 2015 14:01:39 Michael Neuling wrote:
>> This adds a benchmark directory to the powerpc selftests and adds a
>> gettimeofday() benchmark to it.
>>
>> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
>> Signed-off-by: Michael Neuling <mikey@neuling.org>
>>
>
> Any reason for keeping this powerpc specific? It seems generally useful.
> and portable.
You're right. Moreover, we can put some comment to the benchmark why
we've made such decision to add it (reference to the commit
"powerpc/vdso: Avoid link stack corruption in __get_datapage()")

>
> 	Arnd
>
Gabriel Paubert Sept. 25, 2015, 9:37 a.m. UTC | #3
On Fri, Sep 25, 2015 at 12:28:30PM +0300, Denis Kirjanov wrote:
> On 9/25/15, Arnd Bergmann <arnd@arndb.de> wrote:
> > On Friday 25 September 2015 14:01:39 Michael Neuling wrote:
> >> This adds a benchmark directory to the powerpc selftests and adds a
> >> gettimeofday() benchmark to it.
> >>
> >> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
> >> Signed-off-by: Michael Neuling <mikey@neuling.org>
> >>
> >
> > Any reason for keeping this powerpc specific? It seems generally useful.
> > and portable.
> You're right. Moreover, we can put some comment to the benchmark why
> we've made such decision to add it (reference to the commit
> "powerpc/vdso: Avoid link stack corruption in __get_datapage()")

Why gettimeofday? Isn't clock_gettime the modern variant?

BTW: dows anyone receive 2 copies of every messge in this thread ?

I do, and I suspect that this is due to the Cc: list having both
linuxppc-dev@ozlabs.org and linuxppc-dev@lists.ozlabs.org. I removed the
former for this reply.

    Gabriel
Denis Kirjanov Sept. 25, 2015, 12:47 p.m. UTC | #4
On 9/25/15, Gabriel Paubert <paubert@iram.es> wrote:
> On Fri, Sep 25, 2015 at 12:28:30PM +0300, Denis Kirjanov wrote:
>> On 9/25/15, Arnd Bergmann <arnd@arndb.de> wrote:
>> > On Friday 25 September 2015 14:01:39 Michael Neuling wrote:
>> >> This adds a benchmark directory to the powerpc selftests and adds a
>> >> gettimeofday() benchmark to it.
>> >>
>> >> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
>> >> Signed-off-by: Michael Neuling <mikey@neuling.org>
>> >>
>> >
>> > Any reason for keeping this powerpc specific? It seems generally
>> > useful.
>> > and portable.
>> You're right. Moreover, we can put some comment to the benchmark why
>> we've made such decision to add it (reference to the commit
>> "powerpc/vdso: Avoid link stack corruption in __get_datapage()")
>
> Why gettimeofday? Isn't clock_gettime the modern variant?

Mostly, I think, for historical reasons. Both of them are implemented
as vsyscalls (on ppc, ) so why bother?

BTW: Found an interesting vdso testsuite on github:
https://github.com/nlynch-mentor/vdsotest under GPL. Not sure if we
really need such similar thing in the kernel selftest sources.

>
> BTW: dows anyone receive 2 copies of every messge in this thread ?
>
> I do, and I suspect that this is due to the Cc: list having both
> linuxppc-dev@ozlabs.org and linuxppc-dev@lists.ozlabs.org. I removed the
> former for this reply.
>
>     Gabriel
>
Michael Neuling Sept. 28, 2015, 8:58 a.m. UTC | #5
On Fri, 2015-09-25 at 11:37 +0200, Gabriel Paubert wrote:
> On Fri, Sep 25, 2015 at 12:28:30PM +0300, Denis Kirjanov wrote:
> > On 9/25/15, Arnd Bergmann <arnd@arndb.de> wrote:
> > > On Friday 25 September 2015 14:01:39 Michael Neuling wrote:
> > >> This adds a benchmark directory to the powerpc selftests and adds a
> > >> gettimeofday() benchmark to it.
> > >>
> > >> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
> > >> Signed-off-by: Michael Neuling <mikey@neuling.org>
> > >>
> > >
> > > Any reason for keeping this powerpc specific? It seems generally useful.
> > > and portable.
> > You're right. Moreover, we can put some comment to the benchmark why
> > we've made such decision to add it (reference to the commit
> > "powerpc/vdso: Avoid link stack corruption in __get_datapage()")
> 
> Why gettimeofday? Isn't clock_gettime the modern variant?

We can do either here really.  I just wanted to test __get_datapage()
really.  I just stole the benchmark from Anton, which turned into mpe
wanting it in selftests.  I dumped it in powerpc mostly because I knew
mpe would take it (ie. I'm was being lazy).

> BTW: dows anyone receive 2 copies of every messge in this thread ?

I'm not.

Mikey

> 
> I do, and I suspect that this is due to the Cc: list having both
> linuxppc-dev@ozlabs.org and linuxppc-dev@lists.ozlabs.org. I removed the
> former for this reply.
> 
>     Gabriel
Denis Kirjanov Sept. 28, 2015, 9:56 a.m. UTC | #6
On 9/28/15, Michael Neuling <mikey@neuling.org> wrote:
> On Fri, 2015-09-25 at 11:37 +0200, Gabriel Paubert wrote:
>> On Fri, Sep 25, 2015 at 12:28:30PM +0300, Denis Kirjanov wrote:
>> > On 9/25/15, Arnd Bergmann <arnd@arndb.de> wrote:
>> > > On Friday 25 September 2015 14:01:39 Michael Neuling wrote:
>> > >> This adds a benchmark directory to the powerpc selftests and adds a
>> > >> gettimeofday() benchmark to it.
>> > >>
>> > >> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
>> > >> Signed-off-by: Michael Neuling <mikey@neuling.org>
>> > >>
>> > >
>> > > Any reason for keeping this powerpc specific? It seems generally
>> > > useful.
>> > > and portable.
>> > You're right. Moreover, we can put some comment to the benchmark why
>> > we've made such decision to add it (reference to the commit
>> > "powerpc/vdso: Avoid link stack corruption in __get_datapage()")
>>
>> Why gettimeofday? Isn't clock_gettime the modern variant?
>
> We can do either here really.  I just wanted to test __get_datapage()
> really.  I just stole the benchmark from Anton, which turned into mpe
> wanting it in selftests.  I dumped it in powerpc mostly because I knew
> mpe would take it (ie. I'm was being lazy).

Yeah, so the quickest way would be to apply the patch as is. Then
someone can make it generic.
So now it depends on Michael's decision :)
>
>> BTW: dows anyone receive 2 copies of every messge in this thread ?
>
> I'm not.
>
> Mikey
>
>>
>> I do, and I suspect that this is due to the Cc: list having both
>> linuxppc-dev@ozlabs.org and linuxppc-dev@lists.ozlabs.org. I removed the
>> former for this reply.
>>
>>     Gabriel
>
>
Michael Ellerman Sept. 30, 2015, 1:49 a.m. UTC | #7
On Mon, 2015-09-28 at 12:56 +0300, Denis Kirjanov wrote:
> On 9/28/15, Michael Neuling <mikey@neuling.org> wrote:
> > On Fri, 2015-09-25 at 11:37 +0200, Gabriel Paubert wrote:
> >> On Fri, Sep 25, 2015 at 12:28:30PM +0300, Denis Kirjanov wrote:
> >> > On 9/25/15, Arnd Bergmann <arnd@arndb.de> wrote:
> >> > > On Friday 25 September 2015 14:01:39 Michael Neuling wrote:
> >> > >> This adds a benchmark directory to the powerpc selftests and adds a
> >> > >> gettimeofday() benchmark to it.
> >> > >>
> >> > >> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
> >> > >> Signed-off-by: Michael Neuling <mikey@neuling.org>
> >> > >>
> >> > >
> >> > > Any reason for keeping this powerpc specific? It seems generally
> >> > > useful.
> >> > > and portable.
> >> > You're right. Moreover, we can put some comment to the benchmark why
> >> > we've made such decision to add it (reference to the commit
> >> > "powerpc/vdso: Avoid link stack corruption in __get_datapage()")
> >>
> >> Why gettimeofday? Isn't clock_gettime the modern variant?
> >
> > We can do either here really.  I just wanted to test __get_datapage()
> > really.  I just stole the benchmark from Anton, which turned into mpe
> > wanting it in selftests.  I dumped it in powerpc mostly because I knew
> > mpe would take it (ie. I'm was being lazy).
> 
> Yeah, so the quickest way would be to apply the patch as is. Then
> someone can make it generic.

> So now it depends on Michael's decision :)

Yeah I'll merge it and then folks can do whatever they like.

cheers
Michael Ellerman Oct. 2, 2015, 7:47 a.m. UTC | #8
On Fri, 2015-25-09 at 04:01:39 UTC, Michael Neuling wrote:
> This adds a benchmark directory to the powerpc selftests and adds a
> gettimeofday() benchmark to it.
> 
> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
> Signed-off-by: Michael Neuling <mikey@neuling.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/d17475d906fde8e9fe39fff3

cheers
diff mbox

Patch

diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
index 03ca2e6..847adf6 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -12,7 +12,7 @@  CFLAGS := -Wall -O2 -flto -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CUR
 
 export CFLAGS
 
-SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian dscr
+SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian dscr benchmarks
 
 endif
 
diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
new file mode 100644
index 0000000..5fa4870
--- /dev/null
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -0,0 +1,12 @@ 
+TEST_PROGS := gettimeofday
+
+CFLAGS += -O2
+
+all: $(TEST_PROGS)
+
+$(TEST_PROGS): ../harness.c
+
+include ../../lib.mk
+
+clean:
+	rm -f $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/benchmarks/gettimeofday.c b/tools/testing/selftests/powerpc/benchmarks/gettimeofday.c
new file mode 100644
index 0000000..3af3c21
--- /dev/null
+++ b/tools/testing/selftests/powerpc/benchmarks/gettimeofday.c
@@ -0,0 +1,31 @@ 
+/*
+ * Copyright 2015, Anton Blanchard, IBM Corp.
+ * Licensed under GPLv2.
+ */
+
+#include <sys/time.h>
+#include <stdio.h>
+
+#include "utils.h"
+
+static int test_gettimeofday(void)
+{
+	int i;
+
+	struct timeval tv_start, tv_end;
+
+	gettimeofday(&tv_start, NULL);
+
+	for(i = 0; i < 100000000; i++) {
+		gettimeofday(&tv_end, NULL);
+	}
+
+	printf("time = %.6f\n", tv_end.tv_sec - tv_start.tv_sec + (tv_end.tv_usec - tv_start.tv_usec) * 1e-6);
+
+	return 0;
+}
+
+int main(void)
+{
+	return test_harness(test_gettimeofday, "gettimeofday");
+}