diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-timechart.c | 6 | ||||
-rw-r--r-- | tools/perf/util/svghelper.c | 56 | ||||
-rw-r--r-- | tools/perf/util/svghelper.h | 5 |
3 files changed, 60 insertions, 7 deletions
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index b3f175a30d94..6a848b8c4c16 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c | |||
@@ -798,11 +798,11 @@ static void draw_process_bars(void) | |||
798 | sample = c->samples; | 798 | sample = c->samples; |
799 | while (sample) { | 799 | while (sample) { |
800 | if (sample->type == TYPE_RUNNING) | 800 | if (sample->type == TYPE_RUNNING) |
801 | svg_sample(Y, sample->cpu, sample->start_time, sample->end_time); | 801 | svg_running(Y, sample->cpu, sample->start_time, sample->end_time); |
802 | if (sample->type == TYPE_BLOCKED) | 802 | if (sample->type == TYPE_BLOCKED) |
803 | svg_box(Y, sample->start_time, sample->end_time, "blocked"); | 803 | svg_blocked(Y, sample->cpu, sample->start_time, sample->end_time); |
804 | if (sample->type == TYPE_WAITING) | 804 | if (sample->type == TYPE_WAITING) |
805 | svg_waiting(Y, sample->start_time, sample->end_time); | 805 | svg_waiting(Y, sample->cpu, sample->start_time, sample->end_time); |
806 | sample = sample->next; | 806 | sample = sample->next; |
807 | } | 807 | } |
808 | 808 | ||
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c index 96c866045d60..9a5b41392e01 100644 --- a/tools/perf/util/svghelper.c +++ b/tools/perf/util/svghelper.c | |||
@@ -95,6 +95,7 @@ void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end) | |||
95 | 95 | ||
96 | total_height = (1 + rows + cpu2slot(cpus)) * SLOT_MULT; | 96 | total_height = (1 + rows + cpu2slot(cpus)) * SLOT_MULT; |
97 | fprintf(svgfile, "<?xml version=\"1.0\" standalone=\"no\"?> \n"); | 97 | fprintf(svgfile, "<?xml version=\"1.0\" standalone=\"no\"?> \n"); |
98 | fprintf(svgfile, "<!DOCTYPE svg SYSTEM \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"); | ||
98 | fprintf(svgfile, "<svg width=\"%i\" height=\"%" PRIu64 "\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n", svg_page_width, total_height); | 99 | fprintf(svgfile, "<svg width=\"%i\" height=\"%" PRIu64 "\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n", svg_page_width, total_height); |
99 | 100 | ||
100 | fprintf(svgfile, "<defs>\n <style type=\"text/css\">\n <![CDATA[\n"); | 101 | fprintf(svgfile, "<defs>\n <style type=\"text/css\">\n <![CDATA[\n"); |
@@ -128,12 +129,29 @@ void svg_box(int Yslot, u64 start, u64 end, const char *type) | |||
128 | time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT, type); | 129 | time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT, type); |
129 | } | 130 | } |
130 | 131 | ||
131 | void svg_sample(int Yslot, int cpu, u64 start, u64 end) | 132 | static char *time_to_string(u64 duration); |
133 | void svg_blocked(int Yslot, int cpu, u64 start, u64 end) | ||
134 | { | ||
135 | if (!svgfile) | ||
136 | return; | ||
137 | |||
138 | fprintf(svgfile, "<g>\n"); | ||
139 | fprintf(svgfile, "<title>#%d blocked %s</title>\n", cpu, | ||
140 | time_to_string(end - start)); | ||
141 | svg_box(Yslot, start, end, "blocked"); | ||
142 | fprintf(svgfile, "</g>\n"); | ||
143 | } | ||
144 | |||
145 | void svg_running(int Yslot, int cpu, u64 start, u64 end) | ||
132 | { | 146 | { |
133 | double text_size; | 147 | double text_size; |
134 | if (!svgfile) | 148 | if (!svgfile) |
135 | return; | 149 | return; |
136 | 150 | ||
151 | fprintf(svgfile, "<g>\n"); | ||
152 | |||
153 | fprintf(svgfile, "<title>#%d running %s</title>\n", | ||
154 | cpu, time_to_string(end - start)); | ||
137 | fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"sample\"/>\n", | 155 | fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"sample\"/>\n", |
138 | time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT); | 156 | time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT); |
139 | 157 | ||
@@ -148,6 +166,7 @@ void svg_sample(int Yslot, int cpu, u64 start, u64 end) | |||
148 | fprintf(svgfile, "<text x=\"%1.8f\" y=\"%1.8f\" font-size=\"%1.8fpt\">%i</text>\n", | 166 | fprintf(svgfile, "<text x=\"%1.8f\" y=\"%1.8f\" font-size=\"%1.8fpt\">%i</text>\n", |
149 | time2pixels(start), Yslot * SLOT_MULT + SLOT_HEIGHT - 1, text_size, cpu + 1); | 167 | time2pixels(start), Yslot * SLOT_MULT + SLOT_HEIGHT - 1, text_size, cpu + 1); |
150 | 168 | ||
169 | fprintf(svgfile, "</g>\n"); | ||
151 | } | 170 | } |
152 | 171 | ||
153 | static char *time_to_string(u64 duration) | 172 | static char *time_to_string(u64 duration) |
@@ -168,7 +187,7 @@ static char *time_to_string(u64 duration) | |||
168 | return text; | 187 | return text; |
169 | } | 188 | } |
170 | 189 | ||
171 | void svg_waiting(int Yslot, u64 start, u64 end) | 190 | void svg_waiting(int Yslot, int cpu, u64 start, u64 end) |
172 | { | 191 | { |
173 | char *text; | 192 | char *text; |
174 | const char *style; | 193 | const char *style; |
@@ -192,6 +211,7 @@ void svg_waiting(int Yslot, u64 start, u64 end) | |||
192 | font_size = round_text_size(font_size); | 211 | font_size = round_text_size(font_size); |
193 | 212 | ||
194 | fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), Yslot * SLOT_MULT); | 213 | fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), Yslot * SLOT_MULT); |
214 | fprintf(svgfile, "<title>#%d waiting %s</title>\n", cpu, time_to_string(end - start)); | ||
195 | fprintf(svgfile, "<rect x=\"0\" width=\"%4.8f\" y=\"0\" height=\"%4.1f\" class=\"%s\"/>\n", | 215 | fprintf(svgfile, "<rect x=\"0\" width=\"%4.8f\" y=\"0\" height=\"%4.1f\" class=\"%s\"/>\n", |
196 | time2pixels(end)-time2pixels(start), SLOT_HEIGHT, style); | 216 | time2pixels(end)-time2pixels(start), SLOT_HEIGHT, style); |
197 | if (font_size > MIN_TEXT_SIZE) | 217 | if (font_size > MIN_TEXT_SIZE) |
@@ -242,6 +262,8 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq) | |||
242 | max_freq = __max_freq; | 262 | max_freq = __max_freq; |
243 | turbo_frequency = __turbo_freq; | 263 | turbo_frequency = __turbo_freq; |
244 | 264 | ||
265 | fprintf(svgfile, "<g>\n"); | ||
266 | |||
245 | fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"cpu\"/>\n", | 267 | fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"cpu\"/>\n", |
246 | time2pixels(first_time), | 268 | time2pixels(first_time), |
247 | time2pixels(last_time)-time2pixels(first_time), | 269 | time2pixels(last_time)-time2pixels(first_time), |
@@ -253,6 +275,8 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq) | |||
253 | 275 | ||
254 | fprintf(svgfile, "<text transform=\"translate(%4.8f,%4.8f)\" font-size=\"1.25pt\">%s</text>\n", | 276 | fprintf(svgfile, "<text transform=\"translate(%4.8f,%4.8f)\" font-size=\"1.25pt\">%s</text>\n", |
255 | 10+time2pixels(first_time), cpu2y(cpu) + SLOT_MULT + SLOT_HEIGHT - 4, cpu_model()); | 277 | 10+time2pixels(first_time), cpu2y(cpu) + SLOT_MULT + SLOT_HEIGHT - 4, cpu_model()); |
278 | |||
279 | fprintf(svgfile, "</g>\n"); | ||
256 | } | 280 | } |
257 | 281 | ||
258 | void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name) | 282 | void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name) |
@@ -264,6 +288,7 @@ void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name | |||
264 | 288 | ||
265 | 289 | ||
266 | fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), cpu2y(cpu)); | 290 | fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), cpu2y(cpu)); |
291 | fprintf(svgfile, "<title>%s %s</title>\n", name, time_to_string(end - start)); | ||
267 | fprintf(svgfile, "<rect x=\"0\" width=\"%4.8f\" y=\"0\" height=\"%4.1f\" class=\"%s\"/>\n", | 292 | fprintf(svgfile, "<rect x=\"0\" width=\"%4.8f\" y=\"0\" height=\"%4.1f\" class=\"%s\"/>\n", |
268 | time2pixels(end)-time2pixels(start), SLOT_MULT+SLOT_HEIGHT, type); | 293 | time2pixels(end)-time2pixels(start), SLOT_MULT+SLOT_HEIGHT, type); |
269 | width = time2pixels(end)-time2pixels(start); | 294 | width = time2pixels(end)-time2pixels(start); |
@@ -288,6 +313,8 @@ void svg_cstate(int cpu, u64 start, u64 end, int type) | |||
288 | return; | 313 | return; |
289 | 314 | ||
290 | 315 | ||
316 | fprintf(svgfile, "<g>\n"); | ||
317 | |||
291 | if (type > 6) | 318 | if (type > 6) |
292 | type = 6; | 319 | type = 6; |
293 | sprintf(style, "c%i", type); | 320 | sprintf(style, "c%i", type); |
@@ -306,6 +333,8 @@ void svg_cstate(int cpu, u64 start, u64 end, int type) | |||
306 | if (width > MIN_TEXT_SIZE) | 333 | if (width > MIN_TEXT_SIZE) |
307 | fprintf(svgfile, "<text x=\"%4.8f\" y=\"%4.8f\" font-size=\"%3.8fpt\">C%i</text>\n", | 334 | fprintf(svgfile, "<text x=\"%4.8f\" y=\"%4.8f\" font-size=\"%3.8fpt\">C%i</text>\n", |
308 | time2pixels(start), cpu2y(cpu)+width, width, type); | 335 | time2pixels(start), cpu2y(cpu)+width, width, type); |
336 | |||
337 | fprintf(svgfile, "</g>\n"); | ||
309 | } | 338 | } |
310 | 339 | ||
311 | static char *HzToHuman(unsigned long hz) | 340 | static char *HzToHuman(unsigned long hz) |
@@ -339,6 +368,8 @@ void svg_pstate(int cpu, u64 start, u64 end, u64 freq) | |||
339 | if (!svgfile) | 368 | if (!svgfile) |
340 | return; | 369 | return; |
341 | 370 | ||
371 | fprintf(svgfile, "<g>\n"); | ||
372 | |||
342 | if (max_freq) | 373 | if (max_freq) |
343 | height = freq * 1.0 / max_freq * (SLOT_HEIGHT + SLOT_MULT); | 374 | height = freq * 1.0 / max_freq * (SLOT_HEIGHT + SLOT_MULT); |
344 | height = 1 + cpu2y(cpu) + SLOT_MULT + SLOT_HEIGHT - height; | 375 | height = 1 + cpu2y(cpu) + SLOT_MULT + SLOT_HEIGHT - height; |
@@ -347,6 +378,7 @@ void svg_pstate(int cpu, u64 start, u64 end, u64 freq) | |||
347 | fprintf(svgfile, "<text x=\"%4.8f\" y=\"%4.8f\" font-size=\"0.25pt\">%s</text>\n", | 378 | fprintf(svgfile, "<text x=\"%4.8f\" y=\"%4.8f\" font-size=\"0.25pt\">%s</text>\n", |
348 | time2pixels(start), height+0.9, HzToHuman(freq)); | 379 | time2pixels(start), height+0.9, HzToHuman(freq)); |
349 | 380 | ||
381 | fprintf(svgfile, "</g>\n"); | ||
350 | } | 382 | } |
351 | 383 | ||
352 | 384 | ||
@@ -358,6 +390,12 @@ void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc | |||
358 | return; | 390 | return; |
359 | 391 | ||
360 | 392 | ||
393 | fprintf(svgfile, "<g>\n"); | ||
394 | |||
395 | fprintf(svgfile, "<title>%s wakes up %s</title>\n", | ||
396 | desc1 ? desc1 : "?", | ||
397 | desc2 ? desc2 : "?"); | ||
398 | |||
361 | if (row1 < row2) { | 399 | if (row1 < row2) { |
362 | if (row1) { | 400 | if (row1) { |
363 | fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n", | 401 | fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n", |
@@ -395,6 +433,8 @@ void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc | |||
395 | if (row1) | 433 | if (row1) |
396 | fprintf(svgfile, "<circle cx=\"%4.8f\" cy=\"%4.2f\" r = \"0.01\" style=\"fill:rgb(32,255,32)\"/>\n", | 434 | fprintf(svgfile, "<circle cx=\"%4.8f\" cy=\"%4.2f\" r = \"0.01\" style=\"fill:rgb(32,255,32)\"/>\n", |
397 | time2pixels(start), height); | 435 | time2pixels(start), height); |
436 | |||
437 | fprintf(svgfile, "</g>\n"); | ||
398 | } | 438 | } |
399 | 439 | ||
400 | void svg_wakeline(u64 start, int row1, int row2) | 440 | void svg_wakeline(u64 start, int row1, int row2) |
@@ -405,6 +445,8 @@ void svg_wakeline(u64 start, int row1, int row2) | |||
405 | return; | 445 | return; |
406 | 446 | ||
407 | 447 | ||
448 | fprintf(svgfile, "<g>\n"); | ||
449 | |||
408 | if (row1 < row2) | 450 | if (row1 < row2) |
409 | fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n", | 451 | fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%4.2f\" style=\"stroke:rgb(32,255,32);stroke-width:0.009\"/>\n", |
410 | time2pixels(start), row1 * SLOT_MULT + SLOT_HEIGHT, time2pixels(start), row2 * SLOT_MULT); | 452 | time2pixels(start), row1 * SLOT_MULT + SLOT_HEIGHT, time2pixels(start), row2 * SLOT_MULT); |
@@ -417,6 +459,8 @@ void svg_wakeline(u64 start, int row1, int row2) | |||
417 | height += SLOT_HEIGHT; | 459 | height += SLOT_HEIGHT; |
418 | fprintf(svgfile, "<circle cx=\"%4.8f\" cy=\"%4.2f\" r = \"0.01\" style=\"fill:rgb(32,255,32)\"/>\n", | 460 | fprintf(svgfile, "<circle cx=\"%4.8f\" cy=\"%4.2f\" r = \"0.01\" style=\"fill:rgb(32,255,32)\"/>\n", |
419 | time2pixels(start), height); | 461 | time2pixels(start), height); |
462 | |||
463 | fprintf(svgfile, "</g>\n"); | ||
420 | } | 464 | } |
421 | 465 | ||
422 | void svg_interrupt(u64 start, int row) | 466 | void svg_interrupt(u64 start, int row) |
@@ -424,10 +468,16 @@ void svg_interrupt(u64 start, int row) | |||
424 | if (!svgfile) | 468 | if (!svgfile) |
425 | return; | 469 | return; |
426 | 470 | ||
471 | fprintf(svgfile, "<g>\n"); | ||
472 | |||
473 | fprintf(svgfile, "<title>Wakeup from interrupt</title>\n"); | ||
474 | |||
427 | fprintf(svgfile, "<circle cx=\"%4.8f\" cy=\"%4.2f\" r = \"0.01\" style=\"fill:rgb(255,128,128)\"/>\n", | 475 | fprintf(svgfile, "<circle cx=\"%4.8f\" cy=\"%4.2f\" r = \"0.01\" style=\"fill:rgb(255,128,128)\"/>\n", |
428 | time2pixels(start), row * SLOT_MULT); | 476 | time2pixels(start), row * SLOT_MULT); |
429 | fprintf(svgfile, "<circle cx=\"%4.8f\" cy=\"%4.2f\" r = \"0.01\" style=\"fill:rgb(255,128,128)\"/>\n", | 477 | fprintf(svgfile, "<circle cx=\"%4.8f\" cy=\"%4.2f\" r = \"0.01\" style=\"fill:rgb(255,128,128)\"/>\n", |
430 | time2pixels(start), row * SLOT_MULT + SLOT_HEIGHT); | 478 | time2pixels(start), row * SLOT_MULT + SLOT_HEIGHT); |
479 | |||
480 | fprintf(svgfile, "</g>\n"); | ||
431 | } | 481 | } |
432 | 482 | ||
433 | void svg_text(int Yslot, u64 start, const char *text) | 483 | void svg_text(int Yslot, u64 start, const char *text) |
@@ -455,6 +505,7 @@ void svg_legenda(void) | |||
455 | if (!svgfile) | 505 | if (!svgfile) |
456 | return; | 506 | return; |
457 | 507 | ||
508 | fprintf(svgfile, "<g>\n"); | ||
458 | svg_legenda_box(0, "Running", "sample"); | 509 | svg_legenda_box(0, "Running", "sample"); |
459 | svg_legenda_box(100, "Idle","c1"); | 510 | svg_legenda_box(100, "Idle","c1"); |
460 | svg_legenda_box(200, "Deeper Idle", "c3"); | 511 | svg_legenda_box(200, "Deeper Idle", "c3"); |
@@ -462,6 +513,7 @@ void svg_legenda(void) | |||
462 | svg_legenda_box(550, "Sleeping", "process2"); | 513 | svg_legenda_box(550, "Sleeping", "process2"); |
463 | svg_legenda_box(650, "Waiting for cpu", "waiting"); | 514 | svg_legenda_box(650, "Waiting for cpu", "waiting"); |
464 | svg_legenda_box(800, "Blocked on IO", "blocked"); | 515 | svg_legenda_box(800, "Blocked on IO", "blocked"); |
516 | fprintf(svgfile, "</g>\n"); | ||
465 | } | 517 | } |
466 | 518 | ||
467 | void svg_time_grid(void) | 519 | void svg_time_grid(void) |
diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h index e0781989cc31..aa533459ab76 100644 --- a/tools/perf/util/svghelper.h +++ b/tools/perf/util/svghelper.h | |||
@@ -5,8 +5,9 @@ | |||
5 | 5 | ||
6 | extern void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end); | 6 | extern void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end); |
7 | extern void svg_box(int Yslot, u64 start, u64 end, const char *type); | 7 | extern void svg_box(int Yslot, u64 start, u64 end, const char *type); |
8 | extern void svg_sample(int Yslot, int cpu, u64 start, u64 end); | 8 | extern void svg_blocked(int Yslot, int cpu, u64 start, u64 end); |
9 | extern void svg_waiting(int Yslot, u64 start, u64 end); | 9 | extern void svg_running(int Yslot, int cpu, u64 start, u64 end); |
10 | extern void svg_waiting(int Yslot, int cpu, u64 start, u64 end); | ||
10 | extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency); | 11 | extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency); |
11 | 12 | ||
12 | 13 | ||