public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] syscalls/perf_event_open02: Fix indentation and typo in help
@ 2016-07-15 15:35 Yuriy Kolerov
  2016-07-15 15:35 ` [LTP] [PATCH 2/2] syscalls/perf_event_open{01, 02}: Add -n arg for size of idle loop Yuriy Kolerov
  0 siblings, 1 reply; 4+ messages in thread
From: Yuriy Kolerov @ 2016-07-15 15:35 UTC (permalink / raw)
  To: ltp

Signed-off-by: Yuriy Kolerov <yuriy.kolerov@synopsys.com>
---
 testcases/kernel/syscalls/perf_event_open/perf_event_open02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
index 5dc205b..ba840f5 100644
--- a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
+++ b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
@@ -338,7 +338,7 @@ static void verify(void)
 
 static void help(void)
 {
-	printf("-v  print verbose infomation\n");
+	printf("  -v      Print verbose information\n");
 }
 
 #else
-- 
2.2.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP]  [PATCH 2/2] syscalls/perf_event_open{01, 02}: Add -n arg for size of idle loop
  2016-07-15 15:35 [LTP] [PATCH 1/2] syscalls/perf_event_open02: Fix indentation and typo in help Yuriy Kolerov
@ 2016-07-15 15:35 ` Yuriy Kolerov
  2016-07-18 16:14   ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Yuriy Kolerov @ 2016-07-15 15:35 UTC (permalink / raw)
  To: ltp

The value of this option is used in do_word() idle loop. By default
do_work() iterates 1000000000 times. However such loop may take a
long time to finish for all available performance counters on some
boards. It would be useful to have an ability to choose the size of
idle loop.

Signed-off-by: Yuriy Kolerov <yuriy.kolerov@synopsys.com>
---
 .../syscalls/perf_event_open/perf_event_open01.c   | 32 +++++++++++++++++++---
 .../syscalls/perf_event_open/perf_event_open02.c   | 18 ++++++++++--
 2 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c b/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c
index 9c87e65..3823e5e 100644
--- a/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c
+++ b/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c
@@ -49,8 +49,20 @@
 char *TCID = "perf_event_open01";
 
 #if HAVE_PERF_EVENT_ATTR
+
+#define DEFAULT_LOOPS	1000000000
+
 static void setup(void);
 static void cleanup(void);
+static void help(void);
+
+static int loops;
+static int loops_flag;
+static char *loops_arg;
+static option_t options[] = {
+	{"n:", &loops_flag, &loops_arg},
+	{NULL, NULL, NULL},
+};
 
 static struct test_case_t {
 	uint32_t type;
@@ -82,7 +94,15 @@ int main(int ac, char **av)
 {
 	int i, lc;
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	tst_parse_opts(ac, av, options, help);
+
+	loops = DEFAULT_LOOPS;
+	if (loops_flag) {
+		if (sscanf(loops_arg, "%i", &loops) != 1)
+			tst_brkm(TBROK, NULL, "-n option arg is not a number");
+		if (loops <= 0)
+			tst_brkm(TBROK, NULL, "-n option arg is less than 1");
+	}
 
 	setup();
 
@@ -129,13 +149,11 @@ static int perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
 }
 
 /* do_work() is copied form performance_counter02.c */
-#define LOOPS	1000000000
-
 static void do_work(void)
 {
 	int i;
 
-	for (i = 0; i < LOOPS; ++i)
+	for (i = 0; i < loops; ++i)
 		asm volatile ("" : : "g" (i));
 }
 
@@ -197,6 +215,12 @@ static void cleanup(void)
 {
 }
 
+static void help(void)
+{
+	printf("  -n x    Number of iterations in idle loop, default is %d\n",
+		DEFAULT_LOOPS);
+}
+
 #else
 
 int main(void)
diff --git a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
index ba840f5..dc7c85e 100644
--- a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
+++ b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
@@ -79,7 +79,7 @@ int TST_TOTAL = 1;
 #if HAVE_PERF_EVENT_ATTR
 
 #define MAX_CTRS	1000
-#define LOOPS		1000000000
+#define DEFAULT_LOOPS	1000000000
 
 static int count_hardware_counters(void);
 static void setup(void);
@@ -89,7 +89,11 @@ static void help(void);
 
 static int n, nhw;
 static int verbose;
+static int loops;
+static int loops_flag;
+static char *loops_arg;
 static option_t options[] = {
+	{"n:", &loops_flag, &loops_arg},
 	{"v", &verbose, NULL},
 	{NULL, NULL, NULL},
 };
@@ -103,6 +107,14 @@ int main(int ac, char **av)
 
 	tst_parse_opts(ac, av, options, help);
 
+	loops = DEFAULT_LOOPS;
+	if (loops_flag) {
+		if (sscanf(loops_arg, "%i", &loops) != 1)
+			tst_brkm(TBROK, NULL, "-n option arg is not a number");
+		if (loops <= 0)
+			tst_brkm(TBROK, NULL, "-n option arg is less than 1");
+	}
+
 	setup();
 
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
@@ -129,7 +141,7 @@ static void do_work(void)
 {
 	int i;
 
-	for (i = 0; i < LOOPS; ++i)
+	for (i = 0; i < loops; ++i)
 		asm volatile (""::"g" (i));
 }
 
@@ -338,6 +350,8 @@ static void verify(void)
 
 static void help(void)
 {
+	printf("  -n x    Number of iterations in idle loop, default is %d\n",
+		DEFAULT_LOOPS);
 	printf("  -v      Print verbose information\n");
 }
 
-- 
2.2.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP] [PATCH 2/2] syscalls/perf_event_open{01, 02}: Add -n arg for size of idle loop
  2016-07-15 15:35 ` [LTP] [PATCH 2/2] syscalls/perf_event_open{01, 02}: Add -n arg for size of idle loop Yuriy Kolerov
@ 2016-07-18 16:14   ` Cyril Hrubis
  2016-07-19 10:25     ` Yuriy Kolerov
  0 siblings, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2016-07-18 16:14 UTC (permalink / raw)
  To: ltp

Hi!
> The value of this option is used in do_word() idle loop. By default
> do_work() iterates 1000000000 times. However such loop may take a
> long time to finish for all available performance counters on some
> boards. It would be useful to have an ability to choose the size of
> idle loop.

Ideally LTP testcases should run just fine without any specific tweaks.

Looking at the code for perf_event_open01.c we can simply change the
predefined value of loops. Since this is just a basic test that enables
the interface and reads the values but does not try do anything with
them. The test would run just fine even if we didn't do anything in
between ENABLE and DISABLE ioctls().

The perf_event_open02.c is a bit more complicated, it test grouping and
multiplexing. Looking at the test it runs for about 4 second on a cheap
notebook so I can imagine that it takes couple of minutes on slow
hardware. I guess that we can safely divide the nunber of default loops
by 10 and everything should continue just fine.

So would diving by 10 work for you?


If that is still too slow we can always change the test to setup an
timer that would send a signal which would set set a variable which
would stop the loop in do_work() so that the test runs defined amount of
time regardless of the machine speed.

Or we could measure how long reasonably small number of iterations takes
in order to callibrate the number of loops the do_work() function should
do.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH 2/2] syscalls/perf_event_open{01, 02}: Add -n arg for size of idle loop
  2016-07-18 16:14   ` Cyril Hrubis
