perf_event_mmap_page.time_shift

If cap_usr_time the below fields can be used to compute the time delta since time_enabled (in ns) using rdtsc or similar.

u64 quot, rem; u64 delta;

quot = (cyc >> time_shift); rem = cyc & (((u64)1 << time_shift) - 1); delta = time_offset + quot * time_mult + ((rem * time_mult) >> time_shift);

Where time_offset,time_mult,time_shift and cyc are read in the seqcount loop described above. This delta can then be added to enabled and possible running (if index), improving the scaling:

enabled += delta; if (index) running += delta;

quot = count / running; rem = count % running; count = quot * enabled + (rem * enabled) / running;

struct perf_event_mmap_page
ushort time_shift;

Meta