Module: xenomai-3
Branch: next
Commit: b4ae80b8a1a9e33d3ff52b7315765473798b71a7
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b4ae80b8a1a9e33d3ff52b7315765473798b71a7

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

utils/autotune: suppress load generator

---

 doc/asciidoc/man1/autotune.adoc |    7 ----
 utils/autotune/autotune.c       |   84 ++++++---------------------------------
 2 files changed, 12 insertions(+), 79 deletions(-)

diff --git a/doc/asciidoc/man1/autotune.adoc b/doc/asciidoc/man1/autotune.adoc
index efea67e..9ff44a2 100644
--- a/doc/asciidoc/man1/autotune.adoc
+++ b/doc/asciidoc/man1/autotune.adoc
@@ -97,13 +97,6 @@ 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
-systems.  Therefore, keeping the load generation enabled most often
-leads to a more accurate estimation.
-
 *--quiet*::
 Tame down verbosity of the auto-tuner.
 
diff --git a/utils/autotune/autotune.c b/utils/autotune/autotune.c
index 1c13084..5b2964d 100644
--- a/utils/autotune/autotune.c
+++ b/utils/autotune/autotune.c
@@ -28,7 +28,7 @@
 
 static int tune_irqlat, tune_kernlat, tune_userlat;
 
-static int reset, nohog, quiet;
+static int reset, quiet;
 
 static const struct option base_options[] = {
        {
@@ -63,19 +63,13 @@ static const struct option base_options[] = {
                .val = 1
        },
        {
-#define nohog_opt      5
-               .name = "nohog",
-               .flag = &nohog,
-               .val = 1
-       },
-       {
-#define quiet_opt      6
+#define quiet_opt      5
                .name = "quiet",
                .flag = &quiet,
                .val = 1
        },
        {
-#define period_opt     7
+#define period_opt     6
                .name = "period",
                .has_arg = 1,
        },
@@ -107,35 +101,6 @@ static void *sampler_thread(void *arg)
        return NULL;
 }
 
-static void *hog_thread(void *arg)
-{
-       int fdi, fdo, count = 0;
-       ssize_t nbytes, ret;
-       char buf[512];
-
-       fdi = open("/dev/zero", O_RDONLY);
-       if (fdi < 0)
-               error(1, errno, "/dev/zero");
-
-       fdo = open("/dev/null", O_WRONLY);
-       if (fdi < 0)
-               error(1, errno, "/dev/null");
-
-       for (;;) {
-               nbytes = read(fdi, buf, sizeof(buf));
-               if (nbytes <= 0)
-                       error(1, EIO, "hog streaming");
-               if (nbytes > 0) {
-                       ret = write(fdo, buf, nbytes);
-                       (void)ret;
-               }
-               if ((++count % 1024) == 0)
-                       usleep(10000);
-       }
-
-       return NULL;
-}
-
 static void create_sampler(pthread_t *tid, int fd)
 {
        struct sched_param param;
@@ -157,27 +122,6 @@ static void create_sampler(pthread_t *tid, int fd)
        pthread_setname_np(*tid, "sampler");
 }
 
-static void create_hog(pthread_t *tid)
-{
-       struct sched_param param;
-       pthread_attr_t attr;
-       int ret;
-
-       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_setschedparam(&attr, &param);
-       pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN * 8);
-       ret = pthread_create(tid, &attr, hog_thread, NULL);
-       if (ret)
-               error(1, ret, "hog thread");
-
-       pthread_attr_destroy(&attr);
-       pthread_setname_np(*tid, "hog");
-}
-
 static void usage(void)
 {
        fprintf(stderr, "usage: autotune [options], tuning core timer for:\n");
@@ -186,7 +130,6 @@ static void usage(void)
        fprintf(stderr, "   --user              user scheduling latency\n");
        fprintf(stderr, "   --period            set the sampling period\n");
        fprintf(stderr, "   --reset             reset core timer gravity to 
factory defaults\n");
-       fprintf(stderr, "   --nohog             disable load generation\n");
        fprintf(stderr, "   --quiet             tame down verbosity\n");
        fprintf(stderr, "   --help              print this help\n\n");
        fprintf(stderr, "if no option is given, tune for all contexts using the 
default period.\n");
@@ -227,7 +170,7 @@ static void run_tuner(int fd, int op, int period, const 
char *type)
 int main(int argc, char *const argv[])
 {
        int fd, period, ret, c, lindex, tuned = 0;
-       pthread_t hog;
+       time_t start;
 
        period = CONFIG_XENO_DEFAULT_PERIOD;
 
@@ -252,7 +195,6 @@ int main(int argc, char *const argv[])
                                error(1, EINVAL, "invalid sampling period 
(default %d)",
                                      CONFIG_XENO_DEFAULT_PERIOD);
                        break;
-               case nohog_opt:
                case quiet_opt:
                        break;
                case irq_opt:
@@ -279,14 +221,11 @@ int main(int argc, char *const argv[])
                        error(1, errno, "reset failed");
        }
 
-       if (tune_irqlat || tune_kernlat || tune_userlat) {
-               if (!nohog)
-                       create_hog(&hog);
-               if (!quiet)
-                       printf("Auto-tuning started, period=%d ns (may take a 
while)\n",
-                               period);
-       } else
-               nohog = 1;
+       if (!quiet && (tune_irqlat || tune_kernlat || tune_userlat))
+               printf("== auto-tuning started, period=%d ns (may take a 
while)\n",
+                      period);
+
+       time(&start);
 
        if (tune_irqlat)
                run_tuner(fd, AUTOTUNE_RTIOC_IRQ, period, "irq");
@@ -297,8 +236,9 @@ int main(int argc, char *const argv[])
        if (tune_userlat)
                run_tuner(fd, AUTOTUNE_RTIOC_USER, period, "user");
 
-       if (!nohog)
-               pthread_cancel(hog);
+       if (!quiet && (tune_irqlat || tune_kernlat || tune_userlat))
+               printf("== auto-tuning completed after %ds\n",
+                      (int)(time(NULL) - start));
 
        close(fd);
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to