@ 2016-07-19 10:25     ` Yuriy Kolerov
  0 siblings, 0 replies; 4+ messages in thread
From: Yuriy Kolerov @ 2016-07-19 10:25 UTC (permalink / raw)
  To: ltp

Hi Cyril,

We have a pretty slow development board with 50-100MHz cores and perf_event_open0x.c can take ~10 minutes on it. I think that dividing LOOPS macro by 10 is fine even for such slow targets. I will prepare a second version of the patch.

-----Original Message-----
From: Cyril Hrubis [mailto:chrubis@suse.cz] 
Sent: Monday, July 18, 2016 7:15 PM
To: Yuriy Kolerov <yuriy.kolerov@synopsys.com>
Cc: ltp@lists.linux.it; Vineet.Gupta1@synopsys.com; Alexey.Brodkin@synopsys.com
Subject: Re: [LTP] [PATCH 2/2] syscalls/perf_event_open{01, 02}: Add -n arg for size of idle loop

Hi!
> The value of this option is used in do_word() idle loop. By default
> do_work() iterates 1000000000 times. However such loop may take a long 
> time to finish for all available performance counters on some boards. 
> It would be useful to have an ability to choose the size of idle loop.

Ideally LTP testcases should run just fine without any specific tweaks.

Looking at the code for perf_event_open01.c we can simply change the predefined value of loops. Since this is just a basic test that enables the interface and reads the values but does not try do anything with them. The test would run just fine even if we didn't do anything in between ENABLE and DISABLE ioctls().

The perf_event_open02.c is a bit more complicated, it test grouping and multiplexing. Looking at the test it runs for about 4 second on a cheap notebook so I can imagine that it takes couple of minutes on slow hardware. I guess that we can safely divide the nunber of default loops by 10 and everything should continue just fine.

So would diving by 10 work for you?


If that is still too slow we can always change the test to setup an timer that would send a signal which would set set a variable which would stop the loop in do_work() so that the test runs defined amount of time regardless of the machine speed.

Or we could measure how long reasonably small number of iterations takes in order to callibrate the number of loops the do_work() function should do.

--
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-07-19 10:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-15 15:35 [LTP] [PATCH 1/2] syscalls/perf_event_open02: Fix indentation and typo in help Yuriy Kolerov
2016-07-15 15:35 ` [LTP] [PATCH 2/2] syscalls/perf_event_open{01, 02}: Add -n arg for size of idle loop Yuriy Kolerov
2016-07-18 16:14   ` Cyril Hrubis
2016-07-19 10:25     ` Yuriy Kolerov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox