Re: [PATCH v2 03/13] btrace, linux: add perf event buffer abstraction

Pedro Alves
2015-01-27T11:17:40Z

On 11/20/2014 10:47 AM, Markus Metzger wrote:

> - volatile struct perf_event_mmap_page *header;
> + struct perf_event_buffer *pevent;
> const uint8_t *begin, *end, *start;
> - unsigned long data_head, data_tail, retries = 5;
> - size_t buffer_size, size;
> + unsigned long long data_head, data_tail, buffer_size, size;
> + size_t retries = 5;

I notice that this is changing types from long to long long.
Also, a bit odd that retries is now size_t, given it's just a counter.

> +#if HAVE_LINUX_PERF_EVENT_H
> +/* A Linux perf event buffer. */
> +struct perf_event_buffer
> +{
> + /* The mapped memory. */
> + const uint8_t *mem;
> +
> + /* The size of the mapped memory in bytes. */
> + unsigned long long size;
> +
> + /* A pointer to the data_head field for this buffer. */
> + volatile unsigned long long *data_head;
> +
> + /* The data_head value from the last read. */
> + unsigned long long last_head;
> +};

Isn't there a better type to use here instead of "long long"?
Why not size_t, if a host buffer size; uint64_t, if it's a fixed
buffer format, assuming 64-bit here; or ULONGEST, the widest
integer we support?

> +#endif /* HAVE_LINUX_PERF_EVENT_H */

Thanks,
Pedro Alves