1 #ifndef _KERNEL_EVENTS_INTERNAL_H
2 #define _KERNEL_EVENTS_INTERNAL_H
4 #include <linux/hardirq.h>
8 #define RING_BUFFER_WRITABLE 0x01
12 struct rcu_head rcu_head
;
13 #ifdef CONFIG_PERF_USE_VMALLOC
14 struct work_struct work
;
15 int page_order
; /* allocation order */
17 int nr_pages
; /* nr of data pages */
18 int writable
; /* are we writable */
20 atomic_t poll
; /* POLL_ for wakeups */
22 local_t head
; /* write position */
23 local_t nest
; /* nested writers */
24 local_t events
; /* event limit */
25 local_t wakeup
; /* wakeup stamp */
26 local_t lost
; /* nr records lost */
28 long watermark
; /* wakeup watermark */
30 spinlock_t event_lock
;
31 struct list_head event_list
;
33 struct perf_event_mmap_page
*user_page
;
37 extern void rb_free(struct ring_buffer
*rb
);
38 extern struct ring_buffer
*
39 rb_alloc(int nr_pages
, long watermark
, int cpu
, int flags
);
40 extern void perf_event_wakeup(struct perf_event
*event
);
43 perf_event_header__init_id(struct perf_event_header
*header
,
44 struct perf_sample_data
*data
,
45 struct perf_event
*event
);
47 perf_event__output_id_sample(struct perf_event
*event
,
48 struct perf_output_handle
*handle
,
49 struct perf_sample_data
*sample
);
52 perf_mmap_to_page(struct ring_buffer
*rb
, unsigned long pgoff
);
54 #ifdef CONFIG_PERF_USE_VMALLOC
56 * Back perf_mmap() with vmalloc memory.
58 * Required for architectures that have d-cache aliasing issues.
61 static inline int page_order(struct ring_buffer
*rb
)
63 return rb
->page_order
;
68 static inline int page_order(struct ring_buffer
*rb
)
74 static inline unsigned long perf_data_size(struct ring_buffer
*rb
)
76 return rb
->nr_pages
<< (PAGE_SHIFT
+ page_order(rb
));
80 __output_copy(struct perf_output_handle
*handle
,
81 const void *buf
, unsigned int len
)
84 unsigned long size
= min_t(unsigned long, handle
->size
, len
);
86 memcpy(handle
->addr
, buf
, size
);
93 struct ring_buffer
*rb
= handle
->rb
;
96 handle
->page
&= rb
->nr_pages
- 1;
97 handle
->addr
= rb
->data_pages
[handle
->page
];
98 handle
->size
= PAGE_SIZE
<< page_order(rb
);
103 /* Callchain handling */
104 extern struct perf_callchain_entry
*perf_callchain(struct pt_regs
*regs
);
105 extern int get_callchain_buffers(void);
106 extern void put_callchain_buffers(void);
108 static inline int get_recursion_context(int *recursion
)
116 else if (in_softirq())
130 static inline void put_recursion_context(int *recursion
, int rctx
)
136 #endif /* _KERNEL_EVENTS_INTERNAL_H */