|
|
Subscribe / Log in / New account

C++ already gives us a tool for pointer zapping

C++ already gives us a tool for pointer zapping

Posted Oct 17, 2024 6:39 UTC (Thu) by jrtc27 (subscriber, #107748)
In reply to: C++ already gives us a tool for pointer zapping by PaulMcKenney
Parent article: Zapping pointers out of thin air

CHERI can support lock-free CAS algorithms like that just fine, the implementation (whether of a language feature or in your assembly, likely the latter given language-level provenance rules even without CHERI) just needs to do a compare of the full capability, not just the address portion. Morello, being based on an AArch64 with LSE, has CAS(A)(L) instructions that do just that. CHERI-RISC-V, and Morello if you opt to not use LSE, can emulate CAS with a load-linked/store-conditional loop (or non-loop for weak CAS) and a full capability comparison (CHKEQ on Morello) instruction in the middle.


to post comments

C++ already gives us a tool for pointer zapping

Posted Oct 17, 2024 23:58 UTC (Thu) by PaulMcKenney (✭ supporter ✭, #9624) [Link] (2 responses)

Good to hear, thank you!

If you can say, what is the performance of the CAS(A)(L) instructions that handle both the address and the capability compared to those that handle only the address?

C++ already gives us a tool for pointer zapping

Posted Oct 18, 2024 0:41 UTC (Fri) by jrtc27 (subscriber, #107748) [Link] (1 responses)

Performance is always going to be dependent on the implementation, as a tradeoff with power and area, and there are some quirks on Morello due to being an experimental prototype implementation, but in general it would be reasonable to expect them to perform somewhere between plain CAS(A)(L) and CAS(A)(L)P. On a high-performance implementation there will likely be a 128-bit data path already there (true of Morello) so they probably all perform about the same, but a lower-performance implementation could choose to have a narrower data path to reduce core area and take an extra cycle. But in terms of cache coherency traffic it's the same, it still fits in a single cache line, you're just accessing more of that cache line.

C++ already gives us a tool for pointer zapping

Posted Oct 18, 2024 16:36 UTC (Fri) by PaulMcKenney (✭ supporter ✭, #9624) [Link]

Very good, thank you!

With that performance issue mostly out of the way, one big remaining issue is the memory occupancy. Interesting tradeoff, the overhead of double-size pointers vs. the overhead of killer static analysis. ;-)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds