You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/11/03 13:32:08 UTC

[GitHub] [incubator-nuttx] Gary-Hobson opened a new pull request, #7518: split sched_node_* functions

Gary-Hobson opened a new pull request, #7518:
URL: https://github.com/apache/incubator-nuttx/pull/7518

   ## Summary
   Split the sched_node_* functions into two parts
   and moved from sched_note.c to noteram_driver.c
   
   This will be used to support sched_note multi-channel output
   ## Impact
   modified the visibility of some functions
   ```
   note_common :         private -> public
   sched_note_flatten   private ->  public
   sched_note_add       public ->   private
   ```
   ## Testing
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] Gary-Hobson closed pull request #7518: split sched_node_* functions

Posted by GitBox <gi...@apache.org>.
Gary-Hobson closed pull request #7518: split sched_node_* functions
URL: https://github.com/apache/nuttx/pull/7518


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7518: split sched_node_* functions

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7518:
URL: https://github.com/apache/incubator-nuttx/pull/7518#discussion_r1013401210


##########
drivers/note/noteram_driver.c:
##########
@@ -896,3 +934,330 @@ int noteram_register(void)
 {
   return register_driver("/dev/note", &g_noteram_fops, 0666, NULL);
 }
+
+/****************************************************************************
+ * Name: sched_ramnote_*
+ *
+ * Description:
+ *   These are the hooks into the scheduling instrumentation logic.  Each
+ *   simply formats the note associated with the schedule event and adds
+ *   that note to the circular buffer.
+ *
+ * Input Parameters:
+ *   tcb - The TCB of the thread.
+ *
+ * Returned Value:
+ *   None
+ *
+ * Assumptions:
+ *   We are within a critical section.
+ *
+ ****************************************************************************/
+
+void sched_ramnote_start(FAR struct tcb_s *tcb)
+{
+  struct note_startalloc_s note;
+  unsigned int length;
+#if CONFIG_TASK_NAME_SIZE > 0
+  int namelen;
+#endif
+
+  /* Copy the task name (if possible) and get the length of the note */
+
+#if CONFIG_TASK_NAME_SIZE > 0
+  namelen = strlen(tcb->name);
+
+  DEBUGASSERT(namelen <= CONFIG_TASK_NAME_SIZE);
+  strlcpy(note.nsa_name, tcb->name, sizeof(note.nsa_name));
+
+  length = SIZEOF_NOTE_START(namelen + 1);
+#else
+  length = SIZEOF_NOTE_START(0);
+#endif
+
+  /* Finish formatting the note */
+
+  note_common(tcb, &note.nsa_cmn, length, NOTE_START);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, length);
+}
+
+void sched_ramnote_stop(FAR struct tcb_s *tcb)
+{
+  struct note_stop_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.nsp_cmn, sizeof(struct note_stop_s), NOTE_STOP);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_stop_s));
+}
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_suspend(FAR struct tcb_s *tcb)
+{
+  struct note_suspend_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.nsu_cmn, sizeof(struct note_suspend_s),
+              NOTE_SUSPEND);
+  note.nsu_state           = tcb->task_state;
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_suspend_s));
+}
+
+void sched_ramnote_resume(FAR struct tcb_s *tcb)
+{
+  struct note_resume_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.nre_cmn, sizeof(struct note_resume_s), NOTE_RESUME);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_resume_s));
+}
+#endif
+
+#ifdef CONFIG_SMP
+void sched_ramnote_cpu_start(FAR struct tcb_s *tcb, int cpu)
+{
+  struct note_cpu_start_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncs_cmn, sizeof(struct note_cpu_start_s),
+              NOTE_CPU_START);
+  note.ncs_target = (uint8_t)cpu;
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_start_s));
+}
+
+void sched_ramnote_cpu_started(FAR struct tcb_s *tcb)
+{
+  struct note_cpu_started_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncs_cmn, sizeof(struct note_cpu_started_s),
+              NOTE_CPU_STARTED);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_started_s));
+}
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_cpu_pause(FAR struct tcb_s *tcb, int cpu)
+{
+  struct note_cpu_pause_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncp_cmn, sizeof(struct note_cpu_pause_s),
+              NOTE_CPU_PAUSE);
+  note.ncp_target = (uint8_t)cpu;
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_pause_s));
+}
+
+void sched_ramnote_cpu_paused(FAR struct tcb_s *tcb)
+{
+  struct note_cpu_paused_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncp_cmn, sizeof(struct note_cpu_paused_s),
+              NOTE_CPU_PAUSED);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_paused_s));
+}
+
+void sched_ramnote_cpu_resume(FAR struct tcb_s *tcb, int cpu)
+{
+  struct note_cpu_resume_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncr_cmn, sizeof(struct note_cpu_resume_s),
+              NOTE_CPU_RESUME);
+  note.ncr_target = (uint8_t)cpu;
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_resume_s));
+}
+
+void sched_ramnote_cpu_resumed(FAR struct tcb_s *tcb)
+{
+  struct note_cpu_resumed_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncr_cmn, sizeof(struct note_cpu_resumed_s),
+              NOTE_CPU_RESUMED);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_resumed_s));
+}
+#endif
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
+void sched_ramnote_premption(FAR struct tcb_s *tcb, bool locked)
+{
+  struct note_preempt_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.npr_cmn, sizeof(struct note_preempt_s),
+              locked ? NOTE_PREEMPT_LOCK : NOTE_PREEMPT_UNLOCK);
+  sched_note_flatten(note.npr_count,
+                     &tcb->lockcount, sizeof(tcb->lockcount));
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_preempt_s));
+}
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
+void sched_ramnote_csection(FAR struct tcb_s *tcb, bool enter)
+{
+  struct note_csection_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncs_cmn, sizeof(struct note_csection_s),
+              enter ? NOTE_CSECTION_ENTER : NOTE_CSECTION_LEAVE);
+#ifdef CONFIG_SMP
+  sched_note_flatten(note.ncs_count, &tcb->irqcount, sizeof(tcb->irqcount));
+#endif
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_csection_s));
+}
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
+void sched_ramnote_spinlock(FAR struct tcb_s *tcb,
+                            FAR volatile void *spinlock)
+{
+  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCK);
+}
+
+void sched_ramnote_spinlocked(FAR struct tcb_s *tcb,
+                           FAR volatile void *spinlock)

Review Comment:
   ```suggestion
   void sched_ramnote_spinlocked(FAR struct tcb_s *tcb,
                                 FAR volatile void *spinlock)
   ```



##########
include/nuttx/sched_note.h:
##########
@@ -566,28 +612,74 @@ void sched_note_end(uintptr_t ip);
 #  define sched_note_end(ip)
 #endif /* CONFIG_SCHED_INSTRUMENTATION_DUMP */
 
-#if defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT)
-
 /****************************************************************************
- * Name: sched_note_add
+ * Name: sched_ramnote_*
  *
  * Description:
- *   Add the variable length note to the transport layer
+ *   If instrumentation of the scheduler is enabled, then some outboard
+ *   logic must provide the following interfaces.  These interfaces are not
+ *   available to application code.
  *
  * Input Parameters:
- *   note    - The note buffer
- *   notelen - The buffer length
+ *   tcb - The TCB of the thread.
  *
  * Returned Value:
  *   None
  *
- * Assumptions:
- *   We are within a critical section.
- *
  ****************************************************************************/
 
-void sched_note_add(FAR const void *note, size_t notelen);
+void sched_ramnote_start(FAR struct tcb_s *tcb);
+void sched_ramnote_stop(FAR struct tcb_s *tcb);
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_suspend(FAR struct tcb_s *tcb);
+void sched_ramnote_resume(FAR struct tcb_s *tcb);
+#endif
 
+#ifdef CONFIG_SMP
+void sched_ramnote_cpu_start(FAR struct tcb_s *tcb, int cpu);
+void sched_ramnote_cpu_started(FAR struct tcb_s *tcb);
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_cpu_pause(FAR struct tcb_s *tcb, int cpu);
+void sched_ramnote_cpu_paused(FAR struct tcb_s *tcb);
+void sched_ramnote_cpu_resume(FAR struct tcb_s *tcb, int cpu);
+void sched_ramnote_cpu_resumed(FAR struct tcb_s *tcb);
+#endif
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
+void sched_ramnote_premption(FAR struct tcb_s *tcb, bool locked);
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
+void sched_ramnote_csection(FAR struct tcb_s *tcb, bool enter);
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
+void sched_ramnote_spinlock(FAR struct tcb_s *tcb,
+                         FAR volatile void *spinlock);

Review Comment:
   ```suggestion
   void sched_ramnote_spinlock(FAR struct tcb_s *tcb,
                               FAR volatile void *spinlock);
   ```



##########
sched/sched/sched_note.c:
##########
@@ -698,54 +524,58 @@ void sched_note_csection(FAR struct tcb_s *tcb, bool enter)
       return;
     }
 
-  /* Format the note */
-
-  note_common(tcb, &note.ncs_cmn, sizeof(struct note_csection_s),
-              enter ? NOTE_CSECTION_ENTER : NOTE_CSECTION_LEAVE);
-#ifdef CONFIG_SMP
-  sched_note_flatten(note.ncs_count, &tcb->irqcount, sizeof(tcb->irqcount));
-#endif
-
-  /* Add the note to circular buffer */
-
-  sched_note_add(&note, sizeof(struct note_csection_s));
+  sched_ramnote_csection(tcb, enter);
 }
 #endif
 
 #ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
 void sched_note_spinlock(FAR struct tcb_s *tcb, FAR volatile void *spinlock)
 {
-  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCK);
+  if (!note_isenabled())
+    {
+      return;
+    }
+
+  sched_ramnote_spinlock(tcb, spinlock);
 }
 
 void sched_note_spinlocked(FAR struct tcb_s *tcb,
                            FAR volatile void *spinlock)
 {
-  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCKED);
+  if (!note_isenabled())
+    {
+      return;
+    }
+
+  sched_ramnote_spinlocked(tcb, spinlock);

Review Comment:
   ```suggestion
     if (note_isenabled())
       {
         sched_ramnote_spinlocked(tcb, spinlock);
       }
   ```



##########
sched/sched/sched_note.c:
##########
@@ -698,54 +524,58 @@ void sched_note_csection(FAR struct tcb_s *tcb, bool enter)
       return;
     }
 
