perf_counter: Add PERF_SAMPLE_PERIOD
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Fri, 5 Jun 2009 13:05:43 +0000 (15:05 +0200)
committerIngo Molnar <mingo@elte.hu>
Fri, 5 Jun 2009 16:07:47 +0000 (18:07 +0200)
In order to allow easy tracking of the period, also provide means of
adding it to the sample data.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
include/linux/perf_counter.h
kernel/perf_counter.c

index 9cea32a0655d845c20e33efd979f9ef14a8cf9b9..6bc250039738085a9e7c5c1a54b9e9f24efc51b4 100644 (file)
@@ -106,6 +106,7 @@ enum perf_counter_sample_format {
        PERF_SAMPLE_CALLCHAIN           = 1U << 5,
        PERF_SAMPLE_ID                  = 1U << 6,
        PERF_SAMPLE_CPU                 = 1U << 7,
+       PERF_SAMPLE_PERIOD              = 1U << 8,
 };
 
 /*
@@ -260,6 +261,7 @@ enum perf_event_type {
         * struct {
         *      struct perf_event_header        header;
         *      u64                             time;
+        *      u64                             id;
         *      u64                             sample_period;
         * };
         */
index e75b91a76a58f16f278a0acc58ddedb7379304a4..f8390668c39129dfd2a65b6970dcfcd6333e4805 100644 (file)
@@ -2404,6 +2404,11 @@ static void perf_counter_output(struct perf_counter *counter,
                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) +
@@ -2445,6 +2450,9 @@ static void perf_counter_output(struct perf_counter *counter,
        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.
         */
@@ -2835,6 +2843,7 @@ static void perf_log_period(struct perf_counter *counter, u64 period)
        struct {
                struct perf_event_header        header;
                u64                             time;
+               u64                             id;
                u64                             period;
        } freq_event = {
                .header = {
@@ -2843,6 +2852,7 @@ static void perf_log_period(struct perf_counter *counter, u64 period)
                        .size = sizeof(freq_event),
                },
                .time = sched_clock(),
+               .id = counter->id,
                .period = period,
        };