1 #ifndef _KERNEL_EVENTS_INTERNAL_H
2 #define _KERNEL_EVENTS_INTERNAL_H
4 #define RING_BUFFER_WRITABLE 0x01
8 struct rcu_head rcu_head
;
9 #ifdef CONFIG_PERF_USE_VMALLOC
10 struct work_struct work
;
11 int page_order
; /* allocation order */
13 int nr_pages
; /* nr of data pages */
14 int writable
; /* are we writable */
16 atomic_t poll
; /* POLL_ for wakeups */
18 local_t head
; /* write position */
19 local_t nest
; /* nested writers */
20 local_t events
; /* event limit */
21 local_t wakeup
; /* wakeup stamp */
22 local_t lost
; /* nr records lost */
24 long watermark
; /* wakeup watermark */
26 spinlock_t event_lock
;
27 struct list_head event_list
;
29 struct perf_event_mmap_page
*user_page
;
33 extern void rb_free(struct ring_buffer
*rb
);
34 extern struct ring_buffer
*
35 rb_alloc(int nr_pages
, long watermark
, int cpu
, int flags
);
36 extern void perf_event_wakeup(struct perf_event
*event
);
39 perf_event_header__init_id(struct perf_event_header
*header
,
40 struct perf_sample_data
*data
,
41 struct perf_event
*event
);
43 perf_event__output_id_sample(struct perf_event
*event
,
44 struct perf_output_handle
*handle
,
45 struct perf_sample_data
*sample
);
48 perf_mmap_to_page(struct ring_buffer
*rb
, unsigned long pgoff
);
50 #ifdef CONFIG_PERF_USE_VMALLOC
52 * Back perf_mmap() with vmalloc memory.
54 * Required for architectures that have d-cache aliasing issues.
57 static inline int page_order(struct ring_buffer
*rb
)
59 return rb
->page_order
;
64 static inline int page_order(struct ring_buffer
*rb
)
70 static unsigned long perf_data_size(struct ring_buffer
*rb
)
72 return rb
->nr_pages
<< (PAGE_SHIFT
+ page_order(rb
));
76 __output_copy(struct perf_output_handle
*handle
,
77 const void *buf
, unsigned int len
)
80 unsigned long size
= min_t(unsigned long, handle
->size
, len
);
82 memcpy(handle
->addr
, buf
, size
);
89 struct ring_buffer
*rb
= handle
->rb
;
92 handle
->page
&= rb
->nr_pages
- 1;
93 handle
->addr
= rb
->data_pages
[handle
->page
];
94 handle
->size
= PAGE_SIZE
<< page_order(rb
);
99 #endif /* _KERNEL_EVENTS_INTERNAL_H */