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