chiark / gitweb /
0fe4d2f4da75ce530c7bc7454a5d4d3f4196d0af
[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 #include <stdbool.h>
25
26 #define MAXCPUS        16
27 #define MAXPIDS     65535
28 #define MAXSAMPLES   8192
29
30
31 struct block_stat_struct {
32         /* /proc/vmstat pgpgin & pgpgout */
33         int bi;
34         int bo;
35 };
36
37 struct cpu_stat_sample_struct {
38         /* /proc/schedstat fields 10 & 11 (after name) */
39         double runtime;
40         double waittime;
41 };
42
43 struct cpu_stat_struct {
44         /* per cpu array */
45         struct cpu_stat_sample_struct sample[MAXSAMPLES];
46 };
47
48 /* per process, per sample data we will log */
49 struct ps_sched_struct {
50         /* /proc/<n>/schedstat fields 1 & 2 */
51         double runtime;
52         double waittime;
53         int pss;
54 };
55
56 /* process info */
57 struct ps_struct {
58         struct ps_struct *next_ps;    /* SLL pointer */
59         struct ps_struct *parent;     /* ppid ref */
60         struct ps_struct *children;   /* children */
61         struct ps_struct *next;       /* siblings */
62
63         /* must match - otherwise it's a new process with same PID */
64         char name[256];
65         int pid;
66         int ppid;
67
68         /* cache fd's */
69         int sched;
70         int schedstat;
71         FILE *smaps;
72
73         /* index to first/last seen timestamps */
74         int first;
75         int last;
76
77         /* records actual start time, may be way before bootchart runs */
78         double starttime;
79
80         /* record human readable total cpu time */
81         double total;
82
83         /* largest PSS size found */
84         int pss_max;
85
86         /* for drawing connection lines later */
87         double pos_x;
88         double pos_y;
89
90         struct ps_sched_struct *sample;
91 };
92
93 extern int entropy_avail[];
94
95 extern double graph_start;
96 extern double log_start;
97 extern double sampletime[];
98 extern struct ps_struct *ps_first;
99 extern struct block_stat_struct blockstat[];
100 extern struct cpu_stat_struct cpustat[];
101 extern int pscount;
102 extern bool relative;
103 extern bool filter;
104 extern bool show_cmdline;
105 extern bool pss;
106 extern bool entropy;
107 extern bool initcall;
108 extern int samples;
109 extern int cpus;
110 extern int samples_len;
111 extern double hz;
112 extern double scale_x;
113 extern double scale_y;
114 extern int overrun;
115 extern double interval;
116
117 extern char output_path[PATH_MAX];
118 extern char init_path[PATH_MAX];
119
120 extern FILE *of;
121 extern DIR *proc;
122 extern int procfd;
123 extern int sysfd;
124
125 extern double gettime_ns(void);
126 extern void log_uptime(void);
127 extern void log_sample(int sample);
128
129 extern void svg_do(const char *build);