#include <stdlib.h>
#include <ctype.h>
#include <dirent.h>
#include "op_events.h"
#include "op_libiberty.h"
Go to the source code of this file.
Data Structures | |
struct | counter_arc_head |
struct | counter_arc |
Functions | |
static counter_arc_head * | build_counter_arc (struct op_event const *pev[], int nr_events) |
static void | delete_counter_arc (counter_arc_head *ctr_arc, int nr_events) |
static int | allocate_counter (counter_arc_head const *ctr_arc, int max_depth, int depth, u32 allocated_mask, size_t *counter_map) |
static int | perfcounterdir (const struct dirent *entry) |
static int | op_get_counter_mask (u32 *mask) |
size_t * | map_event_to_counter (struct op_event const *pev[], int nr_events, op_cpu cpu_type) |
hardware counter allocation
You can have silliness here.
Definition in file op_alloc_counter.c.
static int allocate_counter | ( | counter_arc_head const * | ctr_arc, | |
int | max_depth, | |||
int | depth, | |||
u32 | allocated_mask, | |||
size_t * | counter_map | |||
) | [static] |
ctr_arc | tree description, ctr_arc[i] is the i-th level of tree. | |
max_depth | number of entry in array ctr_arc == depth of tree | |
depth | current level we are exploring | |
allocated_mask | current counter already allocated mask | |
counter_map | array of counter number mapping, returned results go here |
return non zero on succees, in this case counter_map is set to the counter mapping number.
Solution is searched through a simple backtracking exploring recursively all possible solution until one is found, prunning is done in O(1) by tracking a bitmask of already allocated counter. Walking through node is done in preorder left to right.
In case of extended events (required no phisical counters), the associated counter_map entry will be -1.
Possible improvment if neccessary: partition counters in class of counter, two counter belong to the same class if they allow exactly the same set of event. Now using a variant of the backtrack algo can works on class of counter rather on counter (this is not an improvment if each counter goes in it's own class)
Definition at line 126 of file op_alloc_counter.c.
References counter_arc::counter, list_entry, list_for_each, and list_head::next.
Referenced by map_event_to_counter().
static counter_arc_head* build_counter_arc | ( | struct op_event const * | pev[], | |
int | nr_events | |||
) | [static] |
pev | an array of event | |
nr_events | number of entry in pev |
build an array of counter list allowed for each events counter_arc_head[i] is the list of allowed counter for pev[i] events The returned pointer is an array of nr_events entry
Definition at line 45 of file op_alloc_counter.c.
References counter_arc::counter, op_event::counter_mask, list_add_tail(), list_init(), counter_arc_head::next, counter_arc::next, and list_head::next.
Referenced by map_event_to_counter().
static void delete_counter_arc | ( | counter_arc_head * | ctr_arc, | |
int | nr_events | |||
) | [static] |
ctr_arc | the array to deallocate | |
nr_events | number of entry in array |
deallocate all previously allocated resource by build_counter_arc()
Definition at line 85 of file op_alloc_counter.c.
References list_del(), list_entry, list_for_each_safe, counter_arc::next, and list_head::next.
Referenced by map_event_to_counter().
pev | array of selected event we want to bind to counter | |
nr_events | size of pev array | |
cpu_type | cpu type |
Try to calculate a binding between passed event in pev and counter number. The binding is returned in a size_t * where returned ptr[i] is the counter number bound to pev[i]
Definition at line 202 of file op_alloc_counter.c.
References allocate_counter(), build_counter_arc(), delete_counter_arc(), op_get_counter_mask(), op_get_cpu_type(), and op_get_nr_counters().
Referenced by oprof_start::alloc_selected_events(), do_test(), and resolve_events().
static int op_get_counter_mask | ( | u32 * | mask | ) | [static] |
mask | pointer where to place bit mask of unavailable counters |
return >= 0 number of counters that are available < 0 could not determine number of counters
Definition at line 175 of file op_alloc_counter.c.
References op_cpu_has_timer_fs(), op_get_cpu_type(), op_get_nr_counters(), and perfcounterdir().
Referenced by map_event_to_counter().
static int perfcounterdir | ( | const struct dirent * | entry | ) | [static] |
Definition at line 162 of file op_alloc_counter.c.
Referenced by op_get_counter_mask().