From 29a7d267fbabb77e370cad05bbc2784c7259d715 Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Thu, 23 Feb 2023 16:40:54 +0800 Subject: [PATCH] note: correct systime with perf count Signed-off-by: yinshengkai --- drivers/note/note_driver.c | 7 +++++++ sched/Kconfig | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/note/note_driver.c b/drivers/note/note_driver.c index fd3181e5f7..d73bf506be 100644 --- a/drivers/note/note_driver.c +++ b/drivers/note/note_driver.c @@ -223,8 +223,15 @@ static void note_common(FAR struct tcb_s *tcb, FAR struct note_common_s *note, uint8_t length, uint8_t type) { +#ifdef CONFIG_SCHED_INSTRUMENTATION_PERFCOUNT + struct timespec perftime; +#endif struct timespec ts; clock_systime_timespec(&ts); +#ifdef CONFIG_SCHED_INSTRUMENTATION_PERFCOUNT + up_perf_convert(up_perf_gettime(), &perftime); + ts.tv_nsec = perftime.tv_nsec; +#endif /* Save all of the common fields */ diff --git a/sched/Kconfig b/sched/Kconfig index cb90fca2a8..5f76c8ff79 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -973,6 +973,14 @@ config SCHED_INSTRUMENTATION_CPUSET ---help--- Monitor only CPUs in the bitset. Bit 0=CPU0, Bit1=CPU1, etc. +config SCHED_INSTRUMENTATION_PERFCOUNT + bool "Use perf count for instrumentation" + default n + ---help--- + Enabling this option will use perfcount as the clock source for tv_nsec + to achieve higher precision time. + This requires calling up_perf_init at system startup. + config SCHED_INSTRUMENTATION_FILTER bool "Instrumentation filter" default n