linux/include/linux/perf_event.h
<<
>>
Prefs
   1/*
   2 * Performance events:
   3 *
   4 *    Copyright (C) 2008-2009, Thomas Gleixner <tglx@linutronix.de>
   5 *    Copyright (C) 2008-2011, Red Hat, Inc., Ingo Molnar
   6 *    Copyright (C) 2008-2011, Red Hat, Inc., Peter Zijlstra
   7 *
   8 * Data type definitions, declarations, prototypes.
   9 *
  10 *    Started by: Thomas Gleixner and Ingo Molnar
  11 *
  12 * For licencing details see kernel-base/COPYING
  13 */
  14#ifndef _LINUX_PERF_EVENT_H
  15#define _LINUX_PERF_EVENT_H
  16
  17#include <uapi/linux/perf_event.h>
  18#include <uapi/linux/bpf_perf_event.h>
  19
  20/*
  21 * Kernel-internal data types and definitions:
  22 */
  23
  24#ifdef CONFIG_PERF_EVENTS
  25# include <asm/perf_event.h>
  26# include <asm/local64.h>
  27#endif
  28
  29struct perf_guest_info_callbacks {
  30        int                             (*is_in_guest)(void);
  31        int                             (*is_user_mode)(void);
  32        unsigned long                   (*get_guest_ip)(void);
  33};
  34
  35#ifdef CONFIG_HAVE_HW_BREAKPOINT
  36#include <asm/hw_breakpoint.h>
  37#endif
  38
  39#include <linux/list.h>
  40#include <linux/mutex.h>
  41#include <linux/rculist.h>
  42#include <linux/rcupdate.h>
  43#include <linux/spinlock.h>
  44#include <linux/hrtimer.h>
  45#include <linux/fs.h>
  46#include <linux/pid_namespace.h>
  47#include <linux/workqueue.h>
  48#include <linux/ftrace.h>
  49#include <linux/cpu.h>
  50#include <linux/irq_work.h>
  51#include <linux/static_key.h>
  52#include <linux/jump_label_ratelimit.h>
  53#include <linux/atomic.h>
  54#include <linux/sysfs.h>
  55#include <linux/perf_regs.h>
  56#include <linux/workqueue.h>
  57#ifndef __GENKSYMS__
  58#include <linux/cgroup.h>
  59#endif
  60#include <asm/local.h>
  61
  62#include <linux/rh_kabi.h>
  63
  64struct perf_callchain_entry {
  65        __u64                           nr;
  66        __u64                           ip[PERF_MAX_STACK_DEPTH];
  67};
  68
  69typedef unsigned long (*perf_copy_f)(void *dst, const void *src,
  70                                     unsigned long off, unsigned long len);
  71
  72struct perf_raw_frag {
  73        union {
  74                struct perf_raw_frag    *next;
  75                unsigned long           pad;
  76        };
  77        perf_copy_f                     copy;
  78        void                            *data;
  79        u32                             size;
  80} __packed;
  81
  82struct perf_raw_record {
  83        u32                                     size;
  84        RH_KABI_DEPRECATE(void *,               data)
  85        RH_KABI_EXTEND(struct perf_raw_frag     frag)
  86};
  87
  88/*
  89 * branch stack layout:
  90 *  nr: number of taken branches stored in entries[]
  91 *
  92 * Note that nr can vary from sample to sample
  93 * branches (to, from) are stored from most recent
  94 * to least recent, i.e., entries[0] contains the most
  95 * recent branch.
  96 */
  97struct perf_branch_stack {
  98        __u64                           nr;
  99        struct perf_branch_entry        entries[0];
 100};
 101
 102struct task_struct;
 103
 104/*
 105 * extra PMU register associated with an event
 106 */
 107struct hw_perf_event_extra {
 108        u64             config; /* register value */
 109        unsigned int    reg;    /* register address or index */
 110        int             alloc;  /* extra register already allocated */
 111        int             idx;    /* index in shared_regs->regs[] */
 112};
 113
 114struct event_constraint;
 115
 116/**
 117 * struct hw_perf_event - performance event hardware details:
 118 */
 119struct hw_perf_event {
 120#ifdef CONFIG_PERF_EVENTS
 121        union {
 122                struct { /* hardware */
 123                        u64             config;
 124                        u64             last_tag;
 125                        unsigned long   config_base;
 126                        unsigned long   event_base;
 127                        int             event_base_rdpmc;
 128                        int             idx;
 129                        int             last_cpu;
 130                        int             flags;
 131
 132                        struct hw_perf_event_extra extra_reg;
 133                        struct hw_perf_event_extra branch_reg;
 134                };
 135                struct { /* software */
 136                        struct hrtimer  hrtimer;
 137                };
 138                struct { /* tracepoint */
 139                        RH_KABI_DEPRECATE(struct task_struct*, tp_target)
 140                        /* for tp_event->class */
 141                        struct list_head        tp_list;
 142                };
 143#ifdef CONFIG_HAVE_HW_BREAKPOINT
 144                struct { /* breakpoint */
 145                        /*
 146                         * Crufty hack to avoid the chicken and egg
 147                         * problem hw_breakpoint has with context
 148                         * creation and event initalization.
 149                         */
 150                        RH_KABI_DEPRECATE(struct task_struct*, bp_target)
 151                        struct arch_hw_breakpoint       info;
 152                        struct list_head                bp_list;
 153                };
 154#endif
 155        };
 156        int                             state;
 157        local64_t                       prev_count;
 158        u64                             sample_period;
 159        u64                             last_period;
 160        local64_t                       period_left;
 161        u64                             interrupts_seq;
 162        u64                             interrupts;
 163
 164        u64                             freq_time_stamp;
 165        u64                             freq_count_stamp;
 166
 167        RH_KABI_EXTEND(struct event_constraint *constraint)
 168        RH_KABI_EXTEND(struct task_struct       *target)
 169
 170        /*
 171         * PMU would store hardware filter configuration
 172         * here.
 173         */
 174        RH_KABI_EXTEND(void                     *addr_filters)
 175
 176        /* Last sync'ed generation of filters */
 177        RH_KABI_EXTEND(unsigned long            addr_filters_gen)
 178#endif
 179};
 180
 181/*
 182 * hw_perf_event::state flags
 183 */
 184#define PERF_HES_STOPPED        0x01 /* the counter is stopped */
 185#define PERF_HES_UPTODATE       0x02 /* event->count up-to-date */
 186#define PERF_HES_ARCH           0x04
 187
 188struct perf_event;
 189
 190/*
 191 * Common implementation detail of pmu::{start,commit,cancel}_txn
 192 */
 193#define PERF_PMU_TXN_ADD  0x1           /* txn to add/schedule event on PMU */
 194#define PERF_PMU_TXN_READ 0x2           /* txn to read event group from PMU */
 195
 196/**
 197 * pmu::capabilities flags
 198 */
 199#define PERF_PMU_CAP_NO_INTERRUPT               0x01
 200#define PERF_PMU_CAP_NO_NMI                     0x02
 201#define PERF_PMU_CAP_AUX_NO_SG                  0x04
 202#define PERF_PMU_CAP_AUX_SW_DOUBLEBUF           0x08
 203#define PERF_PMU_CAP_EXCLUSIVE                  0x10
 204#define PERF_PMU_CAP_ITRACE                     0x20
 205
 206/**
 207 * struct pmu - generic performance monitoring unit
 208 */
 209struct pmu {
 210        struct list_head                entry;
 211
 212        struct device                   *dev;
 213        const struct attribute_group    **attr_groups;
 214        const char                      *name;
 215        int                             type;
 216
 217        int * __percpu                  pmu_disable_count;
 218        struct perf_cpu_context * __percpu pmu_cpu_context;
 219        int                             task_ctx_nr;
 220        int                             hrtimer_interval_ms;
 221
 222        /*
 223         * Fully disable/enable this PMU, can be used to protect from the PMI
 224         * as well as for lazy/batch writing of the MSRs.
 225         */
 226        void (*pmu_enable)              (struct pmu *pmu); /* optional */
 227        void (*pmu_disable)             (struct pmu *pmu); /* optional */
 228
 229        /*
 230         * Try and initialize the event for this PMU.
 231         * Should return -ENOENT when the @event doesn't match this PMU.
 232         */
 233        int (*event_init)               (struct perf_event *event);
 234
 235#define PERF_EF_START   0x01            /* start the counter when adding    */
 236#define PERF_EF_RELOAD  0x02            /* reload the counter when starting */
 237#define PERF_EF_UPDATE  0x04            /* update the counter when stopping */
 238
 239        /*
 240         * Adds/Removes a counter to/from the PMU, can be done inside
 241         * a transaction, see the ->*_txn() methods.
 242         */
 243        int  (*add)                     (struct perf_event *event, int flags);
 244        void (*del)                     (struct perf_event *event, int flags);
 245
 246        /*
 247         * Starts/Stops a counter present on the PMU. The PMI handler
 248         * should stop the counter when perf_event_overflow() returns
 249         * !0. ->start() will be used to continue.
 250         */
 251        void (*start)                   (struct perf_event *event, int flags);
 252        void (*stop)                    (struct perf_event *event, int flags);
 253
 254        /*
 255         * Updates the counter value of the event.
 256         */
 257        void (*read)                    (struct perf_event *event);
 258
 259        /*
 260         * Group events scheduling is treated as a transaction, add
 261         * group events as a whole and perform one schedulability test.
 262         * If the test fails, roll back the whole group
 263         *
 264         * Start the transaction, after this ->add() doesn't need to
 265         * do schedulability tests.
 266         *
 267         * Optional.
 268         */
 269        RH_KABI_REPLACE(void (*start_txn)(struct pmu *pmu),
 270                        void (*start_txn)(struct pmu *pmu, unsigned int txn_flags))
 271
 272        /*
 273         * If ->start_txn() disabled the ->add() schedulability test
 274         * then ->commit_txn() is required to perform one. On success
 275         * the transaction is closed. On error the transaction is kept
 276         * open until ->cancel_txn() is called.
 277         *
 278         * Optional.
 279         */
 280        int  (*commit_txn)              (struct pmu *pmu);
 281        /*
 282         * Will cancel the transaction, assumes ->del() is called
 283         * for each successful ->add() during the transaction.
 284         *
 285         * Optional.
 286         */
 287        void (*cancel_txn)              (struct pmu *pmu);
 288
 289        /*
 290         * Will return the value for perf_event_mmap_page::index for this event,
 291         * if no implementation is provided it will default to: event->hw.idx + 1.
 292         */
 293        int (*event_idx)                (struct perf_event *event); /*optional */
 294
 295        /*
 296         * flush branch stack on context-switches (needed in cpu-wide mode)
 297         */
 298#ifdef __GENKSYMS__
 299        void (*flush_branch_stack)      (void);
 300#else
 301        /* KABI this pointer is deprecated */
 302        void (*rh_reserved_flush_branch_stack)  (void);
 303#endif
 304
 305        RH_KABI_EXTEND(struct module *module)
 306
 307        /*
 308         * various common per-pmu feature flags
 309         */
 310        RH_KABI_EXTEND(int      capabilities)
 311
 312        /*
 313         * context-switches callback
 314         */
 315        RH_KABI_EXTEND(void (*sched_task) (struct perf_event_context *ctx, bool sched_in))
 316
 317        /*
 318         * PMU specific data size
 319         */
 320        RH_KABI_EXTEND(size_t task_ctx_size)
 321
 322        /*
 323         * Set up pmu-private data structures for an AUX area
 324         */
 325        RH_KABI_EXTEND(void *(*setup_aux)               (int cpu, void **pages,
 326                                         int nr_pages, bool overwrite))
 327                                        /* optional */
 328
 329        /*
 330         * Free pmu-private AUX data structures
 331         */
 332        RH_KABI_EXTEND(void (*free_aux)         (void *aux)) /* optional */
 333        RH_KABI_EXTEND(atomic_t                 exclusive_cnt) /* < 0: cpu; > 0: tsk */
 334
 335
 336        /*
 337         * Validate address range filters: make sure the HW supports the
 338         * requested configuration and number of filters; return 0 if the
 339         * supplied filters are valid, -errno otherwise.
 340         *
 341         * Runs in the context of the ioctl()ing process and is not serialized
 342         * with the rest of the PMU callbacks.
 343         */
 344        RH_KABI_EXTEND(int (*addr_filters_validate)     (struct list_head *filters))
 345
 346        /*
 347         * Synchronize address range filter configuration:
 348         * translate hw-agnostic filters into hardware configuration in
 349         * event::hw::addr_filters.
 350         *
 351         * Runs as a part of filter sync sequence that is done in ->start()
 352         * callback by calling perf_event_addr_filters_sync().
 353         *
 354         * May (and should) traverse event::addr_filters::list, for which its
 355         * caller provides necessary serialization.
 356         */
 357        RH_KABI_EXTEND(void (*addr_filters_sync)        (struct perf_event *event))
 358                                        /* optional */
 359
 360        /* number of address filters this PMU can do */
 361        RH_KABI_EXTEND(unsigned int                     nr_addr_filters)
 362};
 363
 364/**
 365 * struct perf_addr_filter - address range filter definition
 366 * @entry:      event's filter list linkage
 367 * @inode:      object file's inode for file-based filters
 368 * @offset:     filter range offset
 369 * @size:       filter range size
 370 * @range:      1: range, 0: address
 371 * @filter:     1: filter/start, 0: stop
 372 *
 373 * This is a hardware-agnostic filter configuration as specified by the user.
 374 */
 375struct perf_addr_filter {
 376        struct list_head        entry;
 377        struct inode            *inode;
 378        unsigned long           offset;
 379        unsigned long           size;
 380        unsigned int            range   : 1,
 381                                filter  : 1;
 382};
 383
 384/**
 385 * struct perf_addr_filters_head - container for address range filters
 386 * @list:       list of filters for this event
 387 * @lock:       spinlock that serializes accesses to the @list and event's
 388 *              (and its children's) filter generations.
 389 * @nr_file_filters:    number of file-based filters
 390 *
 391 * A child event will use parent's @list (and therefore @lock), so they are
 392 * bundled together; see perf_event_addr_filters().
 393 */
 394struct perf_addr_filters_head {
 395        struct list_head        list;
 396        raw_spinlock_t          lock;
 397        unsigned int            nr_file_filters;
 398};
 399
 400/**
 401 * enum perf_event_active_state - the states of a event
 402 */
 403enum perf_event_active_state {
 404#ifndef __GENKSYMS__
 405        PERF_EVENT_STATE_DEAD           = -4,
 406        PERF_EVENT_STATE_EXIT           = -3,
 407#endif
 408        PERF_EVENT_STATE_ERROR          = -2,
 409        PERF_EVENT_STATE_OFF            = -1,
 410        PERF_EVENT_STATE_INACTIVE       =  0,
 411        PERF_EVENT_STATE_ACTIVE         =  1,
 412};
 413
 414struct file;
 415struct perf_sample_data;
 416
 417typedef void (*perf_overflow_handler_t)(struct perf_event *,
 418                                        struct perf_sample_data *,
 419                                        struct pt_regs *regs);
 420
 421/*
 422 * Event capabilities. For event_caps and groups caps.
 423 *
 424 * PERF_EV_CAP_SOFTWARE: Is a software event.
 425 * PERF_EV_CAP_READ_ACTIVE_PKG: A CPU event (or cgroup event) that can be read
 426 * from any CPU in the package where it is active.
 427 */
 428#define PERF_EV_CAP_SOFTWARE            BIT(0)
 429#define PERF_EV_CAP_READ_ACTIVE_PKG     BIT(1)
 430
 431#define SWEVENT_HLIST_BITS              8
 432#define SWEVENT_HLIST_SIZE              (1 << SWEVENT_HLIST_BITS)
 433
 434struct swevent_hlist {
 435        struct hlist_head               heads[SWEVENT_HLIST_SIZE];
 436        struct rcu_head                 rcu_head;
 437};
 438
 439#define PERF_ATTACH_CONTEXT     0x01
 440#define PERF_ATTACH_GROUP       0x02
 441#define PERF_ATTACH_TASK        0x04
 442#define PERF_ATTACH_TASK_DATA   0x08
 443#define PERF_ATTACH_ITRACE      0x10
 444
 445struct perf_cgroup;
 446struct ring_buffer;
 447
 448struct pmu_event_list {
 449        raw_spinlock_t          lock;
 450        struct list_head        list;
 451};
 452
 453/**
 454 * struct perf_event - performance event kernel representation:
 455 */
 456struct perf_event {
 457#ifdef CONFIG_PERF_EVENTS
 458        /*
 459         * XXX: group_entry and sibling_list should be mutually exclusive;
 460         * either you're a sibling on a group, or you're the group leader.
 461         * Rework the code to always use the same list element.
 462         *
 463         * Locked for modification by both ctx->mutex and ctx->lock; holding
 464         * either sufficies for read.
 465         */
 466        struct list_head                group_entry;
 467        /*
 468         * entry onto perf_event_context::event_list;
 469         *   modifications require ctx->lock
 470         *   RCU safe iterations.
 471         */
 472        struct list_head                event_entry;
 473        struct list_head                sibling_list;
 474        struct hlist_node               hlist_entry;
 475        int                             nr_siblings;
 476
 477        /* Not serialized. Only written during event initialization. */
 478        RH_KABI_RENAME(int group_flags, int event_caps);
 479
 480        struct perf_event               *group_leader;
 481        struct pmu                      *pmu;
 482
 483        enum perf_event_active_state    state;
 484        unsigned int                    attach_state;
 485        local64_t                       count;
 486        atomic64_t                      child_count;
 487
 488        /*
 489         * These are the total time in nanoseconds that the event
 490         * has been enabled (i.e. eligible to run, and the task has
 491         * been scheduled in, if this is a per-task event)
 492         * and running (scheduled onto the CPU), respectively.
 493         */
 494        u64                             total_time_enabled;
 495        u64                             total_time_running;
 496        RH_KABI_DEPRECATE(u64,          tstamp_enabled)
 497        RH_KABI_DEPRECATE(u64,          tstamp_running)
 498        RH_KABI_REPLACE(u64             tstamp_stopped,
 499                        u64             tstamp)
 500
 501        /*
 502         * timestamp shadows the actual context timing but it can
 503         * be safely used in NMI interrupt context. It reflects the
 504         * context time as it was when the event was last scheduled in.
 505         *
 506         * ctx_time already accounts for ctx->timestamp. Therefore to
 507         * compute ctx_time for a sample, simply add perf_clock().
 508         */
 509        u64                             shadow_ctx_time;
 510
 511        struct perf_event_attr          attr;
 512        u16                             header_size;
 513        u16                             id_header_size;
 514        u16                             read_size;
 515        struct hw_perf_event            hw;
 516
 517        struct perf_event_context       *ctx;
 518        atomic_long_t                   refcount;
 519
 520        /*
 521         * These accumulate total time (in nanoseconds) that children
 522         * events have been enabled and running, respectively.
 523         */
 524        atomic64_t                      child_total_time_enabled;
 525        atomic64_t                      child_total_time_running;
 526
 527        /*
 528         * Protect attach/detach and child_list:
 529         */
 530        struct mutex                    child_mutex;
 531        struct list_head                child_list;
 532        struct perf_event               *parent;
 533
 534        int                             oncpu;
 535        int                             cpu;
 536
 537        struct list_head                owner_entry;
 538        struct task_struct              *owner;
 539
 540        /* mmap bits */
 541        struct mutex                    mmap_mutex;
 542        atomic_t                        mmap_count;
 543
 544        struct ring_buffer              *rb;
 545        struct list_head                rb_entry;
 546
 547        /* poll related */
 548        wait_queue_head_t               waitq;
 549        struct fasync_struct            *fasync;
 550
 551        /* delayed work for NMIs and such */
 552        int                             pending_wakeup;
 553        int                             pending_kill;
 554        int                             pending_disable;
 555        struct irq_work                 pending;
 556
 557        atomic_t                        event_limit;
 558
 559        void (*destroy)(struct perf_event *);
 560        struct rcu_head                 rcu_head;
 561
 562        struct pid_namespace            *ns;
 563        u64                             id;
 564
 565        perf_overflow_handler_t         overflow_handler;
 566        void                            *overflow_handler_context;
 567
 568#ifdef CONFIG_EVENT_TRACING
 569        struct ftrace_event_call        *tp_event;
 570        struct event_filter             *filter;
 571#if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_X86_64)
 572        struct ftrace_ops               ftrace_ops;
 573#endif
 574#endif
 575
 576#ifdef CONFIG_CGROUP_PERF
 577        struct perf_cgroup              *cgrp; /* cgroup event is attach to */
 578        RH_KABI_DEPRECATE(int,           cgrp_defer_enabled)
 579#endif
 580
 581        /*
 582         * We need storage to track the entries in perf_pmu_migrate_context; we
 583         * cannot use the event_entry because of RCU and we want to keep the
 584         * group in tact which avoids us using the other two entries.
 585         */
 586        RH_KABI_EXTEND(struct list_head         migrate_entry)
 587        RH_KABI_EXTEND(struct list_head         active_entry)
 588        RH_KABI_EXTEND(void                     *pmu_private)
 589#if defined(CONFIG_FUNCTION_TRACER) && !defined(CONFIG_X86_64)
 590        RH_KABI_EXTEND(struct ftrace_ops         ftrace_ops)
 591#endif
 592        /* address range filters */
 593        RH_KABI_EXTEND(struct perf_addr_filters_head     addr_filters)
 594        /* vma address array for file-based filders */
 595        RH_KABI_EXTEND(unsigned long                    *addr_filters_offs)
 596        RH_KABI_EXTEND(unsigned long                     addr_filters_gen)
 597        RH_KABI_EXTEND(struct list_head                  sb_list)
 598        RH_KABI_EXTEND(u64                              (*clock)(void))
 599        /* The cumulative AND of all event_caps for events in this group. */
 600        RH_KABI_EXTEND(int                              group_caps)
 601        /*
 602         * Node on the pinned or flexible tree located at the event context;
 603         */
 604        RH_KABI_EXTEND(struct rb_node                   group_node)
 605        RH_KABI_EXTEND(u64                              group_index)
 606        RH_KABI_EXTEND(struct list_head                 active_list)
 607
 608#ifdef CONFIG_BPF_SYSCALL
 609        RH_KABI_EXTEND(perf_overflow_handler_t          orig_overflow_handler)
 610        RH_KABI_EXTEND(struct bpf_prog                  *prog)
 611#endif
 612#endif /* CONFIG_PERF_EVENTS */
 613};
 614
 615enum perf_event_context_type {
 616        task_context,
 617        cpu_context,
 618};
 619
 620struct perf_event_groups {
 621        struct rb_root  tree;
 622        u64             index;
 623};
 624
 625/**
 626 * struct perf_event_context - event context structure
 627 *
 628 * Used as a container for task events and CPU events as well:
 629 */
 630struct perf_event_context {
 631        struct pmu                      *pmu;
 632        RH_KABI_DEPRECATE(enum perf_event_context_type, type)
 633        /*
 634         * Protect the states of the events in the list,
 635         * nr_active, and the list:
 636         */
 637        raw_spinlock_t                  lock;
 638        /*
 639         * Protect the list of events.  Locking either mutex or lock
 640         * is sufficient to ensure the list doesn't change; to change
 641         * the list you need to lock both the mutex and the spinlock.
 642         */
 643        struct mutex                    mutex;
 644
 645        RH_KABI_DEPRECATE(struct list_head, pinned_groups)
 646        RH_KABI_DEPRECATE(struct list_head, flexible_groups)
 647        struct list_head                event_list;
 648
 649        int                             nr_events;
 650        int                             nr_active;
 651        int                             is_active;
 652        int                             nr_stat;
 653        int                             nr_freq;
 654        int                             rotate_disable;
 655        atomic_t                        refcount;
 656        struct task_struct              *task;
 657
 658        /*
 659         * Context clock, runs when context enabled.
 660         */
 661        u64                             time;
 662        u64                             timestamp;
 663
 664        /*
 665         * These fields let us detect when two contexts have both
 666         * been cloned (inherited) from a common ancestor.
 667         */
 668        struct perf_event_context       *parent_ctx;
 669        u64                             parent_gen;
 670        u64                             generation;
 671        int                             pin_count;
 672        int                             nr_cgroups;      /* cgroup evts */
 673        RH_KABI_DEPRECATE(int, nr_branch_stack)
 674        struct rcu_head                 rcu_head;
 675        RH_KABI_EXTEND(struct list_head         active_ctx_list)
 676        RH_KABI_EXTEND(void                     *task_ctx_data) /* pmu specific data */
 677        RH_KABI_EXTEND(struct perf_event_groups pinned_groups)
 678        RH_KABI_EXTEND(struct perf_event_groups flexible_groups)
 679        RH_KABI_EXTEND(struct list_head         pinned_active)
 680        RH_KABI_EXTEND(struct list_head         flexible_active)
 681};
 682
 683/*
 684 * Number of contexts where an event can trigger:
 685 *      task, softirq, hardirq, nmi.
 686 */
 687#define PERF_NR_CONTEXTS        4
 688
 689/**
 690 * struct perf_event_cpu_context - per cpu event context structure
 691 */
 692struct perf_cpu_context {
 693        struct perf_event_context       ctx;
 694        struct perf_event_context       *task_ctx;
 695        int                             active_oncpu;
 696        int                             exclusive;
 697        struct hrtimer                  hrtimer;
 698        ktime_t                         hrtimer_interval;
 699
 700        RH_KABI_DEPRECATE(struct list_head,     rotation_list)
 701
 702        struct pmu                      *unique_pmu;
 703        struct perf_cgroup              *cgrp;
 704
 705        RH_KABI_EXTEND(raw_spinlock_t   hrtimer_lock)
 706        RH_KABI_EXTEND(unsigned int     hrtimer_active)
 707};
 708
 709struct perf_output_handle {
 710        struct perf_event               *event;
 711        struct ring_buffer              *rb;
 712        unsigned long                   wakeup;
 713        unsigned long                   size;
 714        u64                             aux_flags;
 715        union {
 716                void                    *addr;
 717                unsigned long           head;
 718        };
 719        int                             page;
 720};
 721
 722struct bpf_perf_event_data_kern {
 723        bpf_user_pt_regs_t *regs;
 724        struct perf_sample_data *data;
 725        struct perf_event *event;
 726};
 727
 728#ifdef CONFIG_CGROUP_PERF
 729
 730#ifndef __GENKSYMS__
 731/*
 732 * perf_cgroup_info keeps track of time_enabled for a cgroup.
 733 * This is a per-cpu dynamically allocated data structure.
 734 */
 735struct perf_cgroup_info {
 736        u64                             time;
 737        u64                             timestamp;
 738};
 739
 740struct perf_cgroup {
 741        struct cgroup_subsys_state      css;
 742        struct perf_cgroup_info __percpu *info;
 743};
 744#endif /* __GENKSYMS__ */
 745
 746/*
 747 * Must ensure cgroup is pinned (css_get) before calling
 748 * this function. In other words, we cannot call this function
 749 * if there is no cgroup event for the current CPU context.
 750 */
 751static inline struct perf_cgroup *
 752perf_cgroup_from_task(struct task_struct *task)
 753{
 754        return container_of(task_subsys_state(task, perf_subsys_id),
 755                            struct perf_cgroup, css);
 756}
 757#endif /* CONFIG_CGROUP_PERF */
 758
 759#ifdef CONFIG_PERF_EVENTS
 760
 761extern void *perf_aux_output_begin(struct perf_output_handle *handle,
 762                                   struct perf_event *event);
 763extern void perf_aux_output_end(struct perf_output_handle *handle,
 764                                unsigned long size);
 765extern int perf_aux_output_skip(struct perf_output_handle *handle,
 766                                unsigned long size);
 767extern void *perf_get_aux(struct perf_output_handle *handle);
 768extern void perf_aux_output_flag(struct perf_output_handle *handle, u64 flags);
 769extern void perf_event_itrace_started(struct perf_event *event);
 770
 771extern int perf_pmu_register(struct pmu *pmu, const char *name, int type);
 772extern void perf_pmu_unregister(struct pmu *pmu);
 773
 774extern int perf_num_counters(void);
 775extern const char *perf_pmu_name(void);
 776extern void __perf_event_task_sched_in(struct task_struct *prev,
 777                                       struct task_struct *task);
 778extern void __perf_event_task_sched_out(struct task_struct *prev,
 779                                        struct task_struct *next);
 780extern int perf_event_init_task(struct task_struct *child);
 781extern void perf_event_exit_task(struct task_struct *child);
 782extern void perf_event_free_task(struct task_struct *task);
 783extern void perf_event_delayed_put(struct task_struct *task);
 784extern struct file *perf_event_get(unsigned int fd);
 785extern const struct perf_event_attr *perf_event_attrs(struct perf_event *event);
 786extern void perf_event_print_debug(void);
 787extern void perf_pmu_disable(struct pmu *pmu);
 788extern void perf_pmu_enable(struct pmu *pmu);
 789extern void perf_sched_cb_dec(struct pmu *pmu);
 790extern void perf_sched_cb_inc(struct pmu *pmu);
 791extern int perf_event_task_disable(void);
 792extern int perf_event_task_enable(void);
 793extern int perf_event_refresh(struct perf_event *event, int refresh);
 794extern void perf_event_update_userpage(struct perf_event *event);
 795extern int perf_event_release_kernel(struct perf_event *event);
 796extern struct perf_event *
 797perf_event_create_kernel_counter(struct perf_event_attr *attr,
 798                                int cpu,
 799                                struct task_struct *task,
 800                                perf_overflow_handler_t callback,
 801                                void *context);
 802extern void perf_pmu_migrate_context(struct pmu *pmu,
 803                                int src_cpu, int dst_cpu);
 804int perf_event_read_local(struct perf_event *event, u64 *value,
 805                          u64 *enabled, u64 *running);
 806extern u64 perf_event_read_value(struct perf_event *event,
 807                                 u64 *enabled, u64 *running);
 808
 809struct perf_regs_user {
 810        __u64           abi;
 811        struct pt_regs  *regs;
 812};
 813
 814struct perf_sample_data {
 815        u64                             type;
 816
 817        u64                             ip;
 818        struct {
 819                u32     pid;
 820                u32     tid;
 821        }                               tid_entry;
 822        u64                             time;
 823        u64                             addr;
 824        u64                             id;
 825        u64                             stream_id;
 826        struct {
 827                u32     cpu;
 828                u32     reserved;
 829        }                               cpu_entry;
 830        u64                             period;
 831        union  perf_mem_data_src        data_src;
 832        struct perf_callchain_entry     *callchain;
 833        struct perf_raw_record          *raw;
 834        struct perf_branch_stack        *br_stack;
 835
 836        RH_KABI_REPLACE(struct perf_regs_user       regs_user,
 837                            struct perf_regs            regs_user)
 838
 839        u64                             stack_user_size;
 840        u64                             weight;
 841
 842        /*
 843         * Transaction flags for abort events:
 844         */
 845        RH_KABI_EXTEND(u64                              txn)
 846        RH_KABI_EXTEND(struct perf_regs                 regs_intr)
 847
 848        /*
 849         * regs_user may point to task_pt_regs or to regs_user_copy, depending
 850         * on arch details.
 851         */
 852        RH_KABI_EXTEND(struct pt_regs                   regs_user_copy)
 853
 854        RH_KABI_EXTEND(u64                              phys_addr)
 855
 856} ____cacheline_aligned;
 857
 858/* default value for data source */
 859#define PERF_MEM_NA (PERF_MEM_S(OP, NA)   |\
 860                    PERF_MEM_S(LVL, NA)   |\
 861                    PERF_MEM_S(SNOOP, NA) |\
 862                    PERF_MEM_S(LOCK, NA)  |\
 863                    PERF_MEM_S(TLB, NA))
 864
 865static inline void perf_sample_data_init(struct perf_sample_data *data,
 866                                         u64 addr, u64 period)
 867{
 868        /* remaining struct members initialized in perf_prepare_sample() */
 869        data->addr = addr;
 870        data->raw  = NULL;
 871        data->br_stack = NULL;
 872        data->period = period;
 873        data->weight = 0;
 874        data->data_src.val = PERF_MEM_NA;
 875        data->txn = 0;
 876}
 877
 878extern void perf_output_sample(struct perf_output_handle *handle,
 879                               struct perf_event_header *header,
 880                               struct perf_sample_data *data,
 881                               struct perf_event *event);
 882extern void perf_prepare_sample(struct perf_event_header *header,
 883                                struct perf_sample_data *data,
 884                                struct perf_event *event,
 885                                struct pt_regs *regs);
 886
 887extern int perf_event_overflow(struct perf_event *event,
 888                                 struct perf_sample_data *data,
 889                                 struct pt_regs *regs);
 890
 891extern void perf_event_output_forward(struct perf_event *event,
 892                                     struct perf_sample_data *data,
 893                                     struct pt_regs *regs);
 894extern void perf_event_output_backward(struct perf_event *event,
 895                                       struct perf_sample_data *data,
 896                                       struct pt_regs *regs);
 897extern void perf_event_output(struct perf_event *event,
 898                              struct perf_sample_data *data,
 899                              struct pt_regs *regs);
 900
 901static inline bool
 902is_default_overflow_handler(struct perf_event *event)
 903{
 904        if (likely(event->overflow_handler == perf_event_output_forward))
 905                return true;
 906        if (unlikely(event->overflow_handler == perf_event_output_backward))
 907                return true;
 908        return false;
 909}
 910
 911extern void
 912perf_event_header__init_id(struct perf_event_header *header,
 913                           struct perf_sample_data *data,
 914                           struct perf_event *event);
 915extern void
 916perf_event__output_id_sample(struct perf_event *event,
 917                             struct perf_output_handle *handle,
 918                             struct perf_sample_data *sample);
 919
 920extern void
 921perf_log_lost_samples(struct perf_event *event, u64 lost);
 922
 923static inline bool is_sampling_event(struct perf_event *event)
 924{
 925        return event->attr.sample_period != 0;
 926}
 927
 928/*
 929 * Return 1 for a software event, 0 for a hardware event
 930 */
 931static inline int is_software_event(struct perf_event *event)
 932{
 933        return event->event_caps & PERF_EV_CAP_SOFTWARE;
 934}
 935
 936extern struct static_key perf_swevent_enabled[PERF_COUNT_SW_MAX];
 937
 938extern void ___perf_sw_event(u32, u64, struct pt_regs *, u64);
 939extern void __perf_sw_event(u32, u64, struct pt_regs *, u64);
 940
 941#ifndef perf_arch_fetch_caller_regs
 942static inline void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip) { }
 943#endif
 944
 945/*
 946 * Take a snapshot of the regs. Skip ip and frame pointer to
 947 * the nth caller. We only need a few of the regs:
 948 * - ip for PERF_SAMPLE_IP
 949 * - cs for user_mode() tests
 950 * - bp for callchains
 951 * - eflags, for future purposes, just in case
 952 */
 953static inline void perf_fetch_caller_regs(struct pt_regs *regs)
 954{
 955        perf_arch_fetch_caller_regs(regs, CALLER_ADDR0);
 956}
 957
 958static __always_inline void
 959perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)
 960{
 961        if (static_key_false(&perf_swevent_enabled[event_id]))
 962                __perf_sw_event(event_id, nr, regs, addr);
 963}
 964
 965DECLARE_PER_CPU(struct pt_regs, __perf_regs[4]);
 966
 967/*
 968 * 'Special' version for the scheduler, it hard assumes no recursion,
 969 * which is guaranteed by us not actually scheduling inside other swevents
 970 * because those disable preemption.
 971 */
 972static __always_inline void
 973perf_sw_event_sched(u32 event_id, u64 nr, u64 addr)
 974{
 975        if (static_key_false(&perf_swevent_enabled[event_id])) {
 976                struct pt_regs *regs = this_cpu_ptr(&__perf_regs[0]);
 977
 978                perf_fetch_caller_regs(regs);
 979                ___perf_sw_event(event_id, nr, regs, addr);
 980        }
 981}
 982
 983extern struct static_key_deferred perf_sched_events;
 984
 985static inline void perf_event_task_sched_in(struct task_struct *prev,
 986                                            struct task_struct *task)
 987{
 988        if (static_key_false(&perf_sched_events.key))
 989                __perf_event_task_sched_in(prev, task);
 990}
 991
 992static inline void perf_event_task_sched_out(struct task_struct *prev,
 993                                             struct task_struct *next)
 994{
 995        perf_sw_event_sched(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, 0);
 996
 997        if (static_key_false(&perf_sched_events.key))
 998                __perf_event_task_sched_out(prev, next);
 999}
1000
1001extern void perf_event_mmap(struct vm_area_struct *vma);
1002extern struct perf_guest_info_callbacks *perf_guest_cbs;
1003extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
1004extern int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
1005
1006extern void perf_event_exec(void);
1007extern void perf_event_comm(struct task_struct *tsk, bool exec);
1008extern void perf_event_fork(struct task_struct *tsk);
1009
1010/* Callchains */
1011DECLARE_PER_CPU(struct perf_callchain_entry, perf_callchain_entry);
1012
1013extern void perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs);
1014extern void perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs);
1015extern struct perf_callchain_entry *
1016get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
1017                   bool crosstask, bool add_mark);
1018extern int get_callchain_buffers(void);
1019extern void put_callchain_buffers(void);
1020
1021static inline int perf_callchain_store(struct perf_callchain_entry *entry, u64 ip)
1022{
1023        if (entry->nr < PERF_MAX_STACK_DEPTH) {
1024                entry->ip[entry->nr++] = ip;
1025                return 0;
1026        } else {
1027                return -1; /* no more room, stop walking the stack */
1028        }
1029}
1030
1031extern int sysctl_perf_event_paranoid;
1032extern int sysctl_perf_event_mlock;
1033extern int sysctl_perf_event_sample_rate;
1034extern int sysctl_perf_cpu_time_max_percent;
1035
1036extern void perf_sample_event_took(u64 sample_len_ns);
1037
1038extern int perf_proc_update_handler(struct ctl_table *table, int write,
1039                void __user *buffer, size_t *lenp,
1040                loff_t *ppos);
1041extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
1042                void __user *buffer, size_t *lenp,
1043                loff_t *ppos);
1044
1045
1046static inline bool perf_paranoid_tracepoint_raw(void)
1047{
1048        return sysctl_perf_event_paranoid > -1;
1049}
1050
1051static inline bool perf_paranoid_cpu(void)
1052{
1053        return sysctl_perf_event_paranoid > 0;
1054}
1055
1056static inline bool perf_paranoid_kernel(void)
1057{
1058        return sysctl_perf_event_paranoid > 1;
1059}
1060
1061extern void perf_event_init(void);
1062extern void perf_tp_event(u64 addr, u64 count, void *record,
1063                          int entry_size, struct pt_regs *regs,
1064                          struct hlist_head *head, int rctx,
1065                          struct task_struct *task);
1066extern void perf_bp_event(struct perf_event *event, void *data);
1067
1068#ifndef perf_misc_flags
1069# define perf_misc_flags(regs) \
1070                (user_mode(regs) ? PERF_RECORD_MISC_USER : PERF_RECORD_MISC_KERNEL)
1071# define perf_instruction_pointer(regs) instruction_pointer(regs)
1072#endif
1073#ifndef perf_arch_bpf_user_pt_regs
1074# define perf_arch_bpf_user_pt_regs(regs) regs
1075#endif
1076
1077static inline bool has_branch_stack(struct perf_event *event)
1078{
1079        return event->attr.sample_type & PERF_SAMPLE_BRANCH_STACK;
1080}
1081
1082static inline bool needs_branch_stack(struct perf_event *event)
1083{
1084        return event->attr.branch_sample_type != 0;
1085}
1086
1087static inline bool has_aux(struct perf_event *event)
1088{
1089        return event->pmu->setup_aux;
1090}
1091
1092static inline bool is_write_backward(struct perf_event *event)
1093{
1094        return !!event->attr.write_backward;
1095}
1096
1097static inline bool has_addr_filter(struct perf_event *event)
1098{
1099        return event->pmu->nr_addr_filters;
1100}
1101
1102/*
1103 * An inherited event uses parent's filters
1104 */
1105static inline struct perf_addr_filters_head *
1106perf_event_addr_filters(struct perf_event *event)
1107{
1108        struct perf_addr_filters_head *ifh = &event->addr_filters;
1109
1110        if (event->parent)
1111                ifh = &event->parent->addr_filters;
1112
1113        return ifh;
1114}
1115
1116extern void perf_event_addr_filters_sync(struct perf_event *event);
1117
1118extern int perf_output_begin(struct perf_output_handle *handle,
1119                             struct perf_event *event, unsigned int size);
1120extern int perf_output_begin_forward(struct perf_output_handle *handle,
1121                                    struct perf_event *event,
1122                                    unsigned int size);
1123extern int perf_output_begin_backward(struct perf_output_handle *handle,
1124                                      struct perf_event *event,
1125                                      unsigned int size);
1126
1127extern void perf_output_end(struct perf_output_handle *handle);
1128extern unsigned int perf_output_copy(struct perf_output_handle *handle,
1129                             const void *buf, unsigned int len);
1130extern unsigned int perf_output_skip(struct perf_output_handle *handle,
1131                                     unsigned int len);
1132extern int perf_swevent_get_recursion_context(void);
1133extern void perf_swevent_put_recursion_context(int rctx);
1134extern u64 perf_swevent_set_period(struct perf_event *event);
1135extern void perf_event_enable(struct perf_event *event);
1136extern void perf_event_disable(struct perf_event *event);
1137extern void perf_event_disable_local(struct perf_event *event);
1138extern void perf_event_disable_inatomic(struct perf_event *event);
1139extern void perf_event_task_tick(void);
1140extern int perf_event_account_interrupt(struct perf_event *event);
1141#else /* !CONFIG_PERF_EVENTS: */
1142static inline void *
1143perf_aux_output_begin(struct perf_output_handle *handle,
1144                      struct perf_event *event)                         { return NULL; }
1145static inline void
1146perf_aux_output_end(struct perf_output_handle *handle, unsigned long size)
1147                                                                        { }
1148static inline int
1149perf_aux_output_skip(struct perf_output_handle *handle,
1150                     unsigned long size)                                { return -EINVAL; }
1151static inline void *
1152perf_get_aux(struct perf_output_handle *handle)                         { return NULL; }
1153static inline void
1154perf_event_task_sched_in(struct task_struct *prev,
1155                         struct task_struct *task)                      { }
1156static inline void
1157perf_event_task_sched_out(struct task_struct *prev,
1158                          struct task_struct *next)                     { }
1159static inline int perf_event_init_task(struct task_struct *child)       { return 0; }
1160static inline void perf_event_exit_task(struct task_struct *child)      { }
1161static inline void perf_event_free_task(struct task_struct *task)       { }
1162static inline void perf_event_delayed_put(struct task_struct *task)     { }
1163static inline struct file *perf_event_get(unsigned int fd)      { return ERR_PTR(-EINVAL); }
1164static inline const struct perf_event_attr *perf_event_attrs(struct perf_event *event)
1165{
1166        return ERR_PTR(-EINVAL);
1167}
1168static inline int perf_event_read_local(struct perf_event *event, u64 *value,
1169                                        u64 *enabled, u64 *running)
1170{
1171        return -EINVAL;
1172}
1173static inline void perf_event_print_debug(void)                         { }
1174static inline int perf_event_task_disable(void)                         { return -EINVAL; }
1175static inline int perf_event_task_enable(void)                          { return -EINVAL; }
1176static inline int perf_event_refresh(struct perf_event *event, int refresh)
1177{
1178        return -EINVAL;
1179}
1180
1181static inline void
1182perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)     { }
1183static inline void
1184perf_sw_event_sched(u32 event_id, u64 nr, u64 addr)                     { }
1185static inline void
1186perf_bp_event(struct perf_event *event, void *data)                     { }
1187
1188static inline int perf_register_guest_info_callbacks
1189(struct perf_guest_info_callbacks *callbacks)                           { return 0; }
1190static inline int perf_unregister_guest_info_callbacks
1191(struct perf_guest_info_callbacks *callbacks)                           { return 0; }
1192
1193static inline void perf_event_mmap(struct vm_area_struct *vma)          { }
1194static inline void perf_event_exec(void)                                { }
1195static inline void perf_event_comm(struct task_struct *tsk, bool exec)  { }
1196static inline void perf_event_fork(struct task_struct *tsk)             { }
1197static inline void perf_event_init(void)                                { }
1198static inline int  perf_swevent_get_recursion_context(void)             { return -1; }
1199static inline void perf_swevent_put_recursion_context(int rctx)         { }
1200static inline u64 perf_swevent_set_period(struct perf_event *event)     { return 0; }
1201static inline void perf_event_enable(struct perf_event *event)          { }
1202static inline void perf_event_disable(struct perf_event *event)         { }
1203static inline int __perf_event_disable(void *info)                      { return -1; }
1204static inline void perf_event_task_tick(void)                           { }
1205static inline int perf_event_release_kernel(struct perf_event *event)   { return 0; }
1206#endif
1207
1208#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_NO_HZ_FULL)
1209extern bool perf_event_can_stop_tick(void);
1210#else
1211static inline bool perf_event_can_stop_tick(void)                       { return true; }
1212#endif
1213
1214#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_INTEL)
1215extern void perf_restore_debug_store(void);
1216#else
1217static inline void perf_restore_debug_store(void)                       { }
1218#endif
1219
1220static __always_inline bool perf_raw_frag_last(const struct perf_raw_frag *frag)
1221{
1222        return frag->pad < sizeof(u64);
1223}
1224
1225#define perf_output_put(handle, x) perf_output_copy((handle), &(x), sizeof(x))
1226
1227/*
1228 * This has to have a higher priority than migration_notifier in sched.c.
1229 */
1230#define perf_cpu_notifier(fn)                                           \
1231do {                                                                    \
1232        static struct notifier_block fn##_nb =                          \
1233                { .notifier_call = fn, .priority = CPU_PRI_PERF };      \
1234        unsigned long cpu = smp_processor_id();                         \
1235        unsigned long flags;                                            \
1236                                                                        \
1237        cpu_notifier_register_begin();                                  \
1238        fn(&fn##_nb, (unsigned long)CPU_UP_PREPARE,                     \
1239                (void *)(unsigned long)cpu);                            \
1240        local_irq_save(flags);                                          \
1241        fn(&fn##_nb, (unsigned long)CPU_STARTING,                       \
1242                (void *)(unsigned long)cpu);                            \
1243        local_irq_restore(flags);                                       \
1244        fn(&fn##_nb, (unsigned long)CPU_ONLINE,                         \
1245                (void *)(unsigned long)cpu);                            \
1246        __register_cpu_notifier(&fn##_nb);                              \
1247        cpu_notifier_register_done();                                   \
1248} while (0)
1249
1250/*
1251 * Bare-bones version of perf_cpu_notifier(), which doesn't invoke the
1252 * callback for already online CPUs.
1253 */
1254#define __perf_cpu_notifier(fn)                                         \
1255do {                                                                    \
1256        static struct notifier_block fn##_nb =                          \
1257                { .notifier_call = fn, .priority = CPU_PRI_PERF };      \
1258                                                                        \
1259        __register_cpu_notifier(&fn##_nb);                              \
1260} while (0)
1261
1262struct perf_pmu_events_attr {
1263        struct device_attribute attr;
1264        u64 id;
1265        const char *event_str;
1266};
1267
1268ssize_t perf_event_sysfs_show(struct device *dev, struct device_attribute *attr,
1269                              char *page);
1270
1271#define PMU_EVENT_ATTR(_name, _var, _id, _show)                         \
1272static struct perf_pmu_events_attr _var = {                             \
1273        .attr = __ATTR(_name, 0444, _show, NULL),                       \
1274        .id   =  _id,                                                   \
1275};
1276
1277#define PMU_EVENT_ATTR_STRING(_name, _var, _str)                            \
1278static struct perf_pmu_events_attr _var = {                                 \
1279        .attr           = __ATTR(_name, 0444, perf_event_sysfs_show, NULL), \
1280        .id             = 0,                                                \
1281        .event_str      = _str,                                             \
1282};
1283
1284#define PMU_FORMAT_ATTR(_name, _format)                                 \
1285static ssize_t                                                          \
1286_name##_show(struct device *dev,                                        \
1287                               struct device_attribute *attr,           \
1288                               char *page)                              \
1289{                                                                       \
1290        BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE);                     \
1291        return sprintf(page, _format "\n");                             \
1292}                                                                       \
1293                                                                        \
1294static struct device_attribute format_attr_##_name = __ATTR_RO(_name)
1295
1296#endif /* _LINUX_PERF_EVENT_H */
1297