-
Notifications
You must be signed in to change notification settings - Fork 8.2k
kernel: deprecate and replace k_uptime_get_32() #18742
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
Conversation
This function does not return the low 32 bits of k_uptime_get() as suggested by it's documentation; it returns the number of milliseconds represented by the low 32-bits of the underlying system clock. The truncation before translation results in discontinuities at every point where the system clock increments bit 33. Refine the documentation to describe what it actually does, mark it deprecated, and replace all in-tree uses with an expression that is slower but does the right thing. Closes zephyrproject-rtos#18739. Signed-off-by: Peter Bigot <[email protected]>
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.
This function does not return the low 32 bits of k_uptime_get() as
suggested by it's documentation
Ok, so that's where the bug lies, and what needs fixing, instead of making a statue of the incorrect implementation in stone and telling not to use it.
We could re-implement I'm happy to instead take the re-implement path, with or without deprecating, if that's preferred. But this API appears to be used in the kernel to measure timeouts: durations are measured by subtracting values returned by PR #18744 takes the alternative approach. |
Not sure I get what you mean here @pfalcon. The current implementation is being marked as deprecated in this PR because what it does now does not reflect what a user might infer from the function name. Do you suggest that we should keep the function and cast to uint32 inside the new implementation or that we keep the current implementation but rename it? |
This way we would have k_uptime_get_32() and k_uptime_get() with no difference on performance, which so far justified existence of k_uptime_get_32(). |
|
@pizi-nordic since |
|
@alexanderwachter: So there is no doubts that this PR should go in... |
Let me explain by example. In #18708, it was found that pthread_cond_timedwait(), pthread_mutex_timedlock() functions don't do what's described in the documentation. However, I don't deprecate them with a desire to make users find workarounds or introduce new names for the same functions. I just fix incorrect implementation.
Really? I thought it exists just because it's convenient API to use. And don't let me start on possible implications on register pressure when returning 64bit, instead of 32bits, on all architectures and compilers, past, present, and future, with LTO and not, with a case when ticks and millisecond perfectly align and not, for the case of no userspace separation and with it (reading comments on #18064 was insightful, even though it talks about 64-bit arguments, not returns). Let me just point that fixing k_uptime_get_32() has a very obvious benefit of making unnecessary patches rampaging thru 47 files of the codebase (2 days before the planned release date, just by pure coincidence, surely nobody thinks about merging it into this release). |
|
Seems like #17155 already addresses the issues here, no? |
|
Withdrawn, prefer #18744 |
This function does not return the low 32 bits of k_uptime_get() as
suggested by it's documentation; it returns the number of milliseconds
represented by the low 32-bits of the underlying system clock. The
truncation before translation results in discontinuities at every point
where the system clock increments bit 33.
Refine the documentation to describe what it actually does, mark it
deprecated, and replace all in-tree uses with an expression that is
slower but does the right thing.
Closes #18739.
Signed-off-by: Peter Bigot [email protected]