diff --git a/include/nuttx/sched_note.h b/include/nuttx/sched_note.h index e04935a589..bb7f032cb6 100644 --- a/include/nuttx/sched_note.h +++ b/include/nuttx/sched_note.h @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -305,6 +306,20 @@ void sched_note_spinabort(FAR struct tcb_s *tcb, FAR volatile void *spinlock); # define sched_note_spinabort(t,s) #endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL +void sched_note_syscall_enter(int nr, int argc, ...); +void sched_note_syscall_leave(int nr, uintptr_t result); +#else +# define sched_note_syscall_enter(n,a...) +# define sched_note_syscall_leave(n,r) +#endif + +#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER +void sched_note_irqhandler(int irq, FAR void *handler, bool enter); +#else +# define sched_note_irqhandler(i,h,e) +#endif + /**************************************************************************** * Name: sched_note_get * @@ -387,6 +402,9 @@ int note_register(void); # define sched_note_spinlocked(t,s) # define sched_note_spinunlock(t,s) # define sched_note_spinabort(t,s) +# define sched_note_syscall_enter(n,a...) +# define sched_note_syscall_leave(n,r) +# define sched_note_irqhandler(i,h,e) #endif /* CONFIG_SCHED_INSTRUMENTATION */ #endif /* __INCLUDE_NUTTX_SCHED_NOTE_H */ diff --git a/sched/Kconfig b/sched/Kconfig index f7fe1efe81..a1d66dd36c 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -972,6 +972,25 @@ config SCHED_INSTRUMENTATION_SPINLOCKS void sched_note_spinunlock(FAR struct tcb_s *tcb, bool state); void sched_note_spinabort(FAR struct tcb_s *tcb, bool state); +config SCHED_INSTRUMENTATION_SYSCALL + bool "System call monitor hooks" + default n + ---help--- + Enables additional hooks for entry and exit from system call. + Board-specific logic must provide this additional logic. + + void sched_note_syscall_enter(int nr, int argc, ...); + void sched_note_syscall_leave(int nr, uintptr_t result); + +config SCHED_INSTRUMENTATION_IRQHANDLER + bool "Interrupt handler monitor hooks" + default n + ---help--- + Enables additional hooks for interrupt handler. Board-specific logic + must provide this additional logic. + + void sched_note_irqhandler(int irq, FAR void *handler, bool enter); + config SCHED_INSTRUMENTATION_BUFFER bool "Buffer instrumentation data in memory" default n diff --git a/sched/irq/irq_dispatch.c b/sched/irq/irq_dispatch.c index f07cc13644..49be385613 100644 --- a/sched/irq/irq_dispatch.c +++ b/sched/irq/irq_dispatch.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "irq/irq.h" #include "clock/clock.h" @@ -171,11 +172,23 @@ void irq_dispatch(int irq, FAR void *context) add_irq_randomness(irq); #endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER + /* Notify that we are entering into the interrupt handler */ + + sched_note_irqhandler(irq, vector, true); +#endif + /* Then dispatch to the interrupt handler */ CALL_VECTOR(ndx, vector, irq, context, arg); UNUSED(ndx); +#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER + /* Notify that we are leaving from the interrupt handler */ + + sched_note_irqhandler(irq, vector, false); +#endif + /* Record the new "running" task. g_running_tasks[] is only used by * assertion logic for reporting crashes. */