chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sd-bus: make sure we always serialize the reply cookie as 64bit on dbus2, and 32bit...
[elogind.git]
/
src
/
bootchart
/
svg.c
diff --git
a/src/bootchart/svg.c
b/src/bootchart/svg.c
index 81211995292761140f3a9aa7daf90fd8895d7408..e111fa9cce57faa612e9957f5b61d675320be160 100644
(file)
--- a/
src/bootchart/svg.c
+++ b/
src/bootchart/svg.c
@@
-39,6
+39,7
@@
#include "svg.h"
#include "bootchart.h"
#include "list.h"
#include "svg.h"
#include "bootchart.h"
#include "list.h"
+#include "utf8.h"
#define time_to_graph(t) ((t) * arg_scale_x)
#define ps_to_graph(n) ((n) * arg_scale_y)
#define time_to_graph(t) ((t) * arg_scale_x)
#define ps_to_graph(n) ((n) * arg_scale_y)
@@
-80,6
+81,8
@@
static void svg_header(void) {
double h;
struct list_sample_data *sampledata_last;
double h;
struct list_sample_data *sampledata_last;
+ assert(head);
+
sampledata = head;
LIST_FIND_TAIL(link, sampledata, head);
sampledata_last = head;
sampledata = head;
LIST_FIND_TAIL(link, sampledata, head);
sampledata_last = head;
@@
-160,7
+163,7
@@
static void svg_title(const char *build) {
char *c;
FILE *f;
time_t t;
char *c;
FILE *f;
time_t t;
- int fd;
+ int fd
, r
;
struct utsname uts;
/* grab /proc/cmdline */
struct utsname uts;
/* grab /proc/cmdline */
@@
-194,7
+197,8
@@
static void svg_title(const char *build) {
/* date */
t = time(NULL);
/* date */
t = time(NULL);
- strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", localtime(&t));
+ r = strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", localtime(&t));
+ assert_se(r > 0);
/* CPU type */
fd = openat(procfd, "cpuinfo", O_RDONLY);
/* CPU type */
fd = openat(procfd, "cpuinfo", O_RDONLY);
@@
-745,11
+749,14
@@
static void svg_io_bo_bar(void) {
}
}
}
}
-static void svg_cpu_bar(
void
) {
+static void svg_cpu_bar(
int cpu_num
) {
svg("<!-- CPU utilization graph -->\n");
svg("<!-- CPU utilization graph -->\n");
- svg("<text class=\"t2\" x=\"5\" y=\"-15\">CPU utilization</text>\n");
+ if (cpu_num < 0)
+ svg("<text class=\"t2\" x=\"5\" y=\"-15\">CPU[overall] utilization</text>\n");
+ else
+ svg("<text class=\"t2\" x=\"5\" y=\"-15\">CPU[%d] utilization</text>\n", cpu_num);
/* surrounding box */
svg_graph_box(5);
/* surrounding box */
svg_graph_box(5);
@@
-762,12
+769,16
@@
static void svg_cpu_bar(void) {
ptrt = trt = 0.0;
ptrt = trt = 0.0;
- for (c = 0; c < cpus; c++)
- trt += sampledata->runtime[c] - prev_sampledata->runtime[c];
+ if (cpu_num < 0)
+ for (c = 0; c < cpus; c++)
+ trt += sampledata->runtime[c] - prev_sampledata->runtime[c];
+ else
+ trt = sampledata->runtime[cpu_num] - prev_sampledata->runtime[cpu_num];
trt = trt / 1000000000.0;
trt = trt / 1000000000.0;
- trt = trt / (double)cpus;
+ if (cpu_num < 0)
+ trt = trt / (double)cpus;
if (trt > 0.0)
ptrt = trt / (sampledata->sampletime - prev_sampledata->sampletime);
if (trt > 0.0)
ptrt = trt / (sampledata->sampletime - prev_sampledata->sampletime);
@@
-786,11
+797,14
@@
static void svg_cpu_bar(void) {
}
}
}
}
-static void svg_wait_bar(
void
) {
+static void svg_wait_bar(
int cpu_num
) {
svg("<!-- Wait time aggregation box -->\n");
svg("<!-- Wait time aggregation box -->\n");
- svg("<text class=\"t2\" x=\"5\" y=\"-15\">CPU wait</text>\n");
+ if (cpu_num < 0)
+ svg("<text class=\"t2\" x=\"5\" y=\"-15\">CPU[overall] wait</text>\n");
+ else
+ svg("<text class=\"t2\" x=\"5\" y=\"-15\">CPU[%d] wait</text>\n", cpu_num);
/* surrounding box */
svg_graph_box(5);
/* surrounding box */
svg_graph_box(5);
@@
-804,12
+818,16
@@
static void svg_wait_bar(void) {
ptwt = twt = 0.0;
ptwt = twt = 0.0;
- for (c = 0; c < cpus; c++)
- twt += sampledata->waittime[c] - prev_sampledata->waittime[c];
+ if (cpu_num < 0)
+ for (c = 0; c < cpus; c++)
+ twt += sampledata->waittime[c] - prev_sampledata->waittime[c];
+ else
+ twt = sampledata->waittime[cpu_num] - prev_sampledata->waittime[cpu_num];
twt = twt / 1000000000.0;
twt = twt / 1000000000.0;
- twt = twt / (double)cpus;
+ if (cpu_num < 0)
+ twt = twt / (double)cpus;
if (twt > 0.0)
ptwt = twt / (sampledata->sampletime - prev_sampledata->sampletime);
if (twt > 0.0)
ptwt = twt / (sampledata->sampletime - prev_sampledata->sampletime);
@@
-828,7
+846,6
@@
static void svg_wait_bar(void) {
}
}
}
}
-
static void svg_entropy_bar(void) {
svg("<!-- entropy pool graph -->\n");
static void svg_entropy_bar(void) {
svg("<!-- entropy pool graph -->\n");
@@
-879,21
+896,21
@@
static struct ps_struct *get_next_ps(struct ps_struct *ps) {
return NULL;
}
return NULL;
}
-static
int
ps_filter(struct ps_struct *ps) {
+static
bool
ps_filter(struct ps_struct *ps) {
if (!arg_filter)
if (!arg_filter)
- return
0
;
+ return
false
;
/* can't draw data when there is only 1 sample (need start + stop) */
if (ps->first == ps->last)
/* can't draw data when there is only 1 sample (need start + stop) */
if (ps->first == ps->last)
- return
-1
;
+ return
true
;
/* don't filter kthreadd */
if (ps->pid == 2)
/* don't filter kthreadd */
if (ps->pid == 2)
- return
0
;
+ return
false
;
/* drop stuff that doesn't use any real CPU time */
if (ps->total <= 0.001)
/* drop stuff that doesn't use any real CPU time */
if (ps->total <= 0.001)
- return
-1
;
+ return
true
;
return 0;
}
return 0;
}
@@
-1003,12
+1020,15
@@
static void svg_ps_bars(void) {
/* pass 2 - ps boxes */
ps = ps_first;
while ((ps = get_next_ps(ps))) {
/* pass 2 - ps boxes */
ps = ps_first;
while ((ps = get_next_ps(ps))) {
- _cleanup_free_ char *enc_name = NULL;
+ _cleanup_free_ char *enc_name = NULL
, *escaped = NULL
;
double endtime;
double starttime;
int t;
double endtime;
double starttime;
int t;
- enc_name = xml_comment_encode(ps->name);
+ if (!utf8_is_printable(ps->name, strlen(ps->name)))
+ escaped = utf8_escape_non_printable(ps->name);
+
+ enc_name = xml_comment_encode(escaped ? escaped : ps->name);
if (!enc_name)
continue;
if (!enc_name)
continue;
@@
-1097,7
+1117,7
@@
static void svg_ps_bars(void) {
svg(" <text x=\"%.03f\" y=\"%.03f\"><![CDATA[%s]]> [%i]<tspan class=\"run\">%.03fs</tspan> %s</text>\n",
time_to_graph(w - graph_start) + 5.0,
ps_to_graph(j) + 14.0,
svg(" <text x=\"%.03f\" y=\"%.03f\"><![CDATA[%s]]> [%i]<tspan class=\"run\">%.03fs</tspan> %s</text>\n",
time_to_graph(w - graph_start) + 5.0,
ps_to_graph(j) + 14.0,
- ps->name,
+
escaped ? escaped :
ps->name,
ps->pid,
(ps->last->runtime - ps->first->runtime) / 1000000000.0,
arg_show_cgroup ? ps->cgroup : "");
ps->pid,
(ps->last->runtime - ps->first->runtime) / 1000000000.0,
arg_show_cgroup ? ps->cgroup : "");
@@
-1249,6
+1269,8
@@
static void svg_top_ten_pss(void) {
void svg_do(const char *build) {
struct ps_struct *ps;
void svg_do(const char *build) {
struct ps_struct *ps;
+ double offset = 7;
+ int c;
memzero(&str, sizeof(str));
memzero(&str, sizeof(str));
@@
-1277,25
+1299,31
@@
void svg_do(const char *build) {
svg_io_bi_bar();
svg("</g>\n\n");
svg_io_bi_bar();
svg("</g>\n\n");
- svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y *
7.0
));
+ svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y *
offset
));
svg_io_bo_bar();
svg("</g>\n\n");
svg_io_bo_bar();
svg("</g>\n\n");
- svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y * 14.0));
- svg_cpu_bar();
- svg("</g>\n\n");
+ for (c = -1; c < (arg_percpu ? cpus : 0); c++) {
+ offset += 7;
+ svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y * offset));
+ svg_cpu_bar(c);
+ svg("</g>\n\n");
- svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y * 21.0));
- svg_wait_bar();
- svg("</g>\n\n");
+ offset += 7;
+ svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y * offset));
+ svg_wait_bar(c);
+ svg("</g>\n\n");
+ }
if (kcount) {
if (kcount) {
- svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y * 28.0));
+ offset += 7;
+ svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y * offset));
svg_do_initcall(0);
svg("</g>\n\n");
}
svg_do_initcall(0);
svg("</g>\n\n");
}
- svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y * 28.0) + ksize);
+ offset += 7;
+ svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y * offset) + ksize);
svg_ps_bars();
svg("</g>\n\n");
svg_ps_bars();
svg("</g>\n\n");
@@
-1308,13
+1336,13
@@
void svg_do(const char *build) {
svg("</g>\n\n");
if (arg_entropy) {
svg("</g>\n\n");
if (arg_entropy) {
- svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y *
28.0
) + ksize + psize);
+ svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y *
offset
) + ksize + psize);
svg_entropy_bar();
svg("</g>\n\n");
}
if (arg_pss) {
svg_entropy_bar();
svg("</g>\n\n");
}
if (arg_pss) {
- svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y *
28.0
) + ksize + psize + esize);
+ svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y *
offset
) + ksize + psize + esize);
svg_pss_graph();
svg("</g>\n\n");
svg_pss_graph();
svg("</g>\n\n");