summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-10 10:04:09 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-14 08:46:49 +0100
commitf980561ee073a7f24f65ed572852fa96edfa1708 (patch)
treea2e62dd469acbe201388c9b8a3e0ebd9d7277e9f /cpukit/score/src
parentsapi: Add SMP lock profiling app. level data (diff)
downloadrtems-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 'cpukit/score/src')
-rw-r--r--cpukit/score/src/profilingisrentryexit.c45
-rw-r--r--cpukit/score/src/threaddispatch.c2
-rw-r--r--cpukit/score/src/threaddispatchdisablelevel.c3
-rw-r--r--cpukit/score/src/threadhandler.c1
-rw-r--r--cpukit/score/src/threadstartmultitasking.c1
5 files changed, 52 insertions, 0 deletions
diff --git a/cpukit/score/src/profilingisrentryexit.c b/cpukit/score/src/profilingisrentryexit.c
new file mode 100644
index 0000000000..3367e9800e
--- /dev/null
+++ b/cpukit/score/src/profilingisrentryexit.c
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/score/profiling.h>
+
+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
+)
+{
+#if defined( RTEMS_PROFILING )
+ Per_CPU_Stats *stats = &per_cpu->Stats;
+ CPU_Counter_ticks delta = _CPU_Counter_difference(
+ interrupt_exit_instant,
+ interrupt_entry_instant
+ );
+
+ ++stats->interrupt_count;
+ stats->total_interrupt_time += delta;
+
+ if ( stats->max_interrupt_time < delta ) {
+ stats->max_interrupt_time = delta;
+ }
+#else
+ (void) per_cpu;
+ (void) interrupt_entry_instant;
+ (void) interrupt_exit_instant;
+#endif
+}
diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c
index ecf6810716..da357c4a44 100644
--- a/cpukit/score/src/threaddispatch.c
+++ b/cpukit/score/src/threaddispatch.c
@@ -40,6 +40,7 @@ void _Thread_Dispatch( void )
per_cpu = _Per_CPU_Get();
_Assert( per_cpu->thread_dispatch_disable_level == 0 );
+ _Profiling_Thread_dispatch_disable( per_cpu, 0 );
per_cpu->thread_dispatch_disable_level = 1;
#if defined( RTEMS_SMP )
@@ -170,6 +171,7 @@ void _Thread_Dispatch( void )
post_switch:
_Assert( per_cpu->thread_dispatch_disable_level == 1 );
per_cpu->thread_dispatch_disable_level = 0;
+ _Profiling_Thread_dispatch_enable( per_cpu, 0 );
_Per_CPU_Release_and_ISR_enable( per_cpu, level );
diff --git a/cpukit/score/src/threaddispatchdisablelevel.c b/cpukit/score/src/threaddispatchdisablelevel.c
index dc03a702a4..ab004c1662 100644
--- a/cpukit/score/src/threaddispatchdisablelevel.c
+++ b/cpukit/score/src/threaddispatchdisablelevel.c
@@ -17,6 +17,7 @@
#include <rtems/score/threaddispatch.h>
#include <rtems/score/assert.h>
+#include <rtems/score/profiling.h>
#include <rtems/score/sysstate.h>
#define NO_OWNER_CPU 0xffffffffU
@@ -89,6 +90,7 @@ uint32_t _Thread_Dispatch_increment_disable_level( void )
_Giant_Do_acquire( self_cpu );
disable_level = self_cpu->thread_dispatch_disable_level;
+ _Profiling_Thread_dispatch_disable( self_cpu, disable_level );
++disable_level;
self_cpu->thread_dispatch_disable_level = disable_level;
@@ -113,6 +115,7 @@ uint32_t _Thread_Dispatch_decrement_disable_level( void )
_Giant_Do_release( self_cpu );
_Assert( disable_level != 0 || _Giant.owner_cpu == NO_OWNER_CPU );
+ _Profiling_Thread_dispatch_enable( self_cpu, disable_level );
_ISR_Enable_without_giant( isr_level );
return disable_level;
diff --git a/cpukit/score/src/threadhandler.c b/cpukit/score/src/threadhandler.c
index 161bb43a6b..a85cebe905 100644
--- a/cpukit/score/src/threadhandler.c
+++ b/cpukit/score/src/threadhandler.c
@@ -153,6 +153,7 @@ void _Thread_Handler( void )
_Assert( _ISR_Get_level() != 0 );
per_cpu->thread_dispatch_disable_level = 0;
+ _Profiling_Thread_dispatch_enable( per_cpu, 0 );
_Per_CPU_Release( per_cpu );
diff --git a/cpukit/score/src/threadstartmultitasking.c b/cpukit/score/src/threadstartmultitasking.c
index 2c40170f36..5eee14c410 100644
--- a/cpukit/score/src/threadstartmultitasking.c
+++ b/cpukit/score/src/threadstartmultitasking.c
@@ -34,6 +34,7 @@ void _Thread_Start_multitasking( void )
* _Per_CPU_Release().
*/
_Per_CPU_Acquire( self_cpu );
+ _Profiling_Thread_dispatch_disable( self_cpu, 0 );
self_cpu->thread_dispatch_disable_level = 1;
#endif