summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Williams <williams@redhat.com>2015-08-28 14:54:43 -0500
committerJohn Kacur <jkacur@redhat.com>2015-09-02 14:50:40 +0200
commita837ba68069f8de803b7815c500e5875d8e5318f (patch)
treec690059f071aebb428669537a9176000f62155dd
parentb1c507531db2a4bdfe2708d2576ad02bbe47abd0 (diff)
downloadrt-tests-a837ba68069f8de803b7815c500e5875d8e5318f.tar.gz
rt-migrate-test: updated to latest code from rostedt
Signed-off-by: Clark Williams <williams@redhat.com> Signed-off-by: John Kacur <jkacur@redhat.com> Put Back #ifndef _GNU_SOURCE We define _GNU_SOURCE in our Makefile. I don't mind having it a second time as documentation in the files, but we need to have the #ifdef to prevent the compiler warning about it being redfined Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r--src/rt-migrate-test/rt-migrate-test.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/rt-migrate-test/rt-migrate-test.c b/src/rt-migrate-test/rt-migrate-test.c
index 430e992..85a78da 100644
--- a/src/rt-migrate-test/rt-migrate-test.c
+++ b/src/rt-migrate-test/rt-migrate-test.c
@@ -112,6 +112,7 @@ static int nr_runs = NR_RUNS;
static int prio_start = PRIO_START;
static int check;
static int stop;
+static int equal;
static unsigned long long now;
@@ -182,6 +183,7 @@ static void usage(char **argv)
"-s time --sleep-time time Sleep time (ms) between intervals (100)\n"
"-m time --maxerr time Max allowed error (microsecs)\n"
"-l loops --loops loops Number of iterations to run (50)\n"
+ "-e Use equal prio for #CPU-1 tasks (requires > 2 CPUS)\n"
"-c --check Stop if lower prio task is quicker than higher (off)\n"
"-h --help\n"
" () above are defaults \n",
@@ -204,18 +206,19 @@ static void parse_options (int argc, char *argv[])
{"help", no_argument, NULL, '?'},
{NULL, 0, NULL, 0}
};
- int c = getopt_long (argc, argv, "p:r:s:m:l:ch",
+ int c = getopt_long (argc, argv, "p:r:s:m:l:ech",
long_options, &option_index);
if (c == -1)
break;
switch (c) {
case 'p': prio_start = atoi(optarg); break;
case 'r':
- run_interval = ms2nano(atoi(optarg));
+ run_interval = atoi(optarg);
break;
- case 's': interval = ms2nano(atoi(optarg)); break;
+ case 's': interval = atoi(optarg); break;
case 'l': nr_runs = atoi(optarg); break;
case 'm': max_err = usec2nano(atoi(optarg)); break;
+ case 'e': equal = 1; break;
case 'c': check = 1; break;
case '?':
case 'h':
@@ -223,14 +226,7 @@ static void parse_options (int argc, char *argv[])
break;
}
}
- if (nr_runs <= 0) {
- fprintf(stderr, "Error: --loops argument is non-positive. Exiting.\n");
- exit(-1);
- }
- if (prio_start < 1 || prio_start > 99) {
- fprintf(stderr, "Error: invalid value for --prio: %d (valid: 1-99)\n", prio_start);
- exit(-1);
- }
+
}
static unsigned long long get_time(void)
@@ -260,6 +256,12 @@ static void record_time(int id, unsigned long long time, unsigned long l)
intervals_loops[loop][id] = l;
}
+static int calc_prio(int id)
+{
+ int prio = equal && id && (id < nr_tasks - 1) ? 1 : id;
+ return prio + prio_start;
+}
+
static void print_results(void)
{
int i;
@@ -310,7 +312,7 @@ static void print_results(void)
printf("Parent pid: %d\n", getpid());
for (t=0; t < nr_tasks; t++) {
- printf(" Task %d (prio %d) (pid %ld):\n", t, t + prio_start,
+ printf(" Task %d (prio %d) (pid %ld):\n", t, calc_prio(t),
thread_pids[t]);
printf(" Max: %lld us\n", nano2usec(tasks_max[t]));
printf(" Min: %lld us\n", nano2usec(tasks_min[t]));
@@ -335,7 +337,7 @@ static unsigned long busy_loop(unsigned long long start_time)
do {
l++;
time = get_time();
- } while ((time - start_time) < run_interval);
+ } while ((time - start_time) < RUN_INTERVAL);
return l;
}
@@ -344,8 +346,9 @@ void *start_task(void *data)
{
long id = (long)data;
unsigned long long start_time;
+ int prio = calc_prio(id);
struct sched_param param = {
- .sched_priority = id + prio_start,
+ .sched_priority = prio,
};
int ret;
int high = 0;
@@ -360,6 +363,7 @@ void *start_task(void *data)
perr("getting affinity");
pid = gettid();
+ thread_pids[id] = pid;
/* Check if we are the highest prio task */
if (id == nr_tasks-1)
@@ -410,6 +414,7 @@ static int check_times(int l)
intervals[l][i] > last_length ||
(intervals_length[l][i] > last_length &&
intervals_length[l][i] - last_length > max_err)) {
+ ftrace_write("Task %d FAILED\n", thread_pids[i]);
check = -1;
return 1;
}
@@ -540,8 +545,8 @@ int main (int argc, char **argv)
- intv.tv_sec = nano2sec(interval);
- intv.tv_nsec = interval % sec2nano(1);
+ intv.tv_sec = nano2sec(INTERVAL);
+ intv.tv_nsec = INTERVAL % sec2nano(1);
print_progress_bar(0);
@@ -550,6 +555,9 @@ int main (int argc, char **argv)
for (loop=0; loop < nr_runs; loop++) {
unsigned long long end;
+ /* Release the CPU so all can get to the next barrier */
+ nanosleep(&intv, NULL);
+
now = get_time();
ftrace_write("Loop %d now=%lld\n", loop, now);