Skip to content

Commit a70175e

Browse files
Gary-Hobsonxiaoxiang781216
authored andcommitted
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]>
1 parent 453cde9 commit a70175e

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

drivers/note/note_driver.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ FAR static struct note_driver_s *
203203
NULL
204204
};
205205

206-
#if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0
206+
#if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0 && \
207+
defined(CONFIG_SCHED_INSTRUMENTATION_SWITCH)
207208
static struct note_taskname_s g_note_taskname;
208209
#endif
209210

@@ -475,6 +476,7 @@ static inline int note_isenabled_dump(uint32_t tag)
475476
}
476477
#endif
477478

479+
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
478480
#if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0
479481

480482
/****************************************************************************
@@ -718,7 +720,6 @@ void sched_note_stop(FAR struct tcb_s *tcb)
718720
}
719721
}
720722

721-
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
722723
void sched_note_suspend(FAR struct tcb_s *tcb)
723724
{
724725
struct note_suspend_s note;
@@ -795,7 +796,6 @@ void sched_note_resume(FAR struct tcb_s *tcb)
795796
note_add(*driver, &note, sizeof(struct note_resume_s));
796797
}
797798
}
798-
#endif
799799

800800
#ifdef CONFIG_SMP
801801
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)
875875
}
876876
}
877877

878-
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
879878
void sched_note_cpu_pause(FAR struct tcb_s *tcb, int cpu)
880879
{
881880
struct note_cpu_pause_s note;
@@ -1029,8 +1028,8 @@ void sched_note_cpu_resumed(FAR struct tcb_s *tcb)
10291028
note_add(*driver, &note, sizeof(struct note_cpu_resumed_s));
10301029
}
10311030
}
1032-
#endif
1033-
#endif
1031+
#endif /* CONFIG_SMP */
1032+
#endif /* CONFIG_SCHED_INSTRUMENTATION_SWITCH */
10341033

10351034
#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
10361035
void sched_note_premption(FAR struct tcb_s *tcb, bool locked)
@@ -1975,20 +1974,25 @@ FAR const char *note_get_taskname(pid_t pid)
19751974
{
19761975
FAR struct note_taskname_info_s *ti;
19771976
FAR struct tcb_s *tcb;
1977+
UNUSED(ti);
19781978

19791979
tcb = nxsched_get_tcb(pid);
19801980
if (tcb != NULL)
19811981
{
19821982
return tcb->name;
19831983
}
19841984

1985+
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
19851986
ti = note_find_taskname(pid);
19861987
if (ti != NULL)
19871988
{
19881989
return ti->name;
19891990
}
19901991

19911992
return NULL;
1993+
#else
1994+
return "unknown";
1995+
#endif
19921996
}
19931997

19941998
#endif

drivers/note/noteram_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@ static int noteram_dump_one(FAR uint8_t *p, FAR struct lib_outstream_s *s,
937937

938938
switch (note->nc_type)
939939
{
940+
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
940941
case NOTE_START:
941942
{
942943
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,
956957
}
957958
break;
958959

959-
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
960960
case NOTE_SUSPEND:
961961
{
962962
FAR struct note_suspend_s *nsu = (FAR struct note_suspend_s *)p;

include/nuttx/sched_note.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -577,36 +577,28 @@ extern "C"
577577
*
578578
****************************************************************************/
579579

580-
#ifdef CONFIG_SCHED_INSTRUMENTATION
580+
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
581581
void sched_note_start(FAR struct tcb_s *tcb);
582582
void sched_note_stop(FAR struct tcb_s *tcb);
583-
#else
584-
# define sched_note_start(t)
585-
# define sched_note_stop(t)
586-
#endif
587-
588-
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
589583
void sched_note_suspend(FAR struct tcb_s *tcb);
590584
void sched_note_resume(FAR struct tcb_s *tcb);
591585
#else
586+
# define sched_note_stop(t)
587+
# define sched_note_start(t)
592588
# define sched_note_suspend(t)
593589
# define sched_note_resume(t)
594590
#endif
595591

596-
#if defined(CONFIG_SMP) && defined(CONFIG_SCHED_INSTRUMENTATION)
592+
#if defined(CONFIG_SMP) && defined(CONFIG_SCHED_INSTRUMENTATION_SWITCH)
597593
void sched_note_cpu_start(FAR struct tcb_s *tcb, int cpu);
598594
void sched_note_cpu_started(FAR struct tcb_s *tcb);
599-
#else
600-
# define sched_note_cpu_start(t,c)
601-
# define sched_note_cpu_started(t)
602-
#endif
603-
604-
#if defined(CONFIG_SMP) && defined(CONFIG_SCHED_INSTRUMENTATION_SWITCH)
605595
void sched_note_cpu_pause(FAR struct tcb_s *tcb, int cpu);
606596
void sched_note_cpu_paused(FAR struct tcb_s *tcb);
607597
void sched_note_cpu_resume(FAR struct tcb_s *tcb, int cpu);
608598
void sched_note_cpu_resumed(FAR struct tcb_s *tcb);
609599
#else
600+
# define sched_note_cpu_start(t,c)
601+
# define sched_note_cpu_started(t)
610602
# define sched_note_cpu_pause(t,c)
611603
# define sched_note_cpu_paused(t)
612604
# define sched_note_cpu_resume(t,c)

0 commit comments

Comments
 (0)