Module: xenomai-forge Branch: master Commit: 34d685a9d7fbe14e9c70b845e903cb0dbf3b1cb7 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=34d685a9d7fbe14e9c70b845e903cb0dbf3b1cb7
Author: Philippe Gerum <r...@xenomai.org> Date: Sun Nov 27 19:10:34 2011 +0100 cobalt, copperplate: add syscalls to thread stats --- include/cobalt/nucleus/thread.h | 2 ++ include/cobalt/pthread.h | 7 ++++--- include/copperplate/threadobj.h | 8 +++++--- kernel/cobalt/nucleus/sched.c | 15 +++++++++------ kernel/cobalt/nucleus/shadow.c | 15 +++++++++------ kernel/cobalt/syscall.c | 1 + lib/copperplate/threadobj.c | 1 + 7 files changed, 31 insertions(+), 18 deletions(-) diff --git a/include/cobalt/nucleus/thread.h b/include/cobalt/nucleus/thread.h index d2b9ba2..a176408 100644 --- a/include/cobalt/nucleus/thread.h +++ b/include/cobalt/nucleus/thread.h @@ -143,6 +143,7 @@ typedef struct xnthread_info { unsigned long modeswitches; /**< Number of primary->secondary mode switches. */ unsigned long ctxswitches; /**< Number of context switches. */ unsigned long pagefaults; /**< Number of triggered page faults. */ + unsigned long syscalls; /**< Number of Xenomai syscalls. */ char name[XNOBJECT_NAME_LEN]; /**< Symbolic name assigned at creation. */ @@ -261,6 +262,7 @@ typedef struct xnthread { struct { xnstat_counter_t ssw; /* Primary -> secondary mode switch count */ xnstat_counter_t csw; /* Context switches (includes secondary -> primary switches) */ + xnstat_counter_t xsc; /* Xenomai syscalls */ xnstat_counter_t pf; /* Number of page faults */ xnstat_exectime_t account; /* Execution time accounting entity */ xnstat_exectime_t lastperiod; /* Interval marker for execution time reports */ diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h index 12a0986..1be4bde 100644 --- a/include/cobalt/pthread.h +++ b/include/cobalt/pthread.h @@ -172,9 +172,10 @@ struct cobalt_cond; struct cobalt_threadstat { unsigned long status; unsigned long long xtime; - int msw; - int csw; - int pf; + unsigned long msw; + unsigned long csw; + unsigned long xsc; + unsigned long pf; }; #if defined(__KERNEL__) || defined(__XENO_SIM__) diff --git a/include/copperplate/threadobj.h b/include/copperplate/threadobj.h index 5d6410c..743e302 100644 --- a/include/copperplate/threadobj.h +++ b/include/copperplate/threadobj.h @@ -40,11 +40,13 @@ struct threadobj_stat { /** Execution time in primary mode (ns). */ ticks_t xtime; /** Number of primary->secondary mode switches. */ - int msw; + unsigned long msw; /** Number of context switches. */ - int csw; + unsigned long csw; + /** Number of Xenomai syscalls. */ + unsigned long xsc; /** Number of page faults. */ - int pf; + unsigned long pf; }; #define SCHED_RT SCHED_COBALT diff --git a/kernel/cobalt/nucleus/sched.c b/kernel/cobalt/nucleus/sched.c index 4bdfe0b..d4261b8 100644 --- a/kernel/cobalt/nucleus/sched.c +++ b/kernel/cobalt/nucleus/sched.c @@ -763,6 +763,7 @@ struct vfile_schedstat_data { char name[XNOBJECT_NAME_LEN]; unsigned long ssw; unsigned long csw; + unsigned long xsc; unsigned long pf; xnticks_t exectime_period; xnticks_t account_period; @@ -821,6 +822,7 @@ static int vfile_schedstat_next(struct xnvfile_snapshot_iterator *it, p->state = xnthread_state_flags(thread); p->ssw = xnstat_counter_get(&thread->stat.ssw); p->csw = xnstat_counter_get(&thread->stat.csw); + p->xsc = xnstat_counter_get(&thread->stat.xsc); p->pf = xnstat_counter_get(&thread->stat.pf); period = sched->last_account_switch - thread->stat.lastperiod.start; @@ -860,6 +862,7 @@ scan_irqs: p->pid = 0; p->state = 0; p->ssw = 0; + p->xsc = 0; p->pf = 0; return 1; @@ -873,9 +876,9 @@ static int vfile_schedstat_show(struct xnvfile_snapshot_iterator *it, if (p == NULL) xnvfile_printf(it, - "%-3s %-6s %-10s %-10s %-4s %-8s %5s" + "%-3s %-6s %-10s %-10s %-10s %-4s %-8s %5s" " %s\n", - "CPU", "PID", "MSW", "CSW", "PF", "STAT", "%CPU", + "CPU", "PID", "MSW", "CSW", "XSC", "PF", "STAT", "%CPU", "NAME"); else { if (p->account_period) { @@ -888,9 +891,9 @@ static int vfile_schedstat_show(struct xnvfile_snapshot_iterator *it, p->account_period, NULL); } xnvfile_printf(it, - "%3u %-6d %-10lu %-10lu %-4lu %.8lx %3u.%u" + "%3u %-6d %-10lu %-10lu %-10lu %-4lu %.8lx %3u.%u" " %s\n", - p->cpu, p->pid, p->ssw, p->csw, p->pf, p->state, + p->cpu, p->pid, p->ssw, p->csw, p->xsc, p->pf, p->state, usage / 10, usage % 10, p->name); } @@ -905,8 +908,8 @@ static int vfile_schedacct_show(struct xnvfile_snapshot_iterator *it, if (p == NULL) return 0; - xnvfile_printf(it, "%u %d %lu %lu %lu %.8lx %Lu %Lu %Lu %s\n", - p->cpu, p->pid, p->ssw, p->csw, p->pf, p->state, + xnvfile_printf(it, "%u %d %lu %lu %lu %lu %.8lx %Lu %Lu %Lu %s\n", + p->cpu, p->pid, p->ssw, p->csw, p->xsc, p->pf, p->state, xnarch_tsc_to_ns(p->account_period), xnarch_tsc_to_ns(p->exectime_period), xnarch_tsc_to_ns(p->exectime_total), diff --git a/kernel/cobalt/nucleus/shadow.c b/kernel/cobalt/nucleus/shadow.c index 991438b..1c7d91e 100644 --- a/kernel/cobalt/nucleus/shadow.c +++ b/kernel/cobalt/nucleus/shadow.c @@ -1726,6 +1726,7 @@ static int xnshadow_sys_current_info(xnthread_info_t __user *u_info) info.modeswitches = xnstat_counter_get(&cur->stat.ssw); info.ctxswitches = xnstat_counter_get(&cur->stat.csw); info.pagefaults = xnstat_counter_get(&cur->stat.pf); + info.syscalls = xnstat_counter_get(&cur->stat.xsc); strcpy(info.name, xnthread_name(cur)); return __xn_safe_copy_to_user(u_info, &info, sizeof(*u_info)); @@ -1992,7 +1993,6 @@ static inline int do_hisyscall_event(unsigned event, unsigned domid, void *data) } err = se->svc(__xn_reg_arglist(regs)); - if (err == -ENOSYS && (sysflags & __xn_exec_adaptive) != 0) { if (switched) { switched = 0; @@ -2030,9 +2030,11 @@ static inline int do_hisyscall_event(unsigned event, unsigned domid, void *data) ret_handled: - /* Update the userland-visible state. */ - if (thread) + /* Update the stats and userland-visible state. */ + if (thread) { + xnstat_counter_inc(&thread->stat.xsc); *thread->u_mode = thread->state; + } trace_mark(xn_nucleus, syscall_histage_exit, "ret %ld", __xn_reg_rval(regs)); @@ -2169,7 +2171,6 @@ static inline int do_losyscall_event(unsigned event, unsigned domid, void *data) switched = 0; err = se->svc(__xn_reg_arglist(regs)); - if (err == -ENOSYS && (sysflags & __xn_exec_adaptive) != 0) { if (switched) { switched = 0; @@ -2203,9 +2204,11 @@ static inline int do_losyscall_event(unsigned event, unsigned domid, void *data) ret_handled: - /* Update the userland-visible state. */ - if (thread) + /* Update the stats and userland-visible state. */ + if (thread) { + xnstat_counter_inc(&thread->stat.xsc); *thread->u_mode = thread->state; + } trace_mark(xn_nucleus, syscall_lostage_exit, "ret %ld", __xn_reg_rval(regs)); diff --git a/kernel/cobalt/syscall.c b/kernel/cobalt/syscall.c index 96c7634..b000d26 100644 --- a/kernel/cobalt/syscall.c +++ b/kernel/cobalt/syscall.c @@ -576,6 +576,7 @@ static int __pthread_stat(unsigned long tid, stat.xtime = xnarch_tsc_to_ns(xtime); stat.msw = xnstat_counter_get(&thread->stat.ssw); stat.csw = xnstat_counter_get(&thread->stat.csw); + stat.xsc = xnstat_counter_get(&thread->stat.xsc); stat.pf = xnstat_counter_get(&thread->stat.pf); stat.status = xnthread_state_flags(thread); diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c index 53e4508..c086c80 100644 --- a/lib/copperplate/threadobj.c +++ b/lib/copperplate/threadobj.c @@ -400,6 +400,7 @@ int threadobj_stat(struct threadobj *thobj, struct threadobj_stat *p) /* thobj-> p->xtime = stat.xtime; p->msw = stat.msw; p->csw = stat.csw; + p->xsc = stat.xsc; p->pf = stat.pf; return 0; _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git