static int pfiltered = 0;
static int pcount = 0;
static int kcount = 0;
-static float psize = 0;
-static float ksize = 0;
-static float esize = 0;
+static double psize = 0;
+static double ksize = 0;
+static double esize = 0;
static struct list_sample_data *sampledata;
static struct list_sample_data *prev_sampledata;
extern struct list_sample_data *head;
static void svg_header(void) {
- float w;
- float h;
+ double w;
+ double h;
struct list_sample_data *sampledata_last;
+ assert(head);
+
sampledata = head;
- LIST_FIND_TAIL(struct list_sample_data, link, sampledata, head);
+ LIST_FIND_TAIL(link, sampledata, head);
sampledata_last = head;
LIST_FOREACH_BEFORE(link, sampledata, head) {
sampledata_last = sampledata;
svg("<defs>\n <style type=\"text/css\">\n <![CDATA[\n");
svg(" rect { stroke-width: 1; }\n");
+ svg(" rect.bg { fill: rgb(255,255,255); }\n");
svg(" rect.cpu { fill: rgb(64,64,240); stroke-width: 0; fill-opacity: 0.7; }\n");
svg(" rect.wait { fill: rgb(240,240,0); stroke-width: 0; fill-opacity: 0.7; }\n");
svg(" rect.bi { fill: rgb(240,128,128); stroke-width: 0; fill-opacity: 0.7; }\n");
char *c;
FILE *f;
time_t t;
- int fd;
+ int fd, r;
struct utsname uts;
/* grab /proc/cmdline */
/* 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);
i = 1;
LIST_FOREACH_BEFORE(link, sampledata, head) {
int bottom;
- int top;
+ int top = 0;
struct ps_sched_struct *prev_sample;
struct ps_sched_struct *cross_place;
- bottom = 0;
- top = 0;
-
/* put all the small pss blocks into the bottom */
ps = ps_first->next_ps;
while (ps->next_ps) {
continue;
enc_name = xml_comment_encode(ps->name);
- if(!enc_name)
+ if (!enc_name)
continue;
svg("<!-- %s [%d] pss=", enc_name, ps->pid);
int max_here = 0;
int i;
int k;
- struct list_sample_data *start_sampledata = sampledata;
- struct list_sample_data *stop_sampledata = sampledata;
+ struct list_sample_data *start_sampledata;
+ struct list_sample_data *stop_sampledata;
svg("<!-- IO utilization graph - In -->\n");
int stop;
int diff;
double tot;
- double pbi;
-
- tot = 0;
- pbi = 0;
+ double pbi = 0;
start = MAX(i - ((range / 2) - 1), 0);
stop = MIN(i + (range / 2), samples);
int max_here = 0;
int i;
int k;
- struct list_sample_data *start_sampledata = sampledata;
- struct list_sample_data *stop_sampledata = sampledata;
+ struct list_sample_data *start_sampledata;
+ struct list_sample_data *stop_sampledata;
svg("<!-- IO utilization graph - out -->\n");
double tot;
double pbo;
- tot = 0;
pbo = 0;
start = MAX(i - ((range / 2) - 1), 0);
return NULL;
}
-static int ps_filter(struct ps_struct *ps) {
+static bool ps_filter(struct ps_struct *ps) {
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)
- return -1;
+ return true;
/* 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)
- return -1;
+ return true;
return 0;
}
int t;
enc_name = xml_comment_encode(ps->name);
- if(!enc_name)
+ if (!enc_name)
continue;
/* leave some trace of what we actually filtered etc. */
w = starttime;
/* text label of process name */
- svg(" <text x=\"%.03f\" y=\"%.03f\"><![CDATA[%s]]> [%i]<tspan class=\"run\">%.03fs</tspan></text>\n",
+ 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,
ps->pid,
- (ps->last->runtime - ps->first->runtime) / 1000000000.0);
+ (ps->last->runtime - ps->first->runtime) / 1000000000.0,
+ arg_show_cgroup ? ps->cgroup : "");
/* paint lines to the parent process */
if (ps->parent) {
/* horizontal part */
void svg_do(const char *build) {
struct ps_struct *ps;
- memset(&str, 0, sizeof(str));
+ memzero(&str, sizeof(str));
ps = ps_first;
/* after this, we can draw the header with proper sizing */
svg_header();
+ svg("<rect class=\"bg\" width=\"100%%\" height=\"100%%\" />\n\n");
svg("<g transform=\"translate(10,400)\">\n");
svg_io_bi_bar();