perf auxtrace: Allow buffers to be mapped read / write
To support in-place update, allow buffers to be mapped read / write. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Reviewed-by: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: https://lore.kernel.org/r/20210430070309.17624-7-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
83d7f5f1ad
commit
6aa3afc9c8
@ -1120,8 +1120,9 @@ int auxtrace_queue_data(struct perf_session *session, bool samples, bool events)
|
||||
auxtrace_queue_data_cb, &qd);
|
||||
}
|
||||
|
||||
void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd)
|
||||
void *auxtrace_buffer__get_data_rw(struct auxtrace_buffer *buffer, int fd, bool rw)
|
||||
{
|
||||
int prot = rw ? PROT_READ | PROT_WRITE : PROT_READ;
|
||||
size_t adj = buffer->data_offset & (page_size - 1);
|
||||
size_t size = buffer->size + adj;
|
||||
off_t file_offset = buffer->data_offset - adj;
|
||||
@ -1130,7 +1131,7 @@ void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd)
|
||||
if (buffer->data)
|
||||
return buffer->data;
|
||||
|
||||
addr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, file_offset);
|
||||
addr = mmap(NULL, size, prot, MAP_SHARED, fd, file_offset);
|
||||
if (addr == MAP_FAILED)
|
||||
return NULL;
|
||||
|
||||
|
@ -533,7 +533,11 @@ int auxtrace_queue_data(struct perf_session *session, bool samples,
|
||||
bool events);
|
||||
struct auxtrace_buffer *auxtrace_buffer__next(struct auxtrace_queue *queue,
|
||||
struct auxtrace_buffer *buffer);
|
||||
void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd);
|
||||
void *auxtrace_buffer__get_data_rw(struct auxtrace_buffer *buffer, int fd, bool rw);
|
||||
static inline void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd)
|
||||
{
|
||||
return auxtrace_buffer__get_data_rw(buffer, fd, false);
|
||||
}
|
||||
void auxtrace_buffer__put_data(struct auxtrace_buffer *buffer);
|
||||
void auxtrace_buffer__drop_data(struct auxtrace_buffer *buffer);
|
||||
void auxtrace_buffer__free(struct auxtrace_buffer *buffer);
|
||||
|
Loading…
Reference in New Issue
Block a user