[Xenomai-git] Philippe Gerum : utils/autotune: update load generator

2014-10-04 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 8580fb8c199f97820434d0e1fb444b227fbb142a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8580fb8c199f97820434d0e1fb444b227fbb142a

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Sep 30 17:09:40 2014 +0200

utils/autotune: update load generator

Create additional load with domain migrations.

---

 doc/asciidoc/man1/autotune.adoc |8 ++---
 utils/autotune/autotune.c   |   68 +--
 2 files changed, 47 insertions(+), 29 deletions(-)

diff --git a/doc/asciidoc/man1/autotune.adoc b/doc/asciidoc/man1/autotune.adoc
index efea67e..b244c96 100644
--- a/doc/asciidoc/man1/autotune.adoc
+++ b/doc/asciidoc/man1/autotune.adoc
@@ -97,10 +97,10 @@ activity can slip in, treading over a larger address space).
 Reset the gravity values to their factory defaults. These defaults
 are statically defined by the Xenomai platform code.
 
-*--nohog*::
-Disable load generation while auto-tuning. *autotune* runs a simple
-load generator internally in parallel to estimating the latency, in
-order to eliminate irregular delays which tend to appear on fully idle
+*--noload*::
+Disable load generation while auto-tuning. *autotune* runs a load
+generator internally in parallel to estimating the latency, in order
+to eliminate irregular delays which tend to appear on fully idle
 systems.  Therefore, keeping the load generation enabled most often
 leads to a more accurate estimation.
 
diff --git a/utils/autotune/autotune.c b/utils/autotune/autotune.c
index 1c13084..5a18310 100644
--- a/utils/autotune/autotune.c
+++ b/utils/autotune/autotune.c
@@ -24,11 +24,12 @@
 #include limits.h
 #include time.h
 #include error.h
+#include sys/cobalt.h
 #include rtdm/autotune.h
 
 static int tune_irqlat, tune_kernlat, tune_userlat;
 
