I wrote a little blog post on storing data in pointers - initially motivated by documenting the impact of >48-bit virtual addresses on such tricks and the various available hardware pointer masking schemes https://muxup.com/2023q4/storing-data-in-pointers Any corrections or additional notes, do let me know!
Storing data in pointers

Some notes on storing data in pointers and the impact of >48-bit virtual addresses

Muxup

@asb I have found that these sort of tricks are usually avoidable. However, these tricks can be kind of necessary when working with lock-free algorithms. You need bit hacking to fit in ABA tags as many architecture just don't offer wide enough atomic operations.

You can also use indexes/side tables but it gets messy.

struct node {
_Atomic uint8_t next;
};

struct info;
struct info infos[];

struct info {
uint64_t aba;
struct node *node;
};

Then preallocate the nodes at startup.

@asb The big problem with side tables is memory management gets icky. It really helps if you already have a garbage collector or are able to preallocate things.
@asb also bit fiddling pointers is difficult to formally verify so I had to do a side table approach with preallocation to get it to sort of work in Ada Spark.