From: Philip Homburg Date: Mon, 10 Jul 2006 12:44:43 +0000 (+0000) Subject: Support for SI_CALL_STATS (counting systemcalls). X-Git-Tag: v3.1.3~258 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/examples/outline.c?a=commitdiff_plain;h=7ce17fe655b105092e5448edd7086a402c884573;p=minix.git Support for SI_CALL_STATS (counting systemcalls). --- diff --git a/servers/fs/main.c b/servers/fs/main.c index f69cb8db8..59c9dfcba 100644 --- a/servers/fs/main.c +++ b/servers/fs/main.c @@ -33,6 +33,10 @@ struct super_block; /* proto.h needs to know this */ #include "param.h" #include "super.h" +#if ENABLE_SYSCALL_STATS +EXTERN unsigned long calls_stats[NCALLS]; +#endif + FORWARD _PROTOTYPE( void fs_init, (void) ); FORWARD _PROTOTYPE( void get_work, (void) ); FORWARD _PROTOTYPE( void init_root, (void) ); @@ -102,6 +106,9 @@ PUBLIC int main() "FS, bad process, who = %d, call_nr = %d, endpt1 = %d\n", who_e, call_nr, m_in.endpt1); } else { +#if ENABLE_SYSCALL_STATS + calls_stats[call_nr]++; +#endif error = (*call_vec[call_nr])(); } diff --git a/servers/fs/misc.c b/servers/fs/misc.c index 40f77fcb5..bc2a81966 100644 --- a/servers/fs/misc.c +++ b/servers/fs/misc.c @@ -38,6 +38,10 @@ #define CORE_NAME "core" #define CORE_MODE 0777 /* mode to use on core image files */ +#if ENABLE_SYSCALL_STATS +PUBLIC unsigned long calls_stats[NCALLS]; +#endif + FORWARD _PROTOTYPE( void free_proc, (struct fproc *freed, int flags)); FORWARD _PROTOTYPE( int dumpcore, (int proc_e, struct mem_map *seg_ptr)); FORWARD _PROTOTYPE( int write_bytes, (struct inode *rip, off_t off, @@ -80,6 +84,12 @@ PUBLIC int do_getsysinfo() src_addr = (vir_bytes) dmap; len = sizeof(struct dmap) * NR_DEVICES; break; +#if ENABLE_SYSCALL_STATS + case SI_CALL_STATS: + src_addr = (vir_bytes) calls_stats; + len = sizeof(calls_stats); + break; +#endif default: return(EINVAL); } diff --git a/servers/pm/main.c b/servers/pm/main.c index 274b538f3..3f23a8566 100644 --- a/servers/pm/main.c +++ b/servers/pm/main.c @@ -29,6 +29,10 @@ #include "../../kernel/type.h" #include "../../kernel/proc.h" +#if ENABLE_SYSCALL_STATS +EXTERN unsigned long calls_stats[NCALLS]; +#endif + FORWARD _PROTOTYPE( void get_work, (void) ); FORWARD _PROTOTYPE( void pm_init, (void) ); FORWARD _PROTOTYPE( int get_nice_value, (int queue) ); @@ -119,6 +123,9 @@ PUBLIC int main() if ((unsigned) call_nr >= NCALLS) { result = ENOSYS; } else { +#if ENABLE_SYSCALL_STATS + calls_stats[call_nr]++; +#endif result = (*call_vec[call_nr])(); } break; diff --git a/servers/pm/misc.c b/servers/pm/misc.c index ca3d67f75..1c795fe4a 100644 --- a/servers/pm/misc.c +++ b/servers/pm/misc.c @@ -53,6 +53,10 @@ PRIVATE char *uts_tbl[] = { NULL, /* No bus */ /* No bus */ }; +#if ENABLE_SYSCALL_STATS +PUBLIC unsigned long calls_stats[NCALLS]; +#endif + /*===========================================================================* * do_allocmem * *===========================================================================*/ @@ -256,6 +260,12 @@ PUBLIC int do_getsysinfo() src_addr = (vir_bytes) &loadinfo; len = sizeof(struct loadinfo); break; +#if ENABLE_SYSCALL_STATS + case SI_CALL_STATS: + src_addr = (vir_bytes) calls_stats; + len = sizeof(calls_stats); + break; +#endif default: return(EINVAL); }