-  /* Format the note */
-
-  note_common(tcb, &note.ncs_cmn, sizeof(struct note_csection_s),
-              enter ? NOTE_CSECTION_ENTER : NOTE_CSECTION_LEAVE);
-#ifdef CONFIG_SMP
-  sched_note_flatten(note.ncs_count, &tcb->irqcount, sizeof(tcb->irqcount));
-#endif
-
-  /* Add the note to circular buffer */
-
-  sched_note_add(&note, sizeof(struct note_csection_s));
+  sched_ramnote_csection(tcb, enter);
 }
 #endif
 
 #ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
 void sched_note_spinlock(FAR struct tcb_s *tcb, FAR volatile void *spinlock)
 {
-  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCK);
+  if (!note_isenabled())
+    {
+      return;
+    }
+
+  sched_ramnote_spinlock(tcb, spinlock);
 }
 
 void sched_note_spinlocked(FAR struct tcb_s *tcb,
                            FAR volatile void *spinlock)
 {
-  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCKED);
+  if (!note_isenabled())
+    {
+      return;
+    }
+
+  sched_ramnote_spinlocked(tcb, spinlock);
 }
 
 void sched_note_spinunlock(FAR struct tcb_s *tcb,
                            FAR volatile void *spinlock)
 {
-  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_UNLOCK);
+  if (!note_isenabled())
+    {
+      return;
+    }
+
+  sched_ramnote_spinunlock(tcb, spinlock);

Review Comment:
   ```suggestion
     if (note_isenabled())
       {
         sched_ramnote_spinunlock(tcb, spinlock);
       }
   ```



##########
drivers/note/noteram_driver.c:
##########
@@ -769,9 +772,40 @@ static int noteram_ioctl(struct file *filep, int cmd, unsigned long arg)
 }
 
 /****************************************************************************
- * Public Functions
+ * Name: note_spincommon
+ *
+ * Description:
+ *   Common logic for NOTE_SPINLOCK, NOTE_SPINLOCKED, and NOTE_SPINUNLOCK
+ *
+ * Input Parameters:
+ *   tcb  - The TCB containing the information
+ *   note - The common note structure to use
+ *
+ * Returned Value:
+ *   None
+ *
  ****************************************************************************/
 
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
+static void note_spincommon(FAR struct tcb_s *tcb,
+                            FAR volatile spinlock_t *spinlock,
+                            int type)
+{
+  struct note_spinlock_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.nsp_cmn, sizeof(struct note_spinlock_s), type);
+
+  sched_note_flatten(note.nsp_spinlock, &spinlock, sizeof(spinlock));
+  note.nsp_value = *(uint8_t *)spinlock;

Review Comment:
   ```suggestion
     note.nsp_value = *(FAR uint8_t *)spinlock;
   ```



##########
drivers/note/noteram_driver.c:
##########
@@ -896,3 +934,330 @@ int noteram_register(void)
 {
   return register_driver("/dev/note", &g_noteram_fops, 0666, NULL);
 }
+
+/****************************************************************************
+ * Name: sched_ramnote_*
+ *
+ * Description:
+ *   These are the hooks into the scheduling instrumentation logic.  Each
+ *   simply formats the note associated with the schedule event and adds
+ *   that note to the circular buffer.
+ *
+ * Input Parameters:
+ *   tcb - The TCB of the thread.
+ *
+ * Returned Value:
+ *   None
+ *
+ * Assumptions:
+ *   We are within a critical section.
+ *
+ ****************************************************************************/
+
+void sched_ramnote_start(FAR struct tcb_s *tcb)
+{
+  struct note_startalloc_s note;
+  unsigned int length;
+#if CONFIG_TASK_NAME_SIZE > 0
+  int namelen;
+#endif
+
+  /* Copy the task name (if possible) and get the length of the note */
+
+#if CONFIG_TASK_NAME_SIZE > 0
+  namelen = strlen(tcb->name);
+
+  DEBUGASSERT(namelen <= CONFIG_TASK_NAME_SIZE);
+  strlcpy(note.nsa_name, tcb->name, sizeof(note.nsa_name));
+
+  length = SIZEOF_NOTE_START(namelen + 1);
+#else
+  length = SIZEOF_NOTE_START(0);
+#endif
+
+  /* Finish formatting the note */
+
+  note_common(tcb, &note.nsa_cmn, length, NOTE_START);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, length);
+}
+
+void sched_ramnote_stop(FAR struct tcb_s *tcb)
+{
+  struct note_stop_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.nsp_cmn, sizeof(struct note_stop_s), NOTE_STOP);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_stop_s));
+}
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_suspend(FAR struct tcb_s *tcb)
+{
+  struct note_suspend_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.nsu_cmn, sizeof(struct note_suspend_s),
+              NOTE_SUSPEND);
+  note.nsu_state           = tcb->task_state;
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_suspend_s));
+}
+
+void sched_ramnote_resume(FAR struct tcb_s *tcb)
+{
+  struct note_resume_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.nre_cmn, sizeof(struct note_resume_s), NOTE_RESUME);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_resume_s));
+}
+#endif
+
+#ifdef CONFIG_SMP
+void sched_ramnote_cpu_start(FAR struct tcb_s *tcb, int cpu)
+{
+  struct note_cpu_start_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncs_cmn, sizeof(struct note_cpu_start_s),
+              NOTE_CPU_START);
+  note.ncs_target = (uint8_t)cpu;
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_start_s));
+}
+
+void sched_ramnote_cpu_started(FAR struct tcb_s *tcb)
+{
+  struct note_cpu_started_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncs_cmn, sizeof(struct note_cpu_started_s),
+              NOTE_CPU_STARTED);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_started_s));
+}
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_cpu_pause(FAR struct tcb_s *tcb, int cpu)
+{
+  struct note_cpu_pause_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncp_cmn, sizeof(struct note_cpu_pause_s),
+              NOTE_CPU_PAUSE);
+  note.ncp_target = (uint8_t)cpu;
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_pause_s));
+}
+
+void sched_ramnote_cpu_paused(FAR struct tcb_s *tcb)
+{
+  struct note_cpu_paused_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncp_cmn, sizeof(struct note_cpu_paused_s),
+              NOTE_CPU_PAUSED);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_paused_s));
+}
+
+void sched_ramnote_cpu_resume(FAR struct tcb_s *tcb, int cpu)
+{
+  struct note_cpu_resume_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncr_cmn, sizeof(struct note_cpu_resume_s),
+              NOTE_CPU_RESUME);
+  note.ncr_target = (uint8_t)cpu;
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_resume_s));
+}
+
+void sched_ramnote_cpu_resumed(FAR struct tcb_s *tcb)
+{
+  struct note_cpu_resumed_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncr_cmn, sizeof(struct note_cpu_resumed_s),
+              NOTE_CPU_RESUMED);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_resumed_s));
+}
+#endif
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
+void sched_ramnote_premption(FAR struct tcb_s *tcb, bool locked)
+{
+  struct note_preempt_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.npr_cmn, sizeof(struct note_preempt_s),
+              locked ? NOTE_PREEMPT_LOCK : NOTE_PREEMPT_UNLOCK);
+  sched_note_flatten(note.npr_count,
+                     &tcb->lockcount, sizeof(tcb->lockcount));
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_preempt_s));
+}
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
+void sched_ramnote_csection(FAR struct tcb_s *tcb, bool enter)
+{
+  struct note_csection_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncs_cmn, sizeof(struct note_csection_s),
+              enter ? NOTE_CSECTION_ENTER : NOTE_CSECTION_LEAVE);
+#ifdef CONFIG_SMP
+  sched_note_flatten(note.ncs_count, &tcb->irqcount, sizeof(tcb->irqcount));
+#endif
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_csection_s));
+}
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
+void sched_ramnote_spinlock(FAR struct tcb_s *tcb,
+                            FAR volatile void *spinlock)
+{
+  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCK);
+}
+
+void sched_ramnote_spinlocked(FAR struct tcb_s *tcb,
+                           FAR volatile void *spinlock)
+{
+  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCKED);
+}
+
+void sched_ramnote_spinunlock(FAR struct tcb_s *tcb,
+                           FAR volatile void *spinlock)

Review Comment:
   ```suggestion
   void sched_ramnote_spinunlock(FAR struct tcb_s *tcb,
                                 FAR volatile void *spinlock)
   ```



##########
include/nuttx/sched_note.h:
##########
@@ -566,28 +612,74 @@ void sched_note_end(uintptr_t ip);
 #  define sched_note_end(ip)
 #endif /* CONFIG_SCHED_INSTRUMENTATION_DUMP */
 
-#if defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT)
-
 /****************************************************************************
- * Name: sched_note_add
+ * Name: sched_ramnote_*
  *
  * Description:
- *   Add the variable length note to the transport layer
+ *   If instrumentation of the scheduler is enabled, then some outboard
+ *   logic must provide the following interfaces.  These interfaces are not
+ *   available to application code.
  *
  * Input Parameters:
- *   note    - The note buffer
- *   notelen - The buffer length
+ *   tcb - The TCB of the thread.
  *
  * Returned Value:
  *   None
  *
- * Assumptions:
- *   We are within a critical section.
- *
  ****************************************************************************/
 
-void sched_note_add(FAR const void *note, size_t notelen);
+void sched_ramnote_start(FAR struct tcb_s *tcb);
+void sched_ramnote_stop(FAR struct tcb_s *tcb);
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_suspend(FAR struct tcb_s *tcb);
+void sched_ramnote_resume(FAR struct tcb_s *tcb);
+#endif
 
+#ifdef CONFIG_SMP
+void sched_ramnote_cpu_start(FAR struct tcb_s *tcb, int cpu);
+void sched_ramnote_cpu_started(FAR struct tcb_s *tcb);
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_cpu_pause(FAR struct tcb_s *tcb, int cpu);
+void sched_ramnote_cpu_paused(FAR struct tcb_s *tcb);
+void sched_ramnote_cpu_resume(FAR struct tcb_s *tcb, int cpu);
+void sched_ramnote_cpu_resumed(FAR struct tcb_s *tcb);
+#endif
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
+void sched_ramnote_premption(FAR struct tcb_s *tcb, bool locked);
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
+void sched_ramnote_csection(FAR struct tcb_s *tcb, bool enter);
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
+void sched_ramnote_spinlock(FAR struct tcb_s *tcb,
+                         FAR volatile void *spinlock);
+void sched_ramnote_spinlocked(FAR struct tcb_s *tcb,
+                           FAR volatile void *spinlock);

