mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
coresight: tmc-etr: Fix updating buffer in not-snapshot mode.
TMC etr always copies all available data to perf aux buffer, which may exceed the available space in perf aux buffer. It isn't suitable for not-snapshot mode, because: 1) It may overwrite previously written data. 2) It may make the perf_event_mmap_page->aux_head report having more or less data than the reality. So change to only copy the latest data fitting the available space in perf aux buffer. Signed-off-by: Yabin Cui <yabinc@google.com> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Link: https://lore.kernel.org/r/20190829202842.580-14-mathieu.poirier@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
89e89b05ef
commit
13af88f312
1 changed files with 11 additions and 7 deletions
|
@ -1414,9 +1414,10 @@ free_etr_perf_buffer:
|
||||||
* tmc_etr_sync_perf_buffer: Copy the actual trace data from the hardware
|
* tmc_etr_sync_perf_buffer: Copy the actual trace data from the hardware
|
||||||
* buffer to the perf ring buffer.
|
* buffer to the perf ring buffer.
|
||||||
*/
|
*/
|
||||||
static void tmc_etr_sync_perf_buffer(struct etr_perf_buffer *etr_perf)
|
static void tmc_etr_sync_perf_buffer(struct etr_perf_buffer *etr_perf,
|
||||||
|
unsigned long to_copy)
|
||||||
{
|
{
|
||||||
long bytes, to_copy;
|
long bytes;
|
||||||
long pg_idx, pg_offset, src_offset;
|
long pg_idx, pg_offset, src_offset;
|
||||||
unsigned long head = etr_perf->head;
|
unsigned long head = etr_perf->head;
|
||||||
char **dst_pages, *src_buf;
|
char **dst_pages, *src_buf;
|
||||||
|
@ -1426,8 +1427,7 @@ static void tmc_etr_sync_perf_buffer(struct etr_perf_buffer *etr_perf)
|
||||||
pg_idx = head >> PAGE_SHIFT;
|
pg_idx = head >> PAGE_SHIFT;
|
||||||
pg_offset = head & (PAGE_SIZE - 1);
|
pg_offset = head & (PAGE_SIZE - 1);
|
||||||
dst_pages = (char **)etr_perf->pages;
|
dst_pages = (char **)etr_perf->pages;
|
||||||
src_offset = etr_buf->offset;
|
src_offset = etr_buf->offset + etr_buf->len - to_copy;
|
||||||
to_copy = etr_buf->len;
|
|
||||||
|
|
||||||
while (to_copy > 0) {
|
while (to_copy > 0) {
|
||||||
/*
|
/*
|
||||||
|
@ -1438,6 +1438,8 @@ static void tmc_etr_sync_perf_buffer(struct etr_perf_buffer *etr_perf)
|
||||||
* 3) what is available in the destination page.
|
* 3) what is available in the destination page.
|
||||||
* in one iteration.
|
* in one iteration.
|
||||||
*/
|
*/
|
||||||
|
if (src_offset >= etr_buf->size)
|
||||||
|
src_offset -= etr_buf->size;
|
||||||
bytes = tmc_etr_buf_get_data(etr_buf, src_offset, to_copy,
|
bytes = tmc_etr_buf_get_data(etr_buf, src_offset, to_copy,
|
||||||
&src_buf);
|
&src_buf);
|
||||||
if (WARN_ON_ONCE(bytes <= 0))
|
if (WARN_ON_ONCE(bytes <= 0))
|
||||||
|
@ -1458,8 +1460,6 @@ static void tmc_etr_sync_perf_buffer(struct etr_perf_buffer *etr_perf)
|
||||||
|
|
||||||
/* Move source pointers */
|
/* Move source pointers */
|
||||||
src_offset += bytes;
|
src_offset += bytes;
|
||||||
if (src_offset >= etr_buf->size)
|
|
||||||
src_offset -= etr_buf->size;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1505,7 +1505,11 @@ tmc_update_etr_buffer(struct coresight_device *csdev,
|
||||||
spin_unlock_irqrestore(&drvdata->spinlock, flags);
|
spin_unlock_irqrestore(&drvdata->spinlock, flags);
|
||||||
|
|
||||||
size = etr_buf->len;
|
size = etr_buf->len;
|
||||||
tmc_etr_sync_perf_buffer(etr_perf);
|
if (!etr_perf->snapshot && size > handle->size) {
|
||||||
|
size = handle->size;
|
||||||
|
lost = true;
|
||||||
|
}
|
||||||
|
tmc_etr_sync_perf_buffer(etr_perf, size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In snapshot mode we simply increment the head by the number of byte
|
* In snapshot mode we simply increment the head by the number of byte
|
||||||
|
|
Loading…
Add table
Reference in a new issue