diff options
| author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2016-04-24 09:45:29 -0400 |
|---|---|---|
| committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2016-04-24 09:45:29 -0400 |
| commit | a321fc5a25a99fe2979439fbed2c4b5d73ad947f (patch) | |
| tree | ef353f67becf314144d45dac0a95df1f22771eeb /src | |
| parent | b2c36fecb42b85f2fe9d6c6ade51aaf00dbbee9d (diff) | |
st-job-stats: output number of preemptions and migrations
Diffstat (limited to 'src')
| -rw-r--r-- | src/job_stats.c | 78 |
1 files changed, 59 insertions, 19 deletions
diff --git a/src/job_stats.c b/src/job_stats.c index 156be60..f1406f4 100644 --- a/src/job_stats.c +++ b/src/job_stats.c | |||
| @@ -17,43 +17,81 @@ static double nano_to_ms(int64_t ns) | |||
| 17 | return ns * 1E-6; | 17 | return ns * 1E-6; |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | static void count_preemptions( | ||
| 21 | struct evlink *release, | ||
| 22 | struct evlink *completion, | ||
| 23 | unsigned int *preemptions, | ||
| 24 | unsigned int *migrations) | ||
| 25 | { | ||
| 26 | struct evlink *e; | ||
| 27 | int seen_switched_away = 0; | ||
| 28 | u8 last_cpu = 0; | ||
| 29 | |||
| 30 | for (e = release; e != completion; e = e->next) { | ||
| 31 | if (e->rec->hdr.job == release->rec->hdr.job) { | ||
| 32 | switch (e->rec->hdr.type) { | ||
| 33 | case ST_SWITCH_AWAY: | ||
| 34 | seen_switched_away = 1; | ||
| 35 | last_cpu = e->rec->hdr.cpu; | ||
| 36 | break; | ||
| 37 | case ST_SWITCH_TO: | ||
| 38 | if (seen_switched_away) | ||
| 39 | (*preemptions)++; | ||
| 40 | if (seen_switched_away && | ||
| 41 | e->rec->hdr.cpu != last_cpu) | ||
| 42 | (*migrations)++; | ||
| 43 | break; | ||
| 44 | default: | ||
| 45 | break; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 20 | static void print_stats( | 51 | static void print_stats( |
| 21 | struct task* t, | 52 | struct task* t, |
| 22 | struct st_event_record *release, | 53 | struct evlink *release, |
| 23 | struct st_event_record *completion) | 54 | struct evlink *completion) |
| 24 | { | 55 | { |
| 25 | int64_t lateness; | 56 | int64_t lateness; |
| 26 | u64 response; | 57 | u64 response; |
| 58 | unsigned int preemptions = 0, migrations = 0; | ||
| 59 | |||
| 60 | lateness = completion->rec->data.completion.when; | ||
| 61 | lateness -= release->rec->data.release.deadline; | ||
| 62 | response = completion->rec->data.completion.when; | ||
| 63 | response -= release->rec->data.release.release; | ||
| 27 | 64 | ||
| 28 | lateness = completion->data.completion.when; | 65 | count_preemptions(release, completion, &preemptions, &migrations); |
| 29 | lateness -= release->data.release.deadline; | ||
| 30 | response = completion->data.completion.when; | ||
| 31 | response -= release->data.release.release; | ||
| 32 | 66 | ||
| 33 | if (want_ms) | 67 | if (want_ms) |
| 34 | printf(" %5u, %5u, %10.2f, %10.2f, %8d, %10.2f, %10.2f, %7d" | 68 | printf(" %5u, %5u, %10.2f, %10.2f, %8d, %10.2f, %10.2f, %7d" |
| 35 | ", %10.2f\n", | 69 | ", %10.2f, %12u, %12u\n", |
| 36 | release->hdr.pid, | 70 | release->rec->hdr.pid, |
| 37 | release->hdr.job, | 71 | release->rec->hdr.job, |
| 38 | nano_to_ms(per(t)), | 72 | nano_to_ms(per(t)), |
| 39 | nano_to_ms(response), | 73 | nano_to_ms(response), |
| 40 | lateness > 0, | 74 | lateness > 0, |
| 41 | nano_to_ms(lateness), | 75 | nano_to_ms(lateness), |
| 42 | lateness > 0 ? nano_to_ms(lateness) : 0, | 76 | lateness > 0 ? nano_to_ms(lateness) : 0, |
| 43 | completion->data.completion.forced, | 77 | completion->rec->data.completion.forced, |
| 44 | nano_to_ms(completion->data.completion.exec_time)); | 78 | nano_to_ms(completion->rec->data.completion.exec_time), |
| 79 | preemptions, | ||
| 80 | migrations); | ||
| 45 | else | 81 | else |
| 46 | printf(" %5u, %5u, %10llu, %10llu, %8d, %10lld, %10lld, %7d" | 82 | printf(" %5u, %5u, %10llu, %10llu, %8d, %10lld, %10lld, %7d" |
| 47 | ", %10llu\n", | 83 | ", %10llu, %12u, %12u\n", |
| 48 | release->hdr.pid, | 84 | release->rec->hdr.pid, |
| 49 | release->hdr.job, | 85 | release->rec->hdr.job, |
| 50 | (unsigned long long) per(t), | 86 | (unsigned long long) per(t), |
| 51 | (unsigned long long) response, | 87 | (unsigned long long) response, |
| 52 | lateness > 0, | 88 | lateness > 0, |
| 53 | (long long) lateness, | 89 | (long long) lateness, |
| 54 | lateness > 0 ? (long long) lateness : 0, | 90 | lateness > 0 ? (long long) lateness : 0, |
| 55 | completion->data.completion.forced, | 91 | completion->rec->data.completion.forced, |
| 56 | (unsigned long long) completion->data.completion.exec_time); | 92 | (unsigned long long) completion->rec->data.completion.exec_time, |
| 93 | preemptions, | ||
| 94 | migrations); | ||
| 57 | } | 95 | } |
| 58 | 96 | ||
| 59 | static void print_task_info(struct task *t) | 97 | static void print_task_info(struct task *t) |
| @@ -173,7 +211,7 @@ int main(int argc, char** argv) | |||
| 173 | } | 211 | } |
| 174 | 212 | ||
| 175 | /* print header */ | 213 | /* print header */ |
| 176 | printf("#%5s, %5s, %10s, %10s, %8s, %10s, %10s, %7s, %10s\n", | 214 | printf("#%5s, %5s, %10s, %10s, %8s, %10s, %10s, %7s, %10s, %12s, %12s\n", |
| 177 | "Task", | 215 | "Task", |
| 178 | "Job", | 216 | "Job", |
| 179 | "Period", | 217 | "Period", |
| @@ -182,7 +220,9 @@ int main(int argc, char** argv) | |||
| 182 | "Lateness", | 220 | "Lateness", |
| 183 | "Tardiness", | 221 | "Tardiness", |
| 184 | "Forced?", | 222 | "Forced?", |
| 185 | "ACET"); | 223 | "ACET", |
| 224 | "Preemptions", | ||
| 225 | "Migrations"); | ||
| 186 | 226 | ||
| 187 | /* print stats for each task */ | 227 | /* print stats for each task */ |
| 188 | for_each_task(t) { | 228 | for_each_task(t) { |
| @@ -204,7 +244,7 @@ int main(int argc, char** argv) | |||
| 204 | while (pos && count < MAX_COMPLETIONS_TO_CHECK) { | 244 | while (pos && count < MAX_COMPLETIONS_TO_CHECK) { |
| 205 | find(pos, ST_COMPLETION); | 245 | find(pos, ST_COMPLETION); |
| 206 | if (pos->rec->hdr.job == rec->hdr.job) { | 246 | if (pos->rec->hdr.job == rec->hdr.job) { |
| 207 | print_stats(t, rec, pos->rec); | 247 | print_stats(t, e, pos); |
| 208 | break; | 248 | break; |
| 209 | } else { | 249 | } else { |
| 210 | pos = pos->next; | 250 | pos = pos->next; |
