summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Rowand <frank.rowand@am.sony.com>2012-05-02 17:02:40 -0700
committerClark Williams <williams@redhat.com>2012-05-03 16:17:38 -0500
commite43bee01585e1407c48dc5ecc5f2be74737fd336 (patch)
tree0c257e099610399ef19090753081ee39e20dd069
parentf4256bfde48fa269758633d79e722d50a431b314 (diff)
downloadrt-tests-e43bee01585e1407c48dc5ecc5f2be74737fd336.tar.gz
rt-tests: incorrect first latency value for --verbose option
When the --verbose option is selected, the first value for each thread is incorrectly reported as zero. This is because when collecting the first value, the index into stat->values is incremented from zero to one before storing the value. But when printing the values, the first value printed is stat->values[0], which has been initialized to zero. Signed-off-by: Frank Rowand <frank.rowand@am.sony.com> Signed-off-by: Clark Williams <williams@redhat.com>
-rw-r--r--src/cyclictest/cyclictest.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index f2566cc..d0a1168 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -108,6 +108,8 @@ extern int clock_nanosleep(clockid_t __clock_id, int __flags,
int enable_events;
+static char *policyname(int policy);
+
enum {
NOTRACE,
CTXTSWITCH,
@@ -644,7 +646,8 @@ void *timerthread(void *param)
memset(&schedp, 0, sizeof(schedp));
schedp.sched_priority = par->prio;
- sched_setscheduler(0, par->policy, &schedp);
+ if (sched_setscheduler(0, par->policy, &schedp))
+ fatal("timerthread%d: failed to set priority to %d\n", par->cpu, par->prio);
/* Get current time */
clock_gettime(par->clock, &now);
@@ -701,10 +704,14 @@ void *timerthread(void *param)
goto out;
}
} else {
- clock_gettime(par->clock, &now);
+ if ((ret = clock_gettime(par->clock, &now))) {
+ if (ret != EINTR)
+ warn("clock_gettime() failed: %s", strerror(errno));
+ goto out;
+ }
if ((ret = clock_nanosleep(par->clock, TIMER_RELTIME, &interval, NULL))) {
if (ret != EINTR)
- warn("clock_gettime failed. errno: %d\n", errno);
+ warn("clock_nanosleep() failed. errno: %d\n", errno);
goto out;
}
next.tv_sec = now.tv_sec + interval.tv_sec;
@@ -716,7 +723,7 @@ void *timerthread(void *param)
case MODE_SYS_NANOSLEEP:
if ((ret = clock_gettime(par->clock, &now))) {
if (ret != EINTR)
- warn("clock_gettime failed: errno %d\n", errno);
+ warn("clock_gettime() failed: errno %d\n", errno);
goto out;
}
if (nanosleep(&interval, NULL)) {
@@ -732,7 +739,7 @@ void *timerthread(void *param)
if ((ret = clock_gettime(par->clock, &now))) {
if (ret != EINTR)
- warn("clock_getttime failed. errno: %d\n", errno);
+ warn("clock_getttime() failed. errno: %d\n", errno);
goto out;
}
@@ -763,7 +770,6 @@ void *timerthread(void *param)
pthread_mutex_unlock(&break_thread_id_lock);
}
stat->act = diff;
- stat->cycles++;
if (par->bufmsk)
stat->values[stat->cycles & par->bufmsk] = diff;
@@ -776,6 +782,8 @@ void *timerthread(void *param)
stat->hist_array[diff]++;
}
+ stat->cycles++;
+
next.tv_sec += interval.tv_sec;
next.tv_nsec += interval.tv_nsec;
if (par->mode == MODE_CYCLIC) {
@@ -1101,6 +1109,8 @@ static void process_options (int argc, char *argv[])
if (smp)
fatal("numa and smp options are mutually exclusive\n");
#ifdef NUMA
+ if (numa_available() == -1)
+ fatal("NUMA functionality not available!");
numa = 1;
num_threads = max_cpus;
setaffinity = AFFINITY_USEALL;