blob: 86d5025c7d2e5fbb1ad12ea4dc0af3b106ad7eaf [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
The Android Open Source Project7984f7a2008-12-17 18:04:47 -080028#define UNUSED_EMBEDDED_OFFSET ~0LLU
Upstreamcc2ee171970-01-12 13:46:40 +000029
30/**
31 * Each set of sample files (where a set is over the physical counter
32 * types) will have one of these for it. We match against the
33 * descriptions here to find which sample DB file we need to modify.
34 *
35 * cg files are stored in the hash.
36 */
37struct sfile {
38 /** hash value for this sfile */
39 unsigned long hashval;
40 /** cookie value for the binary profiled */
41 cookie_t cookie;
42 /** cookie value for the application owner, INVALID_COOKIE if not set */
43 cookie_t app_cookie;
44 /** thread ID, -1 if not set */
45 pid_t tid;
46 /** thread group ID, -1 if not set */
47 pid_t tgid;
48 /** CPU number */
49 unsigned int cpu;
50 /** kernel image if applicable */
51 struct kernel_image * kernel;
52 /** anonymous mapping */
53 struct anon_mapping * anon;
The Android Open Source Project7984f7a2008-12-17 18:04:47 -080054 /** embedded offset for Cell BE SPU */
55 uint64_t embedded_offset;
Upstreamcc2ee171970-01-12 13:46:40 +000056
57 /** hash table link */
58 struct list_head hash;
59 /** lru list */
60 struct list_head lru;
61 /** true if this file should be ignored in profiles */
62 int ignored;
63 /** opened sample files */
64 odb_t files[OP_MAX_COUNTERS];
65 /** hash table of opened cg sample files */
66 struct list_head cg_hash[CG_HASH_SIZE];
67};
68
69/** a call-graph entry */
70struct cg_entry {
71 /** where arc is to */
72 struct sfile to;
73 /** next in the hash slot */
74 struct list_head hash;
75};
76
77/** clear any sfiles that are for the kernel */
78void sfile_clear_kernel(void);
79
The Android Open Source Project7984f7a2008-12-17 18:04:47 -080080struct anon_mapping;
81
82/** clear any sfiles for the given anon mapping */
83void sfile_clear_anon(struct anon_mapping *);
Upstreamcc2ee171970-01-12 13:46:40 +000084
85/** sync sample files */
86void sfile_sync_files(void);
87
88/** close sample files */
89void sfile_close_files(void);
90
91/** clear out a certain amount of LRU entries
92 * return non-zero if the lru is already empty */
93int sfile_lru_clear(void);
94
95/** remove a sfile from the lru list, protecting it from sfile_lru_clear() */
96void sfile_get(struct sfile * sf);
97
98/** add this sfile to lru list */
99void sfile_put(struct sfile * sf);
100
101/**
102 * Find the sfile for the current parameters. Note that is required
103 * that the PC value be set appropriately (needed for kernel images)
104 */
105struct sfile * sfile_find(struct transient const * trans);
106
107/** Log the sample in a previously located sfile. */
108void sfile_log_sample(struct transient const * trans);
109
110/** initialise hashes */
111void sfile_init(void);
112
113#endif /* OPD_SFILE_H */