| 
    libmsr
    0.3.0
    
   A friendlier interface to accessing MSRs on Intel platforms 
   | 
 
#include <stddef.h>#include <stdint.h>#include <stdio.h>#include <sys/time.h>#include "msr_core.h"#include "memhdlr.h"#include "msr_counters.h"#include "cpuid.h"#include "libmsr_debug.h"
Functions | |
| void | print_available_counters (void) | 
| Print available general-purpose performance counters.   | |
| void | perfevtsel_storage (struct perfevtsel **e) | 
| Store the performance event select counter data on the heap.   | |
| void | pmc_storage (struct pmc **p) | 
| Store the general-purpose performance counter data on the heap.   | |
| void | set_pmc_ctrl_flags (uint64_t cmask, uint64_t flags, uint64_t umask, uint64_t eventsel, int pmcnum, unsigned thread) | 
| Set a performance event select counter on a single logical processor.   | |
| void | set_all_pmc_ctrl (uint64_t cmask, uint64_t flags, uint64_t umask, uint64_t eventsel, int pmcnum) | 
| Set a performance event select counter to the same event on all logical processors.   | |
| int | enable_pmc (void) | 
| Allocate storage for performance counters and reset values.   | |
| void | clear_all_pmc (void) | 
| Reset all performance counters for each logical processor.   | |
| int | clear_pmc (int idx) | 
| Reset performance counter on a specific logical processor.   | |
| void | dump_pmc_data_readable (FILE *writedest) | 
| Print out detailed performance counter data.   | |
| void | unc_perfevtsel_storage (struct unc_perfevtsel **uevt) | 
| Store the uncore performance event select counter data on the heap.   | |
| void | unc_counters_storage (struct unc_counters **uc) | 
| Store the uncore general-purpose performance counter data on the heap.   | |
| void | set_pcu_ctrl_flags (uint64_t flags, uint64_t reset, uint64_t occ, uint64_t eventsel, int pcunum, unsigned socket) | 
| Set an uncore performance event select counter to the same event on a single socket.   | |
| void | set_all_pcu_ctrl (uint64_t flags, uint64_t reset, uint64_t occ, uint64_t eventsel, int pcunum) | 
| Set an uncore performance event select counter to the same event on all sockets.   | |
| void | enable_pcu (void) | 
| Allocate storage for uncore performance counters and reset values.   | |
| void | clear_all_pcu (void) | 
| Reset all uncore performance counters for each socket.   | |
| int | clear_pcu (int idx) | 
| Reset uncore performance counter on a specific socket.   | |
| void | dump_unc_counter_data_label (FILE *writedest) | 
| Print the label for the uncore performance counter data print out.   | |
| void | dump_unc_counter_data (FILE *writedest) | 
| Print out uncore performance counter data.   | |
| void | fixed_counter_storage (struct fixed_counter **ctr0, struct fixed_counter **ctr1, struct fixed_counter **ctr2) | 
| Initialize storage for fixed-function performance counter data, and store it on the heap.   | |
| void | fixed_counter_ctrl_storage (uint64_t ***perf_ctrl, uint64_t ***fixed_ctrl) | 
| Initialize storage for performance global control and fixed-function performance control data, and store it on the heap.   | |
| void | init_fixed_counter (struct fixed_counter *ctr) | 
| Initialize storage for fixed-function performance counter data.   | |
| void | get_fixed_ctr_ctrl (struct fixed_counter *ctr0, struct fixed_counter *ctr1, struct fixed_counter *ctr2) | 
| void | set_fixed_counter_ctrl (struct fixed_counter *ctr0, struct fixed_counter *ctr1, struct fixed_counter *ctr2) | 
| Set value of IA32_FIXED_CTR_CTL and IA32_PERF_GLOBAL_CTL and reset all fixed-function performance counters on all logical processors.   | |
| void | get_fixed_counter_config (struct fixed_counter_config *data) | 
| Retrieve number of fixed-function performance counters on the platform and the bit width of these counters.   | |
| void | enable_fixed_counters (void) | 
| Enable fixed-function counters by setting enable bit in IA32_FIXED_CTR_CTL.   | |
| void | disable_fixed_counters (void) | 
| Disable fixed-function counters by clearing enable bit in IA32_FIXED_CTR_CTL.   | |
| void | dump_fixed_counter_data_terse (FILE *writedest) | 
| Print abbreviated fixed-function performance counter data.   | |
| void | dump_fixed_counter_data_terse_label (FILE *writedest) | 
| Print the label for the abbreviated fixed-function performance counter data print out.   | |
| void | dump_fixed_counter_data_readable (FILE *writedest) | 
| Print detailed fixed-function performance counter data.   | |
| void clear_all_pcu | ( | void | ) | 
Reset all uncore performance counters for each socket.
| void clear_all_pmc | ( | void | ) | 
Reset all performance counters for each logical processor.
| int clear_pcu | ( | int | idx | ) | 
Reset uncore performance counter on a specific socket.
| [in] | idx | Unique socket/package identifier. | 
| int clear_pmc | ( | int | idx | ) | 
Reset performance counter on a specific logical processor.
| [in] | idx | Unique logical processor identifier. | 
| void disable_fixed_counters | ( | void | ) | 
Disable fixed-function counters by clearing enable bit in IA32_FIXED_CTR_CTL.
| void dump_fixed_counter_data_readable | ( | FILE * | writedest | ) | 
Print detailed fixed-function performance counter data.
| [in] | writedest | File stream where output will be written to. | 
| void dump_fixed_counter_data_terse | ( | FILE * | writedest | ) | 
Print abbreviated fixed-function performance counter data.
| [in] | writedest | File stream where output will be written to. | 
| void dump_fixed_counter_data_terse_label | ( | FILE * | writedest | ) | 
Print the label for the abbreviated fixed-function performance counter data print out.
| [in] | writedest | File stream where output will be written to. | 
| void dump_pmc_data_readable | ( | FILE * | writedest | ) | 
Print out detailed performance counter data.
| [in] | writedest | File stream where output will be written to. | 
| void dump_unc_counter_data | ( | FILE * | writedest | ) | 
Print out uncore performance counter data.
| [in] | writedest | File stream where output will be written to. | 
| void dump_unc_counter_data_label | ( | FILE * | writedest | ) | 
Print the label for the uncore performance counter data print out.
| [in] | writedest | File stream where output will be written to. | 
| void enable_fixed_counters | ( | void | ) | 
Enable fixed-function counters by setting enable bit in IA32_FIXED_CTR_CTL.
| void enable_pcu | ( | void | ) | 
Allocate storage for uncore performance counters and reset values.
| int enable_pmc | ( | void | ) | 
Allocate storage for performance counters and reset values.
| void fixed_counter_ctrl_storage | ( | uint64_t *** | perf_ctrl, | 
| uint64_t *** | fixed_ctrl | ||
| ) | 
Initialize storage for performance global control and fixed-function performance control data, and store it on the heap.
There are plans to use a struct to make the indirection less crazy.
| [out] | perf_ctrl | Data for controlling counting of each performance counter. | 
| [out] | fixed_ctrl | Pointer to data for controlling the operations of a fixed-function performance counter. | 
| void fixed_counter_storage | ( | struct fixed_counter ** | ctr0, | 
| struct fixed_counter ** | ctr1, | ||
| struct fixed_counter ** | ctr2 | ||
| ) | 
Initialize storage for fixed-function performance counter data, and store it on the heap.
| [out] | ctr0 | Data for fixed-function performance counter for any instructions retired. | 
| [out] | ctr1 | Data for fixed-function performance counter for core unhalted clock cycles. | 
| [out] | ctr2 | Data for fixed-function performance counter for unhalted reference clock cycles. | 
| void get_fixed_counter_config | ( | struct fixed_counter_config * | data | ) | 
Retrieve number of fixed-function performance counters on the platform and the bit width of these counters.
| [out] | data | Data for general information about fixed-function performance counters. | 
| void get_fixed_ctr_ctrl | ( | struct fixed_counter * | ctr0, | 
| struct fixed_counter * | ctr1, | ||
| struct fixed_counter * | ctr2 | ||
| ) | 
| void init_fixed_counter | ( | struct fixed_counter * | ctr | ) | 
Initialize storage for fixed-function performance counter data.
| [out] | ctr | Data for fixed-function performance counters. | 
| void perfevtsel_storage | ( | struct perfevtsel ** | e | ) | 
Store the performance event select counter data on the heap.
| [out] | e | Data for performance event select counters. | 
| void pmc_storage | ( | struct pmc ** | p | ) | 
Store the general-purpose performance counter data on the heap.
| [out] | p | Data for general-purpose performance counters. | 
| void print_available_counters | ( | void | ) | 
Print available general-purpose performance counters.
| void set_all_pcu_ctrl | ( | uint64_t | flags, | 
| uint64_t | reset, | ||
| uint64_t | occ, | ||
| uint64_t | eventsel, | ||
| int | pcunum | ||
| ) | 
Set an uncore performance event select counter to the same event on all sockets.
Can probably consolidate event select into a single function.
| [in] | flags | Toggle additional options, such as user mode vs. OS mode, enable PMI upon counter overflow, invert cmask, edge detection of event occurrence, etc. | 
| [in] | reset | |
| [in] | occ | Reset queue occupancy counter | 
| [in] | eventsel | Unique event logic unit identifier. | 
| [in] | pcunum | Unique performance event select counter identifier. | 
| void set_all_pmc_ctrl | ( | uint64_t | cmask, | 
| uint64_t | flags, | ||
| uint64_t | umask, | ||
| uint64_t | eventsel, | ||
| int | pmcnum | ||
| ) | 
Set a performance event select counter to the same event on all logical processors.
| [in] | cmask | Count multiple event occurrences per cycle. | 
| [in] | flags | Toggle additional options, such as user mode vs. OS mode, enable PMI upon counter overflow, invert cmask, edge detection of event occurrence, etc. | 
| [in] | umask | Condition to be detected by the event logic unit. | 
| [in] | eventsel | Unique event logic unit identifier. | 
| [in] | pmcnum | Unique performance event select counter identifier. | 
| void set_fixed_counter_ctrl | ( | struct fixed_counter * | ctr0, | 
| struct fixed_counter * | ctr1, | ||
| struct fixed_counter * | ctr2 | ||
| ) | 
Set value of IA32_FIXED_CTR_CTL and IA32_PERF_GLOBAL_CTL and reset all fixed-function performance counters on all logical processors.
| [in] | ctr0 | Data for fixed-function performance counter for any instructions retired. | 
| [in] | ctr1 | Data for fixed-function performance counter for core unhalted clock cycles. | 
| [in] | ctr2 | Data for fixed-function performance counter for unhalted reference clock cycles. | 
| void set_pcu_ctrl_flags | ( | uint64_t | flags, | 
| uint64_t | reset, | ||
| uint64_t | occ, | ||
| uint64_t | eventsel, | ||
| int | pcunum, | ||
| unsigned | socket | ||
| ) | 
Set an uncore performance event select counter to the same event on a single socket.
| [in] | flags | Toggle additional options, such as user mode vs. OS mode, enable PMI upon counter overflow, invert cmask, edge detection of event occurrence, etc. | 
| [in] | reset | Enable reset of queue occupancy counter. | 
| [in] | occ | Counter for queue occupancy. | 
| [in] | eventsel | Unique event logic unit identifier. | 
| [in] | pcunum | Unique performance event select counter identifier. | 
| [in] | socket | Unique socket/package identifier. | 
| void set_pmc_ctrl_flags | ( | uint64_t | cmask, | 
| uint64_t | flags, | ||
| uint64_t | umask, | ||
| uint64_t | eventsel, | ||
| int | pmcnum, | ||
| unsigned | thread | ||
| ) | 
Set a performance event select counter on a single logical processor.
| [in] | cmask | Count multiple event occurrences per cycle. | 
| [in] | flags | Toggle additional options, such as user mode vs. OS mode, enable PMI upon counter overflow, invert cmask, edge detection of event occurrence, etc. | 
| [in] | umask | Condition to be detected by the event logic unit. | 
| [in] | eventsel | Unique event logic unit identifier. | 
| [in] | pmcnum | Unique performance event select counter identifier. | 
| [in] | thread | Unique logical processor identifier. | 
| void unc_counters_storage | ( | struct unc_counters ** | uc | ) | 
Store the uncore general-purpose performance counter data on the heap.
| [out] | uc | Pointer to data for uncore general-purpose performance counters. | 
| void unc_perfevtsel_storage | ( | struct unc_perfevtsel ** | uevt | ) | 
Store the uncore performance event select counter data on the heap.
| [out] | uevt | Pointer to data for uncore performance event select counters. | 
 1.8.2