#define _GNU_SOURCE #include #include #include #include struct node { struct node *next; uint64_t value; }; struct node head, middle, tail; volatile uint64_t counter; __attribute__((noinline)) void checkpoint(void) { __asm__ volatile("" ::: "memory"); } int main(void) { const size_t size = (size_t)1 << 32; int fd = memfd_create("ztrace-test-segment", 0); assert(fd >= 0 && ftruncate(fd, size) == 0); unsigned char *bytes = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); assert(bytes != MAP_FAILED); close(fd); bytes[0] = 'A'; bytes[size - 1] = 'Z'; head = (struct node){&middle, 1}; middle = (struct node){&tail, 2}; tail = (struct node){&head, 3}; for (;;) { ++counter; checkpoint(); } }