opd_ibs.c File Reference

#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>
Include dependency graph for opd_ibs.c:

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_tibs_sfile_get (struct transient const *trans, int is_cg)
static struct opd_eventibs_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

Detailed Description

AMD Family10h Instruction Based Sampling (IBS) handling.

Remarks:
Copyright 2007-2010 OProfile authors
Read the file COPYING
Author:
Jason Yeh <jason.yeh@amd.com>
Paul Drongowski <paul.drongowski@amd.com>
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Copyright (c) 2008 Advanced Micro Devices, Inc.

Definition in file opd_ibs.c.


Function Documentation

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().

Here is the caller graph for this function:

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.

Here is the call graph for this function:

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.

Here is the call graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

static int ibs_init ( char const *  argv  )  [static]
static int ibs_parse_and_set_events ( char *  str  )  [static]
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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

static int ibs_print_stats (  )  [static]
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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

static int ibs_sfile_dup ( struct sfile to,
struct sfile from 
) [static]

Definition at line 700 of file opd_ibs.c.

References sfile::ext_files, ibs_selected_size, and odb_init().

Here is the call graph for this function:

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.

static odb_t* ibs_sfile_get ( struct transient const *  trans,
int  is_cg 
) [static]
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().

Here is the call graph for this function:

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.

Here is the call graph for this function:

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.

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

static void opd_put_ibs_sample ( struct transient trans  )  [static]
void sfile_dup ( struct sfile to,
struct sfile from 
)

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().

Here is the call graph for this function:

Here is the caller graph for this function:

int sfile_equal ( struct sfile const *  sf,
struct sfile const *  sf2 
)

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().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

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().

Initial value:
{
    .ext_init        = &ibs_init,
    .ext_deinit      = &ibs_deinit,
    .ext_print_stats = &ibs_print_stats,
    .ext_sfile       = &ibs_sfile_handlers
}

Definition at line 826 of file opd_ibs.c.

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]
Initial value:
{
    .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
}

Definition at line 815 of file opd_ibs.c.

unsigned int ibs_stepping

Definition at line 71 of file opd_ibs.c.

Referenced by check_cpuid_family_model_stepping().

struct opd_event ibs_vc[OP_MAX_IBS_COUNTERS]

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().

Definition at line 77 of file opd_ibs.c.

Referenced by ibs_deinit(), ibs_init(), and trans_ibs_op_ls_memaccess().

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.


Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1