]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/bootchart/bootchart.h
Merge pull request #1937 from evverx/fix-stdout-parsing
[thirdparty/systemd.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 Corporation
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 <stdbool.h>
28
29 #include "list.h"
30
31 #define MAXCPUS 16
32 #define MAXPIDS 65535
33
34 struct block_stat_struct {
35 /* /proc/vmstat pgpgin & pgpgout */
36 int bi;
37 int bo;
38 };
39
40 struct cpu_stat_sample_struct {
41 /* /proc/schedstat fields 10 & 11 (after name) */
42 double runtime;
43 double waittime;
44 };
45
46 /* per process, per sample data we will log */
47 struct ps_sched_struct {
48 /* /proc/<n>/schedstat fields 1 & 2 */
49 double runtime;
50 double waittime;
51 int pss;
52 struct list_sample_data *sampledata;
53 struct ps_sched_struct *next;
54 struct ps_sched_struct *prev;
55 struct ps_sched_struct *cross; /* cross pointer */
56 struct ps_struct *ps_new;
57 };
58
59 struct list_sample_data {
60 double runtime[MAXCPUS];
61 double waittime[MAXCPUS];
62 double sampletime;
63 int entropy_avail;
64 struct block_stat_struct blockstat;
65 LIST_FIELDS(struct list_sample_data, link); /* DLL */
66 int counter;
67 };
68
69 /* process info */
70 struct ps_struct {
71 struct ps_struct *next_ps; /* SLL pointer */
72 struct ps_struct *parent; /* ppid ref */
73 struct ps_struct *children; /* children */
74 struct ps_struct *next; /* siblings */
75
76 /* must match - otherwise it's a new process with same PID */
77 char name[256];
78 int pid;
79 int ppid;
80 char *cgroup;
81
82 /* cache fd's */
83 int sched;
84 int schedstat;
85 FILE *smaps;
86
87 /* pointers to first/last seen timestamps */
88 struct ps_sched_struct *first;
89 struct ps_sched_struct *last;
90
91 /* records actual start time, may be way before bootchart runs */
92 double starttime;
93
94 /* record human readable total cpu time */
95 double total;
96
97 /* largest PSS size found */
98 int pss_max;
99
100 /* for drawing connection lines later */
101 double pos_x;
102 double pos_y;
103
104 struct ps_sched_struct *sample;
105 };
106
107 extern bool arg_relative;
108 extern bool arg_filter;
109 extern bool arg_show_cmdline;
110 extern bool arg_show_cgroup;
111 extern bool arg_pss;
112 extern bool arg_entropy;
113 extern bool arg_percpu;
114 extern bool arg_initcall;
115 extern int arg_samples_len;
116 extern double arg_hz;
117 extern double arg_scale_x;
118 extern double arg_scale_y;
119
120 extern char arg_output_path[PATH_MAX];
121 extern char arg_init_path[PATH_MAX];