#include "opd_sfile.h"
#include "opd_trans.h"
#include "opd_kernel.h"
#include "opd_mangling.h"
#include "opd_anon.h"
#include "opd_printf.h"
#include "opd_stats.h"
#include "opd_extended.h"
#include "oprofiled.h"
#include "op_libiberty.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
Go to the source code of this file.
Data Structures | |
struct | kern_cmdline |
Defines | |
#define | HASH_SIZE 2048 |
#define | HASH_BITS (HASH_SIZE - 1) |
#define | LRU_AMOUNT 256 |
Typedefs | |
typedef int(* | sfile_func )(struct sfile *, void *) |
Functions | |
static | LIST_HEAD (lru_list) |
static unsigned long | sfile_hash (struct transient const *trans, struct kernel_image *ki) |
static int | do_match (struct sfile const *sf, cookie_t cookie, cookie_t app_cookie, struct kernel_image const *ki, struct anon_mapping const *anon, pid_t tgid, pid_t tid, unsigned int cpu) |
static int | trans_match (struct transient const *trans, struct sfile const *sfile, struct kernel_image const *ki) |
int | sfile_equal (struct sfile const *sf, struct sfile const *sf2) |
static int | is_sf_ignored (struct sfile const *sf) |
static struct sfile * | create_sfile (unsigned long hash, struct transient const *trans, struct kernel_image *ki) |
struct sfile * | sfile_find (struct transient const *trans) |
void | sfile_dup (struct sfile *to, struct sfile *from) |
static odb_t * | get_file (struct transient const *trans, int is_cg) |
static void | verbose_print_sample (struct sfile *sf, vma_t pc, uint counter) |
static void | verbose_sample (struct transient const *trans, vma_t pc) |
static void | verbose_arc (struct transient const *trans, vma_t from, vma_t to) |
static void | sfile_log_arc (struct transient const *trans) |
void | sfile_log_sample (struct transient const *trans) |
void | sfile_log_sample_count (struct transient const *trans, unsigned long int count) |
static int | close_sfile (struct sfile *sf, void *data __attribute__((unused))) |
static void | kill_sfile (struct sfile *sf) |
static int | sync_sfile (struct sfile *sf, void *data __attribute__((unused))) |
static int | is_sfile_kernel (struct sfile *sf, void *data __attribute__((unused))) |
static int | is_sfile_anon (struct sfile *sf, void *data) |
static void | for_one_sfile (struct sfile *sf, sfile_func func, void *data) |
static void | for_each_sfile (sfile_func func, void *data) |
void | sfile_clear_kernel (void) |
void | sfile_clear_anon (struct anon_mapping *anon) |
void | sfile_sync_files (void) |
void | sfile_close_files (void) |
static int | always_true (void) |
int | sfile_lru_clear (void) |
void | sfile_get (struct sfile *sf) |
void | sfile_put (struct sfile *sf) |
void | sfile_init (void) |
Variables | |
static struct list_head | hashes [HASH_SIZE] |
static struct list_head | kernel_cmdlines [HASH_SIZE] |
Management of sample files
Definition in file opd_sfile.c.
#define HASH_BITS (HASH_SIZE - 1) |
Definition at line 33 of file opd_sfile.c.
#define HASH_SIZE 2048 |
Definition at line 32 of file opd_sfile.c.
#define LRU_AMOUNT 256 |
Definition at line 700 of file opd_sfile.c.
typedef int(* sfile_func)(struct sfile *, void *) |
Definition at line 629 of file opd_sfile.c.
static int always_true | ( | void | ) | [static] |
Definition at line 694 of file opd_sfile.c.
Referenced by sfile_lru_clear().
static int close_sfile | ( | struct sfile * | sf, | |
void *data | __attribute__(unused) | |||
) | [static] |
Definition at line 582 of file opd_sfile.c.
References sfile::files, odb_close(), op_nr_counters, and opd_ext_sfile_close().
Referenced by kill_sfile(), and sfile_close_files().
static struct sfile* create_sfile | ( | unsigned long | hash, | |
struct transient const * | trans, | |||
struct kernel_image * | ki | |||
) | [static, read] |
create a new sfile matching the current transient parameters
Definition at line 210 of file opd_sfile.c.
References sfile::anon, sfile::app_cookie, sfile::cg_hash, CG_HASH_SIZE, sfile::cookie, operf_transient::cpu, sfile::cpu, sfile::embedded_offset, sfile::ext_files, sfile::files, sfile::hashval, sfile::ignored, operf_transient::in_kernel, INVALID_COOKIE, is_sf_ignored(), sfile::kernel, list_init(), NO_COOKIE, odb_init(), op_nr_counters, opd_ext_sfile_create(), separate_cpu, separate_kernel, separate_lib, separate_thread, operf_transient::tgid, sfile::tgid, operf_transient::tid, sfile::tid, trans, and UNUSED_EMBEDDED_OFFSET.
Referenced by sfile_find().
static int do_match | ( | struct sfile const * | sf, | |
cookie_t | cookie, | |||
cookie_t | app_cookie, | |||
struct kernel_image const * | ki, | |||
struct anon_mapping const * | anon, | |||
pid_t | tgid, | |||
pid_t | tid, | |||
unsigned int | cpu | |||
) | [static] |
Definition at line 129 of file opd_sfile.c.
References sfile::anon, sfile::app_cookie, sfile::cookie, sfile::cpu, sfile::kernel, separate_cpu, separate_kernel, separate_lib, separate_thread, sfile::tgid, and sfile::tid.
Referenced by sfile_equal(), and trans_match().
static void for_each_sfile | ( | sfile_func | func, | |
void * | data | |||
) | [static] |
Definition at line 658 of file opd_sfile.c.
References for_one_sfile(), list_entry, list_for_each_safe, and lru.
Referenced by sfile_clear_anon(), sfile_clear_kernel(), sfile_close_files(), and sfile_sync_files().
static void for_one_sfile | ( | struct sfile * | sf, | |
sfile_func | func, | |||
void * | data | |||
) | [static] |
Definition at line 632 of file opd_sfile.c.
References sfile::cg_hash, CG_HASH_SIZE, cg_entry::hash, kill_sfile(), list_del(), list_entry, list_for_each_safe, and cg_entry::to.
Referenced by for_each_sfile(), and sfile_lru_clear().
Definition at line 402 of file opd_sfile.c.
References sfile::cg_hash, CG_HASH_SIZE, operf_transient::current, operf_transient::event, sfile::files, cg_entry::hash, sfile::hashval, operf_transient::last, list_add(), list_entry, list_for_each, odb_open_count(), op_nr_counters, opd_ext_sfile_get(), opd_open_sample_file(), sfile_dup(), sfile_equal(), cg_entry::to, and trans.
Referenced by sfile_log_arc(), and sfile_log_sample_count().
static int is_sf_ignored | ( | struct sfile const * | sf | ) | [static] |
Definition at line 186 of file opd_sfile.c.
References sfile::anon, sfile::app_cookie, sfile::cookie, is_cookie_ignored(), is_image_ignored(), sfile::kernel, and kernel_image::name.
Referenced by create_sfile().
static int is_sfile_anon | ( | struct sfile * | sf, | |
void * | data | |||
) | [static] |
Definition at line 623 of file opd_sfile.c.
References sfile::anon.
Referenced by sfile_clear_anon().
static int is_sfile_kernel | ( | struct sfile * | sf, | |
void *data | __attribute__(unused) | |||
) | [static] |
Definition at line 617 of file opd_sfile.c.
References sfile::kernel.
Referenced by sfile_clear_kernel().
static void kill_sfile | ( | struct sfile * | sf | ) | [static] |
Definition at line 596 of file opd_sfile.c.
References close_sfile(), sfile::hash, list_del(), and sfile::lru.
Referenced by for_one_sfile().
static LIST_HEAD | ( | lru_list | ) | [static] |
All sfiles are on this list.
void sfile_clear_anon | ( | struct anon_mapping * | ) |
clear any sfiles for the given anon mapping
Definition at line 676 of file opd_sfile.c.
References for_each_sfile(), and is_sfile_anon().
Referenced by clear_anon_maps(), and do_lru().
void sfile_clear_kernel | ( | void | ) |
clear any sfiles that are for the kernel
Definition at line 670 of file opd_sfile.c.
References for_each_sfile(), and is_sfile_kernel().
Referenced by opd_clear_modules().
void sfile_close_files | ( | void | ) |
close sample files
Definition at line 688 of file opd_sfile.c.
References close_sfile(), and for_each_sfile().
Referenced by opd_sighup().
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().
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().
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 267 of file opd_sfile.c.
References create_sfile(), find_kernel_image(), kern_cmdline::has_cmdline, sfile::hash, kern_cmdline::hash, HASH_BITS, hashes, operf_transient::in_kernel, kern_cmdline::kern_pid, kernel_cmdlines, list_add(), list_entry, list_for_each, lru, NO_COOKIE, OPD_LOST_KERNEL, OPD_LOST_NO_MAPPING, OPD_NO_APP_KERNEL_SAMPLE, OPD_NO_CTX, opd_stats, operf_transient::pc, sfile_get(), sfile_hash(), sfile_put(), operf_transient::tgid, trans, trans_match(), verbose_cookie(), verbprintf, and vsamples.
Referenced by opd_put_ibs_sample(), opd_put_sample(), and opd_put_spu_sample().
void sfile_get | ( | struct sfile * | sf | ) |
remove a sfile from the lru list, protecting it from sfile_lru_clear()
Definition at line 728 of file opd_sfile.c.
References list_del(), and sfile::lru.
Referenced by opd_open_sample_file(), and sfile_find().
static unsigned long sfile_hash | ( | struct transient const * | trans, | |
struct kernel_image * | ki | |||
) | [static] |
Hash the transient parameters for lookup.
Definition at line 89 of file opd_sfile.c.
References operf_transient::cpu, DCOOKIE_SHIFT, kernel_image::end, HASH_BITS, operf_transient::in_kernel, NO_COOKIE, separate_cpu, separate_kernel, separate_lib, separate_thread, kernel_image::start, operf_transient::tgid, operf_transient::tid, trans, and VMA_SHIFT.
Referenced by sfile_find().
void sfile_init | ( | void | ) |
initialise hashes
Definition at line 742 of file opd_sfile.c.
References HASH_SIZE, hashes, kernel_cmdlines, and list_init().
Referenced by opd_26_init().
static void sfile_log_arc | ( | struct transient const * | trans | ) | [static] |
Definition at line 491 of file opd_sfile.c.
References operf_transient::current, get_file(), operf_sfile::kernel, operf_transient::last, operf_transient::last_pc, odb_update_node(), OPD_LOST_SAMPLEFILE, opd_stats, operf_transient::pc, operf_kernel_image::start, trans, varcs, and verbose_arc().
Referenced by sfile_log_sample_count().
void sfile_log_sample | ( | struct transient const * | trans | ) |
Log the sample in a previously located sfile.
Definition at line 534 of file opd_sfile.c.
References sfile_log_sample_count(), and trans.
Referenced by opd_put_sample(), and opd_put_spu_sample().
void sfile_log_sample_count | ( | struct transient const * | trans, | |
unsigned long int | count | |||
) |
Log the event/cycle count in a previously located sfile
Definition at line 540 of file opd_sfile.c.
References operf_transient::current, get_file(), operf_sfile::kernel, operf_transient::last, odb_update_node_with_offset(), OPD_LOST_SAMPLEFILE, opd_stats, operf_transient::pc, sfile_log_arc(), operf_kernel_image::start, TRACING_ON, trans, verbose_sample(), and vsamples.
Referenced by opd_log_ibs_count(), opd_log_ibs_event(), and sfile_log_sample().
int sfile_lru_clear | ( | void | ) |
clear out a certain amount of LRU entries return non-zero if the lru is already empty
Definition at line 707 of file opd_sfile.c.
References always_true(), for_one_sfile(), list_empty(), list_entry, list_for_each_safe, lru, and LRU_AMOUNT.
Referenced by complete_dump(), and opd_open_sample_file().
void sfile_put | ( | struct sfile * | sf | ) |
add this sfile to lru list
Definition at line 735 of file opd_sfile.c.
References list_add_tail(), and sfile::lru.
Referenced by opd_open_sample_file(), and sfile_find().
void sfile_sync_files | ( | void | ) |
sync sample files
Definition at line 682 of file opd_sfile.c.
References for_each_sfile(), and sync_sfile().
Referenced by opd_alarm().
static int sync_sfile | ( | struct sfile * | sf, | |
void *data | __attribute__(unused) | |||
) | [static] |
Definition at line 604 of file opd_sfile.c.
References sfile::files, odb_sync(), op_nr_counters, and opd_ext_sfile_sync().
Referenced by sfile_sync_files().
static int trans_match | ( | struct transient const * | trans, | |
struct sfile const * | sfile, | |||
struct kernel_image const * | ki | |||
) | [static] |
Definition at line 169 of file opd_sfile.c.
References operf_transient::cpu, do_match(), operf_transient::tgid, operf_transient::tid, and trans.
Referenced by sfile_find().
Definition at line 482 of file opd_sfile.c.
References operf_transient::current, operf_transient::event, trans, and verbose_print_sample().
Referenced by sfile_log_arc().
Definition at line 455 of file opd_sfile.c.
References sfile::anon, sfile::app_cookie, sfile::cookie, kernel_image::end, anon_mapping::end, sfile::kernel, kernel_image::name, kernel_image::start, anon_mapping::start, anon_mapping::tgid, and verbose_cookie().
Referenced by verbose_arc(), and verbose_sample().
Definition at line 473 of file opd_sfile.c.
References operf_transient::current, operf_transient::event, trans, and verbose_print_sample().
Referenced by sfile_log_sample_count().
All sfiles are hashed into these lists
Definition at line 36 of file opd_sfile.c.
Referenced by sfile_find(), and sfile_init().
struct list_head kernel_cmdlines[HASH_SIZE] [static] |
Definition at line 75 of file opd_sfile.c.
Referenced by sfile_find(), and sfile_init().