HPCToolkit
itimer.c File Reference
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <signal.h>
#include <sys/time.h>
#include <ucontext.h>
#include <time.h>
#include <unistd.h>
#include <include/hpctoolkit-config.h>
#include <monitor.h>
#include "sample_source_obj.h"
#include "common.h"
#include "ss-errno.h"
#include <hpcrun/hpcrun_options.h>
#include <hpcrun/hpcrun_stats.h>
#include <hpcrun/metrics.h>
#include <hpcrun/safe-sampling.h>
#include <hpcrun/sample_event.h>
#include <hpcrun/sample_sources_registered.h>
#include <hpcrun/thread_data.h>
#include <lush/lush-backtrace.h>
#include <messages/messages.h>
#include <utilities/tokenize.h>
#include <utilities/arch/context-pc.h>
#include <unwind/common/unwind.h>
#include <lib/support-lean/timer.h>
#include <sample-sources/blame-shift/blame-shift.h>
#include "ss_obj.h"
Include dependency graph for itimer.c:

Go to the source code of this file.

Macros

#define IDLE_METRIC_NAME   "idleness (usec)"
 
#define WALLCLOCK_EVENT_NAME   "WALLCLOCK"
 
#define WALLCLOCK_METRIC_NAME   "WALLCLOCK (usec)"
 
#define ITIMER_EVENT_NAME   "ITIMER"
 
#define ITIMER_METRIC_NAME   "ITIMER (usec)"
 
#define ITIMER_SIGNAL   SIGPROF
 
#define ITIMER_TYPE   ITIMER_PROF
 
#define REALTIME_EVENT_NAME   "REALTIME"
 
#define REALTIME_METRIC_NAME   "REALTIME (usec)"
 
#define REALTIME_SIGNAL   (SIGRTMIN + 3)
 
#define REALTIME_CLOCK_TYPE   CLOCK_REALTIME
 
#define REALTIME_NOTIFY_METHOD   SIGEV_THREAD_ID
 
#define CPUTIME_EVENT_NAME   "CPUTIME"
 
#define CPUTIME_METRIC_NAME   "CPUTIME (usec)"
 
#define CPUTIME_CLOCK_TYPE   CLOCK_THREAD_CPUTIME_ID
 
#define sigev_notify_thread_id   _sigev_un._tid
 
#define USE_ELAPSED_TIME_FOR_WALLCLOCK
 
#define sample_period   1
 
#define DEFAULT_PERIOD   5000L
 
#define ss_name   itimer
 
#define ss_cls   SS_HARDWARE
 
#define ss_sort_order   20
 

Enumerations

enum  _local_const { PROC_NAME_LEN = 2048, ITIMER_EVENT = 0, _TST_EVENT = 0 }
 

Functions

static int itimer_signal_handler (int sig, siginfo_t *siginfo, void *context)
 
void hpcrun_itimer_wallclock_ok (bool flag)
 
static int hpcrun_create_real_timer (thread_data_t *td)
 
static int hpcrun_delete_real_timer (thread_data_t *td)
 
static int hpcrun_settime (thread_data_t *td, struct itimerspec *spec)
 
static int hpcrun_start_timer (thread_data_t *td)
 
static int hpcrun_stop_timer (thread_data_t *td)
 
static void hpcrun_restart_timer (sample_source_t *self, int safe)
 
static void METHOD_FN (init)
 
static void METHOD_FN (thread_init)
 
static void METHOD_FN (thread_init_action)
 
static void METHOD_FN (start)
 
static void METHOD_FN (thread_fini_action)
 
static void METHOD_FN (stop)
 
static void METHOD_FN (shutdown)
 
static bool METHOD_FN (supports_event, const char *ev_str)
 
static void METHOD_FN (process_event_list, int lush_metrics)
 
static void METHOD_FN (gen_event_set, int lush_metrics)
 
static void METHOD_FN (display_events)
 

Variables

static bool use_itimer = false
 
static bool use_realtime = false
 
static bool use_cputime = false
 
static char * the_event_name = "unknown"
 
static char * the_metric_name = "unknown"
 
static int the_signal_num = 0
 
static long period = DEFAULT_PERIOD
 
static struct itimerval itval_start
 
static struct itimerval itval_stop
 
static struct itimerspec itspec_start
 
static struct itimerspec itspec_stop
 
static sigset_t timer_mask
 
static __thread bool wallclock_ok = false
 
__thread bool hpcrun_thread_suppress_sample
 

Macro Definition Documentation

◆ CPUTIME_CLOCK_TYPE

#define CPUTIME_CLOCK_TYPE   CLOCK_THREAD_CPUTIME_ID

Definition at line 144 of file itimer.c.

◆ CPUTIME_EVENT_NAME

#define CPUTIME_EVENT_NAME   "CPUTIME"

Definition at line 142 of file itimer.c.

◆ CPUTIME_METRIC_NAME

#define CPUTIME_METRIC_NAME   "CPUTIME (usec)"

Definition at line 143 of file itimer.c.

◆ DEFAULT_PERIOD

#define DEFAULT_PERIOD   5000L

Definition at line 162 of file itimer.c.

◆ IDLE_METRIC_NAME

#define IDLE_METRIC_NAME   "idleness (usec)"

Definition at line 125 of file itimer.c.

◆ ITIMER_EVENT_NAME

#define ITIMER_EVENT_NAME   "ITIMER"

Definition at line 130 of file itimer.c.

◆ ITIMER_METRIC_NAME

#define ITIMER_METRIC_NAME   "ITIMER (usec)"

Definition at line 131 of file itimer.c.

◆ ITIMER_SIGNAL

#define ITIMER_SIGNAL   SIGPROF

Definition at line 132 of file itimer.c.

◆ ITIMER_TYPE

#define ITIMER_TYPE   ITIMER_PROF

Definition at line 133 of file itimer.c.

◆ REALTIME_CLOCK_TYPE

#define REALTIME_CLOCK_TYPE   CLOCK_REALTIME

Definition at line 139 of file itimer.c.

◆ REALTIME_EVENT_NAME

#define REALTIME_EVENT_NAME   "REALTIME"

Definition at line 135 of file itimer.c.

◆ REALTIME_METRIC_NAME

#define REALTIME_METRIC_NAME   "REALTIME (usec)"

Definition at line 136 of file itimer.c.

◆ REALTIME_NOTIFY_METHOD

#define REALTIME_NOTIFY_METHOD   SIGEV_THREAD_ID

Definition at line 140 of file itimer.c.

◆ REALTIME_SIGNAL

#define REALTIME_SIGNAL   (SIGRTMIN + 3)

Definition at line 137 of file itimer.c.

◆ sample_period

#define sample_period   1

Definition at line 157 of file itimer.c.

◆ sigev_notify_thread_id

#define sigev_notify_thread_id   _sigev_un._tid

Definition at line 149 of file itimer.c.

◆ ss_cls

#define ss_cls   SS_HARDWARE

Definition at line 667 of file itimer.c.

◆ ss_name

#define ss_name   itimer

Definition at line 666 of file itimer.c.

◆ ss_sort_order

#define ss_sort_order   20

Definition at line 668 of file itimer.c.

◆ USE_ELAPSED_TIME_FOR_WALLCLOCK

#define USE_ELAPSED_TIME_FOR_WALLCLOCK

Definition at line 153 of file itimer.c.

◆ WALLCLOCK_EVENT_NAME

#define WALLCLOCK_EVENT_NAME   "WALLCLOCK"

Definition at line 127 of file itimer.c.

◆ WALLCLOCK_METRIC_NAME

#define WALLCLOCK_METRIC_NAME   "WALLCLOCK (usec)"

Definition at line 128 of file itimer.c.

Enumeration Type Documentation

◆ _local_const

Enumerator
PROC_NAME_LEN 
ITIMER_EVENT 
_TST_EVENT 

Definition at line 169 of file itimer.c.

Function Documentation

◆ hpcrun_create_real_timer()

static int hpcrun_create_real_timer ( thread_data_t td)
static

Definition at line 228 of file itimer.c.

Here is the caller graph for this function:

◆ hpcrun_delete_real_timer()

static int hpcrun_delete_real_timer ( thread_data_t td)
static

Definition at line 257 of file itimer.c.

Here is the caller graph for this function:

◆ hpcrun_itimer_wallclock_ok()

