00001 /** 00002 * @file daemon/opd_sfile.h 00003 * Management of sample files 00004 * 00005 * @remark Copyright 2002 OProfile authors 00006 * @remark Read the file COPYING 00007 * 00008 * @author John Levon 00009 * @author Philippe Elie 00010 */ 00011 00012 #ifndef OPD_SFILE_H 00013 #define OPD_SFILE_H 00014 00015 #include "opd_cookie.h" 00016 00017 #include "odb.h" 00018 #include "op_hw_config.h" 00019 #include "op_types.h" 00020 #include "op_list.h" 00021 00022 #include <sys/types.h> 00023 00024 struct kernel_image; 00025 struct transient; 00026 00027 #define CG_HASH_SIZE 16 00028 #define UNUSED_EMBEDDED_OFFSET ~0LLU 00029 00030 /** 00031 * Each set of sample files (where a set is over the physical counter 00032 * types) will have one of these for it. We match against the 00033 * descriptions here to find which sample DB file we need to modify. 00034 * 00035 * cg files are stored in the hash. 00036 */ 00037 struct sfile { 00038 /** hash value for this sfile */ 00039 unsigned long hashval; 00040 /** cookie value for the binary profiled */ 00041 cookie_t cookie; 00042 /** cookie value for the application owner, INVALID_COOKIE if not set */ 00043 cookie_t app_cookie; 00044 /** thread ID, -1 if not set */ 00045 pid_t tid; 00046 /** thread group ID, -1 if not set */ 00047 pid_t tgid; 00048 /** CPU number */ 00049 unsigned int cpu; 00050 /** kernel image if applicable */ 00051 struct kernel_image * kernel; 00052 /** anonymous mapping */ 00053 struct anon_mapping * anon; 00054 /** embedded offset for Cell BE SPU */ 00055 uint64_t embedded_offset; 00056 00057 /** hash table link */ 00058 struct list_head hash; 00059 /** lru list */ 00060 struct list_head lru; 00061 /** true if this file should be ignored in profiles */ 00062 int ignored; 00063 /** opened sample files */ 00064 odb_t files[OP_MAX_COUNTERS]; 00065 /** extended sample files */ 00066 odb_t * ext_files; 00067 /** hash table of opened cg sample files */ 00068 struct list_head cg_hash[CG_HASH_SIZE]; 00069 }; 00070 00071 /** a call-graph entry */ 00072 struct cg_entry { 00073 /** where arc is to */ 00074 struct sfile to; 00075 /** next in the hash slot */ 00076 struct list_head hash; 00077 }; 00078 00079 /** clear any sfiles that are for the kernel */ 00080 void sfile_clear_kernel(void); 00081 00082 struct anon_mapping; 00083 00084 /** clear any sfiles for the given anon mapping */ 00085 void sfile_clear_anon(struct anon_mapping *); 00086 00087 /** sync sample files */ 00088 void sfile_sync_files(void); 00089 00090 /** close sample files */ 00091 void sfile_close_files(void); 00092 00093 /** clear out a certain amount of LRU entries 00094 * return non-zero if the lru is already empty */ 00095 int sfile_lru_clear(void); 00096 00097 /** remove a sfile from the lru list, protecting it from sfile_lru_clear() */ 00098 void sfile_get(struct sfile * sf); 00099 00100 /** add this sfile to lru list */ 00101 void sfile_put(struct sfile * sf); 00102 00103 /** 00104 * Find the sfile for the current parameters. Note that is required 00105 * that the PC value be set appropriately (needed for kernel images) 00106 */ 00107 struct sfile * sfile_find(struct transient const * trans); 00108 00109 /** Log the sample in a previously located sfile. */ 00110 void sfile_log_sample(struct transient const * trans); 00111 00112 /** Log the event/cycle count in a previously located sfile */ 00113 void sfile_log_sample_count(struct transient const * trans, 00114 unsigned long int count); 00115 00116 /** initialise hashes */ 00117 void sfile_init(void); 00118 00119 #endif /* OPD_SFILE_H */
1.6.1