libmsr  0.3.0
A friendlier interface to accessing MSRs on Intel platforms
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Functions
csr_imc.c File Reference
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "csr_core.h"
#include "memhdlr.h"
#include "msr_core.h"
#include "csr_imc.h"
#include "cpuid.h"
#include "libmsr_debug.h"
#include "libmsr_error.h"
Include dependency graph for csr_imc.c:

Functions

struct pmonctrs_datapmon_ctr_storage (void)
 Store the PMON counter data on the heap.
 
struct pmonctr_globalpmonctr_global_storage (void)
 the PMON global counter data on the heap.
 
int init_pmon_ctrs (void)
 Initialize storage for PMON performance counter data.
 
int init_pmonctr_global (void)
 Initialize storage for PMON global performance counter data.
 
int pmon_config (uint32_t threshold, uint32_t ovf_en, uint32_t edge_det, uint32_t umask, uint8_t event, const unsigned counter)
 Configure iMC performance counters.
 
int set_pmon_unit_ctrl (uint32_t ovf_en, uint16_t freeze_en, uint16_t freeze, uint16_t reset, uint8_t reset_cfg)
 Set PMON controls.
 
int mem_bw_on_ctr (const unsigned counter, const int type)
 iMC memory bandwidth performance counter.
 
int mem_pct_rw_on_ctr (const unsigned rcounter, const unsigned wcounter)
 
int mem_page_empty_on_ctr (const unsigned act_count, const unsigned pre_count, const unsigned cas_count)
 
int mem_page_miss_on_ctr (const unsigned pre_count, const unsigned cas_count)
 
int read_imc_counter_batch (const unsigned counter)
 Read iMC counters.
 
int print_mem_bw_from_ctr (const unsigned counter, FILE *writedest)
 Print memory bandwidth.
 
int print_mem_pct_rw_from_ctr (const unsigned rcounter, const unsigned wcounter, int type, FILE *writedest)
 Print percentage of read/write requests.
 
int print_mem_page_empty_from_ctr (const unsigned act, const unsigned pre, const unsigned cas, FILE *writedest)
 Print percentage of read/write requests that caused a page empty.
 
int print_mem_page_miss_from_ctr (const unsigned pre, const unsigned cas, FILE *writedest)
 Print percentage of read/write requests that caused a page miss.
 
int print_pmon_ctrs (void)
 Print contents of iMC performance monitoring counters.
 

Function Documentation

int init_pmon_ctrs ( void  )

Initialize storage for PMON performance counter data.

Todo:
Combine into 1 counter batch and 1 event batch.
int init_pmonctr_global ( void  )

Initialize storage for PMON global performance counter data.

Returns
-1 if PMON global counters have been initialized, else 2*NUMCTRS*num_sockets.
int mem_bw_on_ctr ( const unsigned  counter,
const int  type 
)

iMC memory bandwidth performance counter.

Parameters
[in]counterUnique counter identifier.
[in]typecsr_data_type_e data type of event.
Returns
0 if pmon_config() was successful, else -1 if counter does not exist or if specified bandwidth measurement is invalid.
int mem_page_empty_on_ctr ( const unsigned  act_count,
const unsigned  pre_count,
const unsigned  cas_count 
)
Todo:
Document mem_page_empty_on_ctr().
Returns
0 if pmon_config() was successful, else -1 if number of counters is larger than number of iMC performance counters.
int mem_page_miss_on_ctr ( const unsigned  pre_count,
const unsigned  cas_count 
)
Todo:
Document mem_page_miss_on_ctr().
Returns
0 if pmon_config() was successful, else -1 if counter does not exist.
int mem_pct_rw_on_ctr ( const unsigned  rcounter,
const unsigned  wcounter 
)
Todo:
Document mem_pct_rw_on_ctr().
Returns
0 if pmon_config() was successful, else -1 if counter does not exist.
int pmon_config ( uint32_t  threshold,
uint32_t  ovf_en,
uint32_t  edge_det,
uint32_t  umask,
uint8_t  event,
const unsigned  counter 
)

Configure iMC performance counters.

Parameters
[in]thresholdThreshold used in counter comparison.
[in]ovf_enWhen set to 1 and the counter overflows, its overflow bit is set in the local status register and global status register.
[in]edge_detWhen set to 1, increment counter when a 0 –> 1 transition (i.e., rising edge) is detected. When 0, the counter will increment in each cycle that the event is asserted.
[in]umaskSelect subevents to be counted within the selected event.
[in]eventSelect event to be counted.
[in]counterUnique counter identifier.
Returns
0 if set_pmon_config() and do_csr_batch_op() are successful, else -1 if counter does not exist.
struct pmonctrs_data* pmon_ctr_storage ( void  )
read

Store the PMON counter data on the heap.

Returns
Pointer to PMON counter data.
struct pmonctr_global* pmonctr_global_storage ( void  )
read

the PMON global counter data on the heap.

Returns
Pointer to PMON global counter data.
int print_mem_bw_from_ctr ( const unsigned  counter,
FILE *  writedest 
)

Print memory bandwidth.

Parameters
[in]counterUnique counter identifier.
[in]writedestFile stream where output will be written to.
Returns
0 if successful.
int print_mem_page_empty_from_ctr ( const unsigned  act,
const unsigned  pre,
const unsigned  cas,
FILE *  writedest 
)

Print percentage of read/write requests that caused a page empty.

Todo:
Document print_mem_page_empty_from_ctr() parameters.
Returns
0 if successful.
int print_mem_page_miss_from_ctr ( const unsigned  pre,
const unsigned  cas,
FILE *  writedest 
)

Print percentage of read/write requests that caused a page miss.

Todo:
Document print_mem_page_miss_from_ctr() parameters.
Returns
0 if successful.
int print_mem_pct_rw_from_ctr ( const unsigned  rcounter,
const unsigned  wcounter,
int  type,
FILE *  writedest 
)

Print percentage of read/write requests.

Parameters
[in]rcounterUnique counter identifier for read requests.
[in]wcounterUnique counter identifier for write requests.
[in]typeIndicates data is reporting read or write requests.
[in]writedestFile stream where output will be written to.
Returns
0 if successful.
int print_pmon_ctrs ( void  )

Print contents of iMC performance monitoring counters.

Returns
0 if successful, else -1 if init_pmon_ctrs() fails.
int read_imc_counter_batch ( const unsigned  counter)

Read iMC counters.

Parameters
[in]counterUnique counter identifier.
Returns
0 if do_csr_batch_op() was successful, else -1 if counter does not exist.
int set_pmon_unit_ctrl ( uint32_t  ovf_en,
uint16_t  freeze_en,
uint16_t  freeze,
uint16_t  reset,
uint8_t  reset_cf 
)

Set PMON controls.

Parameters
[in]ovf_enWhen set to 1 and the counter overflows, its overflow bit is set in the local status register and global status register.
[in]freeze_enEnable freezing of all uncore performance counters.
[in]freezeFreeze all uncore performance monitors.
[in]resetWhen set to 1, the corresponding counter will be cleared to 0.
[in]reset_cfReset to see a new freeze.
Returns
0 if do_csr_batch_op() was successful, else -1.