Add some additional schedule instrumentation

This commit is contained in:
Gregory Nutt 2016-02-16 15:21:45 -06:00
parent 7f18b515f4
commit 384e51cb05
7 changed files with 75 additions and 47 deletions

2
arch

@ -1 +1 @@
Subproject commit 790c6be472dd5c386723e5b54bef495300ad6d7d
Subproject commit bceb7b7852a855d0de9afc4caeee801b4349db8e

View File

@ -145,13 +145,27 @@ int sched_lockcount(void);
void sched_note_start(FAR struct tcb_s *tcb);
void sched_note_stop(FAR struct tcb_s *tcb);
void sched_note_switch(FAR struct tcb_s *pFromTcb,
FAR struct tcb_s *pToTcb);
void sched_note_switch(FAR struct tcb_s *fromtcb,
FAR struct tcb_s *totcb);
#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
void sched_note_premption(FAR struct tcb_s *tcb, bool locked);
#else
# define sched_note_premption(t,l)
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
void sched_note_csection(FAR struct tcb_s *tcb, bool enter);
#else
# define sched_note_csection(t,e)
#endif
#else
# define sched_note_start(t)
# define sched_note_stop(t)
# define sched_note_switch(t1, t2)
# define sched_note_start(t)
# define sched_note_stop(t)
# define sched_note_switch(t1, t2)
# define sched_note_premption(t,l)
# define sched_note_csection(t,e)
#endif /* CONFIG_SCHED_INSTRUMENTATION */
#undef EXTERN

View File

@ -33,10 +33,6 @@
*
****************************************************************************/
/****************************************************************************
* Compilation Switches
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
@ -46,38 +42,6 @@
#include "libc.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Type Declarations
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Public Constant Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Constant Data
****************************************************************************/
/****************************************************************************
* Private Variables
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -108,4 +72,3 @@ int printf(FAR const IPTR char *fmt, ...)
return ret;
}

View File

@ -601,10 +601,32 @@ config SCHED_INSTRUMENTATION
If enabled, then the board-specific logic must provide the following
functions (see include/sched.h):
void sched_note_start(FAR struct tcb_s *tcb);
void sched_note_stop(FAR struct tcb_s *tcb);
void sched_note_switch(FAR struct tcb_s *pFromTcb, FAR struct tcb_s *pToTcb);
void sched_note_start(FAR struct tcb_s *tcb);
void sched_note_stop(FAR struct tcb_s *tcb);
void sched_note_switch(FAR struct tcb_s *pFromTcb, FAR struct tcb_s *pToTcb);
if SCHED_INSTRUMENTATION
config SCHED_INSTRUMENTATION_PREEMPTION
bool "Preemption monitor hooks
default n
---help---
Enables additional hooks for changes to pre-emption state. Board-
specific logic must provide this additional logic.
void sched_note_premption(FAR struct tcb_s *tcb, bool state);
config SCHED_INSTRUMENTATION_CSECTION
bool "Critical section monitor hooks
default n
depends on SMP
---help---
Enables additional hooks for entry and exit from critical sections.
Interrupts are disabled while within a critical section. Board-
specific logic must provide this additional logic.
void sched_note_csection(FAR struct tcb_s *tcb, bool state);
endif # SCHED_INSTRUMENTATION
endmenu # Performance Monitoring
menu "Files and I/O"

View File

@ -129,6 +129,12 @@ irqstate_t enter_critical_section(void)
rtcb->irqcount = 1;
g_cpu_irqset |= (1 << this_cpu());
#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
/* Note that we have entered the critical section */
sched_note_csection(rtcb, true);
#endif
}
/* Then disable interrupts (they may already be disabled, be we need to
@ -170,7 +176,12 @@ void leave_critical_section(irqstate_t flags)
}
else
{
/* NO.. Release the spinlock to allow other access. */
#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
/* No.. Note that we have entered the critical section */
sched_note_csection(rtcb, false);
#endif
/* Release the spinlock to allow other access. */
g_cpu_irqset &= ~(1 << this_cpu());
rtcb->irqcount = 0;

View File

@ -201,6 +201,17 @@ int sched_lock(void)
*/
rtcb->lockcount++;
#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
/* Check if we just acquired the lock */
if (rtcb->lockcount == 1)
{
/* Note that we have pre-emption locked */
sched_note_premption(rtcb, true);
}
#endif
}
return OK;

View File

@ -90,6 +90,13 @@ int sched_unlock(void)
if (rtcb->lockcount <= 0)
{
#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
/* Note that we no longer have pre-emption */
sched_note_premption(rtcb, false);
#endif
/* Set the lock count to zero */
rtcb->lockcount = 0;
#ifdef CONFIG_SMP