template<int PtrBits = TF_POINTER_BITS>
struct tf::TaggedHead64< PtrBits >
tagged free-list head packed into a single 64-bit word
- Template Parameters
-
| PtrBits | number of low bits reserved for the block address; the remaining (64 - PtrBits) bits hold the ABA version counter. Must be at most 48 so that at least 16 tag bits are available. Defaults to TF_POINTER_BITS (48 on x86-64, AArch64, and RISC-V SV48). Override for non-standard VA layouts:
39 for RISC-V SV39, giving 25 tag bits
- Values above 48 (e.g. LA57's 57) are rejected by a
static_assert — use TaggedHead128 in those cases
TaggedHead64 fits both the free-list head pointer and an ABA version counter into a single uintptr_t: the low PtrBits bits store the block address and the remaining high bits store the version counter. Because the entire state is one 64-bit word, std::atomic<TaggedHead64<>> is always lock-free on every 64-bit platform — including those without a native 128-bit CAS instruction (RISC-V, baseline ARMv8.0). |
The default PtrBits of 48 assumes user-space virtual addresses occupy at most 48 bits, which holds for:
- x86-64 with 4-level paging — bits 48–63 are zero in user space
- AArch64 with 48-bit VA space — TTBR0 range
- RISC-V SV39 / SV48 — provides even more headroom (25 / 16 free bits)
The resulting (64 - PtrBits) -bit version counter wraps at 2^(64-PtrBits). With the default of 48, the counter is 16 bits and wraps at 65 536. ABA would require a competing thread to complete exactly that many push/pop cycles on the same shard between another thread's load and its CAS — negligible probability in any task-parallel workload.
sharded fixed-size object allocator with a lock-free hot path
Definition object_pool.hpp:320
- See also
- TaggedHead128 for a variant with a full 64-bit version counter that may use a lock-based fallback on platforms without 128-bit CAS.