panic() cleanup.
[minix.git] / include / minix / profile.h
blobafeeec29867b34101667b4653a4a20ed2fa91b99
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 #include <minix/types.h>
36 # define PROF_GET 2 /* get call profiling tables */
37 # define PROF_RESET 3 /* reset call profiling tables */
39 /* Hash table size in each profiled process is table size + index size.
41 * Table size = CPROF_TABLE_SIZE * (CPROF_CPATH_MAX_LEN + 16).
42 * Index size = CPROF_INDEX_SIZE * 4;
44 * Making CPROF_CPATH_MAX_LEN too small may cause call path overruns.
45 * Making CPROF_TABLE_SIZE too small may cause table overruns.
47 * There are some restrictions: processes in the boot image are loaded
48 * below 16 MB and the kernel is loaded in lower memory (below 640 kB). The
49 * latter is reason to use a different size for the kernel table.
51 #define CPROF_TABLE_SIZE_OTHER 3000 /* nr of slots in hash table */
52 #define CPROF_TABLE_SIZE_KERNEL 1500 /* kernel has a smaller table */
53 #define CPROF_CPATH_MAX_LEN 256 /* len of cpath string field: */
54 /* MUST BE MULTIPLE OF WORDSIZE */
56 #define CPROF_INDEX_SIZE (10*1024)/* size of index to hash table */
57 #define CPROF_STACK_SIZE 24 /* size of call stack */
58 #define CPROF_PROCNAME_LEN 8 /* len of proc name field */
60 #define CPROF_CPATH_OVERRUN 0x1 /* call path overrun */
61 #define CPROF_STACK_OVERRUN 0x2 /* call stack overrun */
62 #define CPROF_TABLE_OVERRUN 0x4 /* hash table overrun */
64 #define CPROF_ANNOUNCE_OTHER 1 /* processes announce their profiling
65 * data on n-th entry of procentry */
66 #define CPROF_ACCOUNCE_KERNEL 10000 /* kernel announces not directly */
68 /* Prototype for function called by procentry to get size of table. */
69 _PROTOTYPE(int profile_get_tbl_size, (void) );
70 /* Prototype for function called by procentry to get announce number. */
71 _PROTOTYPE(int profile_get_announce, (void) );
72 /* Prototype for function called by procentry to announce control struct
73 * and table locations to the kernel. */
74 _PROTOTYPE(void profile_register, (void *ctl_ptr, void *tbl_ptr) );
76 /* Info struct to be copied from kernel to user program. */
77 struct cprof_info_s {
78 int mem_used;
79 int err;
80 } cprof_info_inst;
82 /* Data structures for control structure and profiling data table in the
83 * in the profiled processes.
85 struct cprof_ctl_s {
86 int reset; /* kernel sets to have table reset */
87 int slots_used; /* proc writes nr slots used in table */
88 int err; /* proc writes errors that occurred */
89 } cprof_ctl_inst;
91 struct cprof_tbl_s {
92 struct cprof_tbl_s *next; /* next in chain */
93 char cpath[CPROF_CPATH_MAX_LEN]; /* string with call path */
94 int calls; /* nr of executions of path */
95 u64_t cycles; /* execution time of path, in cycles */
96 } cprof_tbl_inst;
98 _PROTOTYPE( int sprofile, (int action, int size, int freq,
99 void *ctl_ptr, void *mem_ptr) );
101 _PROTOTYPE( int cprofile, (int action, int size, void *ctl_ptr,
102 void *mem_ptr) );
104 #endif /* PROFILE_H */