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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Aug 15 19:13:17 2014 +0200

utils/autotune: allow for changing the sampling period

---

 doc/asciidoc/man1/autotune.adoc |   11 +++++++++++
 utils/autotune/autotune.c       |   21 +++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/doc/asciidoc/man1/autotune.adoc b/doc/asciidoc/man1/autotune.adoc
index 42d76bf..c099130 100644
--- a/doc/asciidoc/man1/autotune.adoc
+++ b/doc/asciidoc/man1/autotune.adoc
@@ -82,6 +82,17 @@ platform needs to deliver an IRQ to a user-space task/thread 
running
 in a Xenomai application process. This delay includes the context
 switching time.
 
+**--period <ns>*::
+Set the sampling period to the given count of nanoseconds. The
+estimation is performed by measuring the jitter between the ideal time
+at which a timer tick should be received, and the actual time it is
+eventually received, for a series of ticks. This value expresses the
+delay between two of these ticks. If too short, a lockup might
+occur. A commonly observed result is: the larger the delay, the higher
+the latency, due to CPU cache effects (i.e. the real-time code/data is
+more likely to get evicted from the cachelines as the non real-time
+activity can slip in, treading over a larger address space).
+
 *--reset*::
 Reset the gravity values to their factory defaults. These defaults
 are statically defined by the Xenomai platform code.
diff --git a/utils/autotune/autotune.c b/utils/autotune/autotune.c
index a36c606..3c019f3 100644
--- a/utils/autotune/autotune.c
+++ b/utils/autotune/autotune.c
@@ -75,6 +75,11 @@ static const struct option base_options[] = {
                .val = 1
        },
        {
+#define period_opt     7
+               .name = "period",
+               .has_arg = 1,
+       },
+       {
                .name = NULL,
        }
 };
@@ -179,11 +184,12 @@ static void usage(void)
        fprintf(stderr, "   --irq               interrupt latency\n");
        fprintf(stderr, "   --kernel            kernel scheduling latency\n");
        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\n");
+       fprintf(stderr, "if no option is given, tune for all contexts using the 
default period.\n");
 }
 
 static void run_tuner(int fd, int op, int period, const char *type)
@@ -223,6 +229,8 @@ int main(int argc, char *const argv[])
        int fd, period, ret, c, lindex, tuned = 0;
        pthread_t hog;
 
+       period = CONFIG_XENO_DEFAULT_PERIOD;
+
        for (;;) {
                c = getopt_long_only(argc, argv, "", base_options, &lindex);
                if (c == EOF)
@@ -238,6 +246,12 @@ int main(int argc, char *const argv[])
                case help_opt:
                        usage();
                        exit(0);
+               case period_opt:
+                       period = atoi(optarg);
+                       if (period <= 0)
+                               error(1, EINVAL, "invalid sampling period 
(default %d)",
+                                     CONFIG_XENO_DEFAULT_PERIOD);
+                       break;
                case nohog_opt:
                case quiet_opt:
                        break;
@@ -265,13 +279,12 @@ int main(int argc, char *const argv[])
                        error(1, errno, "reset failed");
        }
 
-       period = CONFIG_XENO_DEFAULT_PERIOD;
-
        if (tune_irqlat || tune_kernlat || tune_userlat) {
                if (!nohog)
                        create_hog(&hog);
                if (!quiet)
-                       printf("Auto-tuning started (may take a while)\n");
+                       printf("Auto-tuning started, period=%dns (may take a 
while)\n",
+                               period);
        } else
                nohog = 1;
 


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

Reply via email to