diff options
author | Richard Braun <rbraun@sceen.net> | 2014-05-12 21:44:43 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2014-05-12 21:48:49 +0200 |
commit | 575b7eda73fcea52d94ec610bd430d389874ae13 (patch) | |
tree | 643362e7e88d45274180710cd81f4721c9371ac3 | |
parent | c120b2c3197d83452a8658aab6fc1d5a0c1d52e6 (diff) |
kern/thread: track tick events
-rw-r--r-- | kern/thread.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/kern/thread.c b/kern/thread.c index a7e1b8bb..325c4734 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -85,6 +85,7 @@ #include <kern/condition.h> #include <kern/cpumap.h> #include <kern/error.h> +#include <kern/evcnt.h> #include <kern/init.h> #include <kern/kmem.h> #include <kern/list.h> @@ -203,6 +204,8 @@ struct thread_runq { /* Ticks before the next balancing attempt when a run queue is idle */ unsigned int idle_balance_ticks; + + struct evcnt ev_tick; } __aligned(CPU_L1_SIZE); /* @@ -340,9 +343,17 @@ thread_runq_init_ts(struct thread_runq *runq) thread_ts_runq_init(runq->ts_runq_expired); } +static inline unsigned int +thread_runq_id(struct thread_runq *runq) +{ + return runq - thread_runqs; +} + static void __init thread_runq_init(struct thread_runq *runq, struct thread *booter) { + char name[EVCNT_NAME_SIZE]; + spinlock_init(&runq->lock); runq->nr_threads = 0; runq->current = booter; @@ -351,12 +362,8 @@ thread_runq_init(struct thread_runq *runq, struct thread *booter) runq->balancer = NULL; runq->idler = NULL; runq->idle_balance_ticks = (unsigned int)-1; -} - -static inline unsigned int -thread_runq_id(struct thread_runq *runq) -{ - return runq - thread_runqs; + snprintf(name, sizeof(name), "thread_tick/%u", thread_runq_id(runq)); + evcnt_register(&runq->ev_tick, name); } static inline struct thread_runq * @@ -1983,6 +1990,8 @@ thread_tick(void) spinlock_lock(&runq->lock); + evcnt_inc(&runq->ev_tick); + if (runq->nr_threads == 0) thread_balance_idle_tick(runq); |