System statistical and call profiling
support by Rogier Meurs <rogier@meurs.org>.
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
#define XT_WINI_IRQ 5 /* xt winchester */
|
||||
#define FLOPPY_IRQ 6 /* floppy disk */
|
||||
#define PRINTER_IRQ 7
|
||||
#define CMOS_CLOCK_IRQ 8
|
||||
#define KBD_AUX_IRQ 12 /* AUX (PS/2 mouse) port in kbd controller */
|
||||
#define AT_WINI_0_IRQ 14 /* at winchester controller 0 */
|
||||
#define AT_WINI_1_IRQ 15 /* at winchester controller 1 */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#define NCALLS 98 /* number of system calls allowed */
|
||||
#define NCALLS 100 /* number of system calls allowed */
|
||||
|
||||
#define EXIT 1
|
||||
#define FORK 2
|
||||
@@ -78,6 +78,8 @@
|
||||
#define FCHMOD 95 /* to FS */
|
||||
#define FCHOWN 96 /* to FS */
|
||||
#define GETSYSINFO_UP 97 /* to PM or FS */
|
||||
#define SPROF 98 /* to PM */
|
||||
#define CPROF 99 /* to PM */
|
||||
|
||||
/* Calls provided by PM and FS that are not part of the API */
|
||||
#define EXEC_NEWMEM 100 /* from FS or RS to PM: new memory map for
|
||||
|
||||
@@ -308,7 +308,11 @@
|
||||
# define SYS_SETGRANT (KERNEL_CALL + 34) /* sys_setgrant() */
|
||||
# define SYS_READBIOS (KERNEL_CALL + 35) /* sys_readbios() */
|
||||
|
||||
#define NR_SYS_CALLS 36 /* number of system calls */
|
||||
# define SYS_SPROF (KERNEL_CALL + 36) /* sys_sprof() */
|
||||
# define SYS_CPROF (KERNEL_CALL + 37) /* sys_cprof() */
|
||||
# define SYS_PROFBUF (KERNEL_CALL + 38) /* sys_profbuf() */
|
||||
|
||||
#define NR_SYS_CALLS 39 /* number of system calls */
|
||||
|
||||
/* Pseudo call for use in kernel/table.c. */
|
||||
#define SYS_ALL_CALLS (NR_SYS_CALLS)
|
||||
@@ -523,6 +527,14 @@
|
||||
#define SEL_ERRORFDS m8_p3
|
||||
#define SEL_TIMEOUT m8_p4
|
||||
|
||||
/* Field names for SYS_SPROF, _CPROF, _PROFBUF. */
|
||||
#define PROF_ACTION m7_i1 /* start/stop/reset/get */
|
||||
#define PROF_MEM_SIZE m7_i2 /* available memory for data */
|
||||
#define PROF_FREQ m7_i3 /* sample frequency */
|
||||
#define PROF_ENDPT m7_i4 /* endpoint of caller */
|
||||
#define PROF_CTL_PTR m7_p1 /* location of info struct */
|
||||
#define PROF_MEM_PTR m7_p2 /* location of profiling data */
|
||||
|
||||
/* Field names for GETSYSINFO_UP (PM). */
|
||||
#define SIU_WHAT m2_i1
|
||||
#define SIU_LEN m2_i2
|
||||
|
||||
@@ -127,4 +127,8 @@
|
||||
#define ASKDEV _ASKDEV
|
||||
#define FASTLOAD _FASTLOAD
|
||||
|
||||
/* Enable or disable system profiling. */
|
||||
#define SPROFILE 0 /* statistical profiling */
|
||||
#define CPROFILE 0 /* call profiling */
|
||||
|
||||
#endif /* _CONFIG_H */
|
||||
|
||||
109
include/minix/profile.h
Normal file
109
include/minix/profile.h
Normal file
@@ -0,0 +1,109 @@
|
||||
#ifndef _PROFILE_H
|
||||
#define _PROFILE_H
|
||||
|
||||
#include <ansi.h>
|
||||
|
||||
/*
|
||||
* Types relating to system profiling. Types are supplied for both
|
||||
* statistical profiling and call profiling.
|
||||
*/
|
||||
|
||||
#if SPROFILE
|
||||
|
||||
# define PROF_START 0 /* start statistical profiling */
|
||||
# define PROF_STOP 1 /* stop statistical profiling */
|
||||
|
||||
/* Info struct to be copied to from kernel to user program. */
|
||||
struct sprof_info_s {
|
||||
int mem_used;
|
||||
int total_samples;
|
||||
int idle_samples;
|
||||
int system_samples;
|
||||
int user_samples;
|
||||
} sprof_info_inst;
|
||||
|
||||
/* What a profiling sample looks like (used for sizeof()). */
|
||||
struct {
|
||||
char name[8];
|
||||
int pc;
|
||||
} sprof_sample;
|
||||
|
||||
#endif /* SPROFILE */
|
||||
|
||||
|
||||
#if CPROFILE
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
# define PROF_GET 2 /* get call profiling tables */
|
||||
# define PROF_RESET 3 /* reset call profiling tables */
|
||||
|
||||
/* Hash table size in each profiled process is table size + index size.
|
||||
*
|
||||
* Table size = CPROF_TABLE_SIZE * (CPROF_CPATH_MAX_LEN + 16).
|
||||
* Index size = CPROF_INDEX_SIZE * 4;
|
||||
*
|
||||
* Making CPROF_CPATH_MAX_LEN too small may cause call path overruns.
|
||||
* Making CPROF_TABLE_SIZE too small may cause table overruns.
|
||||
*
|
||||
* There are some restrictions: processes in the boot image are loaded
|
||||
* below 16 MB and the kernel is loaded in lower memory (below 640 kB). The
|
||||
* latter is reason to use a different size for the kernel table.
|
||||
*/
|
||||
#define CPROF_TABLE_SIZE_OTHER 3000 /* nr of slots in hash table */
|
||||
#define CPROF_TABLE_SIZE_KERNEL 1500 /* kernel has a smaller table */
|
||||
#define CPROF_CPATH_MAX_LEN 256 /* len of cpath string field: */
|
||||
/* MUST BE MULTIPLE OF WORDSIZE */
|
||||
|
||||
#define CPROF_INDEX_SIZE (10*1024)/* size of index to hash table */
|
||||
#define CPROF_STACK_SIZE 24 /* size of call stack */
|
||||
#define CPROF_PROCNAME_LEN 8 /* len of proc name field */
|
||||
|
||||
#define CPROF_CPATH_OVERRUN 0x1 /* call path overrun */
|
||||
#define CPROF_STACK_OVERRUN 0x2 /* call stack overrun */
|
||||
#define CPROF_TABLE_OVERRUN 0x4 /* hash table overrun */
|
||||
|
||||
#define CPROF_ANNOUNCE_OTHER 1 /* processes announce their profiling
|
||||
* data on n-th entry of procentry */
|
||||
#define CPROF_ACCOUNCE_KERNEL 10000 /* kernel announces not directly */
|
||||
|
||||
/* Prototype for function called by procentry to get size of table. */
|
||||
_PROTOTYPE(int profile_get_tbl_size, (void) );
|
||||
/* Prototype for function called by procentry to get announce number. */
|
||||
_PROTOTYPE(int profile_get_announce, (void) );
|
||||
/* Prototype for function called by procentry to announce control struct
|
||||
* and table locations to the kernel. */
|
||||
_PROTOTYPE(void profile_register, (void *ctl_ptr, void *tbl_ptr) );
|
||||
|
||||
/* Info struct to be copied from kernel to user program. */
|
||||
struct cprof_info_s {
|
||||
int mem_used;
|
||||
int err;
|
||||
} cprof_info_inst;
|
||||
|
||||
/* Data structures for control structure and profiling data table in the
|
||||
* in the profiled processes.
|
||||
*/
|
||||
struct cprof_ctl_s {
|
||||
int reset; /* kernel sets to have table reset */
|
||||
int slots_used; /* proc writes nr slots used in table */
|
||||
int err; /* proc writes errors that occurred */
|
||||
} cprof_ctl_inst;
|
||||
|
||||
struct cprof_tbl_s {
|
||||
struct cprof_tbl_s *next; /* next in chain */
|
||||
char cpath[CPROF_CPATH_MAX_LEN]; /* string with call path */
|
||||
int calls; /* nr of executions of path */
|
||||
u64_t cycles; /* execution time of path, in cycles */
|
||||
} cprof_tbl_inst;
|
||||
|
||||
#endif /* CPROFILE */
|
||||
|
||||
_PROTOTYPE( int sprofile, (int action, int size, int freq,
|
||||
void *ctl_ptr, void *mem_ptr) );
|
||||
|
||||
_PROTOTYPE( int cprofile, (int action, int size, void *ctl_ptr,
|
||||
void *mem_ptr) );
|
||||
|
||||
#endif /* PROFILE_H */
|
||||
|
||||
@@ -197,5 +197,13 @@ _PROTOTYPE( char *pci_dev_name, (U16_t vid, U16_t did) );
|
||||
_PROTOTYPE( char *pci_slot_name, (int devind) );
|
||||
_PROTOTYPE( int pci_set_acl, (struct rs_pci *rs_pci) );
|
||||
|
||||
/* Profiling. */
|
||||
_PROTOTYPE( int sys_sprof, (int action, int size, int freq, int endpt,
|
||||
void *ctl_ptr, void *mem_ptr) );
|
||||
_PROTOTYPE( int sys_cprof, (int action, int size, int endpt,
|
||||
void *ctl_ptr, void *mem_ptr) );
|
||||
_PROTOTYPE( int sys_profbuf, (void *ctl_ptr, void *mem_ptr) );
|
||||
|
||||
|
||||
#endif /* _SYSLIB_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user