Linux Perf
builtin-timechart.c File Reference
#include <errno.h>
#include <inttypes.h>
#include <traceevent/event-parse.h>
#include "builtin.h"
#include "util/util.h"
#include "util/color.h"
#include <linux/list.h>
#include "util/cache.h"
#include "util/evlist.h"
#include "util/evsel.h"
#include <linux/kernel.h>
#include <linux/rbtree.h>
#include <linux/time64.h>
#include "util/symbol.h"
#include "util/thread.h"
#include "util/callchain.h"
#include "perf.h"
#include "util/header.h"
#include <subcmd/parse-options.h>
#include "util/parse-events.h"
#include "util/event.h"
#include "util/session.h"
#include "util/svghelper.h"
#include "util/tool.h"
#include "util/data.h"
#include "util/debug.h"
Include dependency graph for builtin-timechart.c:

Go to the source code of this file.

Classes

struct  timechart
 
struct  per_pid
 
struct  per_pidcomm
 
struct  sample_wrapper
 
struct  cpu_sample
 
struct  io_sample
 
struct  power_event
 
struct  wake_event
 
struct  process_filter
 

Macros

#define SUPPORT_OLD_POWER_EVENTS   1
 
#define PWR_EVENT_EXIT   -1
 
#define TYPE_NONE   0
 
#define TYPE_RUNNING   1
 
#define TYPE_WAITING   2
 
#define TYPE_BLOCKED   3
 
#define CSTATE   1
 
#define PSTATE   2
 
#define MAX_CPUS   4096
 
#define BYTES_THRESH   (1 * 1024 * 1024)
 
#define TIME_THRESH   10000000
 

Typedefs

typedef int(* tracepoint_handler) (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample, const char *backtrace)
 

Enumerations

enum  {
  IOTYPE_READ, IOTYPE_WRITE, IOTYPE_SYNC, IOTYPE_TX,
  IOTYPE_RX, IOTYPE_POLL
}
 

Functions

static struct per_pidfind_create_pid (struct timechart *tchart, int pid)
 
static void pid_set_comm (struct timechart *tchart, int pid, char *comm)
 
static void pid_fork (struct timechart *tchart, int pid, int ppid, u64 timestamp)
 
static void pid_exit (struct timechart *tchart, int pid, u64 timestamp)
 
static void pid_put_sample (struct timechart *tchart, int pid, int type, unsigned int cpu, u64 start, u64 end, const char *backtrace)
 
static int process_comm_event (struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused)
 
static int process_fork_event (struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused)
 
static int process_exit_event (struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused)
 
static void c_state_start (int cpu, u64 timestamp, int state)
 
static void c_state_end (struct timechart *tchart, int cpu, u64 timestamp)
 
static void p_state_change (struct timechart *tchart, int cpu, u64 timestamp, u64 new_freq)
 
static void sched_wakeup (struct timechart *tchart, int cpu, u64 timestamp, int waker, int wakee, u8 flags, const char *backtrace)
 
static void sched_switch (struct timechart *tchart, int cpu, u64 timestamp, int prev_pid, int next_pid, u64 prev_state, const char *backtrace)
 
static const char * cat_backtrace (union perf_event *event, struct perf_sample *sample, struct machine *machine)
 
static int process_sample_event (struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, struct machine *machine)
 
static int process_sample_cpu_idle (struct timechart *tchart __maybe_unused, struct perf_evsel *evsel, struct perf_sample *sample, const char *backtrace __maybe_unused)
 
static int process_sample_cpu_frequency (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample, const char *backtrace __maybe_unused)
 
static int process_sample_sched_wakeup (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample, const char *backtrace)
 
static int process_sample_sched_switch (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample, const char *backtrace)
 
static int process_sample_power_start (struct timechart *tchart __maybe_unused, struct perf_evsel *evsel, struct perf_sample *sample, const char *backtrace __maybe_unused)
 
