driver/note: To support clock_gettime for CPU sleep scenario

Signed-off-by: Majingyun <majingyun@lixiang.com>
This commit is contained in:
majingyun 2025-05-13 19:28:35 +08:00
parent 50c0e13a29
commit a06a75e50c
3 changed files with 33 additions and 0 deletions

View file

@ -36,6 +36,19 @@ config DRIVERS_NOTECTL
If this option is selected, the instrumentation filter control device
/dev/notectl is provided.
config NOTE_GET_PERF_TIME
bool "Note get time config"
default y
---help---
If this option is selected, then note get time from perf time
config NOTE_GET_CLOCK_TIME
bool "Note get time config"
default n
depends on !NOTE_GET_PERF_TIME
---help---
If this option is selected, then note get time from clock time
config DRIVERS_NOTERAM
bool "Note RAM driver"
default y

View file

@ -217,7 +217,17 @@ static void note_common(FAR struct tcb_s *tcb,
note->nc_pid = tcb->pid;
}
#if defined (CONFIG_NOTE_GET_PERF_TIME)
note->nc_systime = perf_gettime();
#elif defined (CONFIG_NOTE_GET_CLOCK_TIME)
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
note->nc_systime = ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
#else
#endif
}
/****************************************************************************

View file

@ -794,7 +794,17 @@ static int noteram_dump_header(FAR struct lib_outstream_s *s,
pid_t pid;
int ret;
#if defined (CONFIG_NOTE_GET_PERF_TIME)
perf_convert(note->nc_systime, &ts);
#elif defined (CONFIG_NOTE_GET_CLOCK_TIME)
ts.tv_sec = note->nc_systime / NSEC_PER_SEC;
ts.tv_nsec = note->nc_systime % NSEC_PER_SEC;
#else
#endif
pid = note->nc_pid;
#ifdef CONFIG_SMP
int cpu = note->nc_cpu;