From d05b9a9c7994a53d4d85e42f7d5c21027b5e3606 Mon Sep 17 00:00:00 2001 From: zhanghu6 Date: Fri, 3 Dec 2021 12:26:42 +0800 Subject: [PATCH] note dump: add CONFIG_SCHED_INSTRUMENTATION_SWITCH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. If CONFIG_SCHED_INSTRUMENTATION_SWITCH is enabled, then these additional interfaces are expected: sched_note_suspend sched_note_resume at the same time,If CONFIG_SMP is enabled,then expected: sched_note_cpu_pause sched_note_cpu_paused sched_note_cpu_resume sched_note_cpu_resumed 2. other board if enable SCHED_INSTRUMENTATION,SCHED_INSTRUMENTATION_SWITCH to defconfig. --- .../spresense/configs/nsh_trace/defconfig | 1 + .../lc823450-xgevk/configs/elf/defconfig | 1 + .../lc823450-xgevk/configs/ipl2/defconfig | 1 + .../lc823450-xgevk/configs/knsh/defconfig | 1 + .../lc823450-xgevk/configs/krndis/defconfig | 1 + .../configs/posix_spawn/defconfig | 1 + .../stm32f746-ws/configs/nsh/defconfig | 1 + .../esp32c3-devkit/configs/watcher/defconfig | 1 + .../k210/maix-bit/configs/smp2/defconfig | 1 + boards/sim/sim/sim/README.txt | 2 ++ boards/sim/sim/sim/configs/note/defconfig | 1 + .../esp32-devkitc/configs/watcher/defconfig | 1 + include/nuttx/sched_note.h | 31 ++++++++++++++++--- sched/Kconfig | 17 ++++++++-- sched/sched/sched_note.c | 4 +++ 15 files changed, 59 insertions(+), 6 deletions(-) diff --git a/boards/arm/cxd56xx/spresense/configs/nsh_trace/defconfig b/boards/arm/cxd56xx/spresense/configs/nsh_trace/defconfig index bd3fee875e..f08776eec6 100644 --- a/boards/arm/cxd56xx/spresense/configs/nsh_trace/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/nsh_trace/defconfig @@ -45,6 +45,7 @@ CONFIG_RTC_DRIVER=y CONFIG_SCHED_INSTRUMENTATION=y CONFIG_SCHED_INSTRUMENTATION_FILTER=y CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y CONFIG_SCHED_INSTRUMENTATION_SYSCALL=y CONFIG_SDCLONE_DISABLE=y CONFIG_SPI=y diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/elf/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/elf/defconfig index 0f21d8a342..7ee4863434 100644 --- a/boards/arm/lc823450/lc823450-xgevk/configs/elf/defconfig +++ b/boards/arm/lc823450/lc823450-xgevk/configs/elf/defconfig @@ -53,6 +53,7 @@ CONFIG_SCHED_ATEXIT=y CONFIG_SCHED_CHILD_STATUS=y CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_INSTRUMENTATION=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y CONFIG_SCHED_ONEXIT=y CONFIG_SCHED_ONEXIT_MAX=32 CONFIG_SCHED_STARTHOOK=y diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/ipl2/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/ipl2/defconfig index 4cc6b85356..7a14d717e8 100644 --- a/boards/arm/lc823450/lc823450-xgevk/configs/ipl2/defconfig +++ b/boards/arm/lc823450/lc823450-xgevk/configs/ipl2/defconfig @@ -52,6 +52,7 @@ CONFIG_SCHED_ATEXIT=y CONFIG_SCHED_CHILD_STATUS=y CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_INSTRUMENTATION=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y CONFIG_SCHED_ONEXIT=y CONFIG_SCHED_ONEXIT_MAX=32 CONFIG_SCHED_STARTHOOK=y diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig index 657bf78406..4d23ea0778 100644 --- a/boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig +++ b/boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig @@ -95,6 +95,7 @@ CONFIG_SCHED_ATEXIT=y CONFIG_SCHED_CHILD_STATUS=y CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_INSTRUMENTATION=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y CONFIG_SCHED_ONEXIT=y CONFIG_SCHED_ONEXIT_MAX=32 CONFIG_SCHED_STARTHOOK=y diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig index 35459b482a..f9c45b3027 100644 --- a/boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig +++ b/boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig @@ -150,6 +150,7 @@ CONFIG_SCHED_HPWORK=y CONFIG_SCHED_HPWORKPRIORITY=192 CONFIG_SCHED_INSTRUMENTATION=y CONFIG_SCHED_INSTRUMENTATION_PREEMPTION=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_LPWORKPRIORITY=60 CONFIG_SCHED_ONEXIT=y diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/posix_spawn/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/posix_spawn/defconfig index 1e0b1e3ce6..0dc4714568 100644 --- a/boards/arm/lc823450/lc823450-xgevk/configs/posix_spawn/defconfig +++ b/boards/arm/lc823450/lc823450-xgevk/configs/posix_spawn/defconfig @@ -52,6 +52,7 @@ CONFIG_SCHED_ATEXIT=y CONFIG_SCHED_CHILD_STATUS=y CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_INSTRUMENTATION=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y CONFIG_SCHED_ONEXIT=y CONFIG_SCHED_ONEXIT_MAX=32 CONFIG_SCHED_STARTHOOK=y diff --git a/boards/arm/stm32f7/stm32f746-ws/configs/nsh/defconfig b/boards/arm/stm32f7/stm32f746-ws/configs/nsh/defconfig index bbb13a69cc..5934031db3 100644 --- a/boards/arm/stm32f7/stm32f746-ws/configs/nsh/defconfig +++ b/boards/arm/stm32f7/stm32f746-ws/configs/nsh/defconfig @@ -69,6 +69,7 @@ CONFIG_SCHED_HPWORK=y CONFIG_SCHED_HPWORKPRIORITY=192 CONFIG_SCHED_HPWORKSTACKSIZE=1800 CONFIG_SCHED_INSTRUMENTATION=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_LPWORKSTACKSIZE=1800 CONFIG_SCHED_WAITPID=y diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/configs/watcher/defconfig b/boards/risc-v/esp32c3/esp32c3-devkit/configs/watcher/defconfig index ab4ab67cc2..1fcb6bf952 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/configs/watcher/defconfig +++ b/boards/risc-v/esp32c3/esp32c3-devkit/configs/watcher/defconfig @@ -40,6 +40,7 @@ CONFIG_PREALLOC_TIMERS=0 CONFIG_RAW_BINARY=y CONFIG_RR_INTERVAL=200 CONFIG_SCHED_INSTRUMENTATION=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y CONFIG_SCHED_WAITPID=y CONFIG_START_DAY=29 CONFIG_START_MONTH=11 diff --git a/boards/risc-v/k210/maix-bit/configs/smp2/defconfig b/boards/risc-v/k210/maix-bit/configs/smp2/defconfig index 2d198857c4..ce3883bc45 100644 --- a/boards/risc-v/k210/maix-bit/configs/smp2/defconfig +++ b/boards/risc-v/k210/maix-bit/configs/smp2/defconfig @@ -45,6 +45,7 @@ CONFIG_SCHED_ATEXIT=y CONFIG_SCHED_CHILD_STATUS=y CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_INSTRUMENTATION=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y CONFIG_SCHED_ONEXIT=y CONFIG_SCHED_ONEXIT_MAX=32 CONFIG_SCHED_STARTHOOK=y diff --git a/boards/sim/sim/sim/README.txt b/boards/sim/sim/sim/README.txt index 1186f7769e..9f6cc330fd 100644 --- a/boards/sim/sim/sim/README.txt +++ b/boards/sim/sim/sim/README.txt @@ -316,7 +316,9 @@ SMP +CONFIG_DEBUG_SCHED=y -# CONFIG_SCHED_INSTRUMENTATION is not set + -# CONFIG_SCHED_INSTRUMENTATION_SWITCH is not set +CONFIG_SCHED_INSTRUMENTATION=y + +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y The SMP configuration will run with: diff --git a/boards/sim/sim/sim/configs/note/defconfig b/boards/sim/sim/sim/configs/note/defconfig index feae620c58..c29c392399 100644 --- a/boards/sim/sim/sim/configs/note/defconfig +++ b/boards/sim/sim/sim/configs/note/defconfig @@ -31,6 +31,7 @@ CONFIG_SCHED_INSTRUMENTATION_CSECTION=y CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER=y CONFIG_SCHED_INSTRUMENTATION_PREEMPTION=y CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y CONFIG_SCHED_ONEXIT=y CONFIG_SCHED_WAITPID=y CONFIG_SYSTEM_NSH=y diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/watcher/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/watcher/defconfig index 99999b00b0..123de81efb 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/watcher/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/watcher/defconfig @@ -41,6 +41,7 @@ CONFIG_RAM_START=0x20000000 CONFIG_RAW_BINARY=y CONFIG_RR_INTERVAL=200 CONFIG_SCHED_INSTRUMENTATION=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y CONFIG_SPI=y diff --git a/include/nuttx/sched_note.h b/include/nuttx/sched_note.h index f96901eba4..1187889c6a 100644 --- a/include/nuttx/sched_note.h +++ b/include/nuttx/sched_note.h @@ -108,18 +108,24 @@ enum note_type_e { NOTE_START = 0, - NOTE_STOP = 1, + NOTE_STOP = 1 +#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH + , NOTE_SUSPEND = 2, NOTE_RESUME = 3 +#endif #ifdef CONFIG_SMP , NOTE_CPU_START = 4, - NOTE_CPU_STARTED = 5, + NOTE_CPU_STARTED = 5 +#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH + , NOTE_CPU_PAUSE = 6, NOTE_CPU_PAUSED = 7, NOTE_CPU_RESUME = 8, NOTE_CPU_RESUMED = 9 #endif +#endif #ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION , NOTE_PREEMPT_LOCK = 10, @@ -191,6 +197,7 @@ struct note_stop_s struct note_common_s nsp_cmn; /* Common note parameters */ }; +#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH /* This is the specific form of the NOTE_SUSPEND note */ struct note_suspend_s @@ -205,6 +212,7 @@ struct note_resume_s { struct note_common_s nre_cmn; /* Common note parameters */ }; +#endif #ifdef CONFIG_SMP @@ -223,6 +231,7 @@ struct note_cpu_started_s struct note_common_s ncs_cmn; /* Common note parameters */ }; +#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH /* This is the specific form of the NOTE_CPU_PAUSE note */ struct note_cpu_pause_s @@ -253,6 +262,7 @@ struct note_cpu_resumed_s struct note_common_s ncr_cmn; /* Common note parameters */ }; #endif +#endif #ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION /* This is the specific form of the NOTE_PREEMPT_LOCK/UNLOCK note */ @@ -406,24 +416,37 @@ struct note_filter_irq_s void sched_note_start(FAR struct tcb_s *tcb); void sched_note_stop(FAR struct tcb_s *tcb); + +#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_suspend(t) +# define sched_note_resume(t) +#endif #ifdef CONFIG_SMP void sched_note_cpu_start(FAR struct tcb_s *tcb, int cpu); 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); 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) # define sched_note_cpu_resumed(t) #endif +#else +# define sched_note_cpu_pause(t,c) +# define sched_note_cpu_paused(t) +# define sched_note_cpu_resume(t,c) +# define sched_note_cpu_resumed(t) +# define sched_note_cpu_start(t,c) +# define sched_note_cpu_started(t) +#endif #ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION void sched_note_premption(FAR struct tcb_s *tcb, bool locked); diff --git a/sched/Kconfig b/sched/Kconfig index bf111c5e45..9aaf1d513c 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -946,6 +946,21 @@ config SCHED_INSTRUMENTATION void sched_note_start(FAR struct tcb_s *tcb); void sched_note_stop(FAR struct tcb_s *tcb); + + If CONFIG_SMP is enabled, then these additional interfaces are + expected: + + void sched_note_cpu_start(FAR struct tcb_s *tcb, int cpu); + void sched_note_cpu_started(FAR struct tcb_s *tcb); + +if SCHED_INSTRUMENTATION + +config SCHED_INSTRUMENTATION_SWITCH + bool "Use note switch for instrumentation" + default n + ---help--- + Use note switch for instrumentation. + void sched_note_suspend(FAR struct tcb_s *tcb); void sched_note_resume(FAR struct tcb_s *tcb); @@ -962,8 +977,6 @@ config SCHED_INSTRUMENTATION done in these interfaces. For example, normal devices may not be used; syslog output cannot be performed. -if SCHED_INSTRUMENTATION - config SCHED_INSTRUMENTATION_EXTERNAL bool "System performance monitor endpoints are external" default n diff --git a/sched/sched/sched_note.c b/sched/sched/sched_note.c index b40db72463..7c224cd9ed 100644 --- a/sched/sched/sched_note.c +++ b/sched/sched/sched_note.c @@ -451,6 +451,7 @@ void sched_note_stop(FAR struct tcb_s *tcb) sched_note_add(¬e, sizeof(struct note_stop_s)); } +#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH void sched_note_suspend(FAR struct tcb_s *tcb) { struct note_suspend_s note; @@ -488,6 +489,7 @@ void sched_note_resume(FAR struct tcb_s *tcb) sched_note_add(¬e, sizeof(struct note_resume_s)); } +#endif #ifdef CONFIG_SMP void sched_note_cpu_start(FAR struct tcb_s *tcb, int cpu) @@ -529,6 +531,7 @@ void sched_note_cpu_started(FAR struct tcb_s *tcb) sched_note_add(¬e, sizeof(struct note_cpu_started_s)); } +#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH void sched_note_cpu_pause(FAR struct tcb_s *tcb, int cpu) { struct note_cpu_pause_s note; @@ -607,6 +610,7 @@ void sched_note_cpu_resumed(FAR struct tcb_s *tcb) sched_note_add(¬e, sizeof(struct note_cpu_resumed_s)); } #endif +#endif #ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION void sched_note_premption(FAR struct tcb_s *tcb, bool locked)