static int process_sample_power_end (struct timechart *tchart, struct perf_evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused)
 
static int process_sample_power_frequency (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample, const char *backtrace __maybe_unused)
 
static void end_sample_processing (struct timechart *tchart)
 
static int pid_begin_io_sample (struct timechart *tchart, int pid, int type, u64 start, int fd)
 
static int pid_end_io_sample (struct timechart *tchart, int pid, int type, u64 end, long ret)
 
static int process_enter_read (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample)
 
static int process_exit_read (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample)
 
static int process_enter_write (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample)
 
static int process_exit_write (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample)
 
static int process_enter_sync (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample)
 
static int process_exit_sync (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample)
 
static int process_enter_tx (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample)
 
static int process_exit_tx (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample)
 
static int process_enter_rx (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample)
 
static int process_exit_rx (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample)
 
static int process_enter_poll (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample)
 
static int process_exit_poll (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample)
 
static void sort_pids (struct timechart *tchart)
 
static void draw_c_p_states (struct timechart *tchart)
 
static void draw_wakeups (struct timechart *tchart)
 
static void draw_cpu_usage (struct timechart *tchart)
 
static void draw_io_bars (struct timechart *tchart)
 
static void draw_process_bars (struct timechart *tchart)
 
static void add_process_filter (const char *string)
 
static int passes_filter (struct per_pid *p, struct per_pidcomm *c)
 
static int determine_display_tasks_filtered (struct timechart *tchart)
 
static int determine_display_tasks (struct timechart *tchart, u64 threshold)
 
static int determine_display_io_tasks (struct timechart *timechart, u64 threshold)
 
static void write_svg_file (struct timechart *tchart, const char *filename)
 
static int process_header (struct perf_file_section *section __maybe_unused, struct perf_header *ph, int feat, int fd __maybe_unused, void *data)
 
static int __cmd_timechart (struct timechart *tchart, const char *output_name)
 
static int timechart__io_record (int argc, const char **argv)
 
static int timechart__record (struct timechart *tchart, int argc, const char **argv)
 
static int parse_process (const struct option *opt __maybe_unused, const char *arg, int __maybe_unused unset)
 
static int parse_highlight (const struct option *opt __maybe_unused, const char *arg, int __maybe_unused unset)
 
static int parse_time (const struct option *opt, const char *arg, int __maybe_unused unset)
 
int cmd_timechart (int argc, const char **argv)
 

Variables

static struct process_filterprocess_filter
 
static u64 cpus_cstate_start_times [MAX_CPUS]
 
static int cpus_cstate_state [MAX_CPUS]
 
static u64 cpus_pstate_start_times [MAX_CPUS]
 
static u64 cpus_pstate_state [MAX_CPUS]
 
static int use_old_power_events
 

Macro Definition Documentation

◆ BYTES_THRESH

#define BYTES_THRESH   (1 * 1024 * 1024)

Definition at line 1450 of file builtin-timechart.c.

◆ CSTATE

#define CSTATE   1

Definition at line 172 of file builtin-timechart.c.

◆ MAX_CPUS

#define MAX_CPUS   4096

Definition at line 308 of file builtin-timechart.c.

◆ PSTATE

#define PSTATE   2

Definition at line 173 of file builtin-timechart.c.

◆ PWR_EVENT_EXIT

#define PWR_EVENT_EXIT   -1

Definition at line 47 of file builtin-timechart.c.

◆ SUPPORT_OLD_POWER_EVENTS

#define SUPPORT_OLD_POWER_EVENTS   1

Definition at line 46 of file builtin-timechart.c.

◆ TIME_THRESH

#define TIME_THRESH   10000000

Definition at line 1451 of file builtin-timechart.c.

◆ TYPE_BLOCKED

#define TYPE_BLOCKED   3

Definition at line 139 of file builtin-timechart.c.

◆ TYPE_NONE

#define TYPE_NONE   0

Definition at line 136 of file builtin-timechart.c.

