add/re-enable at_wini debug output
[minix3.git] / include / minix / profile.h
blob91193a4b91b4d8d3b589f7e797ec34f2e23afc14
1 #ifndef _PROFILE_H
2 #define _PROFILE_H
4 #include <ansi.h>
6 /*
7 * Types relating to system profiling. Types are supplied for both
8 * statistical profiling and call profiling.
9 */
11 #if SPROFILE
13 # define PROF_START 0 /* start statistical profiling */
14 # define PROF_STOP 1 /* stop statistical profiling */
16 /* Info struct to be copied to from kernel to user program. */
17 struct sprof_info_s {
18 int mem_used;
19 int total_samples;
20 int idle_samples;
21 int system_samples;
22 int user_samples;
23 } sprof_info_inst;
25 /* What a profiling sample looks like (used for sizeof()). */
26 struct {
27 char name[8];
28 int pc;
29 } sprof_sample;
31 #endif /* SPROFILE */
34 #if CPROFILE
36 #include <sys/types.h>
38 # define PROF_GET 2 /* get call profiling tables */
39 # define PROF_RESET 3 /* reset call profiling tables */
41 /* Hash table size in each profiled process is table size + index size.
43 * Table size = CPROF_TABLE_SIZE * (CPROF_CPATH_MAX_LEN + 16).
44 * Index size = CPROF_INDEX_SIZE * 4;
46 * Making CPROF_CPATH_MAX_LEN too small may cause call path overruns.
47 * Making CPROF_TABLE_SIZE too small may cause table overruns.
49 * There are some restrictions: processes in the boot image are loaded
50 * below 16 MB and the kernel is loaded in lower memory (below 640 kB). The
51 * latter is reason to use a different size for the kernel table.
53 #define CPROF_TABLE_SIZE_OTHER 3000 /* nr of slots in hash table */
54 #define CPROF_TABLE_SIZE_KERNEL 1500 /* kernel has a smaller table */
55 #define CPROF_CPATH_MAX_LEN 256 /* len of cpath string field: */
56 /* MUST BE MULTIPLE OF WORDSIZE */
58 #define CPROF_INDEX_SIZE (10*1024)/* size of index to hash table */
59 #define CPROF_STACK_SIZE 24 /* size of call stack */
60 #define CPROF_PROCNAME_LEN 8 /* len of proc name field */
62 #define CPROF_CPATH_OVERRUN 0x1 /* call path overrun */
63 #define CPROF_STACK_OVERRUN 0x2 /* call stack overrun */
64 #define CPROF_TABLE_OVERRUN 0x4 /* hash table overrun */
66 #define CPROF_ANNOUNCE_OTHER 1 /* processes announce their profiling
67 * data on n-th entry of procentry */
68 #define CPROF_ACCOUNCE_KERNEL 10000 /* kernel announces not directly */
70 /* Prototype for function called by procentry to get size of table. */
71 _PROTOTYPE(int profile_get_tbl_size, (void) );
72 /* Prototype for function called by procentry to get announce number. */
73 _PROTOTYPE(int profile_get_announce, (void) );
74 /* Prototype for function called by procentry to announce control struct
75 * and table locations to the kernel. */
76 _PROTOTYPE(void profile_register, (void *ctl_ptr, void *tbl_ptr) );
78 /* Info struct to be copied from kernel to user program. */
79 struct cprof_info_s {
80 int mem_used;
81 int err;
82 } cprof_info_inst;
84 /* Data structures for control structure and profiling data table in the
85 * in the profiled processes.
87 struct cprof_ctl_s {
88 int reset; /* kernel sets to have table reset */
89 int slots_used; /* proc writes nr slots used in table */
90 int err; /* proc writes errors that occurred */
91 } cprof_ctl_inst;
93 struct cprof_tbl_s {
94 struct cprof_tbl_s *next; /* next in chain */
95 char cpath[CPROF_CPATH_MAX_LEN]; /* string with call path */
96 int calls; /* nr of executions of path */
97 u64_t cycles; /* execution time of path, in cycles */
98 } cprof_tbl_inst;
100 #endif /* CPROFILE */
102 _PROTOTYPE( int sprofile, (int action, int size, int freq,
103 void *ctl_ptr, void *mem_ptr) );
105 _PROTOTYPE( int cprofile, (int action, int size, void *ctl_ptr,
106 void *mem_ptr) );
108 #endif /* PROFILE_H */