This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit a70175ea0671f00990655a6411e604852d4ef9a3
Author: yinshengkai <[email protected]>
AuthorDate: Tue Oct 8 23:23:21 2024 +0800

    note: make sched_note_start depend on INSTRUMENTATION_SWITCH
    
    In some cases, we only need to use INSTRUMENTATION_DUMP to record custom 
data,
    and we don't want the thread start and end information
    
    Move this part to INSTRUMENTATION_SWTICH for recording
    
    Signed-off-by: yinshengkai <[email protected]>
---
 drivers/note/note_driver.c    | 16 ++++++++++------
 drivers/note/noteram_driver.c |  2 +-
 include/nuttx/sched_note.h    | 20 ++++++--------------
 3 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/drivers/note/note_driver.c b/drivers/note/note_driver.c
index cb0fdd3d8c..f5ce4785b3 100644
--- a/drivers/note/note_driver.c
+++ b/drivers/note/note_driver.c
@@ -203,7 +203,8 @@ FAR static struct note_driver_s *
   NULL
 };
 
-#if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0
+#if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0 && \
+    defined(CONFIG_SCHED_INSTRUMENTATION_SWITCH)
 static struct note_taskname_s g_note_taskname;
 #endif
 
@@ -475,6 +476,7 @@ static inline int note_isenabled_dump(uint32_t tag)
 }
 #endif
 
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
 #if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0
 
 /****************************************************************************
@@ -718,7 +720,6 @@ void sched_note_stop(FAR struct tcb_s *tcb)
     }
 }
 
-#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
 void sched_note_suspend(FAR struct tcb_s *tcb)
 {
   struct note_suspend_s note;
@@ -795,7 +796,6 @@ void sched_note_resume(FAR struct tcb_s *tcb)
       note_add(*driver, &note, sizeof(struct note_resume_s));
     }
 }
-#endif
 
 #ifdef CONFIG_SMP
 void sched_note_cpu_start(FAR struct tcb_s *tcb, int cpu)
@@ -875,7 +875,6 @@ void sched_note_cpu_started(FAR struct tcb_s *tcb)
     }
 }
 
-#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
 void sched_note_cpu_pause(FAR struct tcb_s *tcb, int cpu)
 {
   struct note_cpu_pause_s note;
@@ -1029,8 +1028,8 @@ void sched_note_cpu_resumed(FAR struct tcb_s *tcb)
       note_add(*driver, &note, sizeof(struct note_cpu_resumed_s));
     }
 }
-#endif
-#endif
+#endif /* CONFIG_SMP */
+#endif /* CONFIG_SCHED_INSTRUMENTATION_SWITCH */
 
 #ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
 void sched_note_premption(FAR struct tcb_s *tcb, bool locked)
@@ -1975,6 +1974,7 @@ FAR const char *note_get_taskname(pid_t pid)
 {
   FAR struct note_taskname_info_s *ti;
   FAR struct tcb_s *tcb;
+  UNUSED(ti);
 
   tcb = nxsched_get_tcb(pid);
   if (tcb != NULL)
@@ -1982,6 +1982,7 @@ FAR const char *note_get_taskname(pid_t pid)
       return tcb->name;
     }
 
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
   ti = note_find_taskname(pid);
   if (ti != NULL)
     {
@@ -1989,6 +1990,9 @@ FAR const char *note_get_taskname(pid_t pid)
     }
 
   return NULL;
+#else
+  return "unknown";
+#endif
 }
 
 #endif
diff --git a/drivers/note/noteram_driver.c b/drivers/note/noteram_driver.c
index 81b04d07f1..b05777eef9 100644
--- a/drivers/note/noteram_driver.c
+++ b/drivers/note/noteram_driver.c
@@ -937,6 +937,7 @@ static int noteram_dump_one(FAR uint8_t *p, FAR struct 
lib_outstream_s *s,
 
   switch (note->nc_type)
     {
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
     case NOTE_START:
       {
         ret += noteram_dump_header(s, note, ctx);
@@ -956,7 +957,6 @@ static int noteram_dump_one(FAR uint8_t *p, FAR struct 
lib_outstream_s *s,
       }
       break;
 
-#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
     case NOTE_SUSPEND:
       {
         FAR struct note_suspend_s *nsu = (FAR struct note_suspend_s *)p;
diff --git a/include/nuttx/sched_note.h b/include/nuttx/sched_note.h
index 44cad9b739..b0f3434e0c 100644
--- a/include/nuttx/sched_note.h
+++ b/include/nuttx/sched_note.h
@@ -577,36 +577,28 @@ extern "C"
  *
  ****************************************************************************/
 
-#ifdef CONFIG_SCHED_INSTRUMENTATION
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
 void sched_note_start(FAR struct tcb_s *tcb);
 void sched_note_stop(FAR struct tcb_s *tcb);
-#else
-#  define sched_note_start(t)
-#  define sched_note_stop(t)
-#endif
-
-#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
 void sched_note_suspend(FAR struct tcb_s *tcb);
 void sched_note_resume(FAR struct tcb_s *tcb);
 #else
+#  define sched_note_stop(t)
+#  define sched_note_start(t)
 #  define sched_note_suspend(t)
 #  define sched_note_resume(t)
 #endif
 
-#if defined(CONFIG_SMP) && defined(CONFIG_SCHED_INSTRUMENTATION)
+#if defined(CONFIG_SMP) && defined(CONFIG_SCHED_INSTRUMENTATION_SWITCH)
 void sched_note_cpu_start(FAR struct tcb_s *tcb, int cpu);
 void sched_note_cpu_started(FAR struct tcb_s *tcb);
-#else
-#  define sched_note_cpu_start(t,c)
-#  define sched_note_cpu_started(t)
-#endif
-
-#if defined(CONFIG_SMP) && defined(CONFIG_SCHED_INSTRUMENTATION_SWITCH)
 void sched_note_cpu_pause(FAR struct tcb_s *tcb, int cpu);
 void sched_note_cpu_paused(FAR struct tcb_s *tcb);
 void sched_note_cpu_resume(FAR struct tcb_s *tcb, int cpu);
 void sched_note_cpu_resumed(FAR struct tcb_s *tcb);
 #else
+#  define sched_note_cpu_start(t,c)
+#  define sched_note_cpu_started(t)
 #  define sched_note_cpu_pause(t,c)
 #  define sched_note_cpu_paused(t)
 #  define sched_note_cpu_resume(t,c)

Reply via email to