scheduler instrumentation: Improvements to buffering logic
This commit is contained in:
parent
ccbf514233
commit
adf3c73219
@ -116,22 +116,35 @@ static inline unsigned int note_next(unsigned int ndx, unsigned int offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: note_systime
|
* Name: note_common
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Save the current system time in the note structure as a 32-bit value.
|
* Fill in some of the common fields in the note structure.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* note - The note structure to use
|
* tcb - The TCB containing the information
|
||||||
|
* note - The common note structure to use
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void note_systime(FAR struct note_common_s *note)
|
static void note_common(FAR struct tcb_s *tcb, FAR struct note_common_s *note,
|
||||||
|
uint8_t length, uint8_t type)
|
||||||
{
|
{
|
||||||
uint32_t systime = (uint32_t)clock_systimer();
|
uint32_t systime = (uint32_t)clock_systimer();
|
||||||
|
|
||||||
|
/* Save all of the common fields */
|
||||||
|
|
||||||
|
note->nc_length = length;
|
||||||
|
note->nc_type = type;
|
||||||
|
note->nc_priority = tcb->sched_priority;
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
note->nc_cpu = tcb->cpu;
|
||||||
|
#endif
|
||||||
|
note->nc_pid[0] = (uint8_t)(tcb->pid & 0xff);
|
||||||
|
note->nc_pid[1] = (uint8_t)((tcb->pid >> 8) & 0xff);
|
||||||
|
|
||||||
/* Save the LS 32-bits of the system timer in little endian order */
|
/* Save the LS 32-bits of the system timer in little endian order */
|
||||||
|
|
||||||
@ -309,16 +322,7 @@ void sched_note_start(FAR struct tcb_s *tcb)
|
|||||||
|
|
||||||
/* Finish formatting the note */
|
/* Finish formatting the note */
|
||||||
|
|
||||||
note.nsa_cmn.nc_length = length;
|
note_common(tcb, ¬e.nsa_cmn, length, NOTE_START);
|
||||||
note.nsa_cmn.nc_type = NOTE_START;
|
|
||||||
note.nsa_cmn.nc_priority = tcb->sched_priority;
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
note.nsa_cmn.nc_cpu = tcb->cpu;
|
|
||||||
#endif
|
|
||||||
note.nsa_cmn.nc_pid[0] = (uint8_t)(tcb->pid & 0xff);
|
|
||||||
note.nsa_cmn.nc_pid[1] = (uint8_t)((tcb->pid >> 8) & 0xff);
|
|
||||||
|
|
||||||
note_systime((FAR struct note_common_s *)¬e);
|
|
||||||
|
|
||||||
/* Add the note to circular buffer */
|
/* Add the note to circular buffer */
|
||||||
|
|
||||||
@ -331,16 +335,7 @@ void sched_note_stop(FAR struct tcb_s *tcb)
|
|||||||
|
|
||||||
/* Format the note */
|
/* Format the note */
|
||||||
|
|
||||||
note.nsp_cmn.nc_length = sizeof(struct note_stop_s);
|
note_common(tcb, ¬e.nsp_cmn, sizeof(struct note_stop_s), NOTE_STOP);
|
||||||
note.nsp_cmn.nc_type = NOTE_STOP;
|
|
||||||
note.nsp_cmn.nc_priority = tcb->sched_priority;
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
note.nsp_cmn.nc_cpu = tcb->cpu;
|
|
||||||
#endif
|
|
||||||
note.nsp_cmn.nc_pid[0] = (uint8_t)(tcb->pid & 0xff);
|
|
||||||
note.nsp_cmn.nc_pid[1] = (uint8_t)((tcb->pid >> 8) & 0xff);
|
|
||||||
|
|
||||||
note_systime((FAR struct note_common_s *)¬e);
|
|
||||||
|
|
||||||
/* Add the note to circular buffer */
|
/* Add the note to circular buffer */
|
||||||
|
|
||||||
@ -353,18 +348,9 @@ void sched_note_suspend(FAR struct tcb_s *tcb)
|
|||||||
|
|
||||||
/* Format the note */
|
/* Format the note */
|
||||||
|
|
||||||
note.nsu_cmn.nc_length = sizeof(struct note_suspend_s);
|
note_common(tcb, ¬e.nsu_cmn, sizeof(struct note_suspend_s), NOTE_SUSPEND);
|
||||||
note.nsu_cmn.nc_type = NOTE_SUSPEND;
|
|
||||||
note.nsu_cmn.nc_priority = tcb->sched_priority;
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
note.nsu_cmn.nc_cpu = tcb->cpu;
|
|
||||||
#endif
|
|
||||||
note.nsu_cmn.nc_pid[0] = (uint8_t)(tcb->pid & 0xff);
|
|
||||||
note.nsu_cmn.nc_pid[1] = (uint8_t)((tcb->pid >> 8) & 0xff);
|
|
||||||
note.nsu_state = tcb->task_state;
|
note.nsu_state = tcb->task_state;
|
||||||
|
|
||||||
note_systime((FAR struct note_common_s *)¬e);
|
|
||||||
|
|
||||||
/* Add the note to circular buffer */
|
/* Add the note to circular buffer */
|
||||||
|
|
||||||
note_add((FAR const uint8_t *)¬e, sizeof(struct note_suspend_s));
|
note_add((FAR const uint8_t *)¬e, sizeof(struct note_suspend_s));
|
||||||
@ -376,16 +362,7 @@ void sched_note_resume(FAR struct tcb_s *tcb)
|
|||||||
|
|
||||||
/* Format the note */
|
/* Format the note */
|
||||||
|
|
||||||
note.nre_cmn.nc_length = sizeof(struct note_resume_s);
|
note_common(tcb, ¬e.nre_cmn, sizeof(struct note_resume_s), NOTE_RESUME);
|
||||||
note.nre_cmn.nc_type = NOTE_RESUME;
|
|
||||||
note.nre_cmn.nc_priority = tcb->sched_priority;
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
note.nre_cmn.nc_cpu = tcb->cpu;
|
|
||||||
#endif
|
|
||||||
note.nre_cmn.nc_pid[0] = (uint8_t)(tcb->pid & 0xff);
|
|
||||||
note.nre_cmn.nc_pid[1] = (uint8_t)((tcb->pid >> 8) & 0xff);
|
|
||||||
|
|
||||||
note_systime((FAR struct note_common_s *)¬e);
|
|
||||||
|
|
||||||
/* Add the note to circular buffer */
|
/* Add the note to circular buffer */
|
||||||
|
|
||||||
@ -399,18 +376,10 @@ void sched_note_premption(FAR struct tcb_s *tcb, bool locked)
|
|||||||
|
|
||||||
/* Format the note */
|
/* Format the note */
|
||||||
|
|
||||||
note.npr_cmn.nc_length = sizeof(struct note_preempt_s);
|
note_common(tcb, ¬e.npr_cmn, sizeof(struct note_preempt_s),
|
||||||
note.npr_cmn.nc_type = locked ? NOTE_PREEMPT_LOCK : NOTE_PREEMPT_UNLOCK;
|
locked ? NOTE_PREEMPT_LOCK : NOTE_PREEMPT_UNLOCK);
|
||||||
note.npr_cmn.nc_priority = tcb->sched_priority;
|
note.npr_count[0] = (uint8_t)(tcb->lockcount & 0xff);
|
||||||
#ifdef CONFIG_SMP
|
note.npr_count[1] = (uint8_t)((tcb->lockcount >> 8) & 0xff);
|
||||||
note.npr_cmn.nc_cpu = tcb->cpu;
|
|
||||||
#endif
|
|
||||||
note.npr_cmn.nc_pid[0] = (uint8_t)(tcb->pid & 0xff);
|
|
||||||
note.npr_cmn.nc_pid[1] = (uint8_t)((tcb->pid >> 8) & 0xff);
|
|
||||||
note.npr_count[0] = (uint8_t)(tcb->lockcount & 0xff);
|
|
||||||
note.npr_count[1] = (uint8_t)((tcb->lockcount >> 8) & 0xff);
|
|
||||||
|
|
||||||
note_systime((FAR struct note_common_s *)¬e);
|
|
||||||
|
|
||||||
/* Add the note to circular buffer */
|
/* Add the note to circular buffer */
|
||||||
|
|
||||||
@ -421,28 +390,22 @@ void sched_note_premption(FAR struct tcb_s *tcb, bool locked)
|
|||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
|
||||||
void sched_note_csection(FAR struct tcb_s *tcb, bool enter)
|
void sched_note_csection(FAR struct tcb_s *tcb, bool enter)
|
||||||
{
|
{
|
||||||
struct note_preempt_s note;
|
struct note_csection_s note;
|
||||||
|
|
||||||
/* Format the note */
|
/* Format the note */
|
||||||
|
|
||||||
note.ncs_cmn.nc_length = sizeof(struct note_preempt_s);
|
note_common(tcb, ¬e.ncs_cmn, sizeof(struct note_csection_s),
|
||||||
note.ncs_cmn.nc_type = enter ? NOTE_CSECTION_ENTER : NOTE_CSECTION_LEAVE;
|
enter ? NOTE_CSECTION_ENTER : NOTE_CSECTION_LEAVE);
|
||||||
note.ncs_cmn.nc_priority = tcb->sched_priority;
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
note.ncs_cmn.nc_cpu = tcb->cpu;
|
note.ncs_count[0] = (uint8_t)(tcb->irqcount & 0xff);
|
||||||
#endif
|
note.ncs_count[1] = (uint8_t)((tcb->irqcount >> 8) & 0xff);
|
||||||
note.ncs_cmn.nc_pid[0] = (uint8_t)(tcb->pid & 0xff);
|
|
||||||
note.ncs_cmn.nc_pid[1] = (uint8_t)((tcb->pid >> 8) & 0xff);
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
note.ncs_count[0] = (uint8_t)(tcb->irqcount & 0xff);
|
|
||||||
note.ncs_count[1] = (uint8_t)((tcb->irqcount >> 8) & 0xff);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
note_systime((FAR struct note_common_s *)¬e);
|
note_systime((FAR struct note_common_s *)¬e);
|
||||||
|
|
||||||
/* Add the note to circular buffer */
|
/* Add the note to circular buffer */
|
||||||
|
|
||||||
note_add((FAR const uint8_t *)¬e, sizeof(struct note_preempt_s));
|
note_add((FAR const uint8_t *)¬e, sizeof(struct note_csection_s));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user