Introduce decompressor to trace reader object so that decompression
could be executed on per trace file basis separately for every
trace file located in trace directory.
Signed-off-by: Alexey Budankov <[email protected]>
---
tools/perf/util/session.c | 4 +++-
tools/perf/util/session.h | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 911b2dbcd0ac..6afc670fdf0c 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -44,6 +44,8 @@ static int perf_session__process_compressed_event(struct perf_session *session,
u64 decomp_last_rem = 0;
size_t mmap_len, decomp_len = session->header.env.comp_mmap_len;
struct decomp *decomp, *decomp_last = session->decomp_last;
+ struct zstd_data *zstd_data = session->reader ?
+ &(session->reader->zstd_data) : &(session->zstd_data);
if (decomp_last) {
decomp_last_rem = decomp_last->size - decomp_last->head;
@@ -71,7 +73,7 @@ static int perf_session__process_compressed_event(struct perf_session *session,
src = (void *)event + sizeof(struct perf_record_compressed);
src_size = event->pack.header.size - sizeof(struct perf_record_compressed);
- decomp_size = zstd_decompress_stream(&(session->zstd_data), src, src_size,
+ decomp_size = zstd_decompress_stream(zstd_data, src, src_size,
&(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem);
if (!decomp_size) {
munmap(decomp, mmap_len);
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index abdb8518a81f..4fc9ccdf7970 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -42,6 +42,7 @@ struct reader {
u64 data_size;
u64 data_offset;
reader_cb_t process;
+ struct zstd_data zstd_data;
};
struct perf_session {
--
2.24.1
On Thu, Oct 22, 2020 at 1:00 AM Alexey Budankov
<[email protected]> wrote:
>
>
> Introduce decompressor to trace reader object so that decompression
> could be executed on per trace file basis separately for every
> trace file located in trace directory.
I'm slightly uncomfortable with the word 'trace' here as it's
used for other cases like perf trace and ftrace. Maybe we can
change it to 'profile' and/or 'data file'?
Thanks
Namhyung
>
> Signed-off-by: Alexey Budankov <[email protected]>
> ---
> tools/perf/util/session.c | 4 +++-
> tools/perf/util/session.h | 1 +
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 911b2dbcd0ac..6afc670fdf0c 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -44,6 +44,8 @@ static int perf_session__process_compressed_event(struct perf_session *session,
> u64 decomp_last_rem = 0;
> size_t mmap_len, decomp_len = session->header.env.comp_mmap_len;
> struct decomp *decomp, *decomp_last = session->decomp_last;
> + struct zstd_data *zstd_data = session->reader ?
> + &(session->reader->zstd_data) : &(session->zstd_data);
>
> if (decomp_last) {
> decomp_last_rem = decomp_last->size - decomp_last->head;
> @@ -71,7 +73,7 @@ static int perf_session__process_compressed_event(struct perf_session *session,
> src = (void *)event + sizeof(struct perf_record_compressed);
> src_size = event->pack.header.size - sizeof(struct perf_record_compressed);
>
> - decomp_size = zstd_decompress_stream(&(session->zstd_data), src, src_size,
> + decomp_size = zstd_decompress_stream(zstd_data, src, src_size,
> &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem);
> if (!decomp_size) {
> munmap(decomp, mmap_len);
> diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
> index abdb8518a81f..4fc9ccdf7970 100644
> --- a/tools/perf/util/session.h
> +++ b/tools/perf/util/session.h
> @@ -42,6 +42,7 @@ struct reader {
> u64 data_size;
> u64 data_offset;
> reader_cb_t process;
> + struct zstd_data zstd_data;
> };
>
> struct perf_session {
> --
> 2.24.1
>
>
On 22.10.2020 7:36, Namhyung Kim wrote:
> On Thu, Oct 22, 2020 at 1:00 AM Alexey Budankov
> <[email protected]> wrote:
>>
>>
>> Introduce decompressor to trace reader object so that decompression
>> could be executed on per trace file basis separately for every
>> trace file located in trace directory.
>
> I'm slightly uncomfortable with the word 'trace' here as it's
> used for other cases like perf trace and ftrace. Maybe we can
> change it to 'profile' and/or 'data file'?
Let's use "data file" and "data directory" terms then.
Thanks,
Alexei
On Wed, Oct 21, 2020 at 07:00:30PM +0300, Alexey Budankov wrote:
>
> Introduce decompressor to trace reader object so that decompression
> could be executed on per trace file basis separately for every
> trace file located in trace directory.
>
> Signed-off-by: Alexey Budankov <[email protected]>
> ---
> tools/perf/util/session.c | 4 +++-
> tools/perf/util/session.h | 1 +
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 911b2dbcd0ac..6afc670fdf0c 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -44,6 +44,8 @@ static int perf_session__process_compressed_event(struct perf_session *session,
> u64 decomp_last_rem = 0;
> size_t mmap_len, decomp_len = session->header.env.comp_mmap_len;
> struct decomp *decomp, *decomp_last = session->decomp_last;
> + struct zstd_data *zstd_data = session->reader ?
> + &(session->reader->zstd_data) : &(session->zstd_data);
I don't think we're using braces in these cases, they are not necessary
jirka
>
> if (decomp_last) {
> decomp_last_rem = decomp_last->size - decomp_last->head;
> @@ -71,7 +73,7 @@ static int perf_session__process_compressed_event(struct perf_session *session,
> src = (void *)event + sizeof(struct perf_record_compressed);
> src_size = event->pack.header.size - sizeof(struct perf_record_compressed);
>
> - decomp_size = zstd_decompress_stream(&(session->zstd_data), src, src_size,
> + decomp_size = zstd_decompress_stream(zstd_data, src, src_size,
> &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem);
> if (!decomp_size) {
> munmap(decomp, mmap_len);
> diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
> index abdb8518a81f..4fc9ccdf7970 100644
> --- a/tools/perf/util/session.h
> +++ b/tools/perf/util/session.h
> @@ -42,6 +42,7 @@ struct reader {
> u64 data_size;
> u64 data_offset;
> reader_cb_t process;
> + struct zstd_data zstd_data;
> };
>
> struct perf_session {
> --
> 2.24.1
>
>
On 24.10.2020 18:44, Jiri Olsa wrote:
> On Wed, Oct 21, 2020 at 07:00:30PM +0300, Alexey Budankov wrote:
>>
>> Introduce decompressor to trace reader object so that decompression
>> could be executed on per trace file basis separately for every
>> trace file located in trace directory.
>>
>> Signed-off-by: Alexey Budankov <[email protected]>
>> ---
>> tools/perf/util/session.c | 4 +++-
>> tools/perf/util/session.h | 1 +
>> 2 files changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
>> index 911b2dbcd0ac..6afc670fdf0c 100644
>> --- a/tools/perf/util/session.c
>> +++ b/tools/perf/util/session.c
>> @@ -44,6 +44,8 @@ static int perf_session__process_compressed_event(struct perf_session *session,
>> u64 decomp_last_rem = 0;
>> size_t mmap_len, decomp_len = session->header.env.comp_mmap_len;
>> struct decomp *decomp, *decomp_last = session->decomp_last;
>> + struct zstd_data *zstd_data = session->reader ?
>> + &(session->reader->zstd_data) : &(session->zstd_data);
>
> I don't think we're using braces in these cases, they are not necessary
Corrected in v3.
Thanks,
Alexei
>
> jirka
>
>>
>> if (decomp_last) {
>> decomp_last_rem = decomp_last->size - decomp_last->head;
>> @@ -71,7 +73,7 @@ static int perf_session__process_compressed_event(struct perf_session *session,
>> src = (void *)event + sizeof(struct perf_record_compressed);
>> src_size = event->pack.header.size - sizeof(struct perf_record_compressed);
>>
>> - decomp_size = zstd_decompress_stream(&(session->zstd_data), src, src_size,
>> + decomp_size = zstd_decompress_stream(zstd_data, src, src_size,
>> &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem);
>> if (!decomp_size) {
>> munmap(decomp, mmap_len);
>> diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
>> index abdb8518a81f..4fc9ccdf7970 100644
>> --- a/tools/perf/util/session.h
>> +++ b/tools/perf/util/session.h
>> @@ -42,6 +42,7 @@ struct reader {
>> u64 data_size;
>> u64 data_offset;
>> reader_cb_t process;
>> + struct zstd_data zstd_data;
>> };
>>
>> struct perf_session {
>> --
>> 2.24.1
>>
>>
>