-static int reset, nohog, quiet;
+static int reset, noload, quiet;
 
 static const struct option base_options[] = {
{
@@ -63,9 +64,9 @@ static const struct option base_options[] = {
.val = 1
},
{
-#define nohog_opt  5
-   .name = nohog,
-   .flag = nohog,
+#define noload_opt 5
+   .name = noload,
+   .flag = noload,
.val = 1
},
{
@@ -107,10 +108,11 @@ static void *sampler_thread(void *arg)
return NULL;
 }
 
-static void *hog_thread(void *arg)
+static void *load_thread(void *arg)
 {
-   int fdi, fdo, count = 0;
+   int fdi, fdo, count = 0, wakelim;
ssize_t nbytes, ret;
+   struct timespec rqt;
char buf[512];
 
fdi = open(/dev/zero, O_RDONLY);
@@ -121,16 +123,25 @@ static void *hog_thread(void *arg)
if (fdi  0)
error(1, errno, /dev/null);
 
+   rqt.tv_sec = 0;
+   rqt.tv_nsec = CONFIG_XENO_DEFAULT_PERIOD * 2;
+   wakelim = 2000 / rqt.tv_nsec;
+
for (;;) {
+   clock_nanosleep(CLOCK_MONOTONIC, 0, rqt, NULL);
+
+   if (++count % wakelim) {
+   cobalt_thread_relax();
+   continue;
+   }
+
nbytes = read(fdi, buf, sizeof(buf));
if (nbytes = 0)
-   error(1, EIO, hog streaming);
+   error(1, EIO, load streaming);
if (nbytes  0) {
ret = write(fdo, buf, nbytes);
(void)ret;
}
-   if ((++count % 1024) == 0)
-   usleep(1);
}
 
return NULL;
@@ -157,7 +168,7 @@ static void create_sampler(pthread_t *tid, int fd)
pthread_setname_np(*tid, sampler);
 }
 
-static void create_hog(pthread_t *tid)
+static void create_load(pthread_t *tid)
 {
struct sched_param param;
pthread_attr_t attr;
@@ -166,16 +177,16 @@ static void create_hog(pthread_t *tid)
pthread_attr_init(attr);
pthread_attr_setdetachstate(attr, PTHREAD_CREATE_JOINABLE);
pthread_attr_setinheritsched(attr, PTHREAD_EXPLICIT_SCHED);
-   pthread_attr_setschedpolicy(attr, SCHED_OTHER);
-   param.sched_priority = 0;
+   pthread_attr_setschedpolicy(attr, SCHED_FIFO);
+   param.sched_priority = 1;
pthread_attr_setschedparam(attr, param);
pthread_attr_setstacksize(attr, PTHREAD_STACK_MIN * 8);
-   ret = pthread_create(tid, attr, hog_thread, NULL);
+   ret = pthread_create(tid, attr, load_thread, NULL);
if (ret)
-   error(1, ret, hog thread);
+   error(1, ret, load thread);
 
pthread_attr_destroy(attr);
-   pthread_setname_np(*tid, hog);
+   pthread_setname_np(*tid, loadgen);
 }
 
 static void usage(void)
@@ -186,7 +197,7 @@ static void usage(void)
fprintf(stderr,--user  user scheduling latency\n);
fprintf(stderr,--periodset the sampling period\n);
fprintf(stderr,--reset reset core timer gravity to 
factory 

[Xenomai-git] Philippe Gerum : utils/autotune: update load generator

2014-10-04 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 403d78ae930551c2d98b3e456f3b9a0e53fd668f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=403d78ae930551c2d98b3e456f3b9a0e53fd668f

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Sep 30 17:09:40 2014 +0200

utils/autotune: update load generator

Create additional load with domain migrations.

---

 doc/asciidoc/man1/autotune.adoc |8 ++---
 utils/autotune/autotune.c   |   68 +--
 2 files changed, 47 insertions(+), 29 deletions(-)

diff --git a/doc/asciidoc/man1/autotune.adoc b/doc/asciidoc/man1/autotune.adoc
index efea67e..b244c96 100644
--- a/doc/asciidoc/man1/autotune.adoc
+++ b/doc/asciidoc/man1/autotune.adoc
@@ -97,10 +97,10 @@ activity can slip in, treading over a larger address space).
 Reset the gravity values to their factory defaults. These defaults
 are statically defined by the Xenomai platform code.
 
-*--nohog*::
-Disable load generation while auto-tuning. *autotune* runs a simple
-load generator internally in parallel to estimating the latency, in
-order to eliminate irregular delays which tend to appear on fully idle
+*--noload*::
+Disable load generation while auto-tuning. *autotune* runs a load
+generator internally in parallel to estimating the latency, in order
+to eliminate irregular delays which tend to appear on fully idle
 systems.  Therefore, keeping the load generation enabled most often
 leads to a more accurate estimation.
 
diff --git a/utils/autotune/autotune.c b/utils/autotune/autotune.c
index 1c13084..5a18310 100644
--- a/utils/autotune/autotune.c
+++ b/utils/autotune/autotune.c
@@ -24,11 +24,12 @@
 #include limits.h
 #include time.h
 #include error.h
+#include sys/cobalt.h
 #include rtdm/autotune.h
 
 static int tune_irqlat, tune_kernlat, tune_userlat;
 
-static int reset, nohog, quiet;
+static int reset, noload, quiet;
 
 static const struct option base_options[] = {
{
@@ -63,9 +64,9 @@ static const struct option base_options[] = {
.val = 1
},
{
-#define nohog_opt  5
-   .name = nohog,
-   .flag = nohog,
+#define noload_opt 5
+   .name = noload,
+   .flag = noload,
.val = 1
},
{
@@ -107,10 +108,11 @@ static void *sampler_thread(void *arg)
return NULL;
 }
 
-static void *hog_thread(void *arg)
+static void *load_thread(void *arg)
 {
-   int fdi, fdo, count = 0;
+   int fdi, fdo, count = 0, wakelim;
ssize_t nbytes, ret;
+   struct timespec rqt;
char buf[512];
 
fdi = open(/dev/zero, O_RDONLY);
@@ -121,16 +123,25 @@ static void *hog_thread(void *arg)
if (fdi  0)
error(1, errno, /dev/null);
 
+   rqt.tv_sec = 0;
+   rqt.tv_nsec = CONFIG_XENO_DEFAULT_PERIOD * 2;
+   wakelim = 2000 / rqt.tv_nsec;
+
for (;;) {
+   clock_nanosleep(CLOCK_MONOTONIC, 0, rqt, NULL);
+
+   if (++count % wakelim) {
+   cobalt_thread_relax();
+   continue;
+   }
+
nbytes = read(fdi, buf, sizeof(buf));
if (nbytes = 0)
-   error(1, EIO, hog streaming);
+   error(1, EIO, load streaming);
if (nbytes  0) {
ret = write(fdo, buf, nbytes);
(void)ret;
}
-   if ((++count % 1024) == 0)
-   usleep(1);
}
 
return NULL;
@@ -157,7 +168,7 @@ static void create_sampler(pthread_t *tid, int fd)
pthread_setname_np(*tid, sampler);
 }
 
-static void create_hog(pthread_t *tid)
+static void create_load(pthread_t *tid)
 {
struct sched_param param;
pthread_attr_t attr;
@@ -166,16 +177,16 @@ static void create_hog(pthread_t *tid)
pthread_attr_init(attr);
pthread_attr_setdetachstate(attr, PTHREAD_CREATE_JOINABLE);
pthread_attr_setinheritsched(attr, PTHREAD_EXPLICIT_SCHED);
-   pthread_attr_setschedpolicy(attr, SCHED_OTHER);
-   param.sched_priority = 0;
+   pthread_attr_setschedpolicy(attr, SCHED_FIFO);
+   param.sched_priority = 1;
pthread_attr_setschedparam(attr, param);
pthread_attr_setstacksize(attr, PTHREAD_STACK_MIN * 8);
-   ret = pthread_create(tid, attr, hog_thread, NULL);
+   ret = pthread_create(tid, attr, load_thread, NULL);
if (ret)
-   error(1, ret, hog thread);
+   error(1, ret, load thread);
 
pthread_attr_destroy(attr);
-   pthread_setname_np(*tid, hog);
+   pthread_setname_np(*tid, loadgen);
 }
 
 static void usage(void)
@@ -186,7 +197,7 @@ static void usage(void)
fprintf(stderr,--user  user scheduling latency\n);
fprintf(stderr,--periodset the sampling period\n);
fprintf(stderr,--reset reset core timer gravity to 
factory 

[Xenomai-git] Philippe Gerum : utils/autotune: update load generator

2014-10-04 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 403d78ae930551c2d98b3e456f3b9a0e53fd668f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=403d78ae930551c2d98b3e456f3b9a0e53fd668f

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Sep 30 17:09:40 2014 +0200

utils/autotune: update load generator

Create additional load with domain migrations.

---

 doc/asciidoc/man1/autotune.adoc |8 ++---
 utils/autotune/autotune.c   |   68 +--
 2 files changed, 47 insertions(+), 29 deletions(-)

diff --git a/doc/asciidoc/man1/autotune.adoc b/doc/asciidoc/man1/autotune.adoc
index efea67e..b244c96 100644
--- a/doc/asciidoc/man1/autotune.adoc
+++ b/doc/asciidoc/man1/autotune.adoc
@@ -97,10 +97,10 @@ activity can slip in, treading over a larger address space).
 Reset the gravity values to their factory defaults. These defaults
 are statically defined by the Xenomai platform code.
 
-*--nohog*::
-Disable load generation while auto-tuning. *autotune* runs a simple
-load generator internally in parallel to estimating the latency, in
-order to eliminate irregular delays which tend to appear on fully idle
+*--noload*::
+Disable load generation while auto-tuning. *autotune* runs a load
+generator internally in parallel to estimating the latency, in order
+to eliminate irregular delays which tend to appear on fully idle
 systems.  Therefore, keeping the load generation enabled most often
 leads to a more accurate estimation.
 
diff --git a/utils/autotune/autotune.c b/utils/autotune/autotune.c
index 1c13084..5a18310 100644
--- a/utils/autotune/autotune.c
+++ b/utils/autotune/autotune.c
@@ -24,11 +24,12 @@
 #include limits.h
 #include time.h
 #include error.h
+#include sys/cobalt.h
 #include rtdm/autotune.h
 
 static int tune_irqlat, tune_kernlat, tune_userlat;
 
-static int reset, nohog, quiet;
+static int reset, noload, quiet;
 
 static const struct option base_options[] = {
{
@@ -63,9 +64,9 @@ static const struct option base_options[] = {
.val = 1
},
{
-#define nohog_opt  5
-   .name = nohog,
-   .flag = nohog,
+#define noload_opt 5
+   .name = noload,
+   .flag = noload,
.val = 1
},
{
@@ -107,10 +108,11 @@ static void *sampler_thread(void *arg)
return NULL;
 }
 
-static void *hog_thread(void *arg)
+static void *load_thread(void *arg)
 {
-   int fdi, fdo, count = 0;
+   int fdi, fdo, count = 0, wakelim;
ssize_t nbytes, ret;
+   struct timespec rqt;
char buf[512];
 
fdi = open(/dev/zero, O_RDONLY);
@@ -121,16 +123,25 @@ static void *hog_thread(void *arg)
if (fdi  0)
error(1, errno, /dev/null);
 
+   rqt.tv_sec = 0;
+   rqt.tv_nsec = CONFIG_XENO_DEFAULT_PERIOD * 2;
+   wakelim = 2000 / rqt.tv_nsec;
+
for (;;) {
+   clock_nanosleep(CLOCK_MONOTONIC, 0, rqt, NULL);
+
+   if (++count % wakelim) {
+   cobalt_thread_relax();
+   continue;
+   }
+
nbytes = read(fdi, buf, sizeof(buf));
if (nbytes = 0)
-   error(1, EIO, hog streaming);
+   error(1, EIO, load streaming);
if (nbytes  0) {
ret = write(fdo, buf, nbytes);
(void)ret;
}
-   if ((++count % 1024) == 0)
-   usleep(1);
}
 
return NULL;
@@ -157,7 +168,7 @@ static void create_sampler(pthread_t *tid, int fd)
pthread_setname_np(*tid, sampler);
 }
 
-static void create_hog(pthread_t *tid)
+static void create_load(pthread_t *tid)
 {
struct sched_param param;
pthread_attr_t attr;
@@ -166,16 +177,16 @@ static void create_hog(pthread_t *tid)
pthread_attr_init(attr);
pthread_attr_setdetachstate(attr, PTHREAD_CREATE_JOINABLE);
pthread_attr_setinheritsched(attr, PTHREAD_EXPLICIT_SCHED);
-   pthread_attr_setschedpolicy(attr, SCHED_OTHER);
-   param.sched_priority = 0;
+   pthread_attr_setschedpolicy(attr, SCHED_FIFO);
+   param.sched_priority = 1;
pthread_attr_setschedparam(attr, param);
pthread_attr_setstacksize(attr, PTHREAD_STACK_MIN * 8);
-   ret = pthread_create(tid, attr, hog_thread, NULL);
+   ret = pthread_create(tid, attr, load_thread, NULL);
if (ret)
-   error(1, ret, hog thread);
+   error(1, ret, load thread);
 
pthread_attr_destroy(attr);
-   pthread_setname_np(*tid, hog);
+   pthread_setname_np(*tid, loadgen);
 }
 
 static void usage(void)
@@ -186,7 +197,7 @@ static void usage(void)
fprintf(stderr,--user  user scheduling latency\n);
fprintf(stderr,--periodset the sampling period\n);
fprintf(stderr,--reset reset core timer gravity to 
factory 

[Xenomai-git] Philippe Gerum : utils/autotune: update load generator

2014-10-04 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 722da4411966267b8d3ae986d086736ae9579b4d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=722da4411966267b8d3ae986d086736ae9579b4d

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Sep 30 17:09:40 2014 +0200

utils/autotune: update load generator

Create additional load with domain migrations.

---

 doc/asciidoc/man1/autotune.adoc |8 ++---
 utils/autotune/autotune.c   |   68 +--
 2 files changed, 47 insertions(+), 29 deletions(-)

diff --git a/doc/asciidoc/man1/autotune.adoc b/doc/asciidoc/man1/autotune.adoc
index efea67e..b244c96 100644
--- a/doc/asciidoc/man1/autotune.adoc
+++ b/doc/asciidoc/man1/autotune.adoc
@@ -97,10 +97,10 @@ activity can slip in, treading over a larger address space).
 Reset the gravity values to their factory defaults. These defaults
 are statically defined by the Xenomai platform code.
 
-*--nohog*::
-Disable load generation while auto-tuning. *autotune* runs a simple
-load generator internally in parallel to estimating the latency, in
-order to eliminate irregular delays which tend to appear on fully idle
+*--noload*::
+Disable load generation while auto-tuning. *autotune* runs a load
+generator internally in parallel to estimating the latency, in order
+to eliminate irregular delays which tend to appear on fully idle
 systems.  Therefore, keeping the load generation enabled most often
 leads to a more accurate estimation.
 
diff --git a/utils/autotune/autotune.c b/utils/autotune/autotune.c
index 1c13084..5a18310 100644
--- a/utils/autotune/autotune.c
+++ b/utils/autotune/autotune.c
@@ -24,11 +24,12 @@
 #include limits.h
 #include time.h
 #include error.h
+#include sys/cobalt.h
 #include rtdm/autotune.h
 
 static int tune_irqlat, tune_kernlat, tune_userlat;
 
-static int reset, nohog, quiet;
+static int reset, noload, quiet;
 
 static const struct option base_options[] = {
{
@@ -63,9 +64,9 @@ static const struct option base_options[] = {
.val = 1
},
{
-#define nohog_opt  5
-   .name = nohog,
-   .flag = nohog,
+#define noload_opt 5
+   .name = noload,
+   .flag = noload,
.val = 1
},
{
@@ -107,10 +108,11 @@ static void *sampler_thread(void *arg)
return NULL;
 }
 
-static void *hog_thread(void *arg)
+static void *load_thread(void *arg)
 {
-   int fdi, fdo, count = 0;
+   int fdi, fdo, count = 0, wakelim;
ssize_t nbytes, ret;
+   struct timespec rqt;
char buf[512];
 
fdi = open(/dev/zero, O_RDONLY);
@@ -121,16 +123,25 @@ static void *hog_thread(void *arg)
if (fdi  0)
error(1, errno, /dev/null);
 
+   rqt.tv_sec = 0;
+   rqt.tv_nsec = CONFIG_XENO_DEFAULT_PERIOD * 2;
+   wakelim = 2000 / rqt.tv_nsec;
+
for (;;) {
+   clock_nanosleep(CLOCK_MONOTONIC, 0, rqt, NULL);
+
+   if (++count % wakelim) {
+   cobalt_thread_relax();
+   continue;
+   }
+
nbytes = read(fdi, buf, sizeof(buf));
if (nbytes = 0)
-   error(1, EIO, hog streaming);
+   error(1, EIO, load streaming);
if (nbytes  0) {
ret = write(fdo, buf, nbytes);
(void)ret;
}
-   if ((++count % 1024) == 0)
-   usleep(1);
}
 
return NULL;
@@ -157,7 +168,7 @@ static void create_sampler(pthread_t *tid, int fd)
pthread_setname_np(*tid, sampler);
 }
 
-static void create_hog(pthread_t *tid)
+static void create_load(pthread_t *tid)
 {
struct sched_param param;
pthread_attr_t attr;
@@ -166,16 +177,16 @@ static void create_hog(pthread_t *tid)
pthread_attr_init(attr);
pthread_attr_setdetachstate(attr, PTHREAD_CREATE_JOINABLE);
pthread_attr_setinheritsched(attr, PTHREAD_EXPLICIT_SCHED);
-   pthread_attr_setschedpolicy(attr, SCHED_OTHER);
-   param.sched_priority = 0;
+   pthread_attr_setschedpolicy(attr, SCHED_FIFO);
+   param.sched_priority = 1;
pthread_attr_setschedparam(attr, param);
pthread_attr_setstacksize(attr, PTHREAD_STACK_MIN * 8);
-   ret = pthread_create(tid, attr, hog_thread, NULL);
+   ret = pthread_create(tid, attr, load_thread, NULL);
if (ret)
-   error(1, ret, hog thread);
+   error(1, ret, load thread);
 
pthread_attr_destroy(attr);
-   pthread_setname_np(*tid, hog);
+   pthread_setname_np(*tid, loadgen);
 }
 
 static void usage(void)
@@ -186,7 +197,7 @@ static void usage(void)
fprintf(stderr,--user  user scheduling latency\n);
fprintf(stderr,--periodset the sampling period\n);
fprintf(stderr,--reset reset core timer gravity to 
factory