All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cyclictest histogram overflow instance tracking
@ 2012-10-11 18:42 Bhavesh Davda
  2012-10-11 19:57 ` Frank Rowand
  0 siblings, 1 reply; 7+ messages in thread
From: Bhavesh Davda @ 2012-10-11 18:42 UTC (permalink / raw)
  To: linux-rt-users; +Cc: Garrett Smith, Lenin Singaravelu

From: Bhavesh Davda <bhavesh@vmware.com>

Add feature to cyclictest histogram mode to track cycle counts every time a
sample overflows the histogram limit. This should help identify if there is a
timing pattern to jitters in cyclictest runs.

Example output (with -h 10):
  ...
  Histogram Overflows: 00278
  Histogram Overflow instances:
    09373 09374 09375 09376 09377 09378 09379 09380 09381 09382 # 00268 others

Signed-off-by: Bhavesh Davda <bhavesh@vmware.com>
---
 src/cyclictest/cyclictest.c |   32 +++++++++++++++++++++++++++-----
 1 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 731b4bd..31131ad 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -147,6 +147,7 @@ struct thread_stat {
 	double avg;
 	long *values;
 	long *hist_array;
+        unsigned long *outliers;
 	pthread_t thread;
 	int threadstarted;
 	int tid;
@@ -154,6 +155,8 @@ struct thread_stat {
 	long redmax;
 	long cycleofmax;
 	long hist_overflow;
+        long num_outliers;
+        long outliers_overflow;
 };
 
 static int shutdown;
@@ -756,8 +759,13 @@ void *timerthread(void *param)
 
 		/* Update the histogram */
 		if (histogram) {
-			if (diff >= histogram)
+			if (diff >= histogram) {
 				stat->hist_overflow++;
+				if (stat->num_outliers < histogram)
+					stat->outliers[stat->num_outliers++] = stat->cycles - 1;
+				else
+					stat->outliers_overflow++;
+			}
 			else
 				stat->hist_array[diff]++;
 		}
@@ -1226,7 +1234,7 @@ static void print_tids(struct thread_param *par[], int nthreads)
 
 static void print_hist(struct thread_param *par[], int nthreads)
 {
-	int i, j;
+	int i, j, k;
 	unsigned long long int log_entries[nthreads+1];
 	unsigned long maxmax, alloverflows;
 
@@ -1280,9 +1288,19 @@ static void print_hist(struct thread_param *par[], int nthreads)
 	printf("# Histogram Overflows:");
 	alloverflows = 0;
 	for (j = 0; j < nthreads; j++) {
- 		printf(" %05lu", par[j]->stats->hist_overflow);
+		printf(" %05lu", par[j]->stats->hist_overflow);
 		alloverflows += par[j]->stats->hist_overflow;
 	}
+	printf("\n");
+	printf("# Histogram Overflow instances:\n");
+	for (j = 0; j < nthreads; j++) {
+		for (k = 0; k < par[j]->stats->num_outliers; k++)
+			printf(" %05lu", par[j]->stats->outliers[k]);
+		if (par[j]->stats->outliers_overflow > 0)
+			printf(" # %05lu others", par[j]->stats->outliers_overflow);
+                printf("\n");
+        }
+
 	if (histofall && nthreads > 1)
 		printf(" %05lu", alloverflows);
 	printf("\n");
@@ -1434,10 +1452,12 @@ int main(int argc, char **argv)
 			int bufsize = histogram * sizeof(long);
 
 			stat->hist_array = threadalloc(bufsize, node);
-			if (stat->hist_array == NULL)
+			stat->outliers = threadalloc(bufsize, node);
+			if (stat->hist_array == NULL || stat->outliers == NULL)
 				fatal("failed to allocate histogram of size %d on node %d\n",
 				      histogram, i);
 			memset(stat->hist_array, 0, bufsize);
+			memset(stat->outliers, 0, bufsize);
 		}
 
 		if (verbose) {
@@ -1553,8 +1573,10 @@ int main(int argc, char **argv)
 
 	if (histogram) {
 		print_hist(parameters, num_threads);
-		for (i = 0; i < num_threads; i++)
+		for (i = 0; i < num_threads; i++) {
 			threadfree(statistics[i]->hist_array, histogram*sizeof(long), parameters[i]->node);
+			threadfree(statistics[i]->outliers, histogram*sizeof(long), parameters[i]->node);
+                }
 	}
 
 	if (tracelimit) {
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-10-16  0:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-11 18:42 [PATCH] cyclictest histogram overflow instance tracking Bhavesh Davda
2012-10-11 19:57 ` Frank Rowand
2012-10-11 20:59   ` Bhavesh Davda
2012-10-15 16:38     ` Bhavesh Davda
2012-10-15 18:11       ` Frank Rowand
2012-10-15 18:13         ` John Kacur
2012-10-16  0:33     ` John Kacur

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.