Skip to content

Commit 3f8d662

Browse files
author
Nicolas Pitre
committed
samples: zbus: benchmark: Filter SMP from benchmark_sync test
The benchmark_sync test produces incorrect results on SMP systems due to a race condition between the producer thread and subscriber threads that only occurs with parallel execution. Thread configuration: - Producer thread: priority 5 (lower priority, runs later) - Subscriber threads (8): priority 3 (higher priority, runs first) Expected behavior on uniprocessor: 1. Producer publishes message 2. Subscriber immediately preempts producer (priority 3 < 5) 3. Subscriber processes message, calls atomic_add(&count, 256) 4. Producer resumes, continues to next message Result: All messages counted before producer checks final count. Race condition on SMP: CPU 0 (Producer): CPU 1-3 (Subscribers): ----------------- ---------------------- Publish msg 1 k_msgq_put(sub1) ✓ k_msgq_get() → processing Publish msg 2 k_msgq_put(sub2) ✓ k_msgq_get() → processing ...continues... Publish msg 128 ✓ atomic_get(&count) Still processing... → Reports incomplete count! atomic_add() comes later On SMP, the producer doesn't get preempted since it runs on a different CPU from the subscribers. It races ahead and checks atomic_get(&count) while subscriber threads on other CPUs are still processing messages. Observed results: - Non-SMP: Bytes sent = 262144, received = 262144 ✓ - SMP: Bytes sent = 262144, received = 260352 ✗ (7 messages lost) This is a benchmark test design issue, not a zbus bug. The test assumes subscribers complete before the producer finishes, which doesn't hold on SMP systems. Filter SMP configurations from this test variant. Fixes CI failures on Arm's FVP SMP configurations. Signed-off-by: Nicolas Pitre <[email protected]>
1 parent 1e3e6b3 commit 3f8d662

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

samples/subsys/zbus/benchmark/sample.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ tests:
4646
sample.zbus.benchmark_sync:
4747
tags: zbus
4848
min_ram: 16
49-
filter: CONFIG_SYS_CLOCK_EXISTS and not (CONFIG_ARCH_POSIX and not CONFIG_BOARD_NATIVE_SIM)
49+
filter: >-
50+
CONFIG_SYS_CLOCK_EXISTS and
51+
not (CONFIG_ARCH_POSIX and not CONFIG_BOARD_NATIVE_SIM) and
52+
not CONFIG_SMP
5053
harness: console
5154
harness_config:
5255
type: multi_line

0 commit comments

Comments
 (0)