From 45e90549aa887ec27a2d92a69b33f8ca96bb8247 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 4 Jun 2026 12:37:20 +0200 Subject: [PATCH] Rewrite TaggedUserlandAddress. Drop dead code. Move tag to low bits, keep ptr at high bits. Protocol bump, as TaggedUserlandAddress is used to transmit "literal" messages. --- public/common/TracyProtocol.hpp | 2 +- public/common/TracyTaggedUserlandAddress.hpp | 30 ++++---------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/public/common/TracyProtocol.hpp b/public/common/TracyProtocol.hpp index 5c799138..495af500 100644 --- a/public/common/TracyProtocol.hpp +++ b/public/common/TracyProtocol.hpp @@ -10,7 +10,7 @@ namespace tracy constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; } -constexpr uint32_t ProtocolVersion = 78; +constexpr uint32_t ProtocolVersion = 79; constexpr uint16_t BroadcastVersion = 3; using lz4sz_t = uint32_t; diff --git a/public/common/TracyTaggedUserlandAddress.hpp b/public/common/TracyTaggedUserlandAddress.hpp index 1d481acf..03308db5 100644 --- a/public/common/TracyTaggedUserlandAddress.hpp +++ b/public/common/TracyTaggedUserlandAddress.hpp @@ -11,37 +11,19 @@ namespace tracy class TaggedUserlandAddress { - // So far no kernel seems to allow userspace address with more than 56bits userspace VAs since now hardware support it. - // See https://docs.kernel.org/next/x86/x86_64/mm.html and https://www.kernel.org/doc/html/v5.8/arm64/memory.html#bit-userspace-vas - static constexpr uint64_t kUserspaceVABits = 56; - static constexpr uint64_t kKernelOnlyBits = 64 - kUserspaceVABits; - static constexpr uint64_t kKernelOnlyBitMask = ( ( uint64_t(1) << kKernelOnlyBits ) - uint64_t(1) ) << kUserspaceVABits; + static constexpr uint64_t ptrShift = 8; + static constexpr uint64_t highBits = 0xFF00000000000000; public: TaggedUserlandAddress() = default; tracy_force_inline explicit TaggedUserlandAddress( uint64_t address, uint8_t tag = 0 ) { - assert( ( address & kKernelOnlyBitMask ) == 0 ); - assert( ( (uint64_t)tag & ~( kKernelOnlyBitMask >> kUserspaceVABits ) ) == 0 ); - m_storage = address | ( (uint64_t)tag << kUserspaceVABits ); + assert( ( address & highBits ) == 0 ); + m_storage = ( address << ptrShift ) | tag; } - tracy_force_inline void SetPackedValue(uint64_t value) { m_storage = value; } - tracy_force_inline uint64_t GetPackedValue() const { return m_storage; } - - tracy_force_inline void SetAddress( uint64_t address) - { - assert( ( address & kKernelOnlyBitMask ) == 0 ); - m_storage = ( m_storage & kKernelOnlyBitMask ) | address; - } - tracy_force_inline uint64_t GetAddress() const { return m_storage & ( ~kKernelOnlyBitMask ); } - - tracy_force_inline void SetTag( uint8_t tag ) - { - assert( ( (uint64_t)tag & ~( kKernelOnlyBitMask >> kUserspaceVABits ) ) == 0 ); - m_storage = ( (uint64_t)tag << kUserspaceVABits ) | ( m_storage & ( ~kKernelOnlyBitMask ) ); - } - tracy_force_inline uint8_t GetTag() const { return (uint8_t)( ( m_storage & kKernelOnlyBitMask ) >> kUserspaceVABits ); } + tracy_force_inline uint64_t GetAddress() const { return m_storage >> ptrShift; } + tracy_force_inline uint8_t GetTag() const { return uint8_t( m_storage & 0xFF ); } private: uint64_t m_storage;