forked from Imagelibrary/rtems
score: Add SMP lock profiling support
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <rtems/score/smplock.h>
|
||||
|
||||
static SMP_lock_Control chain_lock = SMP_LOCK_INITIALIZER;
|
||||
static SMP_lock_Control chain_lock = SMP_LOCK_INITIALIZER("chains");
|
||||
|
||||
static void chain_acquire( SMP_lock_Context *lock_context )
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <rtems/profiling.h>
|
||||
#include <rtems/counter.h>
|
||||
#include <rtems/score/smplock.h>
|
||||
#include <rtems.h>
|
||||
|
||||
#include <string.h>
|
||||
@@ -76,6 +77,66 @@ static void per_cpu_stats_iterate(
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(RTEMS_PROFILING) && defined(RTEMS_SMP)
|
||||
RTEMS_STATIC_ASSERT(
|
||||
RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS
|
||||
== SMP_LOCK_STATS_CONTENTION_COUNTS,
|
||||
smp_lock_contention_counts
|
||||
);
|
||||
#endif
|
||||
|
||||
static void smp_lock_stats_iterate(
|
||||
rtems_profiling_visitor visitor,
|
||||
void *visitor_arg,
|
||||
rtems_profiling_data *data
|
||||
)
|
||||
{
|
||||
#if defined(RTEMS_PROFILING) && defined(RTEMS_SMP)
|
||||
SMP_lock_Stats_iteration_context iteration_context;
|
||||
SMP_lock_Stats snapshot;
|
||||
char name[64];
|
||||
|
||||
memset(data, 0, sizeof(*data));
|
||||
data->header.type = RTEMS_PROFILING_SMP_LOCK;
|
||||
|
||||
_SMP_lock_Stats_iteration_start(&iteration_context);
|
||||
while (
|
||||
_SMP_lock_Stats_iteration_next(
|
||||
&iteration_context,
|
||||
&snapshot,
|
||||
&name[0],
|
||||
sizeof(name)
|
||||
)
|
||||
) {
|
||||
rtems_profiling_smp_lock *smp_lock_data = &data->smp_lock;
|
||||
|
||||
smp_lock_data->name = name;
|
||||
smp_lock_data->max_acquire_time =
|
||||
rtems_counter_ticks_to_nanoseconds(snapshot.max_acquire_time);
|
||||
smp_lock_data->max_section_time =
|
||||
rtems_counter_ticks_to_nanoseconds(snapshot.max_section_time);
|
||||
smp_lock_data->usage_count = snapshot.usage_count;
|
||||
smp_lock_data->total_acquire_time =
|
||||
rtems_counter_ticks_to_nanoseconds(snapshot.total_acquire_time);
|
||||
smp_lock_data->total_section_time =
|
||||
rtems_counter_ticks_to_nanoseconds(snapshot.total_section_time);
|
||||
|
||||
memcpy(
|
||||
&smp_lock_data->contention_counts[0],
|
||||
&snapshot.contention_counts[0],
|
||||
sizeof(smp_lock_data->contention_counts)
|
||||
);
|
||||
|
||||
(*visitor)(visitor_arg, data);
|
||||
}
|
||||
_SMP_lock_Stats_iteration_stop(&iteration_context);
|
||||
#else
|
||||
(void) visitor;
|
||||
(void) visitor_arg;
|
||||
(void) data;
|
||||
#endif
|
||||
}
|
||||
|
||||
void rtems_profiling_iterate(
|
||||
rtems_profiling_visitor visitor,
|
||||
void *visitor_arg
|
||||
@@ -84,4 +145,5 @@ void rtems_profiling_iterate(
|
||||
rtems_profiling_data data;
|
||||
|
||||
per_cpu_stats_iterate(visitor, visitor_arg, &data);
|
||||
smp_lock_stats_iterate(visitor, visitor_arg, &data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user