Date: Sat, 4 Oct 2025 18:14:12 +0000 (UTC)
On Saturday, October 4, 2025 at 01:47:56 PM EDT, Walt Karas <wkaras_at_[hidden]> wrote:
On Saturday, October 4, 2025 at 12:48:00 PM EDT, Thiago Macieira via Std-Proposals <std-proposals_at_[hidden]> wrote:
On Saturday, 4 October 2025 07:19:35 Pacific Daylight Time Frederick Virchanza
Gotham via Std-Proposals wrote:
> FreeNode *const node = &nodes[index];
> FreeNode *oldHead = freeList.load(std::memory_order_relaxed);
>
> do node->next = oldHead;
> while ( false == freeList.compare_exchange_weak(oldHead, node,
> std::memory_order_release, std::memory_order_relaxed) );
There's probably an ABA problem here.
Response: Agreed. AFAIK, the only known solution is to use an atomic versioned pointer as the head pointer of the linked list. In general, to implement atomic versioned pointers cleanly, hardware compare-and-exchange support has to be available for consecutive bytes twice as long as a pointer. This is an implementation I did, which is not Standard-compliant: https://github.com/ywkaras/trafficserver/blob/freelist_upd/include/tscore/ver_ptr.h
On Saturday, October 4, 2025 at 12:48:00 PM EDT, Thiago Macieira via Std-Proposals <std-proposals_at_[hidden]> wrote:
On Saturday, 4 October 2025 07:19:35 Pacific Daylight Time Frederick Virchanza
Gotham via Std-Proposals wrote:
> FreeNode *const node = &nodes[index];
> FreeNode *oldHead = freeList.load(std::memory_order_relaxed);
>
> do node->next = oldHead;
> while ( false == freeList.compare_exchange_weak(oldHead, node,
> std::memory_order_release, std::memory_order_relaxed) );
There's probably an ABA problem here.
Response: Agreed. AFAIK, the only known solution is to use an atomic versioned pointer as the head pointer of the linked list. In general, to implement atomic versioned pointers cleanly, hardware compare-and-exchange support has to be available for consecutive bytes twice as long as a pointer. This is an implementation I did, which is not Standard-compliant: https://github.com/ywkaras/trafficserver/blob/freelist_upd/include/tscore/ver_ptr.h
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Data Center Group -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2025-10-04 18:14:18