Skip to content

Conversation

@jasonbu
Copy link
Contributor

@jasonbu jasonbu commented Nov 30, 2025

Summary

If the round robin is work as expected, the g_rr_value_index atomic and g_rr_values should record different thread be swapped.
And if not working, the g_rr_values will record all thread run and finish one by one. then able to be catch by the code before return.

Also when SMP, two thread able to run in two cores, the case still not able to catch problems.
Add pthread_attr_setaffinity_np to ensure when SMP it still working.

As we rely on the get_primes_thread calulation speed and rr_inerval Kconfig, value, it depend on the cpu performance, so
change TESTING_OSTEST_RR_RANGE default value from 10000 to 30000, to ensure most scene, the default 200ms rr interval able to make get_primes_thread do at least one swap.

Impact

Before patch we never detect the roundrobin fail.
After patch we able to report if the rondrobin not able to successfully trigger context switch even the thread just normal running.
In self environment rr_test time cost from 100ms to 900ms for extra time cost.

Testing

CI-test, self test for qemu armv7a nsh & smp.
manually allow case run when round robin not enabled to ensure it can catch the fail case.

Before patch we never detect the roundrobin fail.
After patch use a array to detect if the calculation swapped when
processing.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
Fix if SMP cause calculation run in multi-core cause case break.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
@jerpelea jerpelea changed the title Add fail detect and print for rondrobin ostest case. apps/ostest: add fail detect and print for roundrobin case. Dec 1, 2025
@xiaoxiang781216 xiaoxiang781216 merged commit 3bd8506 into apache:master Dec 1, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants