perf/x86: Add ability to calculate TSC from perf sample timestamps
[deliverable/linux.git] / include / uapi / linux / perf_event.h
index 0041aedf2297d1a14a08ae08b949dd54cd8e59e9..efef1d37a37188808fc66bc0533264193caa2189 100644 (file)
@@ -378,7 +378,8 @@ struct perf_event_mmap_page {
                struct {
                        __u64   cap_usr_time            : 1,
                                cap_usr_rdpmc           : 1,
-                               cap_____res             : 62;
+                               cap_usr_time_zero       : 1,
+                               cap_____res             : 61;
                };
        };
 
@@ -420,12 +421,29 @@ struct perf_event_mmap_page {
        __u16   time_shift;
        __u32   time_mult;
        __u64   time_offset;
+       /*
+        * If cap_usr_time_zero, the hardware clock (e.g. TSC) can be calculated
+        * from sample timestamps.
+        *
+        *   time = timestamp - time_zero;
+        *   quot = time / time_mult;
+        *   rem  = time % time_mult;
+        *   cyc = (quot << time_shift) + (rem << time_shift) / time_mult;
+        *
+        * And vice versa:
+        *
+        *   quot = cyc >> time_shift;
+        *   rem  = cyc & ((1 << time_shift) - 1);
+        *   timestamp = time_zero + quot * time_mult +
+        *               ((rem * time_mult) >> time_shift);
+        */
+       __u64   time_zero;
 
                /*
                 * Hole for extension of the self monitor capabilities
                 */
 
-       __u64   __reserved[120];        /* align to 1k */
+       __u64   __reserved[119];        /* align to 1k */
 
        /*
         * Control data for the mmap() data buffer.
This page took 0.030293 seconds and 5 git commands to generate.