Skip to content
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

Misc. timing test fixes #19596

Closed
wants to merge 3 commits into from

Conversation

andyross
Copy link
Contributor

@andyross andyross commented Oct 3, 2019

More evacuees from #17155 that can stand on their own. These aren't related to the timeout work per se, except insofar as the bugs are sensitivities to timing. See commit notes for details.

Note that two of the patches were written above the new conversion API, so they require #19591 to be merged before they will build in CI.

@zephyrbot zephyrbot added area: Tests Issues related to a particular existing or missing test area: Kernel labels Oct 3, 2019
Andy Ross added 3 commits October 4, 2019 09:50
These tests had what appeared to be a hard-coded one tick slop added
to the timeout for a fifo to handle the addition of a full tick
(vs. proper rounding) in k_sleep() (which is a separate bug).  But the
timeout side has been tightened with the recent change and doesn't
wait as long as an equivalent sleep anymore (which is a feature), so
the sides don't match.

And it's wrong anyway, as there are two sleeps being accounted for (the
fifo timeout and the sleep in the other thread doing the put), both of
which can misalign.  Do this with the proper tick conversion API, and
use two ticks, not one.

Signed-off-by: Andy Ross <[email protected]>
In the "POLL" implementation of k_queue_get(), if it ever happened
that the elapsed time exactly equalled the time we were supposed to
wait, the k_poll() call would be called (correctly) with a timeout of
zero, and return synchronously.  But the "done" flag would not be set
because of an off by one error, so we would have to spin for the next
tick needlessly.

Even worse: on native_posix, nothing in this loop returns control to
the main loop so in fact there we spin forever! (Which is how this got
discovered.)

Signed-off-by: Andy Ross <[email protected]>
This tests hard codes a 100 Hz tick rate, but it sets a k_timer for a
DURATION value of 5ms, which cannot be done with a precision, then
checks it against an unrelated k_busy_wait() time of exactly 10ms,
which is right at the boundary of what is possible.  Playing with
timer stuff can push this over the edge easily.

Correct DURATION to reflect "one tick", and spin for that value, plus
exactly one tick of slop before testing to see whether the timer ISR
ran.

Signed-off-by: Andy Ross <[email protected]>
@andyross
Copy link
Contributor Author

andyross commented Oct 4, 2019

Removed the mis-merged fix that had already been rediscovered and merged via @vanti

@nashif nashif added the DNM This PR should not be merged (Do Not Merge) label Oct 4, 2019
@carlescufi
Copy link
Member

@andyross should this be revived?

@andyross
Copy link
Contributor Author

andyross commented Apr 22, 2020

The queue one should be cleaned up and merged for sure; it's a rare but real hard spin condition. The other two are less obviously needed. I think they're probably coded wrong, but the final version of the timeout patch matched the per-cycle behavior of the original code a little better than the first version did, so they aren't needed.

@github-actions github-actions bot added has-conflicts Issue/PR has conflicts with another issue/PR and removed has-conflicts Issue/PR has conflicts with another issue/PR labels Jun 29, 2020
@nashif nashif added the Stale label Sep 4, 2020
@github-actions github-actions bot closed this Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Kernel area: Tests Issues related to a particular existing or missing test DNM This PR should not be merged (Do Not Merge) has-conflicts Issue/PR has conflicts with another issue/PR Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants