perf_event.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293
  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. #include <linux/types.h>
  17. #include <linux/ioctl.h>
  18. #include <asm/byteorder.h>
  19. /*
  20. * User-space ABI bits:
  21. */
  22. /*
  23. * attr.type
  24. */
  25. enum perf_type_id {
  26. PERF_TYPE_HARDWARE = 0,
  27. PERF_TYPE_SOFTWARE = 1,
  28. PERF_TYPE_TRACEPOINT = 2,
  29. PERF_TYPE_HW_CACHE = 3,
  30. PERF_TYPE_RAW = 4,
  31. PERF_TYPE_BREAKPOINT = 5,
  32. PERF_TYPE_MAX, /* non-ABI */
  33. };
  34. /*
  35. * Generalized performance event event_id types, used by the
  36. * attr.event_id parameter of the sys_perf_event_open()
  37. * syscall:
  38. */
  39. enum perf_hw_id {
  40. /*
  41. * Common hardware events, generalized by the kernel:
  42. */
  43. PERF_COUNT_HW_CPU_CYCLES = 0,
  44. PERF_COUNT_HW_INSTRUCTIONS = 1,
  45. PERF_COUNT_HW_CACHE_REFERENCES = 2,
  46. PERF_COUNT_HW_CACHE_MISSES = 3,
  47. PERF_COUNT_HW_BRANCH_INSTRUCTIONS = 4,
  48. PERF_COUNT_HW_BRANCH_MISSES = 5,
  49. PERF_COUNT_HW_BUS_CYCLES = 6,
  50. PERF_COUNT_HW_STALLED_CYCLES_FRONTEND = 7,
  51. PERF_COUNT_HW_STALLED_CYCLES_BACKEND = 8,
  52. PERF_COUNT_HW_REF_CPU_CYCLES = 9,
  53. PERF_COUNT_HW_MAX, /* non-ABI */
  54. };
  55. /*
  56. * Generalized hardware cache events:
  57. *
  58. * { L1-D, L1-I, LLC, ITLB, DTLB, BPU, NODE } x
  59. * { read, write, prefetch } x
  60. * { accesses, misses }
  61. */
  62. enum perf_hw_cache_id {
  63. PERF_COUNT_HW_CACHE_L1D = 0,
  64. PERF_COUNT_HW_CACHE_L1I = 1,
  65. PERF_COUNT_HW_CACHE_LL = 2,
  66. PERF_COUNT_HW_CACHE_DTLB = 3,
  67. PERF_COUNT_HW_CACHE_ITLB = 4,
  68. PERF_COUNT_HW_CACHE_BPU = 5,
  69. PERF_COUNT_HW_CACHE_NODE = 6,
  70. PERF_COUNT_HW_CACHE_MAX, /* non-ABI */
  71. };
  72. enum perf_hw_cache_op_id {
  73. PERF_COUNT_HW_CACHE_OP_READ = 0,
  74. PERF_COUNT_HW_CACHE_OP_WRITE = 1,
  75. PERF_COUNT_HW_CACHE_OP_PREFETCH = 2,
  76. PERF_COUNT_HW_CACHE_OP_MAX, /* non-ABI */
  77. };
  78. enum perf_hw_cache_op_result_id {
  79. PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0,
  80. PERF_COUNT_HW_CACHE_RESULT_MISS = 1,
  81. PERF_COUNT_HW_CACHE_RESULT_MAX, /* non-ABI */
  82. };
  83. /*
  84. * Special "software" events provided by the kernel, even if the hardware
  85. * does not support performance events. These events measure various
  86. * physical and sw events of the kernel (and allow the profiling of them as
  87. * well):
  88. */
  89. enum perf_sw_ids {
  90. PERF_COUNT_SW_CPU_CLOCK = 0,
  91. PERF_COUNT_SW_TASK_CLOCK = 1,
  92. PERF_COUNT_SW_PAGE_FAULTS = 2,
  93. PERF_COUNT_SW_CONTEXT_SWITCHES = 3,
  94. PERF_COUNT_SW_CPU_MIGRATIONS = 4,
  95. PERF_COUNT_SW_PAGE_FAULTS_MIN = 5,
  96. PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6,
  97. PERF_COUNT_SW_ALIGNMENT_FAULTS = 7,
  98. PERF_COUNT_SW_EMULATION_FAULTS = 8,
  99. PERF_COUNT_SW_MAX, /* non-ABI */
  100. };
  101. /*
  102. * Bits that can be set in attr.sample_type to request information
  103. * in the overflow packets.
  104. */
  105. enum perf_event_sample_format {
  106. PERF_SAMPLE_IP = 1U << 0,
  107. PERF_SAMPLE_TID = 1U << 1,
  108. PERF_SAMPLE_TIME = 1U << 2,
  109. PERF_SAMPLE_ADDR = 1U << 3,
  110. PERF_SAMPLE_READ = 1U << 4,
  111. PERF_SAMPLE_CALLCHAIN = 1U << 5,
  112. PERF_SAMPLE_ID = 1U << 6,
  113. PERF_SAMPLE_CPU = 1U << 7,
  114. PERF_SAMPLE_PERIOD = 1U << 8,
  115. PERF_SAMPLE_STREAM_ID = 1U << 9,
  116. PERF_SAMPLE_RAW = 1U << 10,
  117. PERF_SAMPLE_BRANCH_STACK = 1U << 11,
  118. PERF_SAMPLE_MAX = 1U << 12, /* non-ABI */
  119. };
  120. /*
  121. * values to program into branch_sample_type when PERF_SAMPLE_BRANCH is set
  122. *
  123. * If the user does not pass priv level information via branch_sample_type,
  124. * the kernel uses the event's priv level. Branch and event priv levels do
  125. * not have to match. Branch priv level is checked for permissions.
  126. *
  127. * The branch types can be combined, however BRANCH_ANY covers all types
  128. * of branches and therefore it supersedes all the other types.
  129. */
  130. enum perf_branch_sample_type {
  131. PERF_SAMPLE_BRANCH_USER = 1U << 0, /* user branches */
  132. PERF_SAMPLE_BRANCH_KERNEL = 1U << 1, /* kernel branches */
  133. PERF_SAMPLE_BRANCH_HV = 1U << 2, /* hypervisor branches */
  134. PERF_SAMPLE_BRANCH_ANY = 1U << 3, /* any branch types */
  135. PERF_SAMPLE_BRANCH_ANY_CALL = 1U << 4, /* any call branch */
  136. PERF_SAMPLE_BRANCH_ANY_RETURN = 1U << 5, /* any return branch */
  137. PERF_SAMPLE_BRANCH_IND_CALL = 1U << 6, /* indirect calls */
  138. PERF_SAMPLE_BRANCH_MAX = 1U << 7, /* non-ABI */
  139. };
  140. #define PERF_SAMPLE_BRANCH_PLM_ALL \
  141. (PERF_SAMPLE_BRANCH_USER|\
  142. PERF_SAMPLE_BRANCH_KERNEL|\
  143. PERF_SAMPLE_BRANCH_HV)
  144. /*
  145. * The format of the data returned by read() on a perf event fd,
  146. * as specified by attr.read_format:
  147. *
  148. * struct read_format {
  149. * { u64 value;
  150. * { u64 time_enabled; } && PERF_FORMAT_TOTAL_TIME_ENABLED
  151. * { u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING
  152. * { u64 id; } && PERF_FORMAT_ID
  153. * } && !PERF_FORMAT_GROUP
  154. *
  155. * { u64 nr;
  156. * { u64 time_enabled; } && PERF_FORMAT_TOTAL_TIME_ENABLED
  157. * { u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING
  158. * { u64 value;
  159. * { u64 id; } && PERF_FORMAT_ID
  160. * } cntr[nr];
  161. * } && PERF_FORMAT_GROUP
  162. * };
  163. */
  164. enum perf_event_read_format {
  165. PERF_FORMAT_TOTAL_TIME_ENABLED = 1U << 0,
  166. PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1,
  167. PERF_FORMAT_ID = 1U << 2,
  168. PERF_FORMAT_GROUP = 1U << 3,
  169. PERF_FORMAT_MAX = 1U << 4, /* non-ABI */
  170. };
  171. #define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */
  172. /*
  173. * Hardware event_id to monitor via a performance monitoring event:
  174. */
  175. struct perf_event_attr {
  176. /*
  177. * Major type: hardware/software/tracepoint/etc.
  178. */
  179. __u32 type;
  180. /*
  181. * Size of the attr structure, for fwd/bwd compat.
  182. */
  183. __u32 size;
  184. /*
  185. * Type specific configuration information.
  186. */
  187. __u64 config;
  188. union {
  189. __u64 sample_period;
  190. __u64 sample_freq;
  191. };
  192. __u64 sample_type;
  193. __u64 read_format;
  194. __u64 disabled : 1, /* off by default */
  195. inherit : 1, /* children inherit it */
  196. pinned : 1, /* must always be on PMU */
  197. exclusive : 1, /* only group on PMU */
  198. exclude_user : 1, /* don't count user */
  199. exclude_kernel : 1, /* ditto kernel */
  200. exclude_hv : 1, /* ditto hypervisor */
  201. exclude_idle : 1, /* don't count when idle */
  202. mmap : 1, /* include mmap data */
  203. comm : 1, /* include comm data */
  204. freq : 1, /* use freq, not period */
  205. inherit_stat : 1, /* per task counts */
  206. enable_on_exec : 1, /* next exec enables */
  207. task : 1, /* trace fork/exit */
  208. watermark : 1, /* wakeup_watermark */
  209. /*
  210. * precise_ip:
  211. *
  212. * 0 - SAMPLE_IP can have arbitrary skid
  213. * 1 - SAMPLE_IP must have constant skid
  214. * 2 - SAMPLE_IP requested to have 0 skid
  215. * 3 - SAMPLE_IP must have 0 skid
  216. *
  217. * See also PERF_RECORD_MISC_EXACT_IP
  218. */
  219. precise_ip : 2, /* skid constraint */
  220. mmap_data : 1, /* non-exec mmap data */
  221. sample_id_all : 1, /* sample_type all events */
  222. exclude_host : 1, /* don't count in host */
  223. exclude_guest : 1, /* don't count in guest */
  224. __reserved_1 : 43;
  225. union {
  226. __u32 wakeup_events; /* wakeup every n events */
  227. __u32 wakeup_watermark; /* bytes before wakeup */
  228. };
  229. __u32 bp_type;
  230. union {
  231. __u64 bp_addr;
  232. __u64 config1; /* extension of config */
  233. };
  234. union {
  235. __u64 bp_len;
  236. __u64 config2; /* extension of config1 */
  237. };
  238. __u64 branch_sample_type; /* enum branch_sample_type */
  239. };
  240. /*
  241. * Ioctls that can be done on a perf event fd:
  242. */
  243. #define PERF_EVENT_IOC_ENABLE _IO ('$', 0)
  244. #define PERF_EVENT_IOC_DISABLE _IO ('$', 1)
  245. #define PERF_EVENT_IOC_REFRESH _IO ('$', 2)
  246. #define PERF_EVENT_IOC_RESET _IO ('$', 3)
  247. #define PERF_EVENT_IOC_PERIOD _IOW('$', 4, __u64)
  248. #define PERF_EVENT_IOC_SET_OUTPUT _IO ('$', 5)
  249. #define PERF_EVENT_IOC_SET_FILTER _IOW('$', 6, char *)
  250. enum perf_event_ioc_flags {
  251. PERF_IOC_FLAG_GROUP = 1U << 0,
  252. };
  253. /*
  254. * Structure of the page that can be mapped via mmap
  255. */
  256. struct perf_event_mmap_page {
  257. __u32 version; /* version number of this structure */
  258. __u32 compat_version; /* lowest version this is compat with */
  259. /*
  260. * Bits needed to read the hw events in user-space.
  261. *
  262. * u32 seq;
  263. * s64 count;
  264. *
  265. * do {
  266. * seq = pc->lock;
  267. *
  268. * barrier()
  269. * if (pc->index) {
  270. * count = pmc_read(pc->index - 1);
  271. * count += pc->offset;
  272. * } else
  273. * goto regular_read;
  274. *
  275. * barrier();
  276. * } while (pc->lock != seq);
  277. *
  278. * NOTE: for obvious reason this only works on self-monitoring
  279. * processes.
  280. */
  281. __u32 lock; /* seqlock for synchronization */
  282. __u32 index; /* hardware event identifier */
  283. __s64 offset; /* add to hardware event value */
  284. __u64 time_enabled; /* time event active */
  285. __u64 time_running; /* time event on cpu */
  286. __u32 time_mult, time_shift;
  287. __u64 time_offset;
  288. /*
  289. * Hole for extension of the self monitor capabilities
  290. */
  291. __u64 __reserved[121]; /* align to 1k */
  292. /*
  293. * Control data for the mmap() data buffer.
  294. *
  295. * User-space reading the @data_head value should issue an rmb(), on
  296. * SMP capable platforms, after reading this value -- see
  297. * perf_event_wakeup().
  298. *
  299. * When the mapping is PROT_WRITE the @data_tail value should be
  300. * written by userspace to reflect the last read data. In this case
  301. * the kernel will not over-write unread data.
  302. */
  303. __u64 data_head; /* head in the data section */
  304. __u64 data_tail; /* user-space written tail */
  305. };
  306. #define PERF_RECORD_MISC_CPUMODE_MASK (7 << 0)
  307. #define PERF_RECORD_MISC_CPUMODE_UNKNOWN (0 << 0)
  308. #define PERF_RECORD_MISC_KERNEL (1 << 0)
  309. #define PERF_RECORD_MISC_USER (2 << 0)
  310. #define PERF_RECORD_MISC_HYPERVISOR (3 << 0)
  311. #define PERF_RECORD_MISC_GUEST_KERNEL (4 << 0)
  312. #define PERF_RECORD_MISC_GUEST_USER (5 << 0)
  313. /*
  314. * Indicates that the content of PERF_SAMPLE_IP points to
  315. * the actual instruction that triggered the event. See also
  316. * perf_event_attr::precise_ip.
  317. */
  318. #define PERF_RECORD_MISC_EXACT_IP (1 << 14)
  319. /*
  320. * Reserve the last bit to indicate some extended misc field
  321. */
  322. #define PERF_RECORD_MISC_EXT_RESERVED (1 << 15)
  323. struct perf_event_header {
  324. __u32 type;
  325. __u16 misc;
  326. __u16 size;
  327. };
  328. enum perf_event_type {
  329. /*
  330. * If perf_event_attr.sample_id_all is set then all event types will
  331. * have the sample_type selected fields related to where/when
  332. * (identity) an event took place (TID, TIME, ID, CPU, STREAM_ID)
  333. * described in PERF_RECORD_SAMPLE below, it will be stashed just after
  334. * the perf_event_header and the fields already present for the existing
  335. * fields, i.e. at the end of the payload. That way a newer perf.data
  336. * file will be supported by older perf tools, with these new optional
  337. * fields being ignored.
  338. *
  339. * The MMAP events record the PROT_EXEC mappings so that we can
  340. * correlate userspace IPs to code. They have the following structure:
  341. *
  342. * struct {
  343. * struct perf_event_header header;
  344. *
  345. * u32 pid, tid;
  346. * u64 addr;
  347. * u64 len;
  348. * u64 pgoff;
  349. * char filename[];
  350. * };
  351. */
  352. PERF_RECORD_MMAP = 1,
  353. /*
  354. * struct {
  355. * struct perf_event_header header;
  356. * u64 id;
  357. * u64 lost;
  358. * };
  359. */
  360. PERF_RECORD_LOST = 2,
  361. /*
  362. * struct {
  363. * struct perf_event_header header;
  364. *
  365. * u32 pid, tid;
  366. * char comm[];
  367. * };
  368. */
  369. PERF_RECORD_COMM = 3,
  370. /*
  371. * struct {
  372. * struct perf_event_header header;
  373. * u32 pid, ppid;
  374. * u32 tid, ptid;
  375. * u64 time;
  376. * };
  377. */
  378. PERF_RECORD_EXIT = 4,
  379. /*
  380. * struct {
  381. * struct perf_event_header header;
  382. * u64 time;
  383. * u64 id;
  384. * u64 stream_id;
  385. * };
  386. */
  387. PERF_RECORD_THROTTLE = 5,
  388. PERF_RECORD_UNTHROTTLE = 6,
  389. /*
  390. * struct {
  391. * struct perf_event_header header;
  392. * u32 pid, ppid;
  393. * u32 tid, ptid;
  394. * u64 time;
  395. * };
  396. */
  397. PERF_RECORD_FORK = 7,
  398. /*
  399. * struct {
  400. * struct perf_event_header header;
  401. * u32 pid, tid;
  402. *
  403. * struct read_format values;
  404. * };
  405. */
  406. PERF_RECORD_READ = 8,
  407. /*
  408. * struct {
  409. * struct perf_event_header header;
  410. *
  411. * { u64 ip; } && PERF_SAMPLE_IP
  412. * { u32 pid, tid; } && PERF_SAMPLE_TID
  413. * { u64 time; } && PERF_SAMPLE_TIME
  414. * { u64 addr; } && PERF_SAMPLE_ADDR
  415. * { u64 id; } && PERF_SAMPLE_ID
  416. * { u64 stream_id;} && PERF_SAMPLE_STREAM_ID
  417. * { u32 cpu, res; } && PERF_SAMPLE_CPU
  418. * { u64 period; } && PERF_SAMPLE_PERIOD
  419. *
  420. * { struct read_format values; } && PERF_SAMPLE_READ
  421. *
  422. * { u64 nr,
  423. * u64 ips[nr]; } && PERF_SAMPLE_CALLCHAIN
  424. *
  425. * #
  426. * # The RAW record below is opaque data wrt the ABI
  427. * #
  428. * # That is, the ABI doesn't make any promises wrt to
  429. * # the stability of its content, it may vary depending
  430. * # on event, hardware, kernel version and phase of
  431. * # the moon.
  432. * #
  433. * # In other words, PERF_SAMPLE_RAW contents are not an ABI.
  434. * #
  435. *
  436. * { u32 size;
  437. * char data[size];}&& PERF_SAMPLE_RAW
  438. *
  439. * { u64 from, to, flags } lbr[nr];} && PERF_SAMPLE_BRANCH_STACK
  440. * };
  441. */
  442. PERF_RECORD_SAMPLE = 9,
  443. PERF_RECORD_MAX, /* non-ABI */
  444. };
  445. enum perf_callchain_context {
  446. PERF_CONTEXT_HV = (__u64)-32,
  447. PERF_CONTEXT_KERNEL = (__u64)-128,
  448. PERF_CONTEXT_USER = (__u64)-512,
  449. PERF_CONTEXT_GUEST = (__u64)-2048,
  450. PERF_CONTEXT_GUEST_KERNEL = (__u64)-2176,
  451. PERF_CONTEXT_GUEST_USER = (__u64)-2560,
  452. PERF_CONTEXT_MAX = (__u64)-4095,
  453. };
  454. #define PERF_FLAG_FD_NO_GROUP (1U << 0)
  455. #define PERF_FLAG_FD_OUTPUT (1U << 1)
  456. #define PERF_FLAG_PID_CGROUP (1U << 2) /* pid=cgroup id, per-cpu mode only */
  457. #ifdef __KERNEL__
  458. /*
  459. * Kernel-internal data types and definitions:
  460. */
  461. #ifdef CONFIG_PERF_EVENTS
  462. # include <linux/cgroup.h>
  463. # include <asm/perf_event.h>
  464. # include <asm/local64.h>
  465. #endif
  466. struct perf_guest_info_callbacks {
  467. int (*is_in_guest)(void);
  468. int (*is_user_mode)(void);
  469. unsigned long (*get_guest_ip)(void);
  470. };
  471. #ifdef CONFIG_HAVE_HW_BREAKPOINT
  472. #include <asm/hw_breakpoint.h>
  473. #endif
  474. #include <linux/list.h>
  475. #include <linux/mutex.h>
  476. #include <linux/rculist.h>
  477. #include <linux/rcupdate.h>
  478. #include <linux/spinlock.h>
  479. #include <linux/hrtimer.h>
  480. #include <linux/fs.h>
  481. #include <linux/pid_namespace.h>
  482. #include <linux/workqueue.h>
  483. #include <linux/ftrace.h>
  484. #include <linux/cpu.h>
  485. #include <linux/irq_work.h>
  486. #include <linux/static_key.h>
  487. #include <linux/atomic.h>
  488. #include <asm/local.h>
  489. #define PERF_MAX_STACK_DEPTH 255
  490. struct perf_callchain_entry {
  491. __u64 nr;
  492. __u64 ip[PERF_MAX_STACK_DEPTH];
  493. };
  494. struct perf_raw_record {
  495. u32 size;
  496. void *data;
  497. };
  498. /*
  499. * single taken branch record layout:
  500. *
  501. * from: source instruction (may not always be a branch insn)
  502. * to: branch target
  503. * mispred: branch target was mispredicted
  504. * predicted: branch target was predicted
  505. *
  506. * support for mispred, predicted is optional. In case it
  507. * is not supported mispred = predicted = 0.
  508. */
  509. struct perf_branch_entry {
  510. __u64 from;
  511. __u64 to;
  512. __u64 mispred:1, /* target mispredicted */
  513. predicted:1,/* target predicted */
  514. reserved:62;
  515. };
  516. /*
  517. * branch stack layout:
  518. * nr: number of taken branches stored in entries[]
  519. *
  520. * Note that nr can vary from sample to sample
  521. * branches (to, from) are stored from most recent
  522. * to least recent, i.e., entries[0] contains the most
  523. * recent branch.
  524. */
  525. struct perf_branch_stack {
  526. __u64 nr;
  527. struct perf_branch_entry entries[0];
  528. };
  529. struct task_struct;
  530. /*
  531. * extra PMU register associated with an event
  532. */
  533. struct hw_perf_event_extra {
  534. u64 config; /* register value */
  535. unsigned int reg; /* register address or index */
  536. int alloc; /* extra register already allocated */
  537. int idx; /* index in shared_regs->regs[] */
  538. };
  539. /**
  540. * struct hw_perf_event - performance event hardware details:
  541. */
  542. struct hw_perf_event {
  543. #ifdef CONFIG_PERF_EVENTS
  544. union {
  545. struct { /* hardware */
  546. u64 config;
  547. u64 last_tag;
  548. unsigned long config_base;
  549. unsigned long event_base;
  550. int idx;
  551. int last_cpu;
  552. struct hw_perf_event_extra extra_reg;
  553. struct hw_perf_event_extra branch_reg;
  554. };
  555. struct { /* software */
  556. struct hrtimer hrtimer;
  557. };
  558. #ifdef CONFIG_HAVE_HW_BREAKPOINT
  559. struct { /* breakpoint */
  560. struct arch_hw_breakpoint info;
  561. struct list_head bp_list;
  562. /*
  563. * Crufty hack to avoid the chicken and egg
  564. * problem hw_breakpoint has with context
  565. * creation and event initalization.
  566. */
  567. struct task_struct *bp_target;
  568. };
  569. #endif
  570. };
  571. int state;
  572. local64_t prev_count;
  573. u64 sample_period;
  574. u64 last_period;
  575. local64_t period_left;
  576. u64 interrupts_seq;
  577. u64 interrupts;
  578. u64 freq_time_stamp;
  579. u64 freq_count_stamp;
  580. #endif
  581. };
  582. /*
  583. * hw_perf_event::state flags
  584. */
  585. #define PERF_HES_STOPPED 0x01 /* the counter is stopped */
  586. #define PERF_HES_UPTODATE 0x02 /* event->count up-to-date */
  587. #define PERF_HES_ARCH 0x04
  588. struct perf_event;
  589. /*
  590. * Common implementation detail of pmu::{start,commit,cancel}_txn
  591. */
  592. #define PERF_EVENT_TXN 0x1
  593. /**
  594. * struct pmu - generic performance monitoring unit
  595. */
  596. struct pmu {
  597. struct list_head entry;
  598. struct device *dev;
  599. const struct attribute_group **attr_groups;
  600. char *name;
  601. int type;
  602. int * __percpu pmu_disable_count;
  603. struct perf_cpu_context * __percpu pmu_cpu_context;
  604. int task_ctx_nr;
  605. /*
  606. * Fully disable/enable this PMU, can be used to protect from the PMI
  607. * as well as for lazy/batch writing of the MSRs.
  608. */
  609. void (*pmu_enable) (struct pmu *pmu); /* optional */
  610. void (*pmu_disable) (struct pmu *pmu); /* optional */
  611. /*
  612. * Try and initialize the event for this PMU.
  613. * Should return -ENOENT when the @event doesn't match this PMU.
  614. */
  615. int (*event_init) (struct perf_event *event);
  616. #define PERF_EF_START 0x01 /* start the counter when adding */
  617. #define PERF_EF_RELOAD 0x02 /* reload the counter when starting */
  618. #define PERF_EF_UPDATE 0x04 /* update the counter when stopping */
  619. /*
  620. * Adds/Removes a counter to/from the PMU, can be done inside
  621. * a transaction, see the ->*_txn() methods.
  622. */
  623. int (*add) (struct perf_event *event, int flags);
  624. void (*del) (struct perf_event *event, int flags);
  625. /*
  626. * Starts/Stops a counter present on the PMU. The PMI handler
  627. * should stop the counter when perf_event_overflow() returns
  628. * !0. ->start() will be used to continue.
  629. */
  630. void (*start) (struct perf_event *event, int flags);
  631. void (*stop) (struct perf_event *event, int flags);
  632. /*
  633. * Updates the counter value of the event.
  634. */
  635. void (*read) (struct perf_event *event);
  636. /*
  637. * Group events scheduling is treated as a transaction, add
  638. * group events as a whole and perform one schedulability test.
  639. * If the test fails, roll back the whole group
  640. *
  641. * Start the transaction, after this ->add() doesn't need to
  642. * do schedulability tests.
  643. */
  644. void (*start_txn) (struct pmu *pmu); /* optional */
  645. /*
  646. * If ->start_txn() disabled the ->add() schedulability test
  647. * then ->commit_txn() is required to perform one. On success
  648. * the transaction is closed. On error the transaction is kept
  649. * open until ->cancel_txn() is called.
  650. */
  651. int (*commit_txn) (struct pmu *pmu); /* optional */
  652. /*
  653. * Will cancel the transaction, assumes ->del() is called
  654. * for each successful ->add() during the transaction.
  655. */
  656. void (*cancel_txn) (struct pmu *pmu); /* optional */
  657. /*
  658. * Will return the value for perf_event_mmap_page::index for this event,
  659. * if no implementation is provided it will default to: event->hw.idx + 1.
  660. */
  661. int (*event_idx) (struct perf_event *event); /*optional */
  662. /*
  663. * flush branch stack on context-switches (needed in cpu-wide mode)
  664. */
  665. void (*flush_branch_stack) (void);
  666. };
  667. /**
  668. * enum perf_event_active_state - the states of a event
  669. */
  670. enum perf_event_active_state {
  671. PERF_EVENT_STATE_ERROR = -2,
  672. PERF_EVENT_STATE_OFF = -1,
  673. PERF_EVENT_STATE_INACTIVE = 0,
  674. PERF_EVENT_STATE_ACTIVE = 1,
  675. };
  676. struct file;
  677. struct perf_sample_data;
  678. typedef void (*perf_overflow_handler_t)(struct perf_event *,
  679. struct perf_sample_data *,
  680. struct pt_regs *regs);
  681. enum perf_group_flag {
  682. PERF_GROUP_SOFTWARE = 0x1,
  683. };
  684. #define SWEVENT_HLIST_BITS 8
  685. #define SWEVENT_HLIST_SIZE (1 << SWEVENT_HLIST_BITS)
  686. struct swevent_hlist {
  687. struct hlist_head heads[SWEVENT_HLIST_SIZE];
  688. struct rcu_head rcu_head;
  689. };
  690. #define PERF_ATTACH_CONTEXT 0x01
  691. #define PERF_ATTACH_GROUP 0x02
  692. #define PERF_ATTACH_TASK 0x04
  693. #ifdef CONFIG_CGROUP_PERF
  694. /*
  695. * perf_cgroup_info keeps track of time_enabled for a cgroup.
  696. * This is a per-cpu dynamically allocated data structure.
  697. */
  698. struct perf_cgroup_info {
  699. u64 time;
  700. u64 timestamp;
  701. };
  702. struct perf_cgroup {
  703. struct cgroup_subsys_state css;
  704. struct perf_cgroup_info *info; /* timing info, one per cpu */
  705. };
  706. #endif
  707. struct ring_buffer;
  708. /**
  709. * struct perf_event - performance event kernel representation:
  710. */
  711. struct perf_event {
  712. #ifdef CONFIG_PERF_EVENTS
  713. struct list_head group_entry;
  714. struct list_head event_entry;
  715. struct list_head sibling_list;
  716. struct hlist_node hlist_entry;
  717. int nr_siblings;
  718. int group_flags;
  719. struct perf_event *group_leader;
  720. struct pmu *pmu;
  721. enum perf_event_active_state state;
  722. unsigned int attach_state;
  723. local64_t count;
  724. atomic64_t child_count;
  725. /*
  726. * These are the total time in nanoseconds that the event
  727. * has been enabled (i.e. eligible to run, and the task has
  728. * been scheduled in, if this is a per-task event)
  729. * and running (scheduled onto the CPU), respectively.
  730. *
  731. * They are computed from tstamp_enabled, tstamp_running and
  732. * tstamp_stopped when the event is in INACTIVE or ACTIVE state.
  733. */
  734. u64 total_time_enabled;
  735. u64 total_time_running;
  736. /*
  737. * These are timestamps used for computing total_time_enabled
  738. * and total_time_running when the event is in INACTIVE or
  739. * ACTIVE state, measured in nanoseconds from an arbitrary point
  740. * in time.
  741. * tstamp_enabled: the notional time when the event was enabled
  742. * tstamp_running: the notional time when the event was scheduled on
  743. * tstamp_stopped: in INACTIVE state, the notional time when the
  744. * event was scheduled off.
  745. */
  746. u64 tstamp_enabled;
  747. u64 tstamp_running;
  748. u64 tstamp_stopped;
  749. /*
  750. * timestamp shadows the actual context timing but it can
  751. * be safely used in NMI interrupt context. It reflects the
  752. * context time as it was when the event was last scheduled in.
  753. *
  754. * ctx_time already accounts for ctx->timestamp. Therefore to
  755. * compute ctx_time for a sample, simply add perf_clock().
  756. */
  757. u64 shadow_ctx_time;
  758. struct perf_event_attr attr;
  759. u16 header_size;
  760. u16 id_header_size;
  761. u16 read_size;
  762. struct hw_perf_event hw;
  763. struct perf_event_context *ctx;
  764. struct file *filp;
  765. /*
  766. * These accumulate total time (in nanoseconds) that children
  767. * events have been enabled and running, respectively.
  768. */
  769. atomic64_t child_total_time_enabled;
  770. atomic64_t child_total_time_running;
  771. /*
  772. * Protect attach/detach and child_list:
  773. */
  774. struct mutex child_mutex;
  775. struct list_head child_list;
  776. struct perf_event *parent;
  777. int oncpu;
  778. int cpu;
  779. struct list_head owner_entry;
  780. struct task_struct *owner;
  781. /* mmap bits */
  782. struct mutex mmap_mutex;
  783. atomic_t mmap_count;
  784. int mmap_locked;
  785. struct user_struct *mmap_user;
  786. struct ring_buffer *rb;
  787. struct list_head rb_entry;
  788. /* poll related */
  789. wait_queue_head_t waitq;
  790. struct fasync_struct *fasync;
  791. /* delayed work for NMIs and such */
  792. int pending_wakeup;
  793. int pending_kill;
  794. int pending_disable;
  795. struct irq_work pending;
  796. atomic_t event_limit;
  797. void (*destroy)(struct perf_event *);
  798. struct rcu_head rcu_head;
  799. struct pid_namespace *ns;
  800. u64 id;
  801. perf_overflow_handler_t overflow_handler;
  802. void *overflow_handler_context;
  803. #ifdef CONFIG_EVENT_TRACING
  804. struct ftrace_event_call *tp_event;
  805. struct event_filter *filter;
  806. #ifdef CONFIG_FUNCTION_TRACER
  807. struct ftrace_ops ftrace_ops;
  808. #endif
  809. #endif
  810. #ifdef CONFIG_CGROUP_PERF
  811. struct perf_cgroup *cgrp; /* cgroup event is attach to */
  812. int cgrp_defer_enabled;
  813. #endif
  814. #endif /* CONFIG_PERF_EVENTS */
  815. };
  816. enum perf_event_context_type {
  817. task_context,
  818. cpu_context,
  819. };
  820. /**
  821. * struct perf_event_context - event context structure
  822. *
  823. * Used as a container for task events and CPU events as well:
  824. */
  825. struct perf_event_context {
  826. struct pmu *pmu;
  827. enum perf_event_context_type type;
  828. /*
  829. * Protect the states of the events in the list,
  830. * nr_active, and the list:
  831. */
  832. raw_spinlock_t lock;
  833. /*
  834. * Protect the list of events. Locking either mutex or lock
  835. * is sufficient to ensure the list doesn't change; to change
  836. * the list you need to lock both the mutex and the spinlock.
  837. */
  838. struct mutex mutex;
  839. struct list_head pinned_groups;
  840. struct list_head flexible_groups;
  841. struct list_head event_list;
  842. int nr_events;
  843. int nr_active;
  844. int is_active;
  845. int nr_stat;
  846. int nr_freq;
  847. int rotate_disable;
  848. atomic_t refcount;
  849. struct task_struct *task;
  850. /*
  851. * Context clock, runs when context enabled.
  852. */
  853. u64 time;
  854. u64 timestamp;
  855. /*
  856. * These fields let us detect when two contexts have both
  857. * been cloned (inherited) from a common ancestor.
  858. */
  859. struct perf_event_context *parent_ctx;
  860. u64 parent_gen;
  861. u64 generation;
  862. int pin_count;
  863. int nr_cgroups; /* cgroup evts */
  864. int nr_branch_stack; /* branch_stack evt */
  865. struct rcu_head rcu_head;
  866. };
  867. /*
  868. * Number of contexts where an event can trigger:
  869. * task, softirq, hardirq, nmi.
  870. */
  871. #define PERF_NR_CONTEXTS 4
  872. /**
  873. * struct perf_event_cpu_context - per cpu event context structure
  874. */
  875. struct perf_cpu_context {
  876. struct perf_event_context ctx;
  877. struct perf_event_context *task_ctx;
  878. int active_oncpu;
  879. int exclusive;
  880. struct list_head rotation_list;
  881. int jiffies_interval;
  882. struct pmu *active_pmu;
  883. struct perf_cgroup *cgrp;
  884. };
  885. struct perf_output_handle {
  886. struct perf_event *event;
  887. struct ring_buffer *rb;
  888. unsigned long wakeup;
  889. unsigned long size;
  890. void *addr;
  891. int page;
  892. };
  893. #ifdef CONFIG_PERF_EVENTS
  894. extern int perf_pmu_register(struct pmu *pmu, char *name, int type);
  895. extern void perf_pmu_unregister(struct pmu *pmu);
  896. extern int perf_num_counters(void);
  897. extern const char *perf_pmu_name(void);
  898. extern void __perf_event_task_sched_in(struct task_struct *prev,
  899. struct task_struct *task);
  900. extern void __perf_event_task_sched_out(struct task_struct *prev,
  901. struct task_struct *next);
  902. extern int perf_event_init_task(struct task_struct *child);
  903. extern void perf_event_exit_task(struct task_struct *child);
  904. extern void perf_event_free_task(struct task_struct *task);
  905. extern void perf_event_delayed_put(struct task_struct *task);
  906. extern void perf_event_print_debug(void);
  907. extern void perf_pmu_disable(struct pmu *pmu);
  908. extern void perf_pmu_enable(struct pmu *pmu);
  909. extern int perf_event_task_disable(void);
  910. extern int perf_event_task_enable(void);
  911. extern int perf_event_refresh(struct perf_event *event, int refresh);
  912. extern void perf_event_update_userpage(struct perf_event *event);
  913. extern int perf_event_release_kernel(struct perf_event *event);
  914. extern struct perf_event *
  915. perf_event_create_kernel_counter(struct perf_event_attr *attr,
  916. int cpu,
  917. struct task_struct *task,
  918. perf_overflow_handler_t callback,
  919. void *context);
  920. extern u64 perf_event_read_value(struct perf_event *event,
  921. u64 *enabled, u64 *running);
  922. struct perf_sample_data {
  923. u64 type;
  924. u64 ip;
  925. struct {
  926. u32 pid;
  927. u32 tid;
  928. } tid_entry;
  929. u64 time;
  930. u64 addr;
  931. u64 id;
  932. u64 stream_id;
  933. struct {
  934. u32 cpu;
  935. u32 reserved;
  936. } cpu_entry;
  937. u64 period;
  938. struct perf_callchain_entry *callchain;
  939. struct perf_raw_record *raw;
  940. struct perf_branch_stack *br_stack;
  941. };
  942. static inline void perf_sample_data_init(struct perf_sample_data *data, u64 addr)
  943. {
  944. data->addr = addr;
  945. data->raw = NULL;
  946. data->br_stack = NULL;
  947. }
  948. extern void perf_output_sample(struct perf_output_handle *handle,
  949. struct perf_event_header *header,
  950. struct perf_sample_data *data,
  951. struct perf_event *event);
  952. extern void perf_prepare_sample(struct perf_event_header *header,
  953. struct perf_sample_data *data,
  954. struct perf_event *event,
  955. struct pt_regs *regs);
  956. extern int perf_event_overflow(struct perf_event *event,
  957. struct perf_sample_data *data,
  958. struct pt_regs *regs);
  959. static inline bool is_sampling_event(struct perf_event *event)
  960. {
  961. return event->attr.sample_period != 0;
  962. }
  963. /*
  964. * Return 1 for a software event, 0 for a hardware event
  965. */
  966. static inline int is_software_event(struct perf_event *event)
  967. {
  968. return event->pmu->task_ctx_nr == perf_sw_context;
  969. }
  970. extern struct static_key perf_swevent_enabled[PERF_COUNT_SW_MAX];
  971. extern void __perf_sw_event(u32, u64, struct pt_regs *, u64);
  972. #ifndef perf_arch_fetch_caller_regs
  973. static inline void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip) { }
  974. #endif
  975. /*
  976. * Take a snapshot of the regs. Skip ip and frame pointer to
  977. * the nth caller. We only need a few of the regs:
  978. * - ip for PERF_SAMPLE_IP
  979. * - cs for user_mode() tests
  980. * - bp for callchains
  981. * - eflags, for future purposes, just in case
  982. */
  983. static inline void perf_fetch_caller_regs(struct pt_regs *regs)
  984. {
  985. memset(regs, 0, sizeof(*regs));
  986. perf_arch_fetch_caller_regs(regs, CALLER_ADDR0);
  987. }
  988. static __always_inline void
  989. perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)
  990. {
  991. struct pt_regs hot_regs;
  992. if (static_key_false(&perf_swevent_enabled[event_id])) {
  993. if (!regs) {
  994. perf_fetch_caller_regs(&hot_regs);
  995. regs = &hot_regs;
  996. }
  997. __perf_sw_event(event_id, nr, regs, addr);
  998. }
  999. }
  1000. extern struct static_key_deferred perf_sched_events;
  1001. static inline void perf_event_task_sched_in(struct task_struct *prev,
  1002. struct task_struct *task)
  1003. {
  1004. if (static_key_false(&perf_sched_events.key))
  1005. __perf_event_task_sched_in(prev, task);
  1006. }
  1007. static inline void perf_event_task_sched_out(struct task_struct *prev,
  1008. struct task_struct *next)
  1009. {
  1010. perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, NULL, 0);
  1011. if (static_key_false(&perf_sched_events.key))
  1012. __perf_event_task_sched_out(prev, next);
  1013. }
  1014. extern void perf_event_mmap(struct vm_area_struct *vma);
  1015. extern struct perf_guest_info_callbacks *perf_guest_cbs;
  1016. extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
  1017. extern int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
  1018. extern void perf_event_comm(struct task_struct *tsk);
  1019. extern void perf_event_fork(struct task_struct *tsk);
  1020. /* Callchains */
  1021. DECLARE_PER_CPU(struct perf_callchain_entry, perf_callchain_entry);
  1022. extern void perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs);
  1023. extern void perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs);
  1024. static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64 ip)
  1025. {
  1026. if (entry->nr < PERF_MAX_STACK_DEPTH)
  1027. entry->ip[entry->nr++] = ip;
  1028. }
  1029. extern int sysctl_perf_event_paranoid;
  1030. extern int sysctl_perf_event_mlock;
  1031. extern int sysctl_perf_event_sample_rate;
  1032. extern int perf_proc_update_handler(struct ctl_table *table, int write,
  1033. void __user *buffer, size_t *lenp,
  1034. loff_t *ppos);
  1035. static inline bool perf_paranoid_tracepoint_raw(void)
  1036. {
  1037. return sysctl_perf_event_paranoid > -1;
  1038. }
  1039. static inline bool perf_paranoid_cpu(void)
  1040. {
  1041. return sysctl_perf_event_paranoid > 0;
  1042. }
  1043. static inline bool perf_paranoid_kernel(void)
  1044. {
  1045. return sysctl_perf_event_paranoid > 1;
  1046. }
  1047. extern void perf_event_init(void);
  1048. extern void perf_tp_event(u64 addr, u64 count, void *record,
  1049. int entry_size, struct pt_regs *regs,
  1050. struct hlist_head *head, int rctx);
  1051. extern void perf_bp_event(struct perf_event *event, void *data);
  1052. #ifndef perf_misc_flags
  1053. # define perf_misc_flags(regs) \
  1054. (user_mode(regs) ? PERF_RECORD_MISC_USER : PERF_RECORD_MISC_KERNEL)
  1055. # define perf_instruction_pointer(regs) instruction_pointer(regs)
  1056. #endif
  1057. static inline bool has_branch_stack(struct perf_event *event)
  1058. {
  1059. return event->attr.sample_type & PERF_SAMPLE_BRANCH_STACK;
  1060. }
  1061. extern int perf_output_begin(struct perf_output_handle *handle,
  1062. struct perf_event *event, unsigned int size);
  1063. extern void perf_output_end(struct perf_output_handle *handle);
  1064. extern void perf_output_copy(struct perf_output_handle *handle,
  1065. const void *buf, unsigned int len);
  1066. extern int perf_swevent_get_recursion_context(void);
  1067. extern void perf_swevent_put_recursion_context(int rctx);
  1068. extern void perf_event_enable(struct perf_event *event);
  1069. extern void perf_event_disable(struct perf_event *event);
  1070. extern void perf_event_task_tick(void);
  1071. #else
  1072. static inline void
  1073. perf_event_task_sched_in(struct task_struct *prev,
  1074. struct task_struct *task) { }
  1075. static inline void
  1076. perf_event_task_sched_out(struct task_struct *prev,
  1077. struct task_struct *next) { }
  1078. static inline int perf_event_init_task(struct task_struct *child) { return 0; }
  1079. static inline void perf_event_exit_task(struct task_struct *child) { }
  1080. static inline void perf_event_free_task(struct task_struct *task) { }
  1081. static inline void perf_event_delayed_put(struct task_struct *task) { }
  1082. static inline void perf_event_print_debug(void) { }
  1083. static inline int perf_event_task_disable(void) { return -EINVAL; }
  1084. static inline int perf_event_task_enable(void) { return -EINVAL; }
  1085. static inline int perf_event_refresh(struct perf_event *event, int refresh)
  1086. {
  1087. return -EINVAL;
  1088. }
  1089. static inline void
  1090. perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr) { }
  1091. static inline void
  1092. perf_bp_event(struct perf_event *event, void *data) { }
  1093. static inline int perf_register_guest_info_callbacks
  1094. (struct perf_guest_info_callbacks *callbacks) { return 0; }
  1095. static inline int perf_unregister_guest_info_callbacks
  1096. (struct perf_guest_info_callbacks *callbacks) { return 0; }
  1097. static inline void perf_event_mmap(struct vm_area_struct *vma) { }
  1098. static inline void perf_event_comm(struct task_struct *tsk) { }
  1099. static inline void perf_event_fork(struct task_struct *tsk) { }
  1100. static inline void perf_event_init(void) { }
  1101. static inline int perf_swevent_get_recursion_context(void) { return -1; }
  1102. static inline void perf_swevent_put_recursion_context(int rctx) { }
  1103. static inline void perf_event_enable(struct perf_event *event) { }
  1104. static inline void perf_event_disable(struct perf_event *event) { }
  1105. static inline void perf_event_task_tick(void) { }
  1106. #endif
  1107. #define perf_output_put(handle, x) perf_output_copy((handle), &(x), sizeof(x))
  1108. /*
  1109. * This has to have a higher priority than migration_notifier in sched.c.
  1110. */
  1111. #define perf_cpu_notifier(fn) \
  1112. do { \
  1113. static struct notifier_block fn##_nb __cpuinitdata = \
  1114. { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
  1115. fn(&fn##_nb, (unsigned long)CPU_UP_PREPARE, \
  1116. (void *)(unsigned long)smp_processor_id()); \
  1117. fn(&fn##_nb, (unsigned long)CPU_STARTING, \
  1118. (void *)(unsigned long)smp_processor_id()); \
  1119. fn(&fn##_nb, (unsigned long)CPU_ONLINE, \
  1120. (void *)(unsigned long)smp_processor_id()); \
  1121. register_cpu_notifier(&fn##_nb); \
  1122. } while (0)
  1123. #endif /* __KERNEL__ */
  1124. #endif /* _LINUX_PERF_EVENT_H */