Thanks.

On Mon, 2008-08-18 at 13:34 -0500, Will Schmidt wrote:
> This is a patch from John, written a few months back.  I have fixed up a
> few cosmetic whitespace bits, and have refreshed it so it should apply
> cleanly to LTP today.
> 
> Comments originally by John Stultz:
> 
> So I've been trying to go through and review our test cases to make sure
> we're getting sane data and the tests are really testing what we want.
> 
> Looking at gtod_latency and gtod_infinite, I was always struck that
> gtod_infinite always came up with much larger latencies while
> gtod_latency usually seemed to miss them.
> 
> Main issues:
> 
> 1) gtod_latency was not running for long enough, I've upped the
> iterations by 10x to make sure we get more solid results.
> 
> 2) gtod_latency was doing too much computation between gtod calls. This
> means it could miss latencies that occur while it was running. I
> reworked the data collection loop so the un-measured window is smaller.
> 
> 3) gtod_infinite was accidentally measuring its own computation in its
> delay, inflating its values. I cut that logic out.
> 
> 4) both gtod_latency and gtod_infinite were not running mlocked. this
> caused background SCHED_OTHER disk access to inject delays, making the
> results less reliable.
> 
> Those four issues have been fixed, and I also converted gtod_latency to
> use clock_gettime() just to be consistent and to give slightly better
> resolution.
> 
> -john
> 
> Signed-off-by: John Stultz <[EMAIL PROTECTED]>
> Acked-by: Darren Hart <[EMAIL PROTECTED]>
> Acked-by: Will Schmidt <[EMAIL PROTECTED]>

A Real Time test case patch after long time. Patch is merged.

Regards--
Subrata

