From ae38e3eb10bf1a7224444a1d4b78ffc2efe8a1b7 Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Tue, 27 Sep 2022 16:05:28 +0800 Subject: [PATCH] sched: Optimize sched_note_begin/end Optimize sched_note_begin/end, replace note_printf with note_string sched_note_begin/end optimized from 50us to 1us per consumption Signed-off-by: yinshengkai --- include/nuttx/sched_note.h | 12 ++++++------ sched/sched/sched_note.c | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/nuttx/sched_note.h b/include/nuttx/sched_note.h index b0613e3b185..ed24982e1a0 100644 --- a/include/nuttx/sched_note.h +++ b/include/nuttx/sched_note.h @@ -125,9 +125,9 @@ # define SCHED_NOTE_BPRINTF(event, fmt, ...) \ sched_note_bprintf(SCHED_NOTE_IP, event, fmt, ##__VA_ARGS__) # define SCHED_NOTE_BEGIN() \ - sched_note_begin(SCHED_NOTE_IP, __FUNCTION__) + sched_note_begin(SCHED_NOTE_IP) # define SCHED_NOTE_END() \ - sched_note_end(SCHED_NOTE_IP, __FUNCTION__) + sched_note_end(SCHED_NOTE_IP) #else # define SCHED_NOTE_STRING(buf) # define SCHED_NOTE_DUMP(event, buf, len) @@ -553,8 +553,8 @@ void sched_note_printf(uintptr_t ip, FAR const char *fmt, ...) printflike(2, 3); void sched_note_bprintf(uintptr_t ip, uint8_t event, FAR const char *fmt, ...) printflike(3, 4); -void sched_note_begin(uintptr_t ip, FAR const char *buf); -void sched_note_end(uintptr_t ip, FAR const char *buf); +void sched_note_begin(uintptr_t ip); +void sched_note_end(uintptr_t ip); #else # define sched_note_string(ip,b) # define sched_note_dump(ip,e,b,l) @@ -562,8 +562,8 @@ void sched_note_end(uintptr_t ip, FAR const char *buf); # define sched_note_vbprintf(ip,e,f,v) # define sched_note_printf(ip,f,...) # define sched_note_bprintf(ip,e,f,...) -# define sched_note_begin(ip,f) -# define sched_note_end(ip,f) +# define sched_note_begin(ip) +# define sched_note_end(ip) #endif /* CONFIG_SCHED_INSTRUMENTATION_DUMP */ #if defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT) diff --git a/sched/sched/sched_note.c b/sched/sched/sched_note.c index 3adc93cd6d8..a4d3bb1dd6b 100644 --- a/sched/sched/sched_note.c +++ b/sched/sched/sched_note.c @@ -1161,14 +1161,14 @@ void sched_note_bprintf(uintptr_t ip, uint8_t event, va_end(va); } -void sched_note_begin(uintptr_t ip, FAR const char *buf) +void sched_note_begin(uintptr_t ip) { - sched_note_printf(ip, "B|%d|%s", getpid(), buf); + sched_note_string(ip, "B"); } -void sched_note_end(uintptr_t ip, FAR const char *buf) +void sched_note_end(uintptr_t ip) { - sched_note_printf(ip, "E|%d|%s", getpid(), buf); + sched_note_string(ip, "E"); } #endif /* CONFIG_SCHED_INSTRUMENTATION_DUMP */