[pull] master from RT-Thread:master#880
Merged
Merged
Conversation
This change fixes intermittent failures of the `core.smp_bind_affinity` utest across SMP CI targets. The original failure was a flaky assertion on unbound threads (`thread_inc[x] != thread_tic[x]` in thread_entry), not incorrect bind_cpu behavior. CI logs already showed T0 binding worked (thread_inc[0] == thread_tic[0] == 100) while the not_equal check failed. The root issue is that unbound-thread CPU placement is platform-dependent and outside the bind_cpu contract. On dual-core RISC-V/ARMv7 CI, an unbound thread may legitimately run all iterations on core 0 while T0 delays on the same core, so any assertion requiring cross-core migration (thread_inc != thread_tic, or core_mask with multiple bits) remains flaky. This patch narrows the test to what bind_affinity actually verifies: T0 bound to core 0 must always execute on core 0. Unbound threads only add scheduling pressure; their core_mask is printed for observation but not asserted. Changes: - Sample `rt_hw_cpu_id()` and update counters under `rt_sched_lock` to avoid migration skew between counting and CPU sampling. - Track `thread_core_mask` for diagnostics; assert only T0 binding via `thread_inc[0] == thread_tic[0]` and `thread_core_mask[0] == 1`. - Remove flaky unbound-thread assertions (`thread_inc != thread_tic` and multi-core core_mask checks). - Move T0 assertions to the main test thread after all workers finish. - Use atomic `finsh_flag`; reset counters and `threads[]` in `utest_tc_init`. - Spin in worker loops after `run_num` until cleanup deletes them (do not return from thread_entry or use `RT_WAITING_FOREVER` with `rt_thread_delay`). - Guard `rt_thread_delete` in cleanup with non-NULL checks. Signed-off-by: GuEe-GUI <2991707448@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )