-
Notifications
You must be signed in to change notification settings - Fork 7.4k
logging: Use k_uptime_get_32 for high frequency system clock #14074
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
logging: Use k_uptime_get_32 for high frequency system clock #14074
Conversation
Don't you also need to pass a different value to |
Codecov Report
@@ Coverage Diff @@
## master #14074 +/- ##
==========================================
+ Coverage 52.61% 52.61% +<.01%
==========================================
Files 307 307
Lines 45472 45473 +1
Branches 10530 10530
==========================================
+ Hits 23924 23925 +1
Misses 16666 16666
Partials 4882 4882
Continue to review full report at Codecov.
|
If system clock runs fast k_cycle_get_32(), which is the timestamp source, wraps often (few minutes). This patch changes default timestamp function to use k_uptime_get_32() if system clock frequency is higher than 1 MHz and k_cycle_get_32() otherwise. If system clock runs at 1 MHz, counter will wrap every 71.5 minutes. Signed-off-by: Krzysztof Chruscinski <[email protected]>
7c60572
to
dd57136
Compare
Good point. Fixed. |
@@ -298,7 +305,7 @@ void log_core_init(void) | |||
|
|||
/* Set default timestamp. */ | |||
timestamp_func = timestamp_get; | |||
log_output_timestamp_freq_set(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC); | |||
log_output_timestamp_freq_set(freq); |
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.
Couldn't we actually make this a lot simpler by not requiring a separate static function at all:
if (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC > 1000000)
timestamp_func = k_uptime_get_32;
log_output_timestamp_freq_set(MSEC_PER_SEC);
} else {
timestamp_func = k_cycle_get_32;
log_output_timestamp_freq_set(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC);
}
I'll leave it up to you to decide if it makes sense/is worth it.
If system clock runs fast k_cycle_get_32(), which is the timestamp
source, wraps often (few minutes). This patch changes default
timestamp function to use k_uptime_get_32() if system clock
frequency is higher than 1 MHz and k_cycle_get_32() otherwise.
If system clock runs at 1 MHz, counter will wrap every 71.5 minutes.
Fixes #9043.
Fixes #14010.
Signed-off-by: Krzysztof Chruscinski [email protected]