summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Williams <williams@redhat.com>2009-12-10 14:17:34 -0600
committerClark Williams <williams@redhat.com>2009-12-10 14:17:34 -0600
commit93989ec0d61e5220ff14475a9ec44ba4ebfcf1a1 (patch)
treea53de6545a43c37311788a6f081c720ac8632499
parent4176f242c2eeeb4657f51183f55862e3dcd228db (diff)
downloadrt-tests-93989ec0d61e5220ff14475a9ec44ba4ebfcf1a1.tar.gz
[cyclictest] print thread ids when breaktracing
This commit adds some output then the -b option is used to break on exceeding a threshold. the thread id of the thread that exceeded the threshold is printed for use when looking at the trace log. Signed-off-by: Clark Williams <williams@redhat.com>
-rw-r--r--src/cyclictest/cyclictest.c61
1 files changed, 39 insertions, 22 deletions
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 223f343..24d4d83 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -138,6 +138,7 @@ struct thread_stat {
long reduce;
long redmax;
long cycleofmax;
+ long hist_overflow;
};
static int shutdown;
@@ -149,7 +150,6 @@ static int oscope_reduction = 1;
static int lockall = 0;
static int tracetype = NOTRACE;
static int histogram = 0;
-static int histogram_limit_exceeded = 0;
static int duration = 0;
static int use_nsecs = 0;
static int refresh_on_max;
@@ -157,6 +157,9 @@ static int refresh_on_max;
static pthread_cond_t refresh_on_max_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t refresh_on_max_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t break_thread_id_lock = PTHREAD_MUTEX_INITIALIZER;
+static pid_t break_thread_id = 0;
+
/* Backup of kernel variables that we modify */
static struct kvars {
char name[KVARNAMELEN];
@@ -702,6 +705,10 @@ void *timerthread(void *param)
stopped++;
tracing(0);
shutdown++;
+ pthread_mutex_lock(&break_thread_id_lock);
+ if (break_thread_id == 0)
+ break_thread_id = stat->tid;
+ pthread_mutex_unlock(&break_thread_id_lock);
}
stat->act = diff;
stat->cycles++;
@@ -709,18 +716,14 @@ void *timerthread(void *param)
if (par->bufmsk)
stat->values[stat->cycles & par->bufmsk] = diff;
- /* When histogram limit got exceed, mark limit as exceeded,
- * and use last bucket to recored samples of, exceeding
- * latency spikes.
- */
- if (histogram && diff >= histogram) {
- histogram_limit_exceeded = 1;
- diff = histogram - 1;
+ /* Update the histogram */
+ if (histogram) {
+ if (diff >= histogram)
+ stat->hist_overflow++;
+ else
+ stat->hist_array[diff]++;
}
- if (histogram)
- stat->hist_array[diff] += 1;
-
next.tv_sec += interval.tv_sec;
next.tv_nsec += interval.tv_nsec;
tsnorm(&next);
@@ -1092,11 +1095,20 @@ static void sighand(int sig)
tracing(0);
}
+static void print_tids(struct thread_param *par, int nthreads)
+{
+ int i;
+
+ printf("# Thread Ids:");
+ for (i = 0; i < nthreads; i++)
+ printf(" %05d", par[i].stats->tid);
+ printf("\n");
+}
+
static void print_hist(struct thread_param *par, int nthreads)
{
int i, j;
unsigned long long log_entries[nthreads];
- unsigned long max_latency = 0;
bzero(log_entries, sizeof(log_entries));
@@ -1109,8 +1121,6 @@ static void print_hist(struct thread_param *par, int nthreads)
unsigned long curr_latency=par[j].stats->hist_array[i];
printf("%06lu\t", curr_latency);
log_entries[j] += curr_latency;
- if (curr_latency && max_latency < i)
- max_latency = i;
}
printf("\n");
}
@@ -1118,7 +1128,14 @@ static void print_hist(struct thread_param *par, int nthreads)
for (j = 0; j < nthreads; j++)
printf(" %09llu", log_entries[j]);
printf("\n");
- printf("# Max Latency: %lu / %d\n", max_latency, histogram);
+ printf("# Max Latencys:");
+ for (j = 0; j < nthreads; j++)
+ printf(" %05lu", par[j].stats->max);
+ printf("\n");
+ printf("# Histogram Overflows:");
+ for (j = 0; j < nthreads; j++)
+ printf(" %05lu", par[j].stats->hist_overflow);
+ printf("\n");
}
static void print_stat(struct thread_param *par, int index, int verbose)
@@ -1342,6 +1359,13 @@ int main(int argc, char **argv)
free (stat[i].hist_array);
}
+ if (tracelimit) {
+ print_tids(par, num_threads);
+ if (break_thread_id)
+ printf("# Break thread: %d\n", break_thread_id);
+ }
+
+
free(stat);
outpar:
free(par);
@@ -1358,12 +1382,5 @@ int main(int argc, char **argv)
if (kernelversion != KV_26_CURR)
restorekernvars();
- if (histogram && histogram_limit_exceeded) {
- ret = EXIT_FAILURE;
- fprintf(stderr, "ERROR: Histogram limit got exceeded at least once!\n"
- "Limit exceeding got sampled in last bucket.\n");
-
- }
-
exit(ret);
}