◆ TYPE_RUNNING

#define TYPE_RUNNING   1

Definition at line 137 of file builtin-timechart.c.

◆ TYPE_WAITING

#define TYPE_WAITING   2

Definition at line 138 of file builtin-timechart.c.

Typedef Documentation

◆ tracepoint_handler

typedef int(* tracepoint_handler) (struct timechart *tchart, struct perf_evsel *evsel, struct perf_sample *sample, const char *backtrace)

Definition at line 549 of file builtin-timechart.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
IOTYPE_READ 
IOTYPE_WRITE 
IOTYPE_SYNC 
IOTYPE_TX 
IOTYPE_RX 
IOTYPE_POLL 

Definition at line 151 of file builtin-timechart.c.

Function Documentation

◆ __cmd_timechart()

static int __cmd_timechart ( struct timechart tchart,
const char *  output_name 
)
static

Definition at line 1537 of file builtin-timechart.c.

Here is the call graph for this function:

◆ add_process_filter()

static void add_process_filter ( const char *  string)
static

Definition at line 1305 of file builtin-timechart.c.

Here is the call graph for this function:

◆ c_state_end()

static void c_state_end ( struct timechart tchart,
int  cpu,
u64  timestamp 
)
static

Definition at line 355 of file builtin-timechart.c.

Here is the call graph for this function:

◆ c_state_start()

static void c_state_start ( int  cpu,
u64  timestamp,
int  state 
)
static

Definition at line 349 of file builtin-timechart.c.

◆ cat_backtrace()

static const char* cat_backtrace ( union perf_event event,
struct perf_sample sample,
struct machine machine 
)
static

Definition at line 475 of file builtin-timechart.c.

Here is the call graph for this function:

◆ cmd_timechart()

int cmd_timechart ( int  argc,
const char **  argv 
)

Definition at line 1923 of file builtin-timechart.c.

Here is the call graph for this function:

◆ determine_display_io_tasks()

static int determine_display_io_tasks ( struct timechart timechart,
u64  threshold 
)
static

Definition at line 1418 of file builtin-timechart.c.

◆ determine_display_tasks()

static int determine_display_tasks ( struct timechart tchart,
u64  threshold 
)
static

Definition at line 1377 of file builtin-timechart.c.

◆ determine_display_tasks_filtered()

static int determine_display_tasks_filtered ( struct timechart tchart)
static

Definition at line 1337 of file builtin-timechart.c.

Here is the call graph for this function:

◆ draw_c_p_states()

static void draw_c_p_states ( struct timechart tchart)
static

Definition at line 1012 of file builtin-timechart.c.

Here is the call graph for this function:

◆ draw_cpu_usage()

static void draw_cpu_usage ( struct timechart tchart)
static

Definition at line 1105 of file builtin-timechart.c.

Here is the call graph for this function:

◆ draw_io_bars()

static void draw_io_bars ( struct timechart tchart)
static

Definition at line 1133 of file builtin-timechart.c.

Here is the call graph for this function:

◆ draw_process_bars()

static void draw_process_bars ( struct timechart tchart)
static

Definition at line 1248 of file builtin-timechart.c.

Here is the call graph for this function:

◆ draw_wakeups()

static void draw_wakeups ( struct timechart tchart)
static

Definition at line 1037 of file builtin-timechart.c.

Here is the call graph for this function:

◆ end_sample_processing()

static void end_sample_processing ( struct timechart tchart)
static

Definition at line 678 of file builtin-timechart.c.

Here is the call graph for this function:

◆ find_create_pid()

static struct per_pid* find_create_pid ( struct timechart tchart,
int  pid 
)
static

Definition at line 201 of file builtin-timechart.c.

Here is the call graph for this function:

◆ p_state_change()

static void p_state_change ( struct timechart tchart,
int  cpu,
u64  timestamp,
u64  new_freq 
)
static

Definition at line 372 of file builtin-timechart.c.

Here is the call graph for this function:

◆ parse_highlight()

