diff --git a/include/kernel/thread.h b/include/kernel/thread.h index 6c25712a..82d486a0 100644 --- a/include/kernel/thread.h +++ b/include/kernel/thread.h @@ -225,6 +225,12 @@ struct thread_stats { extern struct thread_stats thread_stats; +#define THREAD_STATS_INC(name) do { thread_stats.name++; } while(0) + +#else + +#define THREAD_STATS_INC(name) do { } while (0) + #endif #endif diff --git a/kernel/thread.c b/kernel/thread.c index 9ebce064..d7b62cfb 100644 --- a/kernel/thread.c +++ b/kernel/thread.c @@ -293,9 +293,7 @@ void thread_resched(void) ASSERT(in_critical_section()); #endif -#if THREAD_STATS - thread_stats.reschedules++; -#endif + THREAD_STATS_INC(reschedules); oldthread = current_thread; @@ -343,7 +341,7 @@ void thread_resched(void) } #if THREAD_STATS - thread_stats.context_switches++; + THREAD_STATS_INC(context_switches); if (oldthread == idle_thread) { bigtime_t now = current_time_hires(); @@ -395,9 +393,7 @@ void thread_yield(void) enter_critical_section(); -#if THREAD_STATS - thread_stats.yields++; -#endif + THREAD_STATS_INC(yields); /* we are yielding the cpu, so stick ourselves into the tail of the run queue and reschedule */ current_thread->state = THREAD_READY; @@ -434,7 +430,7 @@ void thread_preempt(void) #if THREAD_STATS if (current_thread != idle_thread) - thread_stats.preempts++; /* only track when a meaningful preempt happens */ + THREAD_STATS_INC(preempts); /* only track when a meaningful preempt happens */ #endif /* we are being preempted, so we get to go back into the front of the run queue if we have quantum left */ diff --git a/kernel/timer.c b/kernel/timer.c index 38bb9d1f..8149d3d0 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -207,9 +207,7 @@ static enum handler_return timer_tick(void *arg, time_t now) timer_t *timer; enum handler_return ret = INT_NO_RESCHEDULE; -#if THREAD_STATS - thread_stats.timer_ints++; -#endif + THREAD_STATS_INC(timer_ints); LTRACEF("now %d, sp 0x%x\n", now, __GET_FRAME()); @@ -229,9 +227,7 @@ static enum handler_return timer_tick(void *arg, time_t now) LTRACEF("dequeued timer %p, scheduled %d periodic %d\n", timer, timer->scheduled_time, timer->periodic_time); -#if THREAD_STATS - thread_stats.timers++; -#endif + THREAD_STATS_INC(timers); bool periodic = timer->periodic_time > 0; diff --git a/platform/armemu/interrupts.c b/platform/armemu/interrupts.c index a7cdefa3..66bd8f45 100644 --- a/platform/armemu/interrupts.c +++ b/platform/armemu/interrupts.c @@ -83,9 +83,7 @@ enum handler_return platform_irq(struct arm_iframe *frame) if (vector == 0xffffffff) return INT_NO_RESCHEDULE; -#if THREAD_STATS - thread_stats.interrupts++; -#endif + THREAD_STATS_INC(interrupts); // printf("platform_irq: spsr 0x%x, pc 0x%x, currthread %p, vector %d\n", frame->spsr, frame->pc, current_thread, vector); diff --git a/platform/omap3/interrupts.c b/platform/omap3/interrupts.c index 77c632d7..31ca7f13 100644 --- a/platform/omap3/interrupts.c +++ b/platform/omap3/interrupts.c @@ -123,9 +123,7 @@ enum handler_return platform_irq(struct arm_iframe *frame) // TRACEF("spsr 0x%x, pc 0x%x, currthread %p, vector %d, handler %p\n", frame->spsr, frame->pc, current_thread, vector, int_handler_table[vector].handler); -#if THREAD_STATS - thread_stats.interrupts++; -#endif + THREAD_STATS_INC(interrupts); // deliver the interrupt enum handler_return ret; diff --git a/platform/omap5912/interrupts.c b/platform/omap5912/interrupts.c index 730618f0..7e53e139 100644 --- a/platform/omap5912/interrupts.c +++ b/platform/omap5912/interrupts.c @@ -138,9 +138,7 @@ enum handler_return platform_irq(struct arm_iframe *frame) // get the current vector unsigned int vector; -#if THREAD_STATS - thread_stats.interrupts++; -#endif + THREAD_STATS_INC(interrupts); // read from the first level int handler vector = *ICReg(0, INTCON_SIR_IRQ); diff --git a/platform/pc/interrupts.c b/platform/pc/interrupts.c index c507c19a..5e24869b 100644 --- a/platform/pc/interrupts.c +++ b/platform/pc/interrupts.c @@ -201,13 +201,11 @@ enum handler_return platform_irq(struct x86_iframe *frame) // get the current vector unsigned int vector = frame->vector; -#if THREAD_STATS - thread_stats.interrupts++; -#endif - + THREAD_STATS_INC(interrupts); + // deliver the interrupt enum handler_return ret = INT_NO_RESCHEDULE; - + switch (vector) { case INT_GP_FAULT: x86_gpf_handler(frame);