You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/06/16 17:05:02 UTC
[incubator-nuttx] 01/03: Add syscall and irqhandler hooks in
sched_note.h
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit df2bc1e4c36b3f706cce83c075659339e27027db
Author: Yuuichi Nakamura <Yu...@sony.com>
AuthorDate: Tue Jun 16 07:57:49 2020 -0600
Add syscall and irqhandler hooks in sched_note.h
---
include/nuttx/sched_note.h | 18 ++++++++++++++++++
sched/Kconfig | 19 +++++++++++++++++++
sched/irq/irq_dispatch.c | 13 +++++++++++++
3 files changed, 50 insertions(+)
diff --git a/include/nuttx/sched_note.h b/include/nuttx/sched_note.h
index e04935a..bb7f032 100644
--- a/include/nuttx/sched_note.h
+++ b/include/nuttx/sched_note.h
@@ -45,6 +45,7 @@
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
+#include <stdarg.h>
#include <nuttx/sched.h>
@@ -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 f7fe1ef..a1d66dd 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 f07cc13..49be385 100644
--- a/sched/irq/irq_dispatch.c
+++ b/sched/irq/irq_dispatch.c
@@ -43,6 +43,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/random.h>
+#include <nuttx/sched_note.h>
#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.
*/