static int parse_highlight ( const struct option *opt  __maybe_unused,
const char *  arg,
int __maybe_unused  unset 
)
static

Definition at line 1883 of file builtin-timechart.c.

◆ parse_process()

static int parse_process ( const struct option *opt  __maybe_unused,
const char *  arg,
int __maybe_unused  unset 
)
static

Definition at line 1874 of file builtin-timechart.c.

Here is the call graph for this function:

◆ parse_time()

static int parse_time ( const struct option *  opt,
const char *  arg,
int __maybe_unused  unset 
)
static

Definition at line 1900 of file builtin-timechart.c.

◆ passes_filter()

static int passes_filter ( struct per_pid p,
struct per_pidcomm c 
)
static

Definition at line 1320 of file builtin-timechart.c.

◆ pid_begin_io_sample()

static int pid_begin_io_sample ( struct timechart tchart,
int  pid,
int  type,
u64  start,
int  fd 
)
static

Definition at line 720 of file builtin-timechart.c.

Here is the call graph for this function:

◆ pid_end_io_sample()

static int pid_end_io_sample ( struct timechart tchart,
int  pid,
int  type,
u64  end,
long  ret 
)
static

Definition at line 765 of file builtin-timechart.c.

Here is the call graph for this function:

◆ pid_exit()

static void pid_exit ( struct timechart tchart,
int  pid,
u64  timestamp 
)
static

Definition at line 260 of file builtin-timechart.c.

Here is the call graph for this function:

◆ pid_fork()

static void pid_fork ( struct timechart tchart,
int  pid,
int  ppid,
u64  timestamp 
)
static

Definition at line 244 of file builtin-timechart.c.

Here is the call graph for this function:

◆ pid_put_sample()

static void pid_put_sample ( struct timechart tchart,
int  pid,
int  type,
unsigned int  cpu,
u64  start,
u64  end,
const char *  backtrace 
)
static

Definition at line 269 of file builtin-timechart.c.

Here is the call graph for this function:

◆ pid_set_comm()

static void pid_set_comm ( struct timechart tchart,
int  pid,
char *  comm 
)
static

Definition at line 218 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_comm_event()

static int process_comm_event ( struct perf_tool tool,
union perf_event event,
struct perf_sample *sample  __maybe_unused,
struct machine *machine  __maybe_unused 
)
static

Definition at line 315 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_enter_poll()

static int process_enter_poll ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample 
)
static

Definition at line 944 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_enter_read()

static int process_enter_read ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample 
)
static

Definition at line 844 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_enter_rx()

static int process_enter_rx ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample 
)
static

Definition at line 924 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_enter_sync()

static int process_enter_sync ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample 
)
static

Definition at line 884 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_enter_tx()

static int process_enter_tx ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample 
)
static

Definition at line 904 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_enter_write()

static int process_enter_write ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample 
)
static

Definition at line 864 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_exit_event()

static int process_exit_event ( struct perf_tool tool,
union perf_event event,
struct perf_sample *sample  __maybe_unused,
struct machine *machine  __maybe_unused 
)
static

Definition at line 335 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_exit_poll()

static int process_exit_poll ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample 
)
static

Definition at line 954 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_exit_read()

static int process_exit_read ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample 
)
static

Definition at line 854 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_exit_rx()

static int process_exit_rx ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample 
)
static

Definition at line 934 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_exit_sync()

static int process_exit_sync ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample 
)
static

Definition at line 894 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_exit_tx()

static int process_exit_tx ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample 
)
static

Definition at line 914 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_exit_write()

static int process_exit_write ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample 
)
static

Definition at line 874 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_fork_event()

static int process_fork_event ( struct perf_tool tool,
union perf_event event,
struct perf_sample *sample  __maybe_unused,
struct machine *machine  __maybe_unused 
)
static

Definition at line 325 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_header()

