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>
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 @@
int enable_events;
+static char *policyname(int policy);
+
enum {
NOTRACE,
CTXTSWITCH,
@@ -644,7 +646,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;