> 
> ---
> 
> diff -Naur ltp.orig/testcases/realtime/func/gtod_latency/gtod_infinite.c 
> ltp/testcases/realtime/func/gtod_latency/gtod_infinite.c
> --- ltp.orig/testcases/realtime/func/gtod_latency/gtod_infinite.c     
> 2008-08-18 13:15:21.000000000 -0500
> +++ ltp/testcases/realtime/func/gtod_latency/gtod_infinite.c  2008-08-18 
> 12:22:23.000000000 -0500
> @@ -53,6 +53,7 @@
>  #include <sched.h>
>  #include <librttest.h>
>  #include <libjvmsim.h>
> +#include <sys/mman.h>
> 
>  /* #define CLOCK_TO_USE CLOCK_MONOTONIC */
>  #define CLOCK_TO_USE CLOCK_REALTIME
> @@ -66,9 +67,9 @@
>  void usage(void)
>  {
>       rt_help();
> -     printf("gtod_infinite specific options:\n");
> -     printf("  -j            enable jvmsim\n");
> -     printf("  -wWINDOW      iterations in max value window (default 
> inf)\n");
> +     printf("gtod_infinite specific options:\n");
> +     printf("  -j            enable jvmsim\n");
> +     printf("  -wWINDOW      iterations in max value window (default 
> inf)\n");
>  }
> 
>  int parse_args(int c, char *v)
> @@ -121,9 +122,11 @@
>               printf("jvmsim disabled\n");
>       }
> 
> +     mlockall(MCL_CURRENT|MCL_FUTURE);
> +
>       if (max_window > 0) {
> -             printf("%d iterations in max calculation window\n", 
> -                    max_window);
> +             printf("%d iterations in max calculation window\n",
> +                     max_window);
>       }
> 
>       param.sched_priority = sched_get_priority_min(SCHED_FIFO) + 80;
> @@ -141,6 +144,7 @@
> 
>       wi = 0;
>       while(1) {
> +             rc = clock_gettime(CLOCK_TO_USE, &p_ts);
>               rc = clock_gettime(CLOCK_TO_USE, &ts);
>               if (rc) {
>                       perror("clock_gettime");
> @@ -153,11 +157,11 @@
>               diff_time = e_time - s_time;
> 
>               if (max_window > 0 ||
> -                       ((diff_time > max_time) || 
> +                     ((diff_time > max_time) ||
>                          (diff_time > REPORT_MIN))) {
>                       if (diff_time > max_time)
>                               max_time = diff_time;
> -                     
> +
>                       if (max_window == 0 || ++wi == max_window) {
>                               tt = (time_t)ts.tv_sec;
>                               printf("Task delayed for %lld nsec!!! %s",
> @@ -170,13 +174,6 @@
>                               }
>                       }
> 
> -                     rc = clock_gettime(CLOCK_TO_USE, &p_ts);
> -                     if (rc) {
> -                             perror("clock_gettime");
> -                             exit(1);
> -                     }
> -             } else {
> -                     p_ts = ts;
>               }
>       }
>       return 0;
> diff -Naur ltp.orig/testcases/realtime/func/gtod_latency/gtod_latency.c 
> ltp/testcases/realtime/func/gtod_latency/gtod_latency.c
> --- ltp.orig/testcases/realtime/func/gtod_latency/gtod_latency.c      
> 2008-08-18 13:15:21.000000000 -0500
> +++ ltp/testcases/realtime/func/gtod_latency/gtod_latency.c   2008-08-18 
> 12:22:10.000000000 -0500
> @@ -54,8 +54,9 @@
>  #include <limits.h>
>  #include <libstats.h>
>  #include <librttest.h>
> +#include <sys/mman.h>
> 
> -#define ITERATIONS 1000000
> +#define ITERATIONS 10000000
>  #define HIST_BUCKETS 20
> 
>  #define SCATTER_FILENAME     0
> @@ -202,19 +203,20 @@
>  }
> 
> 
> -/* return difference in microseconds */
> -unsigned long long tv_minus(struct timeval *tv_start, struct timeval *tv_end)
> +long long timespec_subtract(struct timespec * a, struct timespec *b)
>  {
> -     unsigned long long usecs;
> -     usecs = (tv_end->tv_sec - tv_start->tv_sec) * 1000000;
> -     usecs += tv_end->tv_usec - tv_start->tv_usec;
> -     return usecs;
> +     long long ns;
> +     ns = (b->tv_sec - a->tv_sec) * 1000000000LL;
> +     ns += (b->tv_nsec - a->tv_nsec);
> +     return ns;
>  }
> 
> +struct timespec start_data[ITERATIONS];
> +struct timespec stop_data[ITERATIONS];
> +
>  int main(int argc, char *argv[])
>  {
>       int i, err;
> -     struct timeval tv_a, tv_b;
>       unsigned long long delta;
>       unsigned long long max, min;
>       struct sched_param param;
> @@ -227,6 +229,8 @@
>       stats_quantiles_init(&quantiles, (int)log10(ITERATIONS));
>       setup();
> 
> +     mlockall(MCL_CURRENT|MCL_FUTURE);
> +
>       if (stats_cmdline(argc, argv) < 0) {
>               printf("usage: %s help\n", argv[0]);
>               exit(1);
> @@ -242,7 +246,7 @@
>                       fprintf(stderr, "This program runs with a scheduling 
> policy of SCHED_FIFO at priority %d\n", param.sched_priority);
>                       fprintf(stderr, "You don't have the necessary 
> privileges to create such a real-time process.\n");
>               } else {
> -                     fprintf(stderr, "Failed to set scheduler, errno %d\n", 
> errno);
> +                     fprintf(stderr, "Failed to set scheduler, errno %d\n", 
> errno);
>               }
>               exit(1);
>       }
> @@ -259,9 +263,11 @@
>               latency_trace_start();
>       }
>       for (i = 0; i < ITERATIONS; i++) {
> -             gettimeofday(&tv_a, NULL);
> -             gettimeofday(&tv_b, NULL);
> -             delta = tv_minus(&tv_a, &tv_b);
> +             clock_gettime(CLOCK_MONOTONIC,&start_data[i]);
> +             clock_gettime(CLOCK_MONOTONIC,&stop_data[i]);
> +     }
> +     for (i = 0; i < ITERATIONS; i++) {
> +             delta = timespec_subtract(&start_data[i], &stop_data[i]);
>               dat.records[i].x = i;
>               dat.records[i].y = delta;
>               if (i == 0 || delta < min) min = delta;
> @@ -273,7 +279,7 @@
>               latency_trace_stop();
>               if (i != ITERATIONS) {
>                       printf("Latency threshold (%lluus) exceeded at 
> iteration %d\n",
> -                            latency_threshold, i);
> +                             latency_threshold, i);
>                       latency_trace_print();
>                       stats_container_resize(&dat, i + 1);
>               }
> @@ -281,19 +287,18 @@
> 
>       stats_hist(&hist, &dat);
>       stats_container_save(filenames[SCATTER_FILENAME], titles[SCATTER_TITLE],
> -                          labels[SCATTER_LABELX], labels[SCATTER_LABELY], 
> &dat, "points");
> +                             labels[SCATTER_LABELX], labels[SCATTER_LABELY], 
> &dat, "points");
>       stats_container_save(filenames[HIST_FILENAME], titles[HIST_TITLE],
> -                          labels[HIST_LABELX], labels[HIST_LABELY], &hist, 
> "steps");
> +                             labels[HIST_LABELX], labels[HIST_LABELY], 
> &hist, "steps");
> 
>       /* report on deltas */
> -     printf("Min: %llu us\n", min);
> -     printf("Max: %llu us\n", max);
> -     printf("Avg: %.4f us\n", stats_avg(&dat));
> -     printf("StdDev: %.4f us\n", stats_stddev(&dat));
> +     printf("Min: %llu ns\n", min);
> +     printf("Max: %llu ns\n", max);
> +     printf("Avg: %.4f ns\n", stats_avg(&dat));
> +     printf("StdDev: %.4f ns\n", stats_stddev(&dat));
>       printf("Quantiles:\n");
>       stats_quantiles_calc(&dat, &quantiles);
>       stats_quantiles_print(&quantiles);
> 
> -
>       return 0;
>  }
> 
> 
> 
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Ltp-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ltp-list


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to