blob: 56ed25bf49b339a5bc8da1d36aa5129fab33b660 [file] [log] [blame]
Upstreamcc2ee171970-01-12 13:46:40 +00001/**
2 * @file daemon/opd_sfile.h
3 * Management of sample files
4 *
5 * @remark Copyright 2002 OProfile authors
6 * @remark Read the file COPYING
7 *
8 * @author John Levon
9 * @author Philippe Elie
10 */
11
12#ifndef OPD_SFILE_H
13#define OPD_SFILE_H
14
15#include "opd_cookie.h"
16
17#include "odb.h"
18#include "op_hw_config.h"
19#include "op_types.h"
20#include "op_list.h"
21
22#include <sys/types.h>
23
24struct kernel_image;
25struct transient;
26
27#define CG_HASH_SIZE 16
28
29/**
30 * Each set of sample files (where a set is over the physical counter
31 * types) will have one of these for it. We match against the
32 * descriptions here to find which sample DB file we need to modify.
33 *
34 * cg files are stored in the hash.
35 */
36struct sfile {
37 /** hash value for this sfile */
38 unsigned long hashval;
39 /** cookie value for the binary profiled */
40 cookie_t cookie;
41 /** cookie value for the application owner, INVALID_COOKIE if not set */
42 cookie_t app_cookie;
43 /** thread ID, -1 if not set */
44 pid_t tid;
45 /** thread group ID, -1 if not set */
46 pid_t tgid;
47 /** CPU number */
48 unsigned int cpu;
49 /** kernel image if applicable */
50 struct kernel_image * kernel;
51 /** anonymous mapping */
52 struct anon_mapping * anon;
53
54 /** hash table link */
55 struct list_head hash;
56 /** lru list */
57 struct list_head lru;
58 /** true if this file should be ignored in profiles */
59 int ignored;
60 /** opened sample files */
61 odb_t files[OP_MAX_COUNTERS];
62 /** hash table of opened cg sample files */
63 struct list_head cg_hash[CG_HASH_SIZE];
64};
65
66/** a call-graph entry */
67struct cg_entry {
68 /** where arc is to */
69 struct sfile to;
70 /** next in the hash slot */
71 struct list_head hash;
72};
73
74/** clear any sfiles that are for the kernel */
75void sfile_clear_kernel(void);
76
77/** clear any sfiles that are for anon mappings */
78void sfile_clear_anon(void);
79
80/** sync sample files */
81void sfile_sync_files(void);
82
83/** close sample files */
84void sfile_close_files(void);
85
86/** clear out a certain amount of LRU entries
87 * return non-zero if the lru is already empty */
88int sfile_lru_clear(void);
89
90/** remove a sfile from the lru list, protecting it from sfile_lru_clear() */
91void sfile_get(struct sfile * sf);
92
93/** add this sfile to lru list */
94void sfile_put(struct sfile * sf);
95
96/**
97 * Find the sfile for the current parameters. Note that is required
98 * that the PC value be set appropriately (needed for kernel images)
99 */
100struct sfile * sfile_find(struct transient const * trans);
101
102/** Log the sample in a previously located sfile. */
103void sfile_log_sample(struct transient const * trans);
104
105/** initialise hashes */
106void sfile_init(void);
107
108#endif /* OPD_SFILE_H */