perf_counter: hook up the tracepoint events
[safe/jmp/linux-2.6] / include / linux / perf_counter.h
index 91f1ca4..065984c 100644 (file)
 #ifndef _LINUX_PERF_COUNTER_H
 #define _LINUX_PERF_COUNTER_H
 
-#include <asm/atomic.h>
-#include <asm/ioctl.h>
-
-#ifdef CONFIG_PERF_COUNTERS
-# include <asm/perf_counter.h>
-#endif
-
-#include <linux/list.h>
-#include <linux/mutex.h>
-#include <linux/rculist.h>
-#include <linux/rcupdate.h>
-#include <linux/spinlock.h>
-
-struct task_struct;
+#include <linux/types.h>
+#include <linux/ioctl.h>
 
 /*
  * User-space ABI bits:
@@ -61,8 +49,12 @@ enum hw_event_types {
        PERF_COUNT_PAGE_FAULTS          = -3,
        PERF_COUNT_CONTEXT_SWITCHES     = -4,
        PERF_COUNT_CPU_MIGRATIONS       = -5,
+       PERF_COUNT_PAGE_FAULTS_MIN      = -6,
+       PERF_COUNT_PAGE_FAULTS_MAJ      = -7,
 
-       PERF_SW_EVENTS_MIN              = -6,
+       PERF_SW_EVENTS_MIN              = -8,
+
+       PERF_TP_EVENTS_MIN              = -65536
 };
 
 /*
@@ -78,21 +70,30 @@ enum perf_counter_record_type {
  * Hardware event to monitor via a performance monitoring counter:
  */
 struct perf_counter_hw_event {
-       s64                     type;
-
-       u64                     irq_period;
-       u32                     record_type;
-
-       u32                     disabled     :  1, /* off by default      */
-                               nmi          :  1, /* NMI sampling        */
-                               raw          :  1, /* raw event type      */
-                               inherit      :  1, /* children inherit it */
-                               pinned       :  1, /* must always be on PMU */
-                               exclusive    :  1, /* only counter on PMU */
-
-                               __reserved_1 : 26;
-
-       u64                     __reserved_2;
+       __s64                   type;
+
+       __u64                   irq_period;
+       __u64                   record_type;
+       __u64                   read_format;
+
+       __u64                   disabled       :  1, /* off by default        */
+                               nmi            :  1, /* NMI sampling          */
+                               raw            :  1, /* raw event type        */
+                               inherit        :  1, /* children inherit it   */
+                               pinned         :  1, /* must always be on PMU */
+                               exclusive      :  1, /* only group on PMU     */
+                               exclude_user   :  1, /* don't count user      */
+                               exclude_kernel :  1, /* ditto kernel          */
+                               exclude_hv     :  1, /* ditto hypervisor      */
+                               exclude_idle   :  1, /* don't count when idle */
+
+                               __reserved_1   : 54;
+
+       __u32                   extra_config_len;
+       __u32                   __reserved_4;
+
+       __u64                   __reserved_2;
+       __u64                   __reserved_3;
 };
 
 /*
@@ -101,20 +102,43 @@ struct perf_counter_hw_event {
 #define PERF_COUNTER_IOC_ENABLE                _IO('$', 0)
 #define PERF_COUNTER_IOC_DISABLE       _IO('$', 1)
 
+#ifdef __KERNEL__
 /*
- * Kernel-internal data types:
+ * Kernel-internal data types and definitions:
  */
 
+#ifdef CONFIG_PERF_COUNTERS
+# include <asm/perf_counter.h>
+#endif
+
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/rculist.h>
+#include <linux/rcupdate.h>
+#include <linux/spinlock.h>
+#include <linux/hrtimer.h>
+#include <asm/atomic.h>
+
+struct task_struct;
+
 /**
  * struct hw_perf_counter - performance counter hardware details:
  */
 struct hw_perf_counter {
 #ifdef CONFIG_PERF_COUNTERS
-       u64                             config;
-       unsigned long                   config_base;
-       unsigned long                   counter_base;
-       int                             nmi;
-       unsigned int                    idx;
+       union {
+               struct { /* hardware */
+                       u64                             config;
+                       unsigned long                   config_base;
+                       unsigned long                   counter_base;
+                       int                             nmi;
+                       unsigned int                    idx;
+               };
+               union { /* software */
+                       atomic64_t                      count;
+                       struct hrtimer                  hrtimer;
+               };
+       };
        atomic64_t                      prev_count;
        u64                             irq_period;
        atomic64_t                      period_left;
@@ -165,11 +189,13 @@ struct file;
 struct perf_counter {
 #ifdef CONFIG_PERF_COUNTERS
        struct list_head                list_entry;
+       struct list_head                event_entry;
        struct list_head                sibling_list;
        struct perf_counter             *group_leader;
        const struct hw_perf_counter_ops *hw_ops;
 
        enum perf_counter_active_state  state;
+       enum perf_counter_active_state  prev_state;
        atomic64_t                      count;
 
        struct perf_counter_hw_event    hw_event;
@@ -197,6 +223,9 @@ struct perf_counter {
        struct perf_data                *irqdata;
        struct perf_data                *usrdata;
        struct perf_data                data[2];
+
+       void (*destroy)(struct perf_counter *);
+       struct rcu_head                 rcu_head;
 #endif
 };
 
@@ -220,6 +249,7 @@ struct perf_counter_context {
        struct mutex            mutex;
 
        struct list_head        counter_list;
+       struct list_head        event_list;
        int                     nr_counters;
        int                     nr_active;
        int                     is_active;
@@ -271,7 +301,7 @@ static inline int is_software_counter(struct perf_counter *counter)
        return !counter->hw_event.raw && counter->hw_event.type < 0;
 }
 
-#define PERFMON_MIN_PERIOD_NS 10000
+extern void perf_swcounter_event(enum hw_event_types, u64, int, struct pt_regs *);
 
 #else
 static inline void
@@ -285,10 +315,14 @@ static inline void perf_counter_exit_task(struct task_struct *child)      { }
 static inline void perf_counter_notify(struct pt_regs *regs)           { }
 static inline void perf_counter_print_debug(void)                      { }
 static inline void perf_counter_unthrottle(void)                       { }
-static inline void hw_perf_restore(u64 ctrl)                   { }
+static inline void hw_perf_restore(u64 ctrl)                           { }
 static inline u64 hw_perf_save_disable(void)                 { return 0; }
 static inline int perf_counter_task_disable(void)      { return -EINVAL; }
 static inline int perf_counter_task_enable(void)       { return -EINVAL; }
+
+static inline void perf_swcounter_event(enum hw_event_types event, u64 nr,
+                                       int nmi, struct pt_regs *regs)  { }
 #endif
 
+#endif /* __KERNEL__ */
 #endif /* _LINUX_PERF_COUNTER_H */