#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include "operf_sfile.h"
#include "operf_kernel.h"
#include "operf_utils.h"
#include "cverb.h"
#include "op_string.h"
#include "operf_mangling.h"
#include "operf_stats.h"
#include "op_libiberty.h"
Go to the source code of this file.
Defines | |
#define | HASH_SIZE 2048 |
#define | HASH_BITS (HASH_SIZE - 1) |
#define | LRU_AMOUNT 256 |
Typedefs | |
typedef int(* | operf_sfile_func )(struct operf_sfile *, void *) |
Functions | |
static | LIST_HEAD (lru_list) |
static unsigned long | sfile_hash (struct operf_transient const *trans, struct operf_kernel_image *ki) |
static int | do_match (struct operf_sfile const *sf, struct operf_kernel_image const *ki, bool is_anon, const char *image_name, size_t image_len, const char *appname, size_t app_len, pid_t tgid, pid_t tid, unsigned int cpu) |
int | operf_sfile_equal (struct operf_sfile const *sf, struct operf_sfile const *sf2) |
static struct operf_sfile * | create_sfile (unsigned long hash, struct operf_transient const *trans, struct operf_kernel_image *ki) |
struct operf_sfile * | operf_sfile_find (struct operf_transient const *trans) |
void | operf_sfile_dup (struct operf_sfile *to, struct operf_sfile *from) |
static odb_t * | get_file (struct operf_transient const *trans, int is_cg) |
static void | verbose_print_sample (struct operf_sfile *sf, vma_t pc, uint counter) |
static void | verbose_sample (struct operf_transient const *trans, vma_t pc) |
static void | verbose_arc (struct operf_transient const *trans, vma_t from, vma_t to) |
void | operf_sfile_log_arc (struct operf_transient const *trans) |
void | operf_sfile_log_sample (struct operf_transient const *trans) |
void | operf_sfile_log_sample_count (struct operf_transient const *trans, unsigned long int count) |
static int | close_sfile (struct operf_sfile *sf, void *data __attribute__((unused))) |
static void | kill_sfile (struct operf_sfile *sf) |
static int | sync_sfile (struct operf_sfile *sf, void *data __attribute__((unused))) |
static int | is_sfile_kernel (struct operf_sfile *sf, void *data __attribute__((unused))) |
static void | for_one_sfile (struct operf_sfile *sf, operf_sfile_func func, void *data) |
static void | for_each_sfile (operf_sfile_func func, void *data) |
void | operf_sfile_clear_kernel (void) |
void | operf_sfile_sync_files (void) |
static int | _release_resources (struct operf_sfile *sf __attribute__((unused)), void *p __attribute__((unused))) |
void | operf_sfile_close_files (void) |
static int | always_true (void) |
int | operf_sfile_lru_clear (void) |
void | operf_sfile_get (struct operf_sfile *sf) |
void | operf_sfile_put (struct operf_sfile *sf) |
void | operf_sfile_init (void) |
Variables | |
static struct list_head | hashes [HASH_SIZE] |
#define HASH_BITS (HASH_SIZE - 1) |
Definition at line 28 of file operf_sfile.cpp.
#define HASH_SIZE 2048 |
Definition at line 27 of file operf_sfile.cpp.
#define LRU_AMOUNT 256 |
Definition at line 520 of file operf_sfile.cpp.
typedef int(* operf_sfile_func)(struct operf_sfile *, void *) |
Definition at line 451 of file operf_sfile.cpp.
static int _release_resources | ( | struct operf_sfile *sf | __attribute__(unused), | |
void *p | __attribute__(unused) | |||
) | [static] |
Definition at line 503 of file operf_sfile.cpp.
Referenced by operf_sfile_close_files().
static int always_true | ( | void | ) | [static] |
Definition at line 514 of file operf_sfile.cpp.
Referenced by operf_sfile_lru_clear().
static int close_sfile | ( | struct operf_sfile * | sf, | |
void *data | __attribute__(unused) | |||
) | [static] |
Definition at line 408 of file operf_sfile.cpp.
References operf_sfile::files, odb_close(), and op_nr_counters.
Referenced by kill_sfile().
static struct operf_sfile* create_sfile | ( | unsigned long | hash, | |
struct operf_transient const * | trans, | |||
struct operf_kernel_image * | ki | |||
) | [static, read] |
create a new sfile matching the current transient parameters
Definition at line 133 of file operf_sfile.cpp.
References operf_transient::app_filename, operf_sfile::app_filename, operf_transient::app_len, operf_sfile::app_len, operf_sfile::cg_hash, CG_HASH_SIZE, operf_transient::cpu, operf_sfile::cpu, operf_transient::end_addr, operf_sfile::end_addr, operf_sfile::ext_files, operf_sfile::files, operf_sfile::hashval, operf_transient::image_len, operf_sfile::image_len, operf_transient::image_name, operf_sfile::image_name, operf_transient::is_anon, operf_sfile::is_anon, operf_sfile::kernel, list_init(), odb_init(), op_nr_counters, operf_options::separate_cpu, operf_transient::start_addr, operf_sfile::start_addr, operf_transient::tgid, operf_sfile::tgid, operf_transient::tid, and operf_sfile::tid.
Referenced by operf_sfile_find().
static int do_match | ( | struct operf_sfile const * | sf, | |
struct operf_kernel_image const * | ki, | |||
bool | is_anon, | |||
const char * | image_name, | |||
size_t | image_len, | |||
const char * | appname, | |||
size_t | app_len, | |||
pid_t | tgid, | |||
pid_t | tid, | |||
unsigned int | cpu | |||
) | [static] |
Definition at line 80 of file operf_sfile.cpp.
References operf_sfile::app_filename, operf_sfile::app_len, operf_sfile::cpu, operf_sfile::image_len, operf_sfile::image_name, operf_sfile::is_anon, operf_sfile::kernel, operf_options::separate_cpu, operf_sfile::tgid, and operf_sfile::tid.
Referenced by operf_sfile_equal(), and operf_sfile_find().
static void for_each_sfile | ( | operf_sfile_func | func, | |
void * | data | |||
) | [static] |
Definition at line 480 of file operf_sfile.cpp.
References for_one_sfile(), list_entry, list_for_each_safe, and lru.
Referenced by operf_sfile_clear_kernel(), operf_sfile_close_files(), and operf_sfile_sync_files().
static void for_one_sfile | ( | struct operf_sfile * | sf, | |
operf_sfile_func | func, | |||
void * | data | |||
) | [static] |
Definition at line 454 of file operf_sfile.cpp.
References operf_sfile::cg_hash, CG_HASH_SIZE, operf_cg_entry::hash, kill_sfile(), list_del(), list_entry, list_for_each_safe, and operf_cg_entry::to.
Referenced by for_each_sfile(), and operf_sfile_lru_clear().
static odb_t* get_file | ( | struct operf_transient const * | trans, | |
int | is_cg | |||
) | [static] |
Definition at line 234 of file operf_sfile.cpp.
References operf_sfile::cg_hash, CG_HASH_SIZE, operf_transient::current, operf_transient::event, operf_sfile::files, operf_cg_entry::hash, operf_sfile::hashval, operf_transient::last, list_add(), list_entry, list_for_each, odb_open_count(), op_nr_counters, operf_open_sample_file(), operf_sfile_dup(), operf_sfile_equal(), and operf_cg_entry::to.
Referenced by operf_sfile_log_arc(), and operf_sfile_log_sample_count().
static int is_sfile_kernel | ( | struct operf_sfile * | sf, | |
void *data | __attribute__(unused) | |||
) | [static] |
Definition at line 445 of file operf_sfile.cpp.
References operf_sfile::kernel.
Referenced by operf_sfile_clear_kernel().
static void kill_sfile | ( | struct operf_sfile * | sf | ) | [static] |
Definition at line 423 of file operf_sfile.cpp.
References close_sfile(), operf_sfile::hash, list_del(), and operf_sfile::lru.
Referenced by for_one_sfile().
static LIST_HEAD | ( | lru_list | ) | [static] |
All sfiles are on this list.
void operf_sfile_clear_kernel | ( | void | ) |
clear any sfiles that are for the kernel
Definition at line 492 of file operf_sfile.cpp.
References for_each_sfile(), and is_sfile_kernel().
void operf_sfile_close_files | ( | void | ) |
close sample files
Definition at line 508 of file operf_sfile.cpp.
References _release_resources(), and for_each_sfile().
Referenced by OP_perf_utils::op_release_resources().
void operf_sfile_dup | ( | struct operf_sfile * | to, | |
struct operf_sfile * | from | |||
) |
Definition at line 215 of file operf_sfile.cpp.
References operf_sfile::cg_hash, CG_HASH_SIZE, operf_sfile::files, operf_sfile::hash, list_init(), operf_sfile::lru, odb_init(), and op_nr_counters.
Referenced by get_file().
int operf_sfile_equal | ( | struct operf_sfile const * | sf, | |
struct operf_sfile const * | sf2 | |||
) |
Definition at line 121 of file operf_sfile.cpp.
References operf_sfile::app_filename, operf_sfile::app_len, operf_sfile::cpu, do_match(), operf_sfile::image_len, operf_sfile::image_name, operf_sfile::is_anon, operf_sfile::kernel, operf_sfile::tgid, and operf_sfile::tid.
Referenced by get_file().
struct operf_sfile* operf_sfile_find | ( | struct operf_transient const * | trans | ) | [read] |
Find the sfile for the current parameters. Note that is required that the PC value be set appropriately (needed for kernel images)
Definition at line 175 of file operf_sfile.cpp.
References operf_transient::app_filename, operf_transient::app_len, operf_transient::cpu, create_sfile(), cverb, do_match(), operf_sfile::hash, hashes, operf_transient::image_len, operf_transient::image_name, operf_transient::in_kernel, operf_transient::is_anon, list_add(), list_entry, list_for_each, lru, operf_find_kernel_image(), OPERF_LOST_KERNEL, operf_sfile_get(), operf_sfile_put(), operf_stats, operf_transient::pc, sfile_hash(), operf_transient::tgid, operf_transient::tid, and vsfile.
Referenced by __handle_callchain(), and __handle_sample_event().
void operf_sfile_get | ( | struct operf_sfile * | sf | ) |
remove a sfile from the lru list, protecting it from operf_sfile_lru_clear()
Definition at line 548 of file operf_sfile.cpp.
References list_del(), and operf_sfile::lru.
Referenced by operf_open_sample_file(), and operf_sfile_find().
void operf_sfile_init | ( | void | ) |
initialise hashes
Definition at line 562 of file operf_sfile.cpp.
References HASH_SIZE, hashes, and list_init().
Referenced by OP_perf_utils::op_write_event().
void operf_sfile_log_arc | ( | struct operf_transient const * | trans | ) |
Log a callgraph arc.
Definition at line 323 of file operf_sfile.cpp.
References operf_transient::current, cverb, get_file(), operf_sfile::is_anon, operf_sfile::kernel, operf_transient::last, operf_transient::last_pc, odb_update_node(), OPERF_LOST_SAMPLEFILE, operf_stats, operf_transient::pc, operf_kernel_image::start, operf_sfile::start_addr, varcs, and verbose_arc().
Referenced by __handle_callchain().
void operf_sfile_log_sample | ( | struct operf_transient const * | trans | ) |
Log the sample in a previously located sfile.
Definition at line 366 of file operf_sfile.cpp.
References operf_sfile_log_sample_count().
Referenced by __handle_sample_event().
void operf_sfile_log_sample_count | ( | struct operf_transient const * | trans, | |
unsigned long int | count | |||
) |
Log the event/cycle count in a previously located sfile
Definition at line 372 of file operf_sfile.cpp.
References operf_transient::current, cverb, get_file(), operf_transient::in_kernel, operf_sfile::is_anon, operf_sfile::kernel, odb_update_node_with_offset(), OPERF_KERNEL, OPERF_LOST_SAMPLEFILE, OPERF_PROCESS, OPERF_SAMPLES, operf_stats, operf_transient::pc, operf_kernel_image::start, operf_sfile::start_addr, verbose_sample(), and vsfile.
Referenced by operf_sfile_log_sample().
int operf_sfile_lru_clear | ( | void | ) |
clear out a certain amount of LRU entries return non-zero if the lru is already empty
Definition at line 527 of file operf_sfile.cpp.
References always_true(), for_one_sfile(), list_empty(), list_entry, list_for_each_safe, lru, and LRU_AMOUNT.
Referenced by operf_open_sample_file().
void operf_sfile_put | ( | struct operf_sfile * | sf | ) |
add this sfile to lru list
Definition at line 555 of file operf_sfile.cpp.
References list_add_tail(), and operf_sfile::lru.
Referenced by operf_open_sample_file(), and operf_sfile_find().
void operf_sfile_sync_files | ( | void | ) |
sync sample files
Definition at line 498 of file operf_sfile.cpp.
References for_each_sfile(), and sync_sfile().
static unsigned long sfile_hash | ( | struct operf_transient const * | trans, | |
struct operf_kernel_image * | ki | |||
) | [static] |
Definition at line 38 of file operf_sfile.cpp.
References operf_transient::app_filename, operf_transient::app_len, operf_transient::cpu, operf_kernel_image::end, operf_transient::end_addr, HASH_BITS, operf_transient::image_len, operf_transient::image_name, operf_transient::in_kernel, operf_transient::is_anon, operf_options::separate_cpu, operf_kernel_image::start, operf_transient::start_addr, operf_transient::tgid, and VMA_SHIFT.
Referenced by operf_sfile_find().
static int sync_sfile | ( | struct operf_sfile * | sf, | |
void *data | __attribute__(unused) | |||
) | [static] |
Definition at line 431 of file operf_sfile.cpp.
References operf_sfile::files, odb_sync(), and op_nr_counters.
Referenced by operf_sfile_sync_files().
static void verbose_arc | ( | struct operf_transient const * | trans, | |
vma_t | from, | |||
vma_t | to | |||
) | [static] |
Definition at line 315 of file operf_sfile.cpp.
References operf_transient::current, operf_transient::event, and verbose_print_sample().
Referenced by operf_sfile_log_arc().
static void verbose_print_sample | ( | struct operf_sfile * | sf, | |
vma_t | pc, | |||
uint | counter | |||
) | [static] |
Definition at line 290 of file operf_sfile.cpp.
References operf_sfile::app_filename, operf_kernel_image::end, operf_sfile::end_addr, operf_sfile::image_name, operf_sfile::is_anon, operf_sfile::kernel, operf_kernel_image::name, operf_kernel_image::start, operf_sfile::start_addr, and operf_sfile::tgid.
Referenced by verbose_arc(), and verbose_sample().
static void verbose_sample | ( | struct operf_transient const * | trans, | |
vma_t | pc | |||
) | [static] |
Definition at line 307 of file operf_sfile.cpp.
References operf_transient::current, operf_transient::event, and verbose_print_sample().
Referenced by operf_sfile_log_sample_count().
All sfiles are hashed into these lists
Definition at line 31 of file operf_sfile.cpp.
Referenced by operf_sfile_find(), and operf_sfile_init().