Changeset f980561 in rtems


Ignore:
Timestamp:
Mar 10, 2014, 9:04:09 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
53ad908
Parents:
350f88d
git-author:
Sebastian Huber <sebastian.huber@…> (03/10/14 09:04:09)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/14/14 07:46:49)
Message:

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.

Location:
cpukit
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/src/profilingiterate.c

    r350f88d rf980561  
    1818
    1919#include <rtems/profiling.h>
     20#include <rtems/counter.h>
     21#include <rtems.h>
     22
     23#include <string.h>
     24
     25static void per_cpu_stats_iterate(
     26  rtems_profiling_visitor visitor,
     27  void *visitor_arg,
     28  rtems_profiling_data *data
     29)
     30{
     31#ifdef RTEMS_PROFILING
     32  uint32_t n = rtems_smp_get_processor_count();
     33  uint32_t i;
     34
     35  memset(data, 0, sizeof(*data));
     36  data->header.type = RTEMS_PROFILING_PER_CPU;
     37  for (i = 0; i < n; ++i) {
     38    const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index(i);
     39    const Per_CPU_Stats *stats = &per_cpu->Stats;
     40    rtems_profiling_per_cpu *per_cpu_data = &data->per_cpu;
     41
     42    per_cpu_data->processor_index = i;
     43
     44    per_cpu_data->max_thread_dispatch_disabled_time =
     45      rtems_counter_ticks_to_nanoseconds(
     46        stats->max_thread_dispatch_disabled_time
     47      );
     48
     49    per_cpu_data->max_interrupt_time =
     50      rtems_counter_ticks_to_nanoseconds(stats->max_interrupt_time);
     51
     52    per_cpu_data->max_interrupt_delay =
     53      rtems_counter_ticks_to_nanoseconds(stats->max_interrupt_delay);
     54
     55    per_cpu_data->thread_dispatch_disabled_count =
     56      stats->thread_dispatch_disabled_count;
     57
     58    per_cpu_data->total_thread_dispatch_disabled_time =
     59      rtems_counter_ticks_to_nanoseconds(
     60        stats->total_thread_dispatch_disabled_time
     61      );
     62
     63    per_cpu_data->interrupt_count = stats->interrupt_count;
     64
     65    per_cpu_data->total_interrupt_time =
     66      rtems_counter_ticks_to_nanoseconds(
     67        stats->total_interrupt_time
     68      );
     69
     70    (*visitor)(visitor_arg, data);
     71  }
     72#else
     73  (void) visitor;
     74  (void) visitor_arg;
     75  (void) data;
     76#endif
     77}
    2078
    2179void rtems_profiling_iterate(
     
    2482)
    2583{
     84  rtems_profiling_data data;
     85
     86  per_cpu_stats_iterate(visitor, visitor_arg, &data);
    2687}
  • cpukit/score/Makefile.am

    r350f88d rf980561  
    4646include_rtems_score_HEADERS += include/rtems/score/prioritybitmap.h
    4747include_rtems_score_HEADERS += include/rtems/score/prioritybitmapimpl.h
     48include_rtems_score_HEADERS += include/rtems/score/profiling.h
    4849include_rtems_score_HEADERS += include/rtems/score/rbtree.h
    4950include_rtems_score_HEADERS += include/rtems/score/rbtreeimpl.h
     
    332333    src/assertthreaddispatchingrepressed.c \
    333334    src/interr.c src/isr.c src/wkspace.c src/wkstringduplicate.c
     335libscore_a_SOURCES += src/profilingisrentryexit.c
    334336
    335337EXTRA_DIST = src/Unlimited.txt
  • cpukit/score/include/rtems/score/percpu.h

    r350f88d rf980561  
    156156
    157157/**
     158 * @brief Per-CPU statistics.
     159 */
     160typedef struct {
     161#if defined( RTEMS_PROFILING )
     162  /**
     163   * @brief The thread dispatch disabled begin instant in CPU counter ticks.
     164   *
     165   * This value is used to measure the time of disabled thread dispatching.
     166   */
     167  CPU_Counter_ticks thread_dispatch_disabled_instant;
     168
     169  /**
     170   * @brief The maximum time of disabled thread dispatching in CPU counter
     171   * ticks.
     172   */
     173  CPU_Counter_ticks max_thread_dispatch_disabled_time;
     174
     175  /**
     176   * @brief The maximum time spent to process a single sequence of nested
     177   * interrupts in CPU counter ticks.
     178   *
     179   * This is the time interval between the change of the interrupt nest level
     180   * from zero to one and the change back from one to zero.
     181   */
     182  CPU_Counter_ticks max_interrupt_time;
     183
     184  /**
     185   * @brief The maximum interrupt delay in CPU counter ticks if supported by
     186   * the hardware.
     187   */
     188  CPU_Counter_ticks max_interrupt_delay;
     189
     190  /**
     191   * @brief Count of times when the thread dispatch disable level changes from
     192   * zero to one in thread context.
     193   *
     194   * This value may overflow.
     195   */
     196  uint64_t thread_dispatch_disabled_count;
     197
     198  /**
     199   * @brief Total time of disabled thread dispatching in CPU counter ticks.
     200   *
     201   * The average time of disabled thread dispatching is the total time of
     202   * disabled thread dispatching divided by the thread dispatch disabled
     203   * count.
     204   *
     205   * This value may overflow.
     206   */
     207  uint64_t total_thread_dispatch_disabled_time;
     208
     209  /**
     210   * @brief Count of times when the interrupt nest level changes from zero to
     211   * one.
     212   *
     213   * This value may overflow.
     214   */
     215  uint64_t interrupt_count;
     216
     217  /**
     218   * @brief Total time of interrupt processing in CPU counter ticks.
     219   *
     220   * The average time of interrupt processing is the total time of interrupt
     221   * processing divided by the interrupt count.
     222   *
     223   * This value may overflow.
     224   */
     225  uint64_t total_interrupt_time;
     226#endif /* defined( RTEMS_PROFILING ) */
     227} Per_CPU_Stats;
     228
     229/**
    158230 *  @brief Per CPU Core Structure
    159231 *
     
    237309    Per_CPU_State state;
    238310  #endif
     311
     312  Per_CPU_Stats Stats;
    239313} Per_CPU_Control;
    240314
  • cpukit/score/include/rtems/score/threaddispatch.h

    r350f88d rf980561  
    1717#include <rtems/score/percpu.h>
    1818#include <rtems/score/smplock.h>
     19#include <rtems/score/profiling.h>
    1920
    2021#ifdef __cplusplus
     
    141142  RTEMS_INLINE_ROUTINE uint32_t _Thread_Dispatch_increment_disable_level(void)
    142143  {
    143     uint32_t level = _Thread_Dispatch_disable_level;
    144 
    145     ++level;
    146     _Thread_Dispatch_disable_level = level;
    147 
    148     return level;
     144    uint32_t disable_level = _Thread_Dispatch_disable_level;
     145#if defined( RTEMS_PROFILING )
     146    ISR_Level level;
     147
     148    _ISR_Disable( level );
     149    _Profiling_Thread_dispatch_disable( _Per_CPU_Get(), disable_level );
     150#endif
     151
     152    ++disable_level;
     153    _Thread_Dispatch_disable_level = disable_level;
     154
     155#if defined( RTEMS_PROFILING )
     156    _ISR_Enable( level );
     157#endif
     158
     159    return disable_level;
    149160  }
    150161
     
    156167  RTEMS_INLINE_ROUTINE uint32_t _Thread_Dispatch_decrement_disable_level(void)
    157168  {
    158     uint32_t level = _Thread_Dispatch_disable_level;
    159 
    160     --level;
    161     _Thread_Dispatch_disable_level = level;
    162 
    163     return level;
     169    uint32_t disable_level = _Thread_Dispatch_disable_level;
     170#if defined( RTEMS_PROFILING )
     171    ISR_Level level;
     172
     173    _ISR_Disable( level );
     174#endif
     175
     176    --disable_level;
     177    _Thread_Dispatch_disable_level = disable_level;
     178
     179#if defined( RTEMS_PROFILING )
     180    _Profiling_Thread_dispatch_enable( _Per_CPU_Get(), disable_level );
     181    _ISR_Enable( level );
     182#endif
     183
     184    return disable_level;
    164185  }
    165186#endif /* RTEMS_SMP */
  • cpukit/score/preinstall.am

    r350f88d rf980561  
    163163        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmapimpl.h
    164164PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmapimpl.h
     165
     166$(PROJECT_INCLUDE)/rtems/score/profiling.h: include/rtems/score/profiling.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     167        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/profiling.h
     168PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/profiling.h
    165169
    166170$(PROJECT_INCLUDE)/rtems/score/rbtree.h: include/rtems/score/rbtree.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
  • cpukit/score/src/threaddispatch.c

    r350f88d rf980561  
    4141  per_cpu = _Per_CPU_Get();
    4242  _Assert( per_cpu->thread_dispatch_disable_level == 0 );
     43  _Profiling_Thread_dispatch_disable( per_cpu, 0 );
    4344  per_cpu->thread_dispatch_disable_level = 1;
    4445
     
    171172  _Assert( per_cpu->thread_dispatch_disable_level == 1 );
    172173  per_cpu->thread_dispatch_disable_level = 0;
     174  _Profiling_Thread_dispatch_enable( per_cpu, 0 );
    173175
    174176  _Per_CPU_Release_and_ISR_enable( per_cpu, level );
  • cpukit/score/src/threaddispatchdisablelevel.c

    r350f88d rf980561  
    1818#include <rtems/score/threaddispatch.h>
    1919#include <rtems/score/assert.h>
     20#include <rtems/score/profiling.h>
    2021#include <rtems/score/sysstate.h>
    2122
     
    9091
    9192  disable_level = self_cpu->thread_dispatch_disable_level;
     93  _Profiling_Thread_dispatch_disable( self_cpu, disable_level );
    9294  ++disable_level;
    9395  self_cpu->thread_dispatch_disable_level = disable_level;
     
    114116  _Assert( disable_level != 0 || _Giant.owner_cpu == NO_OWNER_CPU );
    115117
     118  _Profiling_Thread_dispatch_enable( self_cpu, disable_level );
    116119  _ISR_Enable_without_giant( isr_level );
    117120
  • cpukit/score/src/threadhandler.c

    r350f88d rf980561  
    154154
    155155      per_cpu->thread_dispatch_disable_level = 0;
     156      _Profiling_Thread_dispatch_enable( per_cpu, 0 );
    156157
    157158      _Per_CPU_Release( per_cpu );
  • cpukit/score/src/threadstartmultitasking.c

    r350f88d rf980561  
    3535   */
    3636  _Per_CPU_Acquire( self_cpu );
     37  _Profiling_Thread_dispatch_disable( self_cpu, 0 );
    3738  self_cpu->thread_dispatch_disable_level = 1;
    3839#endif
Note: See TracChangeset for help on using the changeset viewer.