-
Notifications
You must be signed in to change notification settings - Fork 1.5k
driver/note: To support clock_gettime for CPU sleep scenario #16369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Majingyun <majingyun@lixiang.com>
@@ -794,7 +794,17 @@ static int noteram_dump_header(FAR struct lib_outstream_s *s, | |||
pid_t pid; | |||
int ret; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a commit message
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use the same message ("Note get time config") in boot configs, it will confuse users. The description in the config should be clear to the users!
bool "Note get time config" | ||
default y | ||
---help--- | ||
If this option is selected, then note get time from perf time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please improve the "---help---", what is "perf time"? What difference to "clock time", etc. These are question that user need to know before enabling this option
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's change to choice
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if defined (CONFIG_NOTE_GET_PERF_TIME) | |
#if defined(CONFIG_NOTE_GET_PERF_TIME) |
note->nc_systime = perf_gettime(); | ||
|
||
#elif defined (CONFIG_NOTE_GET_CLOCK_TIME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#elif defined (CONFIG_NOTE_GET_CLOCK_TIME) | |
#elif defined(CONFIG_NOTE_GET_CLOCK_TIME) |
note->nc_systime = perf_gettime(); | ||
|
||
#elif defined (CONFIG_NOTE_GET_CLOCK_TIME) | ||
struct timespec ts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't allow define the variable in the middle of function
clock_gettime(CLOCK_REALTIME, &ts); | ||
note->nc_systime = ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec; | ||
|
||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DRIVERS_NOTE_PERF_TIME
---help--- | ||
If this option is selected, then note get time from perf time | ||
|
||
config NOTE_GET_CLOCK_TIME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DRIVERS_NOTE_CLOCK_TIME
Note: Please adhere to Contributing Guidelines.
Summary
In the current code, the note module gets the time from perf_gettime(). When encountering instructions such as idle WFI, the CPU cycle will not continue to grow, resulting in time distortion.
Support note to obtain time from clock_gettime() to support scenarios when the CPUis sleeping.
Impact
The note module obtains time from perf_gettime() by default. Add configuration to support obtaining time from clock_gettime().
Testing
Test environment