* cyclictest: add --update_on_max option
@ 2009-08-26 16:11 Arnaldo Carvalho de Melo
2009-08-26 20:31 ` [PATCH v2] " Arnaldo Carvalho de Melo
0 siblings, 1 reply; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2009-08-26 16:11 UTC (permalink / raw)
To: Clark Williams; +Cc: linux-rt-users
When running on a machine with not enough bandwidth it can be helpful to
only update the status when a new max is hit.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 2b4dc50..8181ff7 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -135,6 +135,7 @@ struct thread_stat {
pthread_t thread;
int threadstarted;
int tid;
+ int new_max;
long reduce;
long redmax;
long cycleofmax;
@@ -147,6 +148,7 @@ static int kernelversion;
static int verbose = 0;
static int oscope_reduction = 1;
static int lockall = 0;
+static int refresh_on_max;
static int tracetype = NOTRACE;
static int histogram = 0;
static int histogram_limit_exceeded = 0;
@@ -685,8 +687,10 @@ void *timerthread(void *param)
diff = calcdiff(now, next);
if (diff < stat->min)
stat->min = diff;
- if (diff > stat->max)
+ if (diff > stat->max) {
stat->max = diff;
+ ++stat->new_max;
+ }
stat->avg += (double) diff;
if (duration && (calcdiff(now, stop) >= 0))
@@ -904,6 +908,7 @@ static void process_options (int argc, char *argv[])
{"irqsoff", no_argument, NULL, 'I'},
{"loops", required_argument, NULL, 'l'},
{"mlockall", no_argument, NULL, 'm' },
+ {"refresh_on_max", no_argument, NULL, 'M' },
{"nanosleep", no_argument, NULL, 'n'},
{"nsecs", no_argument, NULL, 'N'},
{"oscope", required_argument, NULL, 'o'},
@@ -923,7 +928,7 @@ static void process_options (int argc, char *argv[])
{"traceopt", required_argument, NULL, 'O'},
{NULL, 0, NULL, 0}
};
- int c = getopt_long (argc, argv, "a::b:Bc:Cd:Efh:i:Il:nNo:O:p:Pmqrst::vD:wWTy:",
+ int c = getopt_long (argc, argv, "a::b:Bc:Cd:Efh:i:Il:MnNo:O:p:Pmqrst::vD:wWTy:",
long_options, &option_index);
if (c == -1)
break;
@@ -974,6 +979,7 @@ static void process_options (int argc, char *argv[])
case 'T': strncpy(tracer, optarg, sizeof(tracer)); break;
case 'v': verbose = 1; break;
case 'm': lockall = 1; break;
+ case 'M': refresh_on_max = 1; break;
case 'D': duration = parse_time_string(optarg);
break;
case 'w': tracetype = WAKEUP; break;
@@ -1124,6 +1130,7 @@ static void print_stat(struct thread_param *par, int index, int verbose)
else
fmt = "T:%2d (%5d) P:%2d I:%ld C:%7lu "
"Min:%7ld Act:%5ld Avg:%5ld Max:%8ld\n";
+
printf(fmt, index, stat->tid, par->prio,
par->interval, stat->cycles, stat->min, stat->act,
stat->cycles ?
@@ -1271,13 +1278,13 @@ int main(int argc, char **argv)
while (!shutdown) {
char lavg[256];
- int fd, len, allstopped = 0;
+ int fd, len, allstopped = 0, threads_with_new_max = 0;
char *policystr = NULL;
if (!policystr)
policystr = policyname(policy);
- if (!verbose && !quiet) {
+ if (!verbose && !quiet && !refresh_on_max) {
fd = open("/proc/loadavg", O_RDONLY, 0666);
len = read(fd, &lavg, 255);
close(fd);
@@ -1287,8 +1294,13 @@ int main(int argc, char **argv)
}
for (i = 0; i < num_threads; i++) {
-
- print_stat(&par[i], i, verbose);
+ if (!refresh_on_max || par[i].stats->new_max) {
+ print_stat(&par[i], i, verbose);
+ if (par[i].stats->new_max)
+ --par[i].stats->new_max;
+ threads_with_new_max++;
+ }
+
if(max_cycles && stat[i].cycles >= max_cycles)
allstopped++;
}
@@ -1296,8 +1308,11 @@ int main(int argc, char **argv)
usleep(10000);
if (shutdown || allstopped)
break;
- if (!verbose && !quiet)
- printf("\033[%dA", num_threads + 2);
+ if (!verbose && !quiet && threads_with_new_max) {
+ if (!refresh_on_max)
+ threads_with_new_max += 2;
+ printf("\033[%dA", threads_with_new_max);
+ }
}
ret = EXIT_SUCCESS;
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH v2] cyclictest: add --update_on_max option
2009-08-26 16:11 cyclictest: add --update_on_max option Arnaldo Carvalho de Melo
@ 2009-08-26 20:31 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2009-08-26 20:31 UTC (permalink / raw)
To: Clark Williams; +Cc: linux-rt-users
Note: the previous one sucked rockz, please try this one instead.
When running on a machine with not enough bandwidth it can be helpful to
only update the status when a new max is hit.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 2b4dc50..97461e5 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -152,7 +152,10 @@ static int histogram = 0;
static int histogram_limit_exceeded = 0;
static int duration = 0;
static int use_nsecs = 0;
+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;
/* Backup of kernel variables that we modify */
static struct kvars {
@@ -685,8 +688,11 @@ void *timerthread(void *param)
diff = calcdiff(now, next);
if (diff < stat->min)
stat->min = diff;
- if (diff > stat->max)
+ if (diff > stat->max) {
stat->max = diff;
+ if (refresh_on_max)
+ pthread_cond_signal(&refresh_on_max_cond);
+ }
stat->avg += (double) diff;
if (duration && (calcdiff(now, stop) >= 0))
@@ -904,6 +910,7 @@ static void process_options (int argc, char *argv[])
{"irqsoff", no_argument, NULL, 'I'},
{"loops", required_argument, NULL, 'l'},
{"mlockall", no_argument, NULL, 'm' },
+ {"refresh_on_max", no_argument, NULL, 'M' },
{"nanosleep", no_argument, NULL, 'n'},
{"nsecs", no_argument, NULL, 'N'},
{"oscope", required_argument, NULL, 'o'},
@@ -923,8 +930,8 @@ static void process_options (int argc, char *argv[])
{"traceopt", required_argument, NULL, 'O'},
{NULL, 0, NULL, 0}
};
- int c = getopt_long (argc, argv, "a::b:Bc:Cd:Efh:i:Il:nNo:O:p:Pmqrst::vD:wWTy:",
- long_options, &option_index);
+ int c = getopt_long(argc, argv, "a::b:Bc:Cd:Efh:i:Il:MnNo:O:p:Pmqrst::vD:wWTy:",
+ long_options, &option_index);
if (c == -1)
break;
switch (c) {
@@ -974,6 +981,7 @@ static void process_options (int argc, char *argv[])
case 'T': strncpy(tracer, optarg, sizeof(tracer)); break;
case 'v': verbose = 1; break;
case 'm': lockall = 1; break;
+ case 'M': refresh_on_max = 1; break;
case 'D': duration = parse_time_string(optarg);
break;
case 'w': tracetype = WAKEUP; break;
@@ -1078,6 +1086,8 @@ static int check_timer(void)
static void sighand(int sig)
{
shutdown = 1;
+ if (refresh_on_max)
+ pthread_cond_signal(&refresh_on_max_cond);
if (tracelimit)
tracing(0);
}
@@ -1298,6 +1308,13 @@ int main(int argc, char **argv)
break;
if (!verbose && !quiet)
printf("\033[%dA", num_threads + 2);
+
+ if (refresh_on_max) {
+ pthread_mutex_lock(&refresh_on_max_lock);
+ pthread_cond_wait(&refresh_on_max_cond,
+ &refresh_on_max_lock);
+ pthread_mutex_unlock(&refresh_on_max_lock);
+ }
}
ret = EXIT_SUCCESS;
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-08-26 20:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-26 16:11 cyclictest: add --update_on_max option Arnaldo Carvalho de Melo
2009-08-26 20:31 ` [PATCH v2] " Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).