Changeset 29c9eb6 in rtems


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

sapi: Add per-CPU profiling application level data

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/include/rtems/profiling.h

    r4dad4b8 r29c9eb6  
    6262 */
    6363typedef enum {
     64  /**
     65   * @brief Type of per-CPU profiling data.
     66   *
     67   * @see rtems_profiling_per_cpu.
     68   */
     69  RTEMS_PROFILING_PER_CPU
    6470} rtems_profiling_type;
    6571
     
    7581
    7682/**
     83 * @brief Per-CPU profiling data.
     84 *
     85 * Theoretically all values in this structure can overflow, but the integer
     86 * types are chosen so that they cannot overflow in practice.  On systems with
     87 * a 1GHz CPU counter, the 64-bit integers can overflow in about 58 years.
     88 * Since the system should not spend most of the time in critical sections the
     89 * actual system run-time is much longer.  Several other counters in the system
     90 * will overflow before we get a problem in the profiling area.
     91 */
     92typedef struct {
     93  /**
     94   * @brief The profiling data header.
     95   */
     96  rtems_profiling_header header;
     97
     98  /**
     99   * @brief The processor index of this profiling data.
     100   */
     101  uint32_t processor_index;
     102
     103  /**
     104   * @brief The maximum time of disabled thread dispatching in nanoseconds.
     105   */
     106  uint32_t max_thread_dispatch_disabled_time;
     107
     108  /**
     109   * @brief Count of times when the thread dispatch disable level changes from
     110   * zero to one in thread context.
     111   *
     112   * This value may overflow.
     113   */
     114  uint64_t thread_dispatch_disabled_count;
     115
     116  /**
     117   * @brief Total time of disabled thread dispatching in nanoseconds.
     118   *
     119   * The average time of disabled thread dispatching is the total time of
     120   * disabled thread dispatching divided by the thread dispatch disabled
     121   * count.
     122   *
     123   * This value may overflow.
     124   */
     125  uint64_t total_thread_dispatch_disabled_time;
     126
     127  /**
     128   * @brief The maximum interrupt delay in nanoseconds if supported by the
     129   * hardware.
     130   *
     131   * The interrupt delay is the time interval from the recognition of an
     132   * interrupt signal by the hardware up to the execution start of the
     133   * corresponding high-level handler.  The interrupt delay is the main
     134   * contributor to the interrupt latency.  To measure this time hardware
     135   * support is required.  A time stamp unit must capture the interrupt signal
     136   * recognition time.  If no hardware support is available, then this field
     137   * will have a constant value of zero.
     138   */
     139  uint32_t max_interrupt_delay;
     140
     141  /**
     142   * @brief The maximum time spent to process a single sequence of nested
     143   * interrupts in nanoseconds.
     144   *
     145   * This is the time interval between the change of the interrupt nest level
     146   * from zero to one and the change back from one to zero.  It is the measured
     147   * worst-case execution time of interrupt service routines.  Please note that
     148   * in case of nested interrupts this time includes the combined execution
     149   * time and not the maximum time of an individual interrupt service routine.
     150   */
     151  uint32_t max_interrupt_time;
     152
     153  /**
     154   * @brief Count of times when the interrupt nest level changes from zero to
     155   * one.
     156   *
     157   * This value may overflow.
     158   */
     159  uint64_t interrupt_count;
     160
     161  /**
     162   * @brief Total time of interrupt processing in nanoseconds.
     163   *
     164   * The average time of interrupt processing is the total time of interrupt
     165   * processing divided by the interrupt count.
     166   *
     167   * This value may overflow.
     168   */
     169  uint64_t total_interrupt_time;
     170} rtems_profiling_per_cpu;
     171
     172/**
    77173 * @brief Collection of profiling data.
    78174 */
     
    82178   */
    83179  rtems_profiling_header header;
     180
     181  /**
     182   * @brief Per-CPU profiling data if indicated by the header.
     183   */
     184  rtems_profiling_per_cpu per_cpu;
    84185} rtems_profiling_data;
    85186
  • cpukit/sapi/src/profilingreportxml.c

    r4dad4b8 r29c9eb6  
    2020
    2121#ifdef RTEMS_PROFILING
     22
     23#include <inttypes.h>
    2224
    2325typedef struct {
     
    4850}
    4951
     52static void report_per_cpu(context *ctx, const rtems_profiling_per_cpu *per_cpu)
     53{
     54  rtems_profiling_printf printf_func = ctx->printf_func;
     55  void *printf_arg = ctx->printf_arg;
     56  int rv;
     57
     58  indent(ctx, 1);
     59  rv = (*printf_func)(
     60    printf_arg,
     61    "<PerCPUProfilingReport processorIndex=\"%" PRIu32 "\">\n",
     62    per_cpu->processor_index
     63  );
     64  update_retval(ctx, rv);
     65
     66  indent(ctx, 2);
     67  rv = (*printf_func)(
     68    printf_arg,
     69    "<MaxThreadDispatchDisabledTime unit=\"ns\">%" PRIu32
     70      "</MaxThreadDispatchDisabledTime>\n",
     71    per_cpu->max_thread_dispatch_disabled_time
     72  );
     73  update_retval(ctx, rv);
     74
     75  indent(ctx, 2);
     76  rv = (*printf_func)(
     77    printf_arg,
     78    "<ThreadDispatchDisabledCount>%" PRIu64 "</ThreadDispatchDisabledCount>\n",
     79    per_cpu->thread_dispatch_disabled_count
     80  );
     81  update_retval(ctx, rv);
     82
     83  indent(ctx, 2);
     84  rv = (*printf_func)(
     85    printf_arg,
     86    "<TotalThreadDispatchDisabledTime unit=\"ns\">%" PRIu64
     87      "</TotalThreadDispatchDisabledTime>\n",
     88    per_cpu->total_thread_dispatch_disabled_time
     89  );
     90  update_retval(ctx, rv);
     91
     92  indent(ctx, 2);
     93  rv = (*printf_func)(
     94    printf_arg,
     95    "<MaxInterruptTime unit=\"ns\">%" PRIu32
     96      "</MaxInterruptTime>\n",
     97    per_cpu->max_interrupt_time
     98  );
     99  update_retval(ctx, rv);
     100
     101  indent(ctx, 2);
     102  rv = (*printf_func)(
     103    printf_arg,
     104    "<MaxInterruptDelay unit=\"ns\">%" PRIu32 "</MaxInterruptDelay>\n",
     105    per_cpu->max_interrupt_delay
     106  );
     107  update_retval(ctx, rv);
     108
     109  indent(ctx, 2);
     110  rv = (*printf_func)(
     111    printf_arg,
     112    "<InterruptCount>%" PRIu64 "</InterruptCount>\n",
     113    per_cpu->interrupt_count
     114  );
     115  update_retval(ctx, rv);
     116
     117  indent(ctx, 2);
     118  rv = (*printf_func)(
     119    printf_arg,
     120    "<TotalInterruptTime unit=\"ns\">%" PRIu64 "</TotalInterruptTime>\n",
     121    per_cpu->total_interrupt_time
     122  );
     123  update_retval(ctx, rv);
     124
     125  indent(ctx, 1);
     126  rv = (*printf_func)(
     127    printf_arg,
     128    "</PerCPUProfilingReport>\n"
     129  );
     130  update_retval(ctx, rv);
     131}
     132
    50133static void report(void *arg, const rtems_profiling_data *data)
    51134{
    52135  context *ctx = arg;
     136
     137  switch (data->header.type) {
     138    case RTEMS_PROFILING_PER_CPU:
     139      report_per_cpu(ctx, &data->per_cpu);
     140      break;
     141  }
    53142}
    54143
  • testsuites/sptests/spprofiling01/spprofiling01.scn

    r4dad4b8 r29c9eb6  
    11*** TEST SPPROFILING 1 ***
    22  <ProfilingReport name="X">
     3    <PerCPUProfilingReport processorIndex="0">
     4      <MaxInterruptDelay unit="ns">0</MaxInterruptDelay>
     5      <MaxThreadDispatchDisabledTime unit="ns">0</MaxThreadDispatchDisabledTime>
     6      <ThreadDispatchDisabledCount>0</ThreadDispatchDisabledCount>
     7      <TotalThreadDispatchDisabledTime unit="ns">0</TotalThreadDispatchDisabledTime>
     8      <InterruptCount>0</InterruptCount>
     9      <TotalInterruptTime unit="ns">0</TotalInterruptTime>
     10    </PerCPUProfilingReport>
    311  </ProfilingReport>
    4 characters produced by rtems_profiling_report_xml(): 50
     12characters produced by rtems_profiling_report_xml(): 516
    513*** END OF TEST SPPROFILING 1 ***
Note: See TracChangeset for help on using the changeset viewer.