-
Notifications
You must be signed in to change notification settings - Fork 96
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
Task/semaphore tweaking #276
Conversation
dacddb1
to
676daa7
Compare
d173733
to
9662b30
Compare
f808505
to
66023c6
Compare
From a brief look it looks good. The whole compat thing isn't exactly pretty but most of the weirdness there originates from problems with the Xtensa backend back then - I think the compiler got much better so it's great to revisit. Back then moving a static variable to a different file made the difference between working and crashing so I was very afraid of touching that code 😆 IMHO we shouldn't check-in the launch config I'll have another look and run the smoke tests |
Ooops, removed. I have more changes in mind but I didn't want this PR to grow colossal. |
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.
LGTM, just one small nit :)
Co-authored-by: Scott Mabin <[email protected]>
Good eyes! |
Still doing the smoketesting but there is one small thing:
GH doesn't let me comment on that line |
Did the tests and it almost looks good. There is one thing which is a bit sus: Running the
In that case the It sometimes works but often not. That is different for me on main.
|
I really need to source a dev board for each line, don't I? ... Can one of you guys help me bisect this issue? It seems very weird to me that a particular line would break. I would expect all RISC-V, but I am also not familiar with them. |
One more thing: Looking at old comments (#235 (review)) it smells to me if something else might be the culprit with |
I'm also surprised it's only on one of the RISC-V socs ... I'll do a git bisect |
Bisect got me to the first commit but maybe we should make sure it's not a red herring and have someone else verify this. @MabezDev or @jessebraham - could you try to run the |
It's not impossible that the first commit has an impact here, as it's changing timer expiration times by a few cycles at least. I'd be very surprised for this to matter. On the other hand, it turns out that on Xtensa, the timestamps must not be read in a critical section, as due to a race condition the function may occasionally return lower timestamps than expected. So if it matters where and how the code accesses the current time, it's a bit of a conflict between the two architectures. |
I see the same behaviour in this branch as the current main branch, so I don't think these changes have worsened anything. |
Thanks for checking this ..... then I guess I will merge it 👍 |
get_systimer_count()
is anAtomicU64
which is implemented using a critical section. The compiler is not smart enough to remove nested critical sections, so they mostly just waste time. If the slightly closer deadlines (caused by hoisting the timestamp reading out of the loop) can be tolerated, this PR should reduce instruction counts slightly in every loop iteration.WORKER_HIGH
doesn't need to be in anOption
. It can be static-initialized instead.TIMERS
are only accessed in critical sections. I don't believe memory fencing is necessary between accessing individual array elements, though I admit I'm not quite sure what a fence achieves at all here.All in all, this PR results in about 1kB reduction in firmware size for me.