bootchart.h revision 184d2ed770ccddbb9b6f6a452fdff42c16cb709f
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#pragma once
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/***
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright (C) 2009-2013 Intel Coproration
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Authors:
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Auke Kok <auke-jan.h.kok@intel.com>
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
b5efdb8af40ea759a1ea584c1bc44ecc81dd00ceLennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
b5efdb8af40ea759a1ea584c1bc44ecc81dd00ceLennart Poettering***/
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering#include <dirent.h>
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include <stdbool.h>
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen#include "list.h"
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen#define MAXCPUS 16
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen#define MAXPIDS 65535
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenstruct block_stat_struct {
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen /* /proc/vmstat pgpgin & pgpgout */
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen int bi;
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen int bo;
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen};
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstruct cpu_stat_sample_struct {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* /proc/schedstat fields 10 & 11 (after name) */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering double runtime;
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering double waittime;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering};
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poettering
3c0cf502796be355431d4a64d738e75f543aa51dLennart Poettering/* per process, per sample data we will log */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstruct ps_sched_struct {
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering /* /proc/<n>/schedstat fields 1 & 2 */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering double runtime;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering double waittime;
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering int pss;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct list_sample_data *sampledata;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct ps_sched_struct *next;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering struct ps_sched_struct *prev;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering struct ps_sched_struct *cross; /* cross pointer */
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering struct ps_struct *ps_new;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering};
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poetteringstruct list_sample_data {
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering double runtime[MAXCPUS];
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering double waittime[MAXCPUS];
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering double sampletime;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering int entropy_avail;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering struct block_stat_struct blockstat;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering LIST_FIELDS(struct list_sample_data, link); /* DLL */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering int counter;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering};
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersen/* process info */
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poetteringstruct ps_struct {
f4461e5641d53f27d6e76e0607bdaa9c0c58c1f6Lennart Poettering struct ps_struct *next_ps; /* SLL pointer */
f4461e5641d53f27d6e76e0607bdaa9c0c58c1f6Lennart Poettering struct ps_struct *parent; /* ppid ref */
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen struct ps_struct *children; /* children */
d74fb368b18f0fbd9a4fe6f15691bbea7f3c4a01Tom Gundersen struct ps_struct *next; /* siblings */
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* must match - otherwise it's a new process with same PID */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char name[256];
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen int pid;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering int ppid;
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering /* cache fd's */
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering int sched;
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering int schedstat;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering FILE *smaps;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering /* pointers to first/last seen timestamps */
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering struct ps_sched_struct *first;
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering struct ps_sched_struct *last;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering /* records actual start time, may be way before bootchart runs */
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering double starttime;
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering /* record human readable total cpu time */
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering double total;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering /* largest PSS size found */
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering int pss_max;
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering /* for drawing connection lines later */
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering double pos_x;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering double pos_y;
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct ps_sched_struct *sample;
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering};
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poetteringextern int entropy_avail[];
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering
3e684349c2cead2e6fd2f816c34eb17daba23a49Lennart Poetteringextern double graph_start;
3e684349c2cead2e6fd2f816c34eb17daba23a49Lennart Poetteringextern double log_start;
3e684349c2cead2e6fd2f816c34eb17daba23a49Lennart Poetteringextern double sampletime[];
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poetteringextern struct ps_struct *ps_first;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringextern struct block_stat_struct blockstat[];
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringextern int pscount;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringextern bool arg_relative;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringextern bool arg_filter;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringextern bool arg_show_cmdline;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringextern bool arg_pss;
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersenextern bool arg_entropy;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringextern bool initcall;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringextern int samples;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringextern int cpus;
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersenextern int arg_samples_len;
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersenextern double arg_hz;
cab5b05903096e1c9cf5575ccc73f89d15c8db69Lennart Poetteringextern double arg_scale_x;
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersenextern double arg_scale_y;
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersenextern int overrun;
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersenextern double interval;
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersenextern char arg_output_path[PATH_MAX];
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersenextern char arg_init_path[PATH_MAX];
3e684349c2cead2e6fd2f816c34eb17daba23a49Lennart Poettering
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poetteringextern FILE *of;
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poetteringextern int sysfd;
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersen