#include "op_hw_config.h"
#include "op_events.h"
#include "op_string.h"
#include "op_hw_specific.h"
#include "op_libiberty.h"
#include "opd_printf.h"
#include "opd_trans.h"
#include "opd_events.h"
#include "opd_kernel.h"
#include "opd_anon.h"
#include "opd_sfile.h"
#include "opd_interface.h"
#include "opd_mangling.h"
#include "opd_extended.h"
#include "opd_ibs.h"
#include "opd_ibs_trans.h"
#include "opd_ibs_macro.h"
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <limits.h>
Go to the source code of this file.
Functions | |
int | sfile_equal (struct sfile const *sf, struct sfile const *sf2) |
void | sfile_dup (struct sfile *to, struct sfile *from) |
static void | opd_log_ibs_fetch (struct transient *trans) |
static void | opd_log_ibs_op (struct transient *trans) |
static void | opd_put_ibs_sample (struct transient *trans) |
static void | get_ibs_bta_status () |
void | code_ibs_fetch_sample (struct transient *trans) |
static void | get_ibs_op_bta_sample (struct transient *trans, struct ibs_op_sample *trans_op) |
void | code_ibs_op_sample (struct transient *trans) |
static unsigned long | ibs_event_to_counter (unsigned long x) |
void | opd_log_ibs_event (unsigned int event, struct transient *trans) |
void | opd_log_ibs_count (unsigned int event, struct transient *trans, unsigned int count) |
static unsigned long | get_ibs_vci_key (unsigned int event) |
static int | ibs_parse_and_set_events (char *str) |
static int | ibs_parse_counts (char *str, unsigned long int *count) |
static int | ibs_parse_and_set_um_fetch (char const *str) |
static int | ibs_parse_and_set_um_op (char const *str, unsigned long int *ibs_op_um) |
static void | check_cpuid_family_model_stepping () |
static int | ibs_init (char const *argv) |
static int | ibs_deinit () |
static int | ibs_print_stats () |
static int | ibs_sfile_create (struct sfile *sf) |
static int | ibs_sfile_dup (struct sfile *to, struct sfile *from) |
static int | ibs_sfile_close (struct sfile *sf) |
static int | ibs_sfile_sync (struct sfile *sf) |
static odb_t * | ibs_sfile_get (struct transient const *trans, int is_cg) |
static struct opd_event * | ibs_sfile_find_counter_event (unsigned long counter) |
Variables | |
op_cpu | cpu_type |
int | no_event_ok |
char * | session_dir |
static unsigned int | ibs_selected_size |
static unsigned int | ibs_fetch_selected_flag |
static unsigned int | ibs_op_selected_flag |
static unsigned int | ibs_op_ls_selected_flag |
static unsigned int | ibs_op_nb_selected_flag |
static unsigned long | ibs_fetch_sample_stats |
static unsigned long | ibs_fetch_incomplete_stats |
static unsigned long | ibs_op_sample_stats |
static unsigned long | ibs_op_incomplete_stats |
static unsigned long | ibs_derived_event_stats |
struct opd_event | ibs_vc [OP_MAX_IBS_COUNTERS] |
unsigned int | ibs_vci_map [OP_MAX_IBS_COUNTERS] |
unsigned int | ibs_family |
unsigned int | ibs_model |
unsigned int | ibs_stepping |
static unsigned long | ibs_bta_enabled |
FILE * | memaccess_log |
FILE * | bta_log |
struct opd_ext_sfile_handlers | ibs_sfile_handlers |
struct opd_ext_handlers | ibs_handlers |
AMD Family10h Instruction Based Sampling (IBS) handling.
Definition in file opd_ibs.c.
static void check_cpuid_family_model_stepping | ( | ) | [static] |
Definition at line 482 of file opd_ibs.c.
References ibs_family, ibs_model, and ibs_stepping.
Referenced by ibs_init().
void code_ibs_fetch_sample | ( | struct transient * | trans | ) |
Handle an IBS fetch sample escape code sequence. An IBS fetch sample is represented as an escape code sequence. (See the comment for the function code_ibs_op_sample() for the sequence of entries in the event buffer.) When this function is called, the ESCAPE_CODE and IBS_FETCH_CODE have already been removed from the event buffer. Thus, 7 more event buffer entries are needed in order to process a complete IBS fetch sample.
Definition at line 193 of file opd_ibs.c.
References operf_transient::cpu, enough_remaining(), ibs_sample::fetch, ibs_fetch_sample::ibs_fetch_ctl_high, ibs_fetch_sample::ibs_fetch_ctl_low, ibs_fetch_incomplete_stats, ibs_fetch_sample::ibs_fetch_lin_addr_high, ibs_fetch_sample::ibs_fetch_lin_addr_low, ibs_fetch_sample::ibs_fetch_phys_addr_high, ibs_fetch_sample::ibs_fetch_phys_addr_low, ibs_fetch_sample_stats, opd_put_ibs_sample(), operf_transient::pc, pop_buffer_value(), ibs_fetch_sample::rip, operf_transient::tgid, trans, verbprintf, vext, and vsamples.
void code_ibs_op_sample | ( | struct transient * | trans | ) |
Handle an IBS op sample escape code sequence. An IBS op sample is represented as an escape code sequence:
IBS fetch IBS op --------------- ---------------- ESCAPE_CODE ESCAPE_CODE IBS_FETCH_CODE IBS_OP_CODE Offset Offset IbsFetchLinAd low IbsOpRip low <-- Logical (virtual) RIP IbsFetchLinAd high IbsOpRip high <-- Logical (virtual) RIP IbsFetchCtl low IbsOpData low IbsFetchCtl high IbsOpData high IbsFetchPhysAd low IbsOpData2 low IbsFetchPhysAd high IbsOpData2 high IbsOpData3 low IbsOpData3 high IbsDcLinAd low IbsDcLinAd high IbsDcPhysAd low IbsDcPhysAd high
When this function is called, the ESCAPE_CODE and IBS_OP_CODE have already been removed from the event buffer. Thus, 13 more event buffer entries are needed to process a complete IBS op sample.
The IbsFetchLinAd and IbsOpRip are the linear (virtual) addresses that were generated by the IBS hardware. These addresses are mapped into the offset.
Definition at line 267 of file opd_ibs.c.
References operf_transient::cpu, enough_remaining(), get_ibs_op_bta_sample(), ibs_op_sample::ibs_op_data1_high, ibs_op_sample::ibs_op_data1_low, ibs_op_sample::ibs_op_data2_high, ibs_op_sample::ibs_op_data2_low, ibs_op_sample::ibs_op_data3_high, ibs_op_sample::ibs_op_data3_low, ibs_op_incomplete_stats, ibs_op_sample::ibs_op_ldst_linaddr_high, ibs_op_sample::ibs_op_ldst_linaddr_low, ibs_op_sample::ibs_op_lin_addr_high, ibs_op_sample::ibs_op_lin_addr_low, ibs_op_sample::ibs_op_phys_addr_high, ibs_op_sample::ibs_op_phys_addr_low, ibs_op_sample_stats, ibs_sample::op, opd_put_ibs_sample(), operf_transient::pc, pop_buffer_value(), ibs_op_sample::rip, operf_transient::tgid, trans, verbprintf, vext, and vsamples.
static void get_ibs_bta_status | ( | ) | [static] |
Definition at line 173 of file opd_ibs.c.
References buf, and ibs_bta_enabled.
Referenced by ibs_init().
static void get_ibs_op_bta_sample | ( | struct transient * | trans, | |
struct ibs_op_sample * | trans_op | |||
) | [static] |
Definition at line 243 of file opd_ibs.c.
References enough_remaining(), ibs_bta_enabled, ibs_op_sample::ibs_op_brtgt_addr, ibs_op_sample::ibs_op_data1_high, ibs_op_incomplete_stats, pop_buffer_value(), trans, verbprintf, and vext.
Referenced by code_ibs_op_sample().
static unsigned long get_ibs_vci_key | ( | unsigned int | event | ) | [static] |
Definition at line 363 of file opd_ibs.c.
References ibs_event_to_counter(), and OP_MAX_COUNTERS.
Referenced by ibs_parse_and_set_events(), and ibs_sfile_get().
static int ibs_deinit | ( | ) | [static] |
Definition at line 661 of file opd_ibs.c.
References bta_log, and memaccess_log.
static unsigned long ibs_event_to_counter | ( | unsigned long | x | ) | [static] |
Convert IBS event to value used for data structure indexing
Definition at line 327 of file opd_ibs.c.
References IBS_FETCH_BASE, IBS_FETCH_MAX, IBS_OP_BASE, IBS_OP_LS_BASE, IBS_OP_LS_MAX, IBS_OP_MAX, IBS_OP_NB_BASE, IS_IBS_FETCH, IS_IBS_OP, IS_IBS_OP_LS, IS_IBS_OP_NB, and OP_MAX_COUNTERS.
Referenced by get_ibs_vci_key().
static int ibs_init | ( | char const * | argv | ) | [static] |
Definition at line 498 of file opd_ibs.c.
References bta_log, check_cpuid_family_model_stepping(), opd_event::count, empty_line(), filename, get_ibs_bta_status(), ibs_bta_enabled, ibs_parse_and_set_events(), ibs_parse_and_set_um_fetch(), ibs_parse_and_set_um_op(), ibs_parse_counts(), ibs_selected_size, ibs_vc, IS_IBS_FETCH, memaccess_log, no_event_ok, op_xstrndup(), session_dir, skip_ws(), opd_event::um, verbprintf, and vext.
static int ibs_parse_and_set_events | ( | char * | str | ) | [static] |
Definition at line 375 of file opd_ibs.c.
References opd_event::counter, CPU_NO_GOOD, find_event_by_name(), get_ibs_vci_key(), IBS_FETCH_OFFSET, ibs_fetch_selected_flag, IBS_OP_LS_OFFSET, ibs_op_ls_selected_flag, IBS_OP_NB_OFFSET, ibs_op_nb_selected_flag, IBS_OP_OFFSET, ibs_op_selected_flag, ibs_selected_size, ibs_vc, ibs_vci_map, IS_IBS_FETCH, IS_IBS_OP, IS_IBS_OP_LS, IS_IBS_OP_NB, opd_event::kernel, opd_event::name, op_events(), op_get_cpu_type(), OP_MAX_COUNTERS, op_xstrndup(), opd_event::user, and opd_event::value.
Referenced by ibs_init().
static int ibs_parse_and_set_um_fetch | ( | char const * | str | ) | [static] |
Definition at line 459 of file opd_ibs.c.
Referenced by ibs_init().
static int ibs_parse_and_set_um_op | ( | char const * | str, | |
unsigned long int * | ibs_op_um | |||
) | [static] |
Definition at line 467 of file opd_ibs.c.
Referenced by ibs_init().
static int ibs_parse_counts | ( | char * | str, | |
unsigned long int * | count | |||
) | [static] |
Definition at line 440 of file opd_ibs.c.
References op_xstrndup().
Referenced by ibs_init().
static int ibs_print_stats | ( | ) | [static] |
Definition at line 676 of file opd_ibs.c.
References ibs_derived_event_stats, ibs_fetch_incomplete_stats, ibs_fetch_sample_stats, ibs_op_incomplete_stats, and ibs_op_sample_stats.
static int ibs_sfile_close | ( | struct sfile * | sf | ) | [static] |
Definition at line 713 of file opd_ibs.c.
References sfile::ext_files, ibs_selected_size, and odb_close().
static int ibs_sfile_create | ( | struct sfile * | sf | ) | [static] |
Definition at line 689 of file opd_ibs.c.
References sfile::ext_files, ibs_selected_size, and odb_init().
Referenced by ibs_sfile_get().
Definition at line 700 of file opd_ibs.c.
References sfile::ext_files, ibs_selected_size, and odb_init().
static struct opd_event* ibs_sfile_find_counter_event | ( | unsigned long | counter | ) | [static, read] |
Filled opd_event structure with IBS derived event information from the given counter value.
Definition at line 799 of file opd_ibs.c.
References ibs_vc, OP_MAX_COUNTERS, and OP_MAX_IBS_COUNTERS.
Definition at line 736 of file opd_ibs.c.
References sfile::cg_hash, CG_HASH_SIZE, operf_transient::current, operf_transient::event, sfile::ext_files, get_ibs_vci_key(), cg_entry::hash, sfile::hashval, ibs_sfile_create(), ibs_vci_map, operf_transient::last, list_add(), list_entry, list_for_each, odb_open_count(), OP_MAX_COUNTERS, opd_open_sample_file(), sfile_dup(), sfile_equal(), cg_entry::to, and trans.
static int ibs_sfile_sync | ( | struct sfile * | sf | ) | [static] |
Definition at line 726 of file opd_ibs.c.
References sfile::ext_files, ibs_selected_size, and odb_sync().
void opd_log_ibs_count | ( | unsigned int | event, | |
struct transient * | trans, | |||
unsigned int | count | |||
) |
Log the specified IBS cycle count.
Definition at line 353 of file opd_ibs.c.
References operf_transient::event, ibs_derived_event_stats, sfile_log_sample_count(), and trans.
void opd_log_ibs_event | ( | unsigned int | event, | |
struct transient * | trans | |||
) |
Log the specified IBS derived event.
Definition at line 344 of file opd_ibs.c.
References operf_transient::event, ibs_derived_event_stats, sfile_log_sample_count(), and trans.
static void opd_log_ibs_fetch | ( | struct transient * | trans | ) | [static] |
This function converts IBS fetch event flags and values into derived events. If the tagged (sampled) fetched caused a derived event, the derived event is tallied.
Definition at line 85 of file opd_ibs.c.
References ibs_sample::fetch, ibs_fetch_selected_flag, trans, and trans_ibs_fetch().
Referenced by opd_put_ibs_sample().
static void opd_log_ibs_op | ( | struct transient * | trans | ) | [static] |
This function translates the IBS op event flags and values into IBS op derived events. If an op derived event occured, it's tallied.
Definition at line 99 of file opd_ibs.c.
References ibs_family, ibs_op_ls_selected_flag, ibs_op_nb_selected_flag, ibs_op_selected_flag, ibs_sample::op, trans, trans_ibs_op(), trans_ibs_op_bta(), trans_ibs_op_ls(), trans_ibs_op_ls_memaccess(), trans_ibs_op_mask_reserved(), trans_ibs_op_nb(), and trans_ibs_op_rip_invalid().
Referenced by opd_put_ibs_sample().
static void opd_put_ibs_sample | ( | struct transient * | trans | ) | [static] |
Definition at line 118 of file opd_ibs.c.
References clear_trans_current(), operf_transient::current, kernel_image::end, enough_remaining(), operf_transient::event, ibs_sample::fetch, find_anon_mapping(), find_kernel_image(), operf_transient::in_kernel, INVALID_COOKIE, NO_COOKIE, opd_log_ibs_fetch(), opd_log_ibs_op(), sfile_find(), kernel_image::start, TRACING_ON, TRACING_START, trans, and update_trans_last().
Referenced by code_ibs_fetch_sample(), and code_ibs_op_sample().
Definition at line 383 of file opd_sfile.c.
References sfile::cg_hash, CG_HASH_SIZE, sfile::files, sfile::hash, list_init(), sfile::lru, odb_init(), op_nr_counters, and opd_ext_sfile_dup().
Referenced by get_file(), and ibs_sfile_get().
Definition at line 178 of file opd_sfile.c.
References sfile::anon, sfile::app_cookie, sfile::cookie, sfile::cpu, do_match(), sfile::kernel, sfile::tgid, and sfile::tid.
Referenced by get_file(), and ibs_sfile_get().
FILE* bta_log |
Definition at line 78 of file opd_ibs.c.
Referenced by ibs_deinit(), ibs_init(), and trans_ibs_op_bta().
Definition at line 55 of file oprofiled.c.
unsigned long ibs_bta_enabled [static] |
Definition at line 74 of file opd_ibs.c.
Referenced by get_ibs_bta_status(), get_ibs_op_bta_sample(), and ibs_init().
unsigned long ibs_derived_event_stats [static] |
Definition at line 58 of file opd_ibs.c.
Referenced by ibs_print_stats(), opd_log_ibs_count(), and opd_log_ibs_event().
unsigned int ibs_family |
Definition at line 69 of file opd_ibs.c.
Referenced by check_cpuid_family_model_stepping(), and opd_log_ibs_op().
unsigned long ibs_fetch_incomplete_stats [static] |
Definition at line 55 of file opd_ibs.c.
Referenced by code_ibs_fetch_sample(), and ibs_print_stats().
unsigned long ibs_fetch_sample_stats [static] |
Definition at line 54 of file opd_ibs.c.
Referenced by code_ibs_fetch_sample(), and ibs_print_stats().
unsigned int ibs_fetch_selected_flag [static] |
Definition at line 48 of file opd_ibs.c.
Referenced by ibs_parse_and_set_events(), and opd_log_ibs_fetch().
struct opd_ext_handlers ibs_handlers |
{ .ext_init = &ibs_init, .ext_deinit = &ibs_deinit, .ext_print_stats = &ibs_print_stats, .ext_sfile = &ibs_sfile_handlers }
unsigned int ibs_model |
Definition at line 70 of file opd_ibs.c.
Referenced by check_cpuid_family_model_stepping().
unsigned long ibs_op_incomplete_stats [static] |
Definition at line 57 of file opd_ibs.c.
Referenced by code_ibs_op_sample(), get_ibs_op_bta_sample(), and ibs_print_stats().
unsigned int ibs_op_ls_selected_flag [static] |
Definition at line 50 of file opd_ibs.c.
Referenced by ibs_parse_and_set_events(), and opd_log_ibs_op().
unsigned int ibs_op_nb_selected_flag [static] |
Definition at line 51 of file opd_ibs.c.
Referenced by ibs_parse_and_set_events(), and opd_log_ibs_op().
unsigned long ibs_op_sample_stats [static] |
Definition at line 56 of file opd_ibs.c.
Referenced by code_ibs_op_sample(), and ibs_print_stats().
unsigned int ibs_op_selected_flag [static] |
Definition at line 49 of file opd_ibs.c.
Referenced by ibs_parse_and_set_events(), and opd_log_ibs_op().
unsigned int ibs_selected_size [static] |
Definition at line 45 of file opd_ibs.c.
Referenced by ibs_init(), ibs_parse_and_set_events(), ibs_sfile_close(), ibs_sfile_create(), ibs_sfile_dup(), and ibs_sfile_sync().
{ .create = &ibs_sfile_create, .dup = &ibs_sfile_dup, .close = &ibs_sfile_close, .sync = &ibs_sfile_sync, .get = &ibs_sfile_get, .find_counter_event = &ibs_sfile_find_counter_event }
unsigned int ibs_stepping |
Definition at line 71 of file opd_ibs.c.
Referenced by check_cpuid_family_model_stepping().
Definition at line 63 of file opd_ibs.c.
Referenced by ibs_init(), ibs_parse_and_set_events(), and ibs_sfile_find_counter_event().
unsigned int ibs_vci_map[OP_MAX_IBS_COUNTERS] |
Definition at line 66 of file opd_ibs.c.
Referenced by ibs_parse_and_set_events(), and ibs_sfile_get().
FILE* memaccess_log |
Definition at line 77 of file opd_ibs.c.
Referenced by ibs_deinit(), ibs_init(), and trans_ibs_op_ls_memaccess().
int no_event_ok |
Definition at line 56 of file oprofiled.c.
Referenced by ibs_init(), and opd_options().
char* session_dir |
Definition at line 70 of file oprofiled.c.