VM: simplify slab allocator
[minix.git] / include / minix / profile.h
blobc3f5eed4692bfba1bade8689f055e5931663b6c7
1 #ifndef _PROFILE_H
2 #define _PROFILE_H
4 #include <minix/type.h>
6 /*
7 * Types relating to system profiling. Types are supplied for both
8 * statistical profiling and call profiling.
9 */
11 # define PROF_START 0 /* start statistical profiling */
12 # define PROF_STOP 1 /* stop statistical profiling */
14 #define PROF_RTC 0 /* RTC based profiling */
15 #define PROF_NMI 1 /* NMI based profiling, profiles kernel too */
17 /* Info struct to be copied to from kernel to user program. */
18 struct sprof_info_s {
19 int mem_used;
20 int total_samples;
21 int idle_samples;
22 int system_samples;
23 int user_samples;
26 /* What a profiling sample looks like (used for sizeof()). */
27 struct sprof_sample {
28 endpoint_t proc;
29 void * pc;
32 struct sprof_proc {
33 endpoint_t proc;
34 char name[PROC_NAME_LEN];
37 #include <minix/types.h>
39 # define PROF_GET 2 /* get call profiling tables */
40 # define PROF_RESET 3 /* reset call profiling tables */
42 /* Hash table size in each profiled process is table size + index size.
44 * Table size = CPROF_TABLE_SIZE * (CPROF_CPATH_MAX_LEN + 16).
45 * Index size = CPROF_INDEX_SIZE * 4;
47 * Making CPROF_CPATH_MAX_LEN too small may cause call path overruns.
48 * Making CPROF_TABLE_SIZE too small may cause table overruns.
50 * There are some restrictions: processes in the boot image are loaded
51 * below 16 MB and the kernel is loaded in lower memory (below 640 kB). The
52 * latter is reason to use a different size for the kernel table.
54 #define CPROF_TABLE_SIZE_OTHER 3000 /* nr of slots in hash table */
55 #define CPROF_TABLE_SIZE_KERNEL 1500 /* kernel has a smaller table */
56 #define CPROF_CPATH_MAX_LEN 256 /* len of cpath string field: */
57 /* MUST BE MULTIPLE OF WORDSIZE */
59 #define CPROF_INDEX_SIZE (10*1024)/* size of index to hash table */
60 #define CPROF_STACK_SIZE 24 /* size of call stack */
61 #define CPROF_PROCNAME_LEN 8 /* len of proc name field */
63 #define CPROF_CPATH_OVERRUN 0x1 /* call path overrun */
64 #define CPROF_STACK_OVERRUN 0x2 /* call stack overrun */
65 #define CPROF_TABLE_OVERRUN 0x4 /* hash table overrun */
67 #define CPROF_ANNOUNCE_OTHER 1 /* processes announce their profiling
68 * data on n-th entry of procentry */
69 #define CPROF_ACCOUNCE_KERNEL 10000 /* kernel announces not directly */
71 /* Prototype for function called by procentry to get size of table. */
72 int profile_get_tbl_size(void);
73 /* Prototype for function called by procentry to get announce number. */
74 int profile_get_announce(void);
75 /* Prototype for function called by procentry to announce control struct
76 * and table locations to the kernel. */
77 void profile_register(void *ctl_ptr, void *tbl_ptr);
79 /* Info struct to be copied from kernel to user program. */
80 struct cprof_info_s {
81 int mem_used;
82 int err;
85 /* Data structures for control structure and profiling data table in the
86 * in the profiled processes.
88 struct cprof_ctl_s {
89 int reset; /* kernel sets to have table reset */
90 int slots_used; /* proc writes nr slots used in table */
91 int err; /* proc writes errors that occurred */
94 struct cprof_tbl_s {
95 struct cprof_tbl_s *next; /* next in chain */
96 char cpath[CPROF_CPATH_MAX_LEN]; /* string with call path */
97 int calls; /* nr of executions of path */
98 u64_t cycles; /* execution time of path, in cycles */
101 int sprofile(int action, int size, int freq, int type, void *ctl_ptr,
102 void *mem_ptr);
104 int cprofile(int action, int size, void *ctl_ptr, void *mem_ptr);
106 #endif /* PROFILE_H */