Review Comment:
   ```suggestion
   void sched_ramnote_spinlocked(FAR struct tcb_s *tcb,
                                 FAR volatile void *spinlock);
   ```



##########
sched/sched/sched_note.c:
##########
@@ -389,49 +304,80 @@ static inline int note_isenabled_dump(void)
 #endif
 
 /****************************************************************************
- * Name: note_spincommon
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: note_common
  *
  * Description:
- *   Common logic for NOTE_SPINLOCK, NOTE_SPINLOCKED, and NOTE_SPINUNLOCK
+ *   Fill in some of the common fields in the note structure.
  *
  * Input Parameters:
- *   tcb  - The TCB containing the information
- *   note - The common note structure to use
+ *   tcb    - The TCB containing the information
+ *   note   - The common note structure to use
+ *   length - The total lengthof the note structure
+ *   type   - The type of the note
  *
  * Returned Value:
  *   None
  *
  ****************************************************************************/
 
-#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
-static void note_spincommon(FAR struct tcb_s *tcb,
-                            FAR volatile spinlock_t *spinlock,
-                            int type)
+void note_common(FAR struct tcb_s *tcb,
+                FAR struct note_common_s *note,
+                uint8_t length, uint8_t type)

Review Comment:
   ```suggestion
   void note_common(FAR struct tcb_s *tcb,
                    FAR struct note_common_s *note,
                    uint8_t length, uint8_t type)
   ```



##########
include/nuttx/sched_note.h:
##########
@@ -566,28 +612,74 @@ void sched_note_end(uintptr_t ip);
 #  define sched_note_end(ip)
 #endif /* CONFIG_SCHED_INSTRUMENTATION_DUMP */
 
-#if defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT)
-
 /****************************************************************************
- * Name: sched_note_add
+ * Name: sched_ramnote_*
  *
  * Description:
- *   Add the variable length note to the transport layer
+ *   If instrumentation of the scheduler is enabled, then some outboard
+ *   logic must provide the following interfaces.  These interfaces are not
+ *   available to application code.
  *
  * Input Parameters:
- *   note    - The note buffer
- *   notelen - The buffer length
+ *   tcb - The TCB of the thread.
  *
  * Returned Value:
  *   None
  *
- * Assumptions:
- *   We are within a critical section.
- *
  ****************************************************************************/
 
-void sched_note_add(FAR const void *note, size_t notelen);
+void sched_ramnote_start(FAR struct tcb_s *tcb);
+void sched_ramnote_stop(FAR struct tcb_s *tcb);
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_suspend(FAR struct tcb_s *tcb);
+void sched_ramnote_resume(FAR struct tcb_s *tcb);
+#endif
 
+#ifdef CONFIG_SMP
+void sched_ramnote_cpu_start(FAR struct tcb_s *tcb, int cpu);
+void sched_ramnote_cpu_started(FAR struct tcb_s *tcb);
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_cpu_pause(FAR struct tcb_s *tcb, int cpu);
+void sched_ramnote_cpu_paused(FAR struct tcb_s *tcb);
+void sched_ramnote_cpu_resume(FAR struct tcb_s *tcb, int cpu);
+void sched_ramnote_cpu_resumed(FAR struct tcb_s *tcb);
+#endif
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
+void sched_ramnote_premption(FAR struct tcb_s *tcb, bool locked);
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
+void sched_ramnote_csection(FAR struct tcb_s *tcb, bool enter);
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
+void sched_ramnote_spinlock(FAR struct tcb_s *tcb,
+                         FAR volatile void *spinlock);
+void sched_ramnote_spinlocked(FAR struct tcb_s *tcb,
+                           FAR volatile void *spinlock);
+void sched_ramnote_spinunlock(FAR struct tcb_s *tcb,
+                           FAR volatile void *spinlock);

Review Comment:
   ```suggestion
   void sched_ramnote_spinunlock(FAR struct tcb_s *tcb,
                                 FAR volatile void *spinlock);
   ```



##########
include/nuttx/sched_note.h:
##########
@@ -566,28 +612,74 @@ void sched_note_end(uintptr_t ip);
 #  define sched_note_end(ip)
 #endif /* CONFIG_SCHED_INSTRUMENTATION_DUMP */
 
-#if defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT)
-
 /****************************************************************************
- * Name: sched_note_add
+ * Name: sched_ramnote_*
  *
  * Description:
- *   Add the variable length note to the transport layer
+ *   If instrumentation of the scheduler is enabled, then some outboard
+ *   logic must provide the following interfaces.  These interfaces are not
+ *   available to application code.
  *
  * Input Parameters:
- *   note    - The note buffer
- *   notelen - The buffer length
+ *   tcb - The TCB of the thread.
  *
  * Returned Value:
  *   None
  *
- * Assumptions:
- *   We are within a critical section.
- *
  ****************************************************************************/
 
