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