2013-03-12 01:47:58 +04:00
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
# pragma once
2013-02-13 03:14:15 +04:00
/***
2013-03-12 01:47:58 +04:00
This file is part of systemd .
2013-02-13 03:14:15 +04:00
2013-06-11 20:26:03 +04:00
Copyright ( C ) 2009 - 2013 Intel Corporation
2013-02-13 03:14:15 +04:00
Authors :
Auke Kok < auke - jan . h . kok @ intel . com >
systemd is free software ; you can redistribute it and / or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation ; either version 2.1 of the License , or
( at your option ) any later version .
systemd is distributed in the hope that it will be useful , but
WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
Lesser General Public License for more details .
You should have received a copy of the GNU Lesser General Public License
along with systemd ; If not , see < http : //www.gnu.org/licenses/>.
2013-03-12 01:47:58 +04:00
* * */
2012-10-18 03:01:12 +04:00
# include <dirent.h>
2013-02-15 00:32:49 +04:00
# include <stdbool.h>
2013-04-25 01:56:15 +04:00
# include "list.h"
2012-10-18 03:01:12 +04:00
# define MAXCPUS 16
# define MAXPIDS 65535
struct block_stat_struct {
2013-01-10 01:38:03 +04:00
/* /proc/vmstat pgpgin & pgpgout */
int bi ;
int bo ;
2012-10-18 03:01:12 +04:00
} ;
struct cpu_stat_sample_struct {
2013-01-10 01:38:03 +04:00
/* /proc/schedstat fields 10 & 11 (after name) */
double runtime ;
double waittime ;
2012-10-18 03:01:12 +04:00
} ;
/* per process, per sample data we will log */
struct ps_sched_struct {
2013-01-10 01:38:03 +04:00
/* /proc/<n>/schedstat fields 1 & 2 */
double runtime ;
double waittime ;
int pss ;
2013-04-25 01:56:15 +04:00
struct list_sample_data * sampledata ;
struct ps_sched_struct * next ;
struct ps_sched_struct * prev ;
struct ps_sched_struct * cross ; /* cross pointer */
struct ps_struct * ps_new ;
} ;
struct list_sample_data {
double runtime [ MAXCPUS ] ;
double waittime [ MAXCPUS ] ;
double sampletime ;
int entropy_avail ;
struct block_stat_struct blockstat ;
LIST_FIELDS ( struct list_sample_data , link ) ; /* DLL */
int counter ;
2012-10-18 03:01:12 +04:00
} ;
/* process info */
struct ps_struct {
2013-01-10 01:38:03 +04:00
struct ps_struct * next_ps ; /* SLL pointer */
struct ps_struct * parent ; /* ppid ref */
struct ps_struct * children ; /* children */
struct ps_struct * next ; /* siblings */
2012-10-18 03:01:12 +04:00
2013-01-10 01:38:03 +04:00
/* must match - otherwise it's a new process with same PID */
2013-03-07 11:52:54 +04:00
char name [ 256 ] ;
2013-01-10 01:38:03 +04:00
int pid ;
int ppid ;
2014-04-24 19:50:51 +04:00
char * cgroup ;
2012-10-18 03:01:12 +04:00
2013-01-10 01:38:03 +04:00
/* cache fd's */
int sched ;
int schedstat ;
FILE * smaps ;
2012-10-18 03:01:12 +04:00
2013-04-25 01:56:15 +04:00
/* pointers to first/last seen timestamps */
struct ps_sched_struct * first ;
struct ps_sched_struct * last ;
2012-10-18 03:01:12 +04:00
2013-01-10 01:38:03 +04:00
/* records actual start time, may be way before bootchart runs */
double starttime ;
2012-10-18 03:01:12 +04:00
2013-01-10 01:38:03 +04:00
/* record human readable total cpu time */
double total ;
2012-10-18 03:01:12 +04:00
2013-01-10 01:38:03 +04:00
/* largest PSS size found */
int pss_max ;
2012-10-18 03:01:12 +04:00
2013-01-10 01:38:03 +04:00
/* for drawing connection lines later */
double pos_x ;
double pos_y ;
2012-10-18 03:01:12 +04:00
2013-01-10 01:38:03 +04:00
struct ps_sched_struct * sample ;
2012-10-18 03:01:12 +04:00
} ;
extern int entropy_avail [ ] ;
extern double graph_start ;
extern double log_start ;
extern double sampletime [ ] ;
extern struct ps_struct * ps_first ;
extern struct block_stat_struct blockstat [ ] ;
extern int pscount ;
2013-03-12 01:47:58 +04:00
extern bool arg_relative ;
extern bool arg_filter ;
extern bool arg_show_cmdline ;
2014-04-24 19:50:51 +04:00
extern bool arg_show_cgroup ;
2013-03-12 01:47:58 +04:00
extern bool arg_pss ;
extern bool arg_entropy ;
2013-02-15 00:32:49 +04:00
extern bool initcall ;
2012-10-18 03:01:12 +04:00
extern int samples ;
extern int cpus ;
2013-03-12 01:47:58 +04:00
extern int arg_samples_len ;
extern double arg_hz ;
extern double arg_scale_x ;
extern double arg_scale_y ;
2012-10-18 03:01:12 +04:00
extern int overrun ;
extern double interval ;
2013-03-12 01:47:58 +04:00
extern char arg_output_path [ PATH_MAX ] ;
extern char arg_init_path [ PATH_MAX ] ;
2012-10-18 03:01:12 +04:00
extern FILE * of ;
2013-02-14 14:26:05 +04:00
extern int sysfd ;