summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Williams <williams@redhat.com>2009-07-05 13:33:52 -0500
committerClark Williams <williams@redhat.com>2009-07-05 13:33:52 -0500
commit1b7ecf004ba2cb196b066603e0d43511d84a725f (patch)
tree38130b3cf499fdf3dfb60f640ec8fdccedbf8e27
parentde70815ad04ac2726d23331bd3d7f4472106b6e5 (diff)
downloadrt-tests-1b7ecf004ba2cb196b066603e0d43511d84a725f.tar.gz
rt-tests-1b7ecf004ba2cb196b066603e0d43511d84a725f.tar.xz
change options for --policy to be string names rather than integers
moved policy display from individual threads to header with load average did some sanity checking so that policy and priority match Signed-off-by: Clark Williams <williams@redhat.com>
-rw-r--r--src/cyclictest/cyclictest.89
-rw-r--r--src/cyclictest/cyclictest.c90
2 files changed, 87 insertions, 12 deletions
diff --git a/src/cyclictest/cyclictest.8 b/src/cyclictest/cyclictest.8
index 7109fdc..f6ae148 100644
--- a/src/cyclictest/cyclictest.8
+++ b/src/cyclictest/cyclictest.8
@@ -18,7 +18,7 @@ cyclictest \- High resolution test program
.B cyclictest
.RI "[ \-hfmnqrsv ] [\-a " proc " ] [\-b " usec " ] [\-c " clock " ] [\-d " dist " ] \
[\-h " histogram " ] [\-i " intv " ] [\-l " loop " ] [\-o " red " ] [\-p " prio " ] \
-[\-t " num " ] [\-D " time "] [\-w] [\-W]
+[\-t " num " ] [\-D " time "] [\-w] [\-W] [\-y " policy "]"
.\" .SH DESCRIPTION
.\" This manual page documents briefly the
@@ -153,8 +153,11 @@ task wakeup tracing (used with \-b)
rt-task wakeup tracing (used with \-b)
.TP
.B \\-y, \-\-policy
-policy of realtime thread (1:FIFO, 2:RR)
-format: --policy=1(default) or --policy=2
+set the scheduler policy of the measurement threads
+
+format: --policy=<name>
+
+where name is one of: other,normal,batch,idle,fifo,rr
.\" .SH SEE ALSO
.\" .BR bar (1),
.\" .BR baz (1).
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index d16782b..bfb8aa9 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -33,6 +33,13 @@
#include <sys/utsname.h>
#include <sys/mman.h>
+#ifndef SCHED_IDLE
+#define SCHED_IDLE 5
+#endif
+#ifndef SCHED_NORMAL
+#define SCHED_NORMAL SCHED_OTHER
+#endif
+
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
/* Ugly, but .... */
@@ -795,7 +802,7 @@ static void display_help(void)
"-w --wakeup task wakeup tracing (used with -b)\n"
"-W --wakeuprt rt task wakeup tracing (used with -b)\n"
"-y POLI --policy=POLI policy of realtime thread (1:FIFO, 2:RR)\n"
- " format: --policy=1(default) or --policy=2\n",
+ " format: --policy=fifo(default) or --policy=rr\n",
tracers
);
exit(0);
@@ -826,6 +833,52 @@ static int clocksources[] = {
CLOCK_REALTIME,
};
+static void handlepolicy(char *polname)
+{
+ if (strncasecmp(polname, "other", 5) == 0)
+ policy = SCHED_OTHER;
+ else if (strncasecmp(polname, "batch", 5) == 0)
+ policy = SCHED_BATCH;
+ else if (strncasecmp(polname, "idle", 4) == 0)
+ policy = SCHED_IDLE;
+ else if (strncasecmp(polname, "fifo", 4) == 0)
+ policy = SCHED_FIFO;
+ else if (strncasecmp(polname, "rr", 2) == 0)
+ policy = SCHED_RR;
+
+ if (policy == SCHED_FIFO || policy == SCHED_RR) {
+ if (policy == 0)
+ policy = 1;
+ }
+ else
+ policy = 0;
+}
+
+static char *policyname(int policy)
+{
+ char *policystr = "";
+
+ switch(policy) {
+ case SCHED_OTHER:
+ policystr = "other";
+ break;
+ case SCHED_FIFO:
+ policystr = "fifo";
+ break;
+ case SCHED_RR:
+ policystr = "rr";
+ break;
+ case SCHED_BATCH:
+ policystr = "batch";
+ break;
+ case SCHED_IDLE:
+ policystr = "idle";
+ break;
+ }
+ return policystr;
+}
+
+
/* Process commandline options */
static void process_options (int argc, char *argv[])
{
@@ -899,7 +952,11 @@ static void process_options (int argc, char *argv[])
case 'N': use_nsecs = 1; break;
case 'o': oscope_reduction = atoi(optarg); break;
case 'O': traceopt(optarg); break;
- case 'p': priority = atoi(optarg); break;
+ case 'p':
+ priority = atoi(optarg);
+ if (policy != SCHED_FIFO && policy != SCHED_RR)
+ policy = SCHED_FIFO;
+ break;
case 'P': tracetype = PREEMPTOFF; break;
case 'q': quiet = 1; break;
case 'r': timermode = TIMER_RELTIME; break;
@@ -919,7 +976,7 @@ static void process_options (int argc, char *argv[])
break;
case 'w': tracetype = WAKEUP; break;
case 'W': tracetype = WAKEUPRT; break;
- case 'y': policy = atoi(optarg); break;
+ case 'y': handlepolicy(optarg); break;
case '?': error = 1; break;
}
}
@@ -954,12 +1011,22 @@ static void process_options (int argc, char *argv[])
if (priority < 0 || priority > 99)
error = 1;
- if (policy < 0 || policy > 2)
- error = 1;
+
+ if (priority && (policy != SCHED_FIFO && policy != SCHED_RR)) {
+ fprintf(stderr, "policy and priority don't match: setting policy to SCHED_FIFO\n");
+ policy = SCHED_FIFO;
+ }
+
+ if ((policy == SCHED_FIFO || policy == SCHED_RR) && priority == 0) {
+ fprintf(stderr, "defaulting realtime priority to %d\n",
+ num_threads+1);
+ priority = num_threads+1;
+ }
if (num_threads < 1)
error = 1;
+
if (error)
display_help ();
}
@@ -1050,12 +1117,12 @@ static void print_stat(struct thread_param *par, int index, int verbose)
if (quiet != 1) {
char *fmt;
if (use_nsecs)
- fmt = "T:%2d (%5d) P:%2d Y:%1d I:%ld C:%7lu "
+ fmt = "T:%2d (%5d) P:%2d I:%ld C:%7lu "
"Min:%7ld Act:%8ld Avg:%8ld Max:%8ld\n";
else
- fmt = "T:%2d (%5d) P:%2d Y:%1d I:%ld C:%7lu "
+ 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->policy,
+ printf(fmt, index, stat->tid, par->prio,
par->interval, stat->cycles, stat->min, stat->act,
stat->cycles ?
(long)(stat->avg/stat->cycles) : 0, stat->max);
@@ -1203,13 +1270,18 @@ int main(int argc, char **argv)
while (!shutdown) {
char lavg[256];
int fd, len, allstopped = 0;
+ char *policystr = NULL;
+
+ if (!policystr)
+ policystr = policyname(policy);
if (!verbose && !quiet) {
fd = open("/proc/loadavg", O_RDONLY, 0666);
len = read(fd, &lavg, 255);
close(fd);
lavg[len-1] = 0x0;
- printf("%s \n\n", lavg);
+ printf("policy: %s: loadavg: %s \n\n",
+ policystr, lavg);
}
for (i = 0; i < num_threads; i++) {