Fix-Point opened a new pull request, #3936:
URL: https://github.com/apache/nuttx-apps/pull/3936

   # Title
   
   `testing/ostest: Sync the spinlock test with vela fixes`
   
   ---
   
   ## Summary
   
   This PR ports the post-merge fixes that vela applied to 
`testing/ostest/spinlock.c` after the upstream merge point, so the test stays 
reliable across SMP, KASAN and watchdog-monitored platforms:
   
   1. **Fix the affinity side-affect** — the test pinned threads to a CPU but 
did not restore the previous affinity, leaking side effects into other tests;
   2. **Update the comments** to describe `MAX_THREAD_NUM` and the loop count;
   3. **Add `CONFIG_TESTING_OSTEST_SPINLOCK_PRIORITY`** — spinlock test threads 
were created at `SCHED_PRIORITY_MAX` (255), which starves watchdog-feeding 
tasks on systems with watchdog monitoring (e.g. BMP + WdgM), eventually 
triggering a WarmReset; the new option (default 255) lets platforms lower the 
priority, and is used in both `spinlock_test()` and `run_test_thread()`;
   4. **Fix the spinlock loop count to match the Kconfig description** — 
`TEST_LOOP_SCALE` is documented as "N x 10,000" but the code used `* 100000`; 
aligned to `* 10000`;
   5. **Lower the loop scale under `MM_KASAN`** — avoid excessively slow runs 
(and watchdog implications) on KASAN builds;
   6. **Fix a Tasking compiler warning (W597) alignment issue**.
   
   Note: fixes already merged upstream (return-value checks, operations fix, 
refactor, Coverity, `atomic_*` migration) are not repeated here; Vela-internal 
(TEE SMP / TrustZone) bits are intentionally excluded.
   
   ## Impact
   
   * **User impact:** test-only; no public API changes.
   * **Build:** no build-system changes; `testing/ostest` builds as before.
   * **Hardware:** none (validated on `qemu-armv7a`, see Testing).
   * **Documentation:** none.
   * **Security:** none.
   * **Compatibility:** the spinlock test now restores thread affinity, uses 
the configurable thread priority, and matches the documented loop counts.
   
   ## Testing
   
   **Host:** x86-64 Linux, `arm-none-eabi-gcc + QEMU (qemu-system-arm)`.
   
   **Config:** `qemu-armv7a:smp` (`-smp 4`), HIGH resolution timer test enabled.
   
   **Result:** `spinlock_test` completes on 1/2/3/4 threads with correct final 
counters (`N x 1000000`) and 0 errors.
   
   Log:
   
   ```
   qemu-system-arm -cpu cortex-a7 -nographic -smp 4 \
   -machine virt,virtualization=off,gic-version=2 \
   -net none -chardev stdio,id=con,mux=on -serial chardev:con \
   -mon chardev=con,mode=readline -kernel ./nuttx
   nsh> hello
   Hello, World!!
   spinlock_test: start......
   Thread num: 1, Loop times: 1000000
   
   Test type: spinlock
   spinlock: Test Results:
   spinlock: Final counter: 1000000
   spinlock: Average throughput : 7881812 op/s
   spinlock: Total execution time: 127776336 ns
   
   Test type: rspinlock
   rspinlock: Test Results:
   rspinlock: Final counter: 1000000
   rspinlock: Average throughput : 4003758 op/s
   spinlock: Total execution time: 250123904 ns
   
   Test type: seqcount
   seqcount: Test Results:
   seqcount: Final counter: 1000000
   seqcount: Average throughput : 7803117 op/s
   seqcount: Total execution time: 128437824 ns
   
   Thread num: 2, Loop times: 1000000
   
   Test type: spinlock
   spinlock: Test Results:
   spinlock: Final counter: 2000000
   spinlock: Average throughput : 3639822 op/s
   spinlock: Total execution time: 275360688 ns
   
   Test type: rspinlock
   rspinlock: Test Results:
   rspinlock: Final counter: 2000000
   rspinlock: Average throughput : 1967137 op/s
   rspinlock: Total execution time: 509021424 ns
   
   Test type: seqcount
   seqcount: Test Results:
   seqcount: Final counter: 2000000
   seqcount: Average throughput : 2913931 op/s
   seqcount: Total execution time: 343893376 ns
   
   Thread num: 3, Loop times: 1000000
   
   Test type: spinlock
   spinlock: Test Results:
   spinlock: Final counter: 3000000
   spinlock: Average throughput : 2436294 op/s
   spinlock: Total execution time: 426570192 ns
   
   Test type: rspinlock
   rspinlock: Test Results:
   rspinlock: Final counter: 3000000
   rspinlock: Average throughput : 1141461 op/s
   rspinlock: Total execution time: 879273104 ns
   
   Test type: seqcount
   seqcount: Test Results:
   seqcount: Final counter: 3000000
   seqcount: Average throughput : 2063639 op/s
   seqcount: Total execution time: 528608448 ns
   
   Thread num: 4, Loop times: 1000000
   
   Test type: spinlock
   spinlock: Test Results:
   spinlock: Final counter: 4000000
   spinlock: Average throughput : 1554178 op/s
   spinlock: Total execution time: 651331712 ns
   
   Test type: rspinlock
   rspinlock: Test Results:
   rspinlock: Final counter: 4000000
   rspinlock: Average throughput : 679824 op/s
   rspinlock: Total execution time: 1506000272 ns
   
   Test type: seqcount
   seqcount: Test Results:
   seqcount: Final counter: 4000000
   seqcount: Average throughput : 1066522 op/s
   seqcount: Total execution time: 949742336 ns
   
   spinlock_test: end......
   nsh>
   ```
   
   ---
   
   **Repo:** https://github.com/Fix-Point/nuttx-apps (branch 
`apps-ostest-spinlock`)
   **Base:** https://github.com/apache/nuttx-apps `master`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to