-void sched_note_add(FAR const void *note, size_t notelen);
+void sched_ramnote_start(FAR struct tcb_s *tcb);
+void sched_ramnote_stop(FAR struct tcb_s *tcb);
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_suspend(FAR struct tcb_s *tcb);
+void sched_ramnote_resume(FAR struct tcb_s *tcb);
+#endif
 
+#ifdef CONFIG_SMP
+void sched_ramnote_cpu_start(FAR struct tcb_s *tcb, int cpu);
+void sched_ramnote_cpu_started(FAR struct tcb_s *tcb);
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_cpu_pause(FAR struct tcb_s *tcb, int cpu);
+void sched_ramnote_cpu_paused(FAR struct tcb_s *tcb);
+void sched_ramnote_cpu_resume(FAR struct tcb_s *tcb, int cpu);
+void sched_ramnote_cpu_resumed(FAR struct tcb_s *tcb);
+#endif
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
+void sched_ramnote_premption(FAR struct tcb_s *tcb, bool locked);
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
+void sched_ramnote_csection(FAR struct tcb_s *tcb, bool enter);
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
+void sched_ramnote_spinlock(FAR struct tcb_s *tcb,
+                         FAR volatile void *spinlock);
+void sched_ramnote_spinlocked(FAR struct tcb_s *tcb,
+                           FAR volatile void *spinlock);
+void sched_ramnote_spinunlock(FAR struct tcb_s *tcb,
+                           FAR volatile void *spinlock);
+void sched_ramnote_spinabort(FAR struct tcb_s *tcb,
+                          FAR volatile void *spinlock);

Review Comment:
   ```suggestion
   void sched_ramnote_spinabort(FAR struct tcb_s *tcb,
                                FAR volatile void *spinlock);
   ```



##########
sched/sched/sched_note.c:
##########
@@ -698,54 +524,58 @@ void sched_note_csection(FAR struct tcb_s *tcb, bool enter)
       return;
     }
 
-  /* Format the note */
-
-  note_common(tcb, &note.ncs_cmn, sizeof(struct note_csection_s),
-              enter ? NOTE_CSECTION_ENTER : NOTE_CSECTION_LEAVE);
-#ifdef CONFIG_SMP
-  sched_note_flatten(note.ncs_count, &tcb->irqcount, sizeof(tcb->irqcount));
-#endif
-
-  /* Add the note to circular buffer */
-
-  sched_note_add(&note, sizeof(struct note_csection_s));
+  sched_ramnote_csection(tcb, enter);
 }
 #endif
 
 #ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
 void sched_note_spinlock(FAR struct tcb_s *tcb, FAR volatile void *spinlock)
 {
-  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCK);
+  if (!note_isenabled())
+    {
+      return;
+    }
+
+  sched_ramnote_spinlock(tcb, spinlock);

Review Comment:
   ```suggestion
     if (note_isenabled())
       {
         sched_ramnote_spinlock(tcb, spinlock);
       }
   ```



##########
drivers/note/noteram_driver.c:
##########
@@ -896,3 +934,330 @@ int noteram_register(void)
 {
   return register_driver("/dev/note", &g_noteram_fops, 0666, NULL);
 }
+
+/****************************************************************************
+ * Name: sched_ramnote_*
+ *
+ * Description:
+ *   These are the hooks into the scheduling instrumentation logic.  Each
+ *   simply formats the note associated with the schedule event and adds
+ *   that note to the circular buffer.
+ *
+ * Input Parameters:
+ *   tcb - The TCB of the thread.
+ *
+ * Returned Value:
+ *   None
+ *
+ * Assumptions:
+ *   We are within a critical section.
+ *
+ ****************************************************************************/
+
+void sched_ramnote_start(FAR struct tcb_s *tcb)
+{
+  struct note_startalloc_s note;
+  unsigned int length;
+#if CONFIG_TASK_NAME_SIZE > 0
+  int namelen;
+#endif
+
+  /* Copy the task name (if possible) and get the length of the note */
+
+#if CONFIG_TASK_NAME_SIZE > 0
+  namelen = strlen(tcb->name);
+
+  DEBUGASSERT(namelen <= CONFIG_TASK_NAME_SIZE);
+  strlcpy(note.nsa_name, tcb->name, sizeof(note.nsa_name));
+
+  length = SIZEOF_NOTE_START(namelen + 1);
+#else
+  length = SIZEOF_NOTE_START(0);
+#endif
+
+  /* Finish formatting the note */
+
+  note_common(tcb, &note.nsa_cmn, length, NOTE_START);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, length);
+}
+
+void sched_ramnote_stop(FAR struct tcb_s *tcb)
+{
+  struct note_stop_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.nsp_cmn, sizeof(struct note_stop_s), NOTE_STOP);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_stop_s));
+}
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_suspend(FAR struct tcb_s *tcb)
+{
+  struct note_suspend_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.nsu_cmn, sizeof(struct note_suspend_s),
+              NOTE_SUSPEND);
+  note.nsu_state           = tcb->task_state;
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_suspend_s));
+}
+
+void sched_ramnote_resume(FAR struct tcb_s *tcb)
+{
+  struct note_resume_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.nre_cmn, sizeof(struct note_resume_s), NOTE_RESUME);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_resume_s));
+}
+#endif
+
+#ifdef CONFIG_SMP
+void sched_ramnote_cpu_start(FAR struct tcb_s *tcb, int cpu)
+{
+  struct note_cpu_start_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncs_cmn, sizeof(struct note_cpu_start_s),
+              NOTE_CPU_START);
+  note.ncs_target = (uint8_t)cpu;
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_start_s));
+}
+
+void sched_ramnote_cpu_started(FAR struct tcb_s *tcb)
+{
+  struct note_cpu_started_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncs_cmn, sizeof(struct note_cpu_started_s),
+              NOTE_CPU_STARTED);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_started_s));
+}
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_ramnote_cpu_pause(FAR struct tcb_s *tcb, int cpu)
+{
+  struct note_cpu_pause_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncp_cmn, sizeof(struct note_cpu_pause_s),
+              NOTE_CPU_PAUSE);
+  note.ncp_target = (uint8_t)cpu;
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_pause_s));
+}
+
+void sched_ramnote_cpu_paused(FAR struct tcb_s *tcb)
+{
+  struct note_cpu_paused_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncp_cmn, sizeof(struct note_cpu_paused_s),
+              NOTE_CPU_PAUSED);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_paused_s));
+}
+
+void sched_ramnote_cpu_resume(FAR struct tcb_s *tcb, int cpu)
+{
+  struct note_cpu_resume_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncr_cmn, sizeof(struct note_cpu_resume_s),
+              NOTE_CPU_RESUME);
+  note.ncr_target = (uint8_t)cpu;
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_resume_s));
+}
+
+void sched_ramnote_cpu_resumed(FAR struct tcb_s *tcb)
+{
+  struct note_cpu_resumed_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncr_cmn, sizeof(struct note_cpu_resumed_s),
+              NOTE_CPU_RESUMED);
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_cpu_resumed_s));
+}
+#endif
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
+void sched_ramnote_premption(FAR struct tcb_s *tcb, bool locked)
+{
+  struct note_preempt_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.npr_cmn, sizeof(struct note_preempt_s),
+              locked ? NOTE_PREEMPT_LOCK : NOTE_PREEMPT_UNLOCK);
+  sched_note_flatten(note.npr_count,
+                     &tcb->lockcount, sizeof(tcb->lockcount));
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_preempt_s));
+}
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
+void sched_ramnote_csection(FAR struct tcb_s *tcb, bool enter)
+{
+  struct note_csection_s note;
+
+  /* Format the note */
+
+  note_common(tcb, &note.ncs_cmn, sizeof(struct note_csection_s),
+              enter ? NOTE_CSECTION_ENTER : NOTE_CSECTION_LEAVE);
+#ifdef CONFIG_SMP
+  sched_note_flatten(note.ncs_count, &tcb->irqcount, sizeof(tcb->irqcount));
+#endif
+
+  /* Add the note to circular buffer */
+
+  sched_note_add(&note, sizeof(struct note_csection_s));
+}
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
+void sched_ramnote_spinlock(FAR struct tcb_s *tcb,
+                            FAR volatile void *spinlock)
+{
+  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCK);
+}
+
+void sched_ramnote_spinlocked(FAR struct tcb_s *tcb,
+                           FAR volatile void *spinlock)
+{
+  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCKED);
+}
+
+void sched_ramnote_spinunlock(FAR struct tcb_s *tcb,
+                           FAR volatile void *spinlock)
+{
+  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_UNLOCK);
+}
+
+void sched_ramnote_spinabort(FAR struct tcb_s *tcb,
+                             FAR volatile void *spinlock)
+{
+  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_ABORT);
+}
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
+void sched_ramnote_syscall_enter(int nr, int argc, va_list ap)
+{
+  struct note_syscall_enter_s note;
+  FAR struct tcb_s *tcb = this_task();
+  unsigned int length;
+  uintptr_t arg;
+  uint8_t *args;

Review Comment:
   ```suggestion
     FAR uint8_t *args;
   ```



##########
sched/sched/sched_note.c:
##########
@@ -759,81 +589,31 @@ void sched_note_syscall_enter(int nr, int argc, ...)
     }
 #endif
 
-  /* Format the note */
-
-  length = SIZEOF_NOTE_SYSCALL_ENTER(argc);
-  note_common(tcb, &note.nsc_cmn, length, NOTE_SYSCALL_ENTER);
-  DEBUGASSERT(nr <= UCHAR_MAX);
-  note.nsc_nr = nr;
-  DEBUGASSERT(argc <= MAX_SYSCALL_ARGS);
-  note.nsc_argc = argc;
-
-  /* If needed, retrieve the given syscall arguments */
-
   va_start(ap, argc);
-
-  args = note.nsc_args;
-  for (i = 0; i < argc; i++)
-    {
-      arg = (uintptr_t)va_arg(ap, uintptr_t);
-      sched_note_flatten(args, &arg, sizeof(arg));
-      args += sizeof(uintptr_t);
-    }
-
+  sched_ramnote_syscall_enter(nr, argc, ap);
   va_end(ap);
-
-  /* Add the note to circular buffer */
-
-  sched_note_add((FAR const uint8_t *)&note, length);
 }
 
 void sched_note_syscall_leave(int nr, uintptr_t result)
 {
-  struct note_syscall_leave_s note;
-  FAR struct tcb_s *tcb = this_task();
-
   if (!note_isenabled_syscall(nr))

Review Comment:
   ditto



##########
sched/sched/sched_note.c:
##########
@@ -868,11 +648,11 @@ void sched_note_string(uintptr_t ip, FAR const char *buf)
 
   /* Add the note to circular buffer */
 
-  sched_note_add(note, length);
+  sched_ramnote_write(note, length);
 }
 
 void sched_note_dump(uintptr_t ip, uint8_t event,
-                     FAR const void *buf, size_t len)
+                                 FAR const void *buf, size_t len)

Review Comment:
   revert



##########
sched/sched/sched_note.c:
##########
@@ -698,54 +524,58 @@ void sched_note_csection(FAR struct tcb_s *tcb, bool enter)
       return;
     }
 
-  /* Format the note */
-
-  note_common(tcb, &note.ncs_cmn, sizeof(struct note_csection_s),
-              enter ? NOTE_CSECTION_ENTER : NOTE_CSECTION_LEAVE);
-#ifdef CONFIG_SMP
-  sched_note_flatten(note.ncs_count, &tcb->irqcount, sizeof(tcb->irqcount));
-#endif
-
-  /* Add the note to circular buffer */
-
-  sched_note_add(&note, sizeof(struct note_csection_s));
+  sched_ramnote_csection(tcb, enter);
 }
 #endif
 
 #ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
 void sched_note_spinlock(FAR struct tcb_s *tcb, FAR volatile void *spinlock)
 {
-  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCK);
+  if (!note_isenabled())
+    {
+      return;
+    }
+
+  sched_ramnote_spinlock(tcb, spinlock);
 }
 
 void sched_note_spinlocked(FAR struct tcb_s *tcb,
                            FAR volatile void *spinlock)
 {
-  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_LOCKED);
+  if (!note_isenabled())
+    {
+      return;
+    }
+
+  sched_ramnote_spinlocked(tcb, spinlock);
 }
 
 void sched_note_spinunlock(FAR struct tcb_s *tcb,
                            FAR volatile void *spinlock)
 {
-  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_UNLOCK);
+  if (!note_isenabled())
+    {
+      return;
+    }
+
+  sched_ramnote_spinunlock(tcb, spinlock);
 }
 
 void sched_note_spinabort(FAR struct tcb_s *tcb, FAR volatile void *spinlock)
 {
-  note_spincommon(tcb, spinlock, NOTE_SPINLOCK_ABORT);
+  if (!note_isenabled())
+    {
+      return;
+    }
+
+  sched_ramnote_spinabort(tcb, spinlock);

Review Comment:
   ```suggestion
     if (note_isenabled())
       {
         sched_ramnote_spinabort(tcb, spinlock);
       }
   ```



##########
sched/sched/sched_note.c:
##########
@@ -759,81 +589,31 @@ void sched_note_syscall_enter(int nr, int argc, ...)
     }
 #endif
 
-  /* Format the note */
-
-  length = SIZEOF_NOTE_SYSCALL_ENTER(argc);
-  note_common(tcb, &note.nsc_cmn, length, NOTE_SYSCALL_ENTER);
-  DEBUGASSERT(nr <= UCHAR_MAX);
-  note.nsc_nr = nr;
-  DEBUGASSERT(argc <= MAX_SYSCALL_ARGS);
-  note.nsc_argc = argc;
-
-  /* If needed, retrieve the given syscall arguments */
-
   va_start(ap, argc);
-
-  args = note.nsc_args;
-  for (i = 0; i < argc; i++)
-    {
-      arg = (uintptr_t)va_arg(ap, uintptr_t);
-      sched_note_flatten(args, &arg, sizeof(arg));
-      args += sizeof(uintptr_t);
-    }
-
+  sched_ramnote_syscall_enter(nr, argc, ap);
   va_end(ap);
-
-  /* Add the note to circular buffer */
-
-  sched_note_add((FAR const uint8_t *)&note, length);
 }
 
 void sched_note_syscall_leave(int nr, uintptr_t result)
 {
-  struct note_syscall_leave_s note;
-  FAR struct tcb_s *tcb = this_task();
-
   if (!note_isenabled_syscall(nr))
     {
       return;
     }
 
-  /* Format the note */
-
-  note_common(tcb, &note.nsc_cmn, sizeof(struct note_syscall_leave_s),
-              NOTE_SYSCALL_LEAVE);
-  DEBUGASSERT(nr <= UCHAR_MAX);
-  note.nsc_nr = nr;
-
-  sched_note_flatten(note.nsc_result, &result, sizeof(result));
-
-  /* Add the note to circular buffer */
-
-  sched_note_add(&note, sizeof(struct note_syscall_leave_s));
+  sched_ramnote_syscall_leave(nr, result);
 }
 #endif
 
 #ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
 void sched_note_irqhandler(int irq, FAR void *handler, bool enter)
 {
-  struct note_irqhandler_s note;
-  FAR struct tcb_s *tcb = this_task();
-
   if (!note_isenabled_irq(irq, enter))

Review Comment:
   ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org