Commit 6fc3e18
fix: stabilize smp_bind_affinity_tc on SMP CI
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>1 parent 72a09a6 commit 6fc3e18
2 files changed
Lines changed: 47 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| |||
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
53 | | - | |
| 52 | + | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
63 | 73 | | |
| 74 | + | |
| 75 | + | |
64 | 76 | | |
65 | 77 | | |
66 | 78 | | |
67 | 79 | | |
| 80 | + | |
68 | 81 | | |
69 | 82 | | |
70 | 83 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 84 | + | |
76 | 85 | | |
77 | 86 | | |
78 | 87 | | |
| |||
104 | 113 | | |
105 | 114 | | |
106 | 115 | | |
107 | | - | |
| 116 | + | |
108 | 117 | | |
109 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
110 | 123 | | |
111 | 124 | | |
112 | 125 | | |
113 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
114 | 129 | | |
115 | 130 | | |
116 | 131 | | |
117 | 132 | | |
118 | 133 | | |
119 | 134 | | |
| 135 | + | |
| 136 | + | |
120 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
121 | 146 | | |
122 | 147 | | |
123 | 148 | | |
124 | 149 | | |
125 | 150 | | |
126 | 151 | | |
127 | 152 | | |
128 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
129 | 158 | | |
130 | 159 | | |
131 | 160 | | |
| |||
0 commit comments