From 0915689c6bc2ec94164340f3924adc4afbbb7051 Mon Sep 17 00:00:00 2001 From: Vadim Skipin Date: Wed, 6 May 2026 20:28:56 +0000 Subject: [PATCH] Assert on queue layout --- include/silk/util/bounded-queue.h | 8 ++++++++ include/silk/util/queue.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/include/silk/util/bounded-queue.h b/include/silk/util/bounded-queue.h index 1732e03..bc67da2 100644 --- a/include/silk/util/bounded-queue.h +++ b/include/silk/util/bounded-queue.h @@ -116,12 +116,20 @@ class BoundedQueue static_assert(sizeof(Slot) == CACHELINE_SIZE); + // Match offsets and stride used by src/gdb/fiber.py::_walk_bounded_queue + static_assert(offsetof(Slot, sequence) == 0); + static_assert(offsetof(Slot, value) == 8); + // // State. // uint64_t mask; std::unique_ptr slots; + + // src/gdb/fiber.py::_walk_bounded_queue reads enqueuePos at offset 64 and + // dequeuePos at offset 128 (mask=8 bytes, slots=8 bytes, then 2 x cacheline). + // Reordering or inserting fields here requires updating that script. alignas(CACHELINE_SIZE) std::atomic enqueuePos{}; alignas(CACHELINE_SIZE) std::atomic dequeuePos{}; }; diff --git a/include/silk/util/queue.h b/include/silk/util/queue.h index ec1b5fb..6d6cfc1 100644 --- a/include/silk/util/queue.h +++ b/include/silk/util/queue.h @@ -30,6 +30,10 @@ class QueueBase static_assert(sizeof(QueueNode) == CACHELINE_SIZE); + // Match offsets used by src/gdb/fiber.py::_walk_queue + static_assert(offsetof(QueueNode, next) == 8); + static_assert(offsetof(QueueNode, value) == 16); + static void initialize() noexcept; static void destroy() noexcept;