forked from Imagelibrary/rtems
score: Fix interrupt profiling
Callers of _Thread_Do_dispatch() must have a valid Per_CPU_Control::Stats::thread_dispatch_disabled_instant. Call _Profiling_Outer_most_interrupt_entry_and_exit() with the interrupt stack to not exceed Per_CPU_Control::Interrupt_frame. Update #2751.
This commit is contained in:
@@ -260,6 +260,9 @@ ppc_exc_wrap_async_normal:
|
|||||||
|
|
||||||
/* Increment ISR nest level and thread dispatch disable level */
|
/* Increment ISR nest level and thread dispatch disable level */
|
||||||
cmpwi ISR_NEST_REGISTER, 0
|
cmpwi ISR_NEST_REGISTER, 0
|
||||||
|
#ifdef RTEMS_PROFILING
|
||||||
|
cmpwi cr2, ISR_NEST_REGISTER, 0
|
||||||
|
#endif
|
||||||
addi ISR_NEST_REGISTER, ISR_NEST_REGISTER, 1
|
addi ISR_NEST_REGISTER, ISR_NEST_REGISTER, 1
|
||||||
addi DISPATCH_LEVEL_REGISTER, DISPATCH_LEVEL_REGISTER, 1
|
addi DISPATCH_LEVEL_REGISTER, DISPATCH_LEVEL_REGISTER, 1
|
||||||
stw ISR_NEST_REGISTER, PER_CPU_ISR_NEST_LEVEL(SELF_CPU_REGISTER)
|
stw ISR_NEST_REGISTER, PER_CPU_ISR_NEST_LEVEL(SELF_CPU_REGISTER)
|
||||||
@@ -285,6 +288,16 @@ ppc_exc_wrap_async_normal:
|
|||||||
bl bsp_interrupt_dispatch
|
bl bsp_interrupt_dispatch
|
||||||
#endif /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
|
#endif /* PPC_EXC_CONFIG_USE_FIXED_HANDLER */
|
||||||
|
|
||||||
|
#ifdef RTEMS_PROFILING
|
||||||
|
/* Update profiling data if necessary */
|
||||||
|
bne cr2, .Lprofiling_done
|
||||||
|
GET_SELF_CPU_CONTROL r3
|
||||||
|
mr r4, ENTRY_INSTANT_REGISTER
|
||||||
|
GET_TIME_BASE r5
|
||||||
|
bl _Profiling_Outer_most_interrupt_entry_and_exit
|
||||||
|
.Lprofiling_done:
|
||||||
|
#endif /* RTEMS_PROFILING */
|
||||||
|
|
||||||
/* Load some per-CPU variables */
|
/* Load some per-CPU variables */
|
||||||
GET_SELF_CPU_CONTROL SELF_CPU_REGISTER
|
GET_SELF_CPU_CONTROL SELF_CPU_REGISTER
|
||||||
lbz SCRATCH_0_REGISTER, PER_CPU_DISPATCH_NEEDED(SELF_CPU_REGISTER)
|
lbz SCRATCH_0_REGISTER, PER_CPU_DISPATCH_NEEDED(SELF_CPU_REGISTER)
|
||||||
@@ -304,37 +317,17 @@ ppc_exc_wrap_async_normal:
|
|||||||
or SCRATCH_0_REGISTER, SCRATCH_0_REGISTER, SCRATCH_1_REGISTER
|
or SCRATCH_0_REGISTER, SCRATCH_0_REGISTER, SCRATCH_1_REGISTER
|
||||||
subi DISPATCH_LEVEL_REGISTER, SCRATCH_2_REGISTER, 1
|
subi DISPATCH_LEVEL_REGISTER, SCRATCH_2_REGISTER, 1
|
||||||
or. SCRATCH_0_REGISTER, SCRATCH_0_REGISTER, DISPATCH_LEVEL_REGISTER
|
or. SCRATCH_0_REGISTER, SCRATCH_0_REGISTER, DISPATCH_LEVEL_REGISTER
|
||||||
#ifdef RTEMS_PROFILING
|
|
||||||
cmpwi cr2, SCRATCH_0_REGISTER, 0
|
|
||||||
subic. ISR_NEST_REGISTER, ISR_NEST_REGISTER, 1
|
|
||||||
#else
|
|
||||||
subi ISR_NEST_REGISTER, ISR_NEST_REGISTER, 1
|
subi ISR_NEST_REGISTER, ISR_NEST_REGISTER, 1
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Store thread dispatch disable and ISR nest levels */
|
/* Store thread dispatch disable and ISR nest levels */
|
||||||
stw DISPATCH_LEVEL_REGISTER, PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL(SELF_CPU_REGISTER)
|
stw DISPATCH_LEVEL_REGISTER, PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL(SELF_CPU_REGISTER)
|
||||||
stw ISR_NEST_REGISTER, PER_CPU_ISR_NEST_LEVEL(SELF_CPU_REGISTER)
|
stw ISR_NEST_REGISTER, PER_CPU_ISR_NEST_LEVEL(SELF_CPU_REGISTER)
|
||||||
|
|
||||||
#ifdef RTEMS_PROFILING
|
|
||||||
/* Store profiling data if necessary */
|
|
||||||
bne .Lprofiling_done
|
|
||||||
mr r3, SELF_CPU_REGISTER
|
|
||||||
mr r4, ENTRY_INSTANT_REGISTER
|
|
||||||
GET_TIME_BASE r5
|
|
||||||
bl _Profiling_Outer_most_interrupt_entry_and_exit
|
|
||||||
GET_SELF_CPU_CONTROL SELF_CPU_REGISTER
|
|
||||||
.Lprofiling_done:
|
|
||||||
#endif /* RTEMS_PROFILING */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check thread dispatch necessary, ISR dispatch disable and thread
|
* Check thread dispatch necessary, ISR dispatch disable and thread
|
||||||
* dispatch disable level.
|
* dispatch disable level.
|
||||||
*/
|
*/
|
||||||
#ifdef RTEMS_PROFILING
|
|
||||||
bne cr2, .Lthread_dispatch_done
|
|
||||||
#else
|
|
||||||
bne .Lthread_dispatch_done
|
bne .Lthread_dispatch_done
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Thread dispatch */
|
/* Thread dispatch */
|
||||||
.Ldo_thread_dispatch:
|
.Ldo_thread_dispatch:
|
||||||
|
|||||||
@@ -119,6 +119,12 @@ static inline void _Profiling_Update_max_interrupt_delay(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Updates the interrupt profiling statistics.
|
||||||
|
*
|
||||||
|
* Must be called with the interrupt stack and before the thread dispatch
|
||||||
|
* disable level is decremented.
|
||||||
|
*/
|
||||||
void _Profiling_Outer_most_interrupt_entry_and_exit(
|
void _Profiling_Outer_most_interrupt_entry_and_exit(
|
||||||
Per_CPU_Control *cpu,
|
Per_CPU_Control *cpu,
|
||||||
CPU_Counter_ticks interrupt_entry_instant,
|
CPU_Counter_ticks interrupt_entry_instant,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 embedded brains GmbH. All rights reserved.
|
* Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved.
|
||||||
*
|
*
|
||||||
* embedded brains GmbH
|
* embedded brains GmbH
|
||||||
* Dornierstr. 4
|
* Dornierstr. 4
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/score/profiling.h>
|
#include <rtems/score/profiling.h>
|
||||||
|
#include <rtems/score/assert.h>
|
||||||
|
|
||||||
void _Profiling_Outer_most_interrupt_entry_and_exit(
|
void _Profiling_Outer_most_interrupt_entry_and_exit(
|
||||||
Per_CPU_Control *cpu,
|
Per_CPU_Control *cpu,
|
||||||
@@ -24,19 +25,27 @@ void _Profiling_Outer_most_interrupt_entry_and_exit(
|
|||||||
CPU_Counter_ticks interrupt_exit_instant
|
CPU_Counter_ticks interrupt_exit_instant
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
#if defined( RTEMS_PROFILING )
|
#if defined(RTEMS_PROFILING)
|
||||||
Per_CPU_Stats *stats = &cpu->Stats;
|
Per_CPU_Stats *stats;
|
||||||
CPU_Counter_ticks delta = _CPU_Counter_difference(
|
CPU_Counter_ticks delta;
|
||||||
|
|
||||||
|
_Assert( cpu->isr_nest_level == 1 );
|
||||||
|
|
||||||
|
stats = &cpu->Stats;
|
||||||
|
delta = _CPU_Counter_difference(
|
||||||
interrupt_exit_instant,
|
interrupt_exit_instant,
|
||||||
interrupt_entry_instant
|
interrupt_entry_instant
|
||||||
);
|
);
|
||||||
|
|
||||||
++stats->interrupt_count;
|
++stats->interrupt_count;
|
||||||
stats->total_interrupt_time += delta;
|
stats->total_interrupt_time += delta;
|
||||||
|
|
||||||
if ( stats->max_interrupt_time < delta ) {
|
if ( stats->max_interrupt_time < delta ) {
|
||||||
stats->max_interrupt_time = delta;
|
stats->max_interrupt_time = delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( cpu->thread_dispatch_disable_level == 1 ) {
|
||||||
|
stats->thread_dispatch_disabled_instant = interrupt_entry_instant;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
(void) cpu;
|
(void) cpu;
|
||||||
(void) interrupt_entry_instant;
|
(void) interrupt_entry_instant;
|
||||||
|
|||||||
Reference in New Issue
Block a user