static int process_header ( struct perf_file_section *section  __maybe_unused,
struct perf_header ph,
int  feat,
int fd  __maybe_unused,
void *  data 
)
static

Definition at line 1506 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_sample_cpu_frequency()

static int process_sample_cpu_frequency ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample,
const char *backtrace  __maybe_unused 
)
static

Definition at line 595 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_sample_cpu_idle()

static int process_sample_cpu_idle ( struct timechart *tchart  __maybe_unused,
struct perf_evsel evsel,
struct perf_sample sample,
const char *backtrace  __maybe_unused 
)
static

Definition at line 579 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_sample_event()

static int process_sample_event ( struct perf_tool tool,
union perf_event event,
struct perf_sample sample,
struct perf_evsel evsel,
struct machine machine 
)
static

Definition at line 554 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_sample_power_end()

static int process_sample_power_end ( struct timechart tchart,
struct perf_evsel *evsel  __maybe_unused,
struct perf_sample sample,
const char *backtrace  __maybe_unused 
)
static

Definition at line 651 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_sample_power_frequency()

static int process_sample_power_frequency ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample,
const char *backtrace  __maybe_unused 
)
static

Definition at line 661 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_sample_power_start()

static int process_sample_power_start ( struct timechart *tchart  __maybe_unused,
struct perf_evsel evsel,
struct perf_sample sample,
const char *backtrace  __maybe_unused 
)
static

Definition at line 638 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_sample_sched_switch()

static int process_sample_sched_switch ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample,
const char *  backtrace 
)
static

Definition at line 622 of file builtin-timechart.c.

Here is the call graph for this function:

◆ process_sample_sched_wakeup()

static int process_sample_sched_wakeup ( struct timechart tchart,
struct perf_evsel evsel,
struct perf_sample sample,
const char *  backtrace 
)
static

Definition at line 608 of file builtin-timechart.c.

Here is the call graph for this function:

◆ sched_switch()

static void sched_switch ( struct timechart tchart,
int  cpu,
u64  timestamp,
int  prev_pid,
int  next_pid,
u64  prev_state,
const char *  backtrace 
)
static

Definition at line 441 of file builtin-timechart.c.

Here is the call graph for this function:

◆ sched_wakeup()

static void sched_wakeup ( struct timechart tchart,
int  cpu,
u64  timestamp,
int  waker,
int  wakee,
u8  flags,
const char *  backtrace 
)
static

Definition at line 408 of file builtin-timechart.c.

Here is the call graph for this function:

◆ sort_pids()

static void sort_pids ( struct timechart tchart)
static

Definition at line 966 of file builtin-timechart.c.

◆ timechart__io_record()

static int timechart__io_record ( int  argc,
const char **  argv 
)
static

Definition at line 1648 of file builtin-timechart.c.

Here is the call graph for this function:

◆ timechart__record()

static int timechart__record ( struct timechart tchart,
int  argc,
const char **  argv 
)
static

Definition at line 1783 of file builtin-timechart.c.

Here is the call graph for this function:

◆ write_svg_file()

static void write_svg_file ( struct timechart tchart,
const char *  filename 
)
static

Definition at line 1453 of file builtin-timechart.c.

Here is the call graph for this function:

Variable Documentation

◆ cpus_cstate_start_times

u64 cpus_cstate_start_times[MAX_CPUS]
static

Definition at line 310 of file builtin-timechart.c.

◆ cpus_cstate_state

int cpus_cstate_state[MAX_CPUS]
static

Definition at line 311 of file builtin-timechart.c.

◆ cpus_pstate_start_times

u64 cpus_pstate_start_times[MAX_CPUS]
static

Definition at line 312 of file builtin-timechart.c.

◆ cpus_pstate_state

u64 cpus_pstate_state[MAX_CPUS]
static

Definition at line 313 of file builtin-timechart.c.

◆ process_filter

Definition at line 198 of file builtin-timechart.c.

◆ use_old_power_events

int use_old_power_events
static

Definition at line 346 of file builtin-timechart.c.