diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-03-10 10:04:09 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-03-14 08:46:49 +0100 |
commit | f980561ee073a7f24f65ed572852fa96edfa1708 (patch) | |
tree | a2e62dd469acbe201388c9b8a3e0ebd9d7277e9f /cpukit/score/include/rtems/score/profiling.h | |
parent | sapi: Add SMP lock profiling app. level data (diff) | |
download | rtems-f980561ee073a7f24f65ed572852fa96edfa1708.tar.bz2 |
score: Add per-CPU profiling
Add per-CPU profiling stats API. Implement the thread dispatch disable
level profiling. The interrupt profiling must be implemented in CPU
port specific parts (mostly assembler code). Add a support function
_Profiling_Outer_most_interrupt_entry_and_exit() for this purpose.
Diffstat (limited to '')
-rw-r--r-- | cpukit/score/include/rtems/score/profiling.h | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/cpukit/score/include/rtems/score/profiling.h b/cpukit/score/include/rtems/score/profiling.h new file mode 100644 index 0000000000..468c124450 --- /dev/null +++ b/cpukit/score/include/rtems/score/profiling.h @@ -0,0 +1,113 @@ +/** + * @file + * + * @ingroup ScoreProfiling + * + * @brief Profiling Support API + */ + +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_PROFILING +#define _RTEMS_SCORE_PROFILING + +#include <rtems/score/percpu.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ScoreProfiling Profiling Support + * + * @brief Profiling support. + * + * @{ + */ + +static inline void _Profiling_Thread_dispatch_disable( + Per_CPU_Control *per_cpu, + uint32_t previous_thread_dispatch_disable_level +) +{ +#if defined( RTEMS_PROFILING ) + if ( previous_thread_dispatch_disable_level == 0 ) { + Per_CPU_Stats *stats = &per_cpu->Stats; + + stats->thread_dispatch_disabled_instant = _CPU_Counter_read(); + ++stats->thread_dispatch_disabled_count; + } +#else + (void) per_cpu; + (void) previous_thread_dispatch_disable_level; +#endif +} + +static inline void _Profiling_Thread_dispatch_enable( + Per_CPU_Control *per_cpu, + uint32_t new_thread_dispatch_disable_level +) +{ +#if defined( RTEMS_PROFILING ) + if ( new_thread_dispatch_disable_level == 0 ) { + Per_CPU_Stats *stats = &per_cpu->Stats; + CPU_Counter_ticks now = _CPU_Counter_read(); + CPU_Counter_ticks delta = _CPU_Counter_difference( + now, + stats->thread_dispatch_disabled_instant + ); + + stats->total_thread_dispatch_disabled_time += delta; + + if ( stats->max_thread_dispatch_disabled_time < delta ) { + stats->max_thread_dispatch_disabled_time = delta; + } + } +#else + (void) per_cpu; + (void) new_thread_dispatch_disable_level; +#endif +} + +static inline void _Profiling_Update_max_interrupt_delay( + Per_CPU_Control *per_cpu, + CPU_Counter_ticks interrupt_delay +) +{ +#if defined( RTEMS_PROFILING ) + Per_CPU_Stats *stats = &per_cpu->Stats; + + if ( stats->max_interrupt_delay < interrupt_delay ) { + stats->max_interrupt_delay = interrupt_delay; + } +#else + (void) per_cpu; + (void) interrupt_delay; +#endif +} + +void _Profiling_Outer_most_interrupt_entry_and_exit( + Per_CPU_Control *per_cpu, + CPU_Counter_ticks interrupt_entry_instant, + CPU_Counter_ticks interrupt_exit_instant +); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_PROFILING */ |