Changeset 350f88d in rtems


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

sapi: Add SMP lock profiling app. level data

Location:
cpukit/sapi
Files:
2 edited

Legend:

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

    r29c9eb6 r350f88d  
    6767   * @see rtems_profiling_per_cpu.
    6868   */
    69   RTEMS_PROFILING_PER_CPU
     69  RTEMS_PROFILING_PER_CPU,
     70
     71  /**
     72   * @brief Type of SMP lock profiling data.
     73   *
     74   * @see rtems_profiling_smp_lock.
     75   */
     76  RTEMS_PROFILING_SMP_LOCK
    7077} rtems_profiling_type;
    7178
     
    171178
    172179/**
     180 * @brief Count of lock contention counters for SMP lock profiling.
     181 */
     182#define RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS 4
     183
     184/**
     185 * @brief SMP lock profiling data.
     186 *
     187 * The lock acquire attempt instant is the point in time right after the
     188 * interrupt disable action in the lock acquire sequence.
     189 *
     190 * The lock acquire instant is the point in time right after the lock
     191 * acquisition.  This is the begin of the critical section code execution.
     192 *
     193 * The lock acquire time is the time elapsed between the lock acquire attempt
     194 * instant and the lock acquire instant.
     195 *
     196 * The lock release instant is the point in time right before the interrupt
     197 * enable action in the lock release sequence.
     198 *
     199 * The lock section time is the time elapsed between the lock acquire instant
     200 * and the lock release instant.
     201 */
     202typedef struct {
     203  /**
     204   * @brief The profiling data header.
     205   */
     206  rtems_profiling_header header;
     207
     208  /**
     209   * @brief The lock name.
     210   */
     211  const char *name;
     212
     213  /**
     214   * @brief The maximum lock acquire time in nanoseconds.
     215   */
     216  uint32_t max_acquire_time;
     217
     218  /**
     219   * @brief The maximum lock section time in nanoseconds.
     220   */
     221  uint32_t max_section_time;
     222
     223  /**
     224   * @brief The count of lock uses.
     225   *
     226   * This value may overflow.
     227   */
     228  uint64_t usage_count;
     229
     230  /**
     231   * @brief Total lock acquire time in nanoseconds.
     232   *
     233   * The average lock acquire time is the total acquire time divided by the
     234   * lock usage count.  The ration of the total section and total acquire times
     235   * gives a measure for the lock contention.
     236   *
     237   * This value may overflow.
     238   */
     239  uint64_t total_acquire_time;
     240
     241  /**
     242   * @brief Total lock section time in nanoseconds.
     243   *
     244   * The average lock section time is the total section time divided by the
     245   * lock usage count.
     246   *
     247   * This value may overflow.
     248   */
     249  uint64_t total_section_time;
     250
     251  /**
     252   * @brief The counts of lock acquire operations by contention.
     253   *
     254   * The contention count for index N corresponds to a lock acquire attempt
     255   * with an initial queue length of N.  The last index corresponds to all
     256   * lock acquire attempts with an initial queue length greater than or equal
     257   * to RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS minus one.
     258   *
     259   * The values may overflow.
     260   */
     261  uint64_t contention_counts[RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS];
     262} rtems_profiling_smp_lock;
     263
     264/**
    173265 * @brief Collection of profiling data.
    174266 */
     
    183275   */
    184276  rtems_profiling_per_cpu per_cpu;
     277
     278  /**
     279   * @brief SMP lock profiling data if indicated by the header.
     280   */
     281  rtems_profiling_smp_lock smp_lock;
    185282} rtems_profiling_data;
    186283
  • cpukit/sapi/src/profilingreportxml.c

    r29c9eb6 r350f88d  
    131131}
    132132
     133static void report_smp_lock(context *ctx, const rtems_profiling_smp_lock *smp_lock)
     134{
     135  rtems_profiling_printf printf_func = ctx->printf_func;
     136  void *printf_arg = ctx->printf_arg;
     137  int rv;
     138  uint32_t i;
     139
     140  indent(ctx, 1);
     141  rv = (*printf_func)(
     142    printf_arg,
     143    "<SMPLockProfilingReport name=\"%s\">\n",
     144    smp_lock->name
     145  );
     146  update_retval(ctx, rv);
     147
     148  indent(ctx, 2);
     149  rv = (*printf_func)(
     150    printf_arg,
     151    "<MaxAcquireTime unit=\"ns\">%" PRIu32 "</MaxAcquireTime>\n",
     152    smp_lock->max_acquire_time
     153  );
     154  update_retval(ctx, rv);
     155
     156  indent(ctx, 2);
     157  rv = (*printf_func)(
     158    printf_arg,
     159    "<MaxSectionTime unit=\"ns\">%" PRIu32 "</MaxSectionTime>\n",
     160    smp_lock->max_section_time
     161  );
     162  update_retval(ctx, rv);
     163
     164  indent(ctx, 2);
     165  rv = (*printf_func)(
     166    printf_arg,
     167    "<UsageCount>%" PRIu64 "</UsageCount>\n",
     168    smp_lock->usage_count
     169  );
     170  update_retval(ctx, rv);
     171
     172  indent(ctx, 2);
     173  rv = (*printf_func)(
     174    printf_arg,
     175    "<TotalAcquireTime unit=\"ns\">%" PRIu64 "</TotalAcquireTime>\n",
     176    smp_lock->total_acquire_time
     177  );
     178  update_retval(ctx, rv);
     179
     180  indent(ctx, 2);
     181  rv = (*printf_func)(
     182    printf_arg,
     183    "<TotalSectionTime unit=\"ns\">%" PRIu64 "</TotalSectionTime>\n",
     184    smp_lock->total_section_time
     185  );
     186  update_retval(ctx, rv);
     187
     188  for (i = 0; i < RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS; ++i) {
     189    indent(ctx, 2);
     190    rv = (*printf_func)(
     191      printf_arg,
     192      "<ContentionCount initialQueueLength=\"%" PRIu32 "\">%"
     193        PRIu64 "</ContentionCount>\n",
     194      i,
     195      smp_lock->contention_counts[i]
     196    );
     197    update_retval(ctx, rv);
     198  }
     199
     200  indent(ctx, 1);
     201  rv = (*printf_func)(
     202    printf_arg,
     203    "</SMPLockProfilingReport>\n"
     204  );
     205  update_retval(ctx, rv);
     206}
     207
    133208static void report(void *arg, const rtems_profiling_data *data)
    134209{
     
    138213    case RTEMS_PROFILING_PER_CPU:
    139214      report_per_cpu(ctx, &data->per_cpu);
     215      break;
     216    case RTEMS_PROFILING_SMP_LOCK:
     217      report_smp_lock(ctx, &data->smp_lock);
    140218      break;
    141219  }
Note: See TracChangeset for help on using the changeset viewer.