void hpcrun_itimer_wallclock_ok ( bool  flag)

Definition at line 215 of file itimer.c.

Here is the caller graph for this function:

◆ hpcrun_restart_timer()

static void hpcrun_restart_timer ( sample_source_t self,
int  safe 
)
static

Definition at line 326 of file itimer.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hpcrun_settime()

static int hpcrun_settime ( thread_data_t td,
struct itimerspec *  spec 
)
static

Definition at line 280 of file itimer.c.

Here is the caller graph for this function:

◆ hpcrun_start_timer()

static int hpcrun_start_timer ( thread_data_t td)
static

Definition at line 291 of file itimer.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hpcrun_stop_timer()

static int hpcrun_stop_timer ( thread_data_t td)
static

Definition at line 303 of file itimer.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ itimer_signal_handler()

static int itimer_signal_handler ( int  sig,
siginfo_t *  siginfo,
void *  context 
)
static

Definition at line 678 of file itimer.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ METHOD_FN() [1/11]

static void METHOD_FN ( init  )
static

Definition at line 389 of file itimer.c.

Here is the call graph for this function:

◆ METHOD_FN() [2/11]

static void METHOD_FN ( thread_init  )
static

Definition at line 397 of file itimer.c.

◆ METHOD_FN() [3/11]

static void METHOD_FN ( thread_init_action  )
static

Definition at line 403 of file itimer.c.

◆ METHOD_FN() [4/11]

static void METHOD_FN ( start  )
static

Definition at line 409 of file itimer.c.

Here is the call graph for this function:

◆ METHOD_FN() [5/11]

static void METHOD_FN ( thread_fini_action  )
static

Definition at line 430 of file itimer.c.

Here is the call graph for this function:

◆ METHOD_FN() [6/11]

static void METHOD_FN ( stop  )
static

Definition at line 443 of file itimer.c.

Here is the call graph for this function:

◆ METHOD_FN() [7/11]

static void METHOD_FN ( shutdown  )
static

Definition at line 465 of file itimer.c.

◆ METHOD_FN() [8/11]

static bool METHOD_FN ( supports_event  ,
const char *  ev_str 
)
static

Definition at line 473 of file itimer.c.

Here is the call graph for this function:

◆ METHOD_FN() [9/11]

static void METHOD_FN ( process_event_list  ,
int  lush_metrics 
)
static

Definition at line 482 of file itimer.c.

Here is the call graph for this function:

◆ METHOD_FN() [10/11]

static void METHOD_FN ( gen_event_set  ,
int  lush_metrics 
)
static

Definition at line 621 of file itimer.c.

Here is the call graph for this function:

◆ METHOD_FN() [11/11]

static void METHOD_FN ( display_events  )
static

Definition at line 627 of file itimer.c.

Variable Documentation

◆ hpcrun_thread_suppress_sample

__thread bool hpcrun_thread_suppress_sample

Definition at line 193 of file main.c.

◆ itspec_start

struct itimerspec itspec_start
static

Definition at line 199 of file itimer.c.

◆ itspec_stop

struct itimerspec itspec_stop
static

Definition at line 200 of file itimer.c.

◆ itval_start

struct itimerval itval_start
static

Definition at line 196 of file itimer.c.

◆ itval_stop

struct itimerval itval_stop
static

Definition at line 197 of file itimer.c.

◆ period

long period = DEFAULT_PERIOD
static

Definition at line 194 of file itimer.c.

◆ the_event_name

char* the_event_name = "unknown"
static

Definition at line 190 of file itimer.c.

◆ the_metric_name

char* the_metric_name = "unknown"
static

Definition at line 191 of file itimer.c.

◆ the_signal_num

int the_signal_num = 0
static

Definition at line 192 of file itimer.c.

◆ timer_mask

sigset_t timer_mask
static

Definition at line 202 of file itimer.c.

◆ use_cputime

bool use_cputime = false
static

Definition at line 188 of file itimer.c.

◆ use_itimer

bool use_itimer = false
static

Definition at line 186 of file itimer.c.

◆ use_realtime

bool use_realtime = false
static

Definition at line 187 of file itimer.c.

◆ wallclock_ok

__thread bool wallclock_ok = false
static

Definition at line 204 of file itimer.c.