xsched/note:add switch and dump instrumentation

Signed-off-by: zhanghu6 <zhanghu6@xiaomi.com>
This commit is contained in:
zhanghu6 2022-02-18 15:05:23 +08:00 committed by Xiang Xiao
parent 13889ba868
commit ebf751b16e
3 changed files with 95 additions and 17 deletions

View File

@ -63,14 +63,20 @@
/* Note filter mode flag definitions */
#define NOTE_FILTER_MODE_FLAG_ENABLE (1 << 0) /* Enable instrumentation */
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
#define NOTE_FILTER_MODE_FLAG_SWITCH (1 << 1) /* Enable syscall instrumentation */
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
#define NOTE_FILTER_MODE_FLAG_SYSCALL (1 << 1) /* Enable syscall instrumentation */
#define NOTE_FILTER_MODE_FLAG_SYSCALL (1 << 2) /* Enable syscall instrumentation */
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
#define NOTE_FILTER_MODE_FLAG_IRQ (1 << 2) /* Enable IRQ instrumentaiton */
#define NOTE_FILTER_MODE_FLAG_IRQ (1 << 3) /* Enable IRQ instrumentaiton */
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP
#define NOTE_FILTER_MODE_FLAG_DUMP (1 << 4) /* Enable dump instrumentaiton */
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
#define NOTE_FILTER_MODE_FLAG_SYSCALL_ARGS (1 << 3) /* Enable collecting syscall arguments */
#define NOTE_FILTER_MODE_FLAG_SYSCALL_ARGS (1 << 5) /* Enable collecting syscall arguments */
#endif
/* Helper macros for syscall instrumentation filter */

View File

@ -1064,13 +1064,15 @@ config SCHED_INSTRUMENTATION_FILTER
config SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE
hex "Default instrumentation filter mode"
depends on SCHED_INSTRUMENTATION_FILTER
default 0xf
default 0x3f
---help---
Default mode of the instrumentation filter logic.
Bit 0 = Enable instrumentation
Bit 1 = Enable syscall instrumentation
Bit 2 = Enable IRQ instrumentation
Bit 3 = Enable collecting syscall arguments
Bit 1 = Enable switch instrumentation
Bit 2 = Enable syscall instrumentation
Bit 3 = Enable IRQ instrumentation
Bit 4 = Enable dump instrumentation
Bit 5 = Enable collecting syscall arguments
endif # SCHED_INSTRUMENTATION
endmenu # Performance Monitoring

View File

@ -204,6 +204,41 @@ static inline int note_isenabled(void)
return true;
}
/****************************************************************************
* Name: note_isenabled_switch
*
* Description:
* Check whether the switch instrumentation is enabled.
*
* Input Parameters:
* None
*
* Returned Value:
* True is returned if the instrumentation is enabled.
*
****************************************************************************/
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
static inline int note_isenabled_switch(void)
{
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
if (!note_isenabled())
{
return false;
}
/* If the switch trace is disabled, do nothing. */
if ((g_note_filter.mode.flag & NOTE_FILTER_MODE_FLAG_SWITCH) == 0)
{
return false;
}
#endif
return true;
}
#endif
/****************************************************************************
* Name: note_isenabled_syscall
*
@ -319,6 +354,41 @@ static inline int note_isenabled_irq(int irq, bool enter)
}
#endif
/****************************************************************************
* Name: note_isenabled_dump
*
* Description:
* Check whether the dump instrumentation is enabled.
*
* Input Parameters:
* None
*
* Returned Value:
* True is returned if the instrumentation is enabled.
*
****************************************************************************/
#ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP
static inline int note_isenabled_dump(void)
{
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
if (!note_isenabled())
{
return false;
}
/* If the dump trace is disabled, do nothing. */
if ((g_note_filter.mode.flag & NOTE_FILTER_MODE_FLAG_DUMP) == 0)
{
return false;
}
#endif
return true;
}
#endif
/****************************************************************************
* Name: note_spincommon
*
@ -452,7 +522,7 @@ void sched_note_suspend(FAR struct tcb_s *tcb)
{
struct note_suspend_s note;
if (!note_isenabled())
if (!note_isenabled_switch())
{
return;
}
@ -472,7 +542,7 @@ void sched_note_resume(FAR struct tcb_s *tcb)
{
struct note_resume_s note;
if (!note_isenabled())
if (!note_isenabled_switch())
{
return;
}
@ -532,7 +602,7 @@ void sched_note_cpu_pause(FAR struct tcb_s *tcb, int cpu)
{
struct note_cpu_pause_s note;
if (!note_isenabled())
if (!note_isenabled_switch())
{
return;
}
@ -552,7 +622,7 @@ void sched_note_cpu_paused(FAR struct tcb_s *tcb)
{
struct note_cpu_paused_s note;
if (!note_isenabled())
if (!note_isenabled_switch())
{
return;
}
@ -571,7 +641,7 @@ void sched_note_cpu_resume(FAR struct tcb_s *tcb, int cpu)
{
struct note_cpu_resume_s note;
if (!note_isenabled())
if (!note_isenabled_switch())
{
return;
}
@ -591,7 +661,7 @@ void sched_note_cpu_resumed(FAR struct tcb_s *tcb)
{
struct note_cpu_resumed_s note;
if (!note_isenabled())
if (!note_isenabled_switch())
{
return;
}
@ -810,7 +880,7 @@ void sched_note_string(FAR const char *buf)
unsigned int length;
FAR struct tcb_s *tcb = this_task();
if (!note_isenabled())
if (!note_isenabled_dump())
{
return;
}
@ -843,7 +913,7 @@ void sched_note_dump(uint32_t module, uint8_t event,
unsigned int length;
FAR struct tcb_s *tcb = this_task();
if (!note_isenabled())
if (!note_isenabled_dump())
{
return;
}
@ -879,7 +949,7 @@ void sched_note_vprintf(FAR const char *fmt, va_list va)
unsigned int length;
FAR struct tcb_s *tcb = this_task();
if (!note_isenabled())
if (!note_isenabled_dump())
{
return;
}
@ -941,7 +1011,7 @@ void sched_note_vbprintf(uint32_t module, uint8_t event,
int next = 0;
FAR struct tcb_s *tcb = this_task();
if (!note_isenabled())
if (!note_isenabled_dump())
{
return;
}