-
Notifications
You must be signed in to change notification settings - Fork 2k
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
periph_rtt: rtt_set_alarm() blocks IRQ for 80 plus usec on STM32 #19520
Comments
One thought I had was to simply not have |
... so another RTT peripheral that's difficult to use properly. :( |
I think the issue at hand here can be fixed by just moving the busy wait out of the critical section. However, the current behavior seems to provide limited thread safety. I think the unwritten rule was that thread safety is the concern of the layers above periph, unless the periph API states otherwise. Maybe I could interest @chrysn in this topic; I think such issues might be one of his pet peeves. IMO RIOT would greatly profit from explicit documentation which API is thread-safe an where the users need to manage synchronization themselves. Assuming that RTT is indeed not thread-safe and users (such as ztimer) have to synchronize RTT API access, just moving the busy wait below the |
yes. but those functions get also called from within (timer-)ISRs. |
@kaspar030 is correct. Moving the busy wait out of the critical section doesn't help, when called from an ISR (which ztimer does). I also tried moving the busy wait to before the critical section. The intent was to busy wait only if the previous call hadn't synced up yet. However, as I recall, ztimer often makes two calls very quickly (when extending clocks out to 32 bits when hardware doesn't support it), so it didn't completely fix things. |
Explicitness on thread safety is indeed something I like, but for this issue I'll have to pass. |
see bug report here: RIOT-OS#19520
Description
When the
ztimer_msec
module is enabled and backed byperiph_rtt
on a STM32 CPU I noticed jitter in my ISRs of 100-200 usec. Digging into the issue I see the implementation of rtt in all STM32 (STM32F1 being the exception I believe, but it may have similar problems) busy waits inside of a critical section of code where IRQs are disabled. This happens inside thertt_set_alarm()
function. I thought to move the busy wait out of the critical section, but I believeztimer
is calling this function from an ISR anyway.Steps to reproduce the issue
Here is the simplest program I can think of to demonstrate the issue:
Makefile:
main.c:
Expected results
Output-ed max values from sample code above should be very small.
Actual results
Output-ed max values from sample code above are 80-90 usec. When the line
USEMODULE += ztimer_msec
is uncomment in the Makefile, that increases to as much as 183 usec.Versions
RIOT Version 2023.04
The text was updated successfully, but these errors were encountered: