PERF_SAMPLE_CALLCHAIN           = 1U << 5,
        PERF_SAMPLE_ID                  = 1U << 6,
        PERF_SAMPLE_CPU                 = 1U << 7,
+       PERF_SAMPLE_PERIOD              = 1U << 8,
 };
 
 /*
         * struct {
         *      struct perf_event_header        header;
         *      u64                             time;
+        *      u64                             id;
         *      u64                             sample_period;
         * };
         */
 
                cpu_entry.cpu = raw_smp_processor_id();
        }
 
+       if (sample_type & PERF_SAMPLE_PERIOD) {
+               header.type |= PERF_SAMPLE_PERIOD;
+               header.size += sizeof(u64);
+       }
+
        if (sample_type & PERF_SAMPLE_GROUP) {
                header.type |= PERF_SAMPLE_GROUP;
                header.size += sizeof(u64) +
        if (sample_type & PERF_SAMPLE_CPU)
                perf_output_put(&handle, cpu_entry);
 
+       if (sample_type & PERF_SAMPLE_PERIOD)
+               perf_output_put(&handle, counter->hw.sample_period);
+
        /*
         * XXX PERF_SAMPLE_GROUP vs inherited counters seems difficult.
         */
        struct {
                struct perf_event_header        header;
                u64                             time;
+               u64                             id;
                u64                             period;
        } freq_event = {
                .header = {
                        .size = sizeof(freq_event),
                },
                .time = sched_clock(),
+               .id = counter->id,
                .period = period,
        };