chiark / gitweb /
7793cfc63ccbe043611f17526f07d6a4ee2c8032
[elogind.git] / src / bootchart / bootchart.h
1 /***
2   bootchart.h - This file is part of systemd-bootchart
3
4   Copyright (C) 2009-2013 Intel Coproration
5
6   Authors:
7     Auke Kok <auke-jan.h.kok@intel.com>
8
9   systemd is free software; you can redistribute it and/or modify it
10   under the terms of the GNU Lesser General Public License as published by
11   the Free Software Foundation; either version 2.1 of the License, or
12   (at your option) any later version.
13
14   systemd is distributed in the hope that it will be useful, but
15   WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   Lesser General Public License for more details.
18
19   You should have received a copy of the GNU Lesser General Public License
20   along with systemd; If not, see <http://www.gnu.org/licenses/>.
21  ***/
22
23 #include <dirent.h>
24
25 #define MAXCPUS        16
26 #define MAXPIDS     65535
27 #define MAXSAMPLES   8192
28
29
30 struct block_stat_struct {
31         /* /proc/vmstat pgpgin & pgpgout */
32         int bi;
33         int bo;
34 };
35
36 struct cpu_stat_sample_struct {
37         /* /proc/schedstat fields 10 & 11 (after name) */
38         double runtime;
39         double waittime;
40 };
41
42 struct cpu_stat_struct {
43         /* per cpu array */
44         struct cpu_stat_sample_struct sample[MAXSAMPLES];
45 };
46
47 /* per process, per sample data we will log */
48 struct ps_sched_struct {
49         /* /proc/<n>/schedstat fields 1 & 2 */
50         double runtime;
51         double waittime;
52         int pss;
53 };
54
55 /* process info */
56 struct ps_struct {
57         struct ps_struct *next_ps;    /* SLL pointer */
58         struct ps_struct *parent;     /* ppid ref */
59         struct ps_struct *children;   /* children */
60         struct ps_struct *next;       /* siblings */
61
62         /* must match - otherwise it's a new process with same PID */
63         char name[16];
64         int pid;
65         int ppid;
66
67         /* cache fd's */
68         int sched;
69         int schedstat;
70         FILE *smaps;
71
72         /* index to first/last seen timestamps */
73         int first;
74         int last;
75
76         /* records actual start time, may be way before bootchart runs */
77         double starttime;
78
79         /* record human readable total cpu time */
80         double total;
81
82         /* largest PSS size found */
83         int pss_max;
84
85         /* for drawing connection lines later */
86         double pos_x;
87         double pos_y;
88
89         struct ps_sched_struct *sample;
90 };
91
92 extern int entropy_avail[];
93
94 extern double graph_start;
95 extern double log_start;
96 extern double sampletime[];
97 extern struct ps_struct *ps_first;
98 extern struct block_stat_struct blockstat[];
99 extern struct cpu_stat_struct cpustat[];
100 extern int pscount;
101 extern int relative;
102 extern int filter;
103 extern int pss;
104 extern int entropy;
105 extern int initcall;
106 extern int samples;
107 extern int cpus;
108 extern int len;
109 extern double hz;
110 extern double scale_x;
111 extern double scale_y;
112 extern int overrun;
113 extern double interval;
114
115 extern char output_path[PATH_MAX];
116 extern char init_path[PATH_MAX];
117
118 extern FILE *of;
119 extern DIR *proc;
120
121 extern double gettime_ns(void);
122 extern void log_uptime(void);
123 extern void log_sample(int sample);
124
125 extern void svg_do(void);