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

tests: kernel: timer: timer_behavior: Tweak expected std deviation #74939

Merged

Conversation

nordic-krch
Copy link
Contributor

If frequency of the system clock is lower then deviation may exceed default value (10us). Instead of adjusting the default value, test is rounding up expected standard deviation to a single clock cycle.

Fixes #71863.

@nordic-krch nordic-krch added the bug The issue is a bug, or the PR is fixing a bug label Jun 25, 2024
@teburd
Copy link
Collaborator

teburd commented Jun 25, 2024

I like the change, agree with @golowanow the calculation should be done once before the TC_PRINT and zaasert usage

andyross
andyross previously approved these changes Jun 25, 2024
Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable. FWIW, an alternate technique would be to do the tracking and math in cycle space and not microseconds and just clamp the minimum to "1", which IMHO would be clearer but require more rework.

npitre
npitre previously approved these changes Jun 25, 2024
If frequency of the system clock is lower then deviation may exceed
default value (10us). Instead of adjusting the default value, test is
rounding up expected standard deviation to a single clock cycle.

Signed-off-by: Krzysztof Chruściński <[email protected]>
cfriedt
cfriedt previously approved these changes Jun 28, 2024
teburd
teburd previously approved these changes Jun 28, 2024
@nordic-krch nordic-krch added this to the v3.7.0 milestone Jul 2, 2024
@@ -283,7 +285,7 @@ static void do_test_using(void (*sample_collection_fn)(void), const char *mechan
", \"CONFIG_SYS_CLOCK_TICKS_PER_SEC\":%d"
", \"CONFIG_TIMER_TEST_PERIOD\":%d"
", \"CONFIG_TIMER_TEST_SAMPLES\":%d"
", \"CONFIG_TIMER_TEST_MAX_STDDEV\":%d"
", \"MAX STD DEV\":%d"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same recording output change should be in pytest/test_timer.py as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the record name is different now ?

@aescolar
Copy link
Member

aescolar commented Jul 8, 2024

@andyross @peter-mitsis please review

@nordic-krch nordic-krch dismissed stale reviews from teburd and cfriedt via 4536c4f July 8, 2024 13:10
Like in C test. If MAX STDDEV is lower than single clock cycle then
set it to a single clock cycle.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Copy link
Member

@golowanow golowanow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks fine to me. One nitpick.

@@ -37,7 +37,10 @@ def do_analysis(test, stats, stats_count, config, sys_clock_hw_cycles_per_sec):
max_bound = (test_period + period_max_drift * test_period +
expected_period_drift) / 1_000_000

cyc_us = 1000000 / sys_clock_hw_cycles_per_sec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming whine: many platforms have cycle rates > 1MHz, making this value a zero. Giving it a name that looks and sounds like "cycles per microsecond" is likely to end up in a divide-by-zero as the code evolves. It's used as a clamp, so e.g. "min_cyc = ...; /* Minimum possible cycles that can be measured */' might be better?

@aescolar aescolar merged commit 44c2b19 into zephyrproject-rtos:main Jul 9, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Kernel bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kernel: timer: timer_behavior: kernel.timer.timer fails
9 participants