RTEMS | cpukit: Create DHRL Library for DRAM Latency Mitigation (!1193)
Wayne Thornton (@wmthornton-dev)
gitlab at rtems.org
Wed May 20 20:49:16 UTC 2026
Wayne Thornton commented on a discussion on cpukit/dhrl/dhrl.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1193#note_150620
> + continue;
> + }
> +
> + unsigned int expected = my_epoch - 1;
> + if (
> + atomic_compare_exchange_strong_explicit(
> + &ctx->completed_epoch,
> + &expected,
> + my_epoch,
> + memory_order_release,
> + memory_order_relaxed
> + )
> + ) {
> + atomic_store_explicit(
> + &ctx->winning_data_ptr,
> + (uintptr_t) target_addr,
@gedare I double-checked the standard on this. It is safe in this specific block because we are not dereferencing the pointer here but rather we are purely storing the numeric address value to pass it across the thread boundary.
As long as the receiver casts it back to `volatile` before accessing the data (which `dhrl_work_routine` enforces via its signature), it avoids undefined behavior. To make sure this invariant is obvious to future readers and static analyzers, I'll add a comment directly above the atomic store explicitly documenting why the cast is safe.
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1193#note_150620
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260520/36cf4532/attachment-0001.htm>
More information about the bugs
mailing list