This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2 03/13] btrace, linux: add perf event buffer abstraction
- From: Pedro Alves <palves at redhat dot com>
- To: Markus Metzger <markus dot t dot metzger at intel dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 27 Jan 2015 11:17:34 +0000
- Subject: Re: [PATCH v2 03/13] btrace, linux: add perf event buffer abstraction
- Authentication-results: sourceware.org; auth=none
- References: <1416480444-9943-1-git-send-email-markus dot t dot metzger at intel dot com> <1416480444-9943-4-git-send-email-markus dot t dot metzger at intel dot com>
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