On Wed, Nov 23, 2016 at 04:44:39AM -0500, [email protected] wrote:
> From: Kan Liang <[email protected]>
> 
> A new perf record is introduced to export perf overhead information to
> userspace. So we can measure the overhead of sampling directly.
> 
> To output the overhead information, it takes advantage of the existing
> event log mechanism. But the overhead information is the system
> overhead, not per-event overhead.
> 
> Signed-off-by: Kan Liang <[email protected]>
> ---
>  include/linux/perf_event.h      |  4 ++++
>  include/uapi/linux/perf_event.h | 29 +++++++++++++++++++++++++++
>  kernel/events/core.c            | 43 
> +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 76 insertions(+)
> 
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index 4741ecd..3a530a7 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -998,6 +998,10 @@ perf_event__output_id_sample(struct perf_event *event,
>  extern void
>  perf_log_lost_samples(struct perf_event *event, u64 lost);
>  
> +extern void
> +perf_log_overhead(struct perf_event *event, u32 type,
> +               struct perf_overhead_entry *entry);
> +
>  static inline bool is_sampling_event(struct perf_event *event)
>  {
>       return event->attr.sample_period != 0;
> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
> index c66a485..ae571be 100644
> --- a/include/uapi/linux/perf_event.h
> +++ b/include/uapi/linux/perf_event.h
> @@ -862,6 +862,17 @@ enum perf_event_type {
>        */
>       PERF_RECORD_SWITCH_CPU_WIDE             = 15,
>  
> +     /*
> +      * Records perf overhead
> +      * struct {
> +      *      struct perf_event_header        header;
> +      *      u32                             type;
> +      *      struct perf_overhead_entry      entry;
> +      *      struct sample_id                sample_id;
> +      * };
> +      */
> +     PERF_RECORD_OVERHEAD                    = 16,
> +
>       PERF_RECORD_MAX,                        /* non-ABI */
>  };

I think we should make this optional/configurable like the
rest of the aux events, like below..

jirka


---
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index 5e7c52278ef0..853a919bd9ae 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -344,7 +344,8 @@ struct perf_event_attr {
                                use_clockid    :  1, /* use @clockid for time 
fields */
                                context_switch :  1, /* context switch data */
                                write_backward :  1, /* Write ring buffer from 
end to beginning */
-                               __reserved_1   : 36;
+                               overhead       :  1,
+                               __reserved_1   : 35;
 
        union {
                __u32           wakeup_events;    /* wakeup every n events */

Reply via email to