You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/02/23 14:30:17 UTC

[nuttx] 02/02: note: correct systime with perf count

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 29a7d267fbabb77e370cad05bbc2784c7259d715
Author: yinshengkai <yi...@xiaomi.com>
AuthorDate: Thu Feb 23 16:40:54 2023 +0800

    note: correct systime with perf count
    
    Signed-off-by: yinshengkai <yi...@xiaomi.com>
---
 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