Commit 610fbc01 authored by Alexey Bayduraev's avatar Alexey Bayduraev Committed by Arnaldo Carvalho de Melo
Browse files

perf record: Introduce data transferred and compressed stats



Introduce bytes_transferred and bytes_compressed stats so they
would capture statistics for the related data buffer transfers.

Reviewed-by: default avatarRiccardo Mancini <rickyman7@gmail.com>
Signed-off-by: default avatarAlexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Tested-by: default avatarJiri Olsa <jolsa@kernel.org>
Tested-by: default avatarRiccardo Mancini <rickyman7@gmail.com>
Acked-by: default avatarAndi Kleen <ak@linux.intel.com>
Acked-by: default avatarNamhyung Kim <namhyung@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/b5d598034c507dfb7544d2125500280b7d434764.1642440724.git.alexey.v.bayduraev@linux.intel.com


[ Use PRiu64 to print u64 values, fixing the build on 32-bit architectures ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 75f5f1fc
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -111,6 +111,8 @@ struct record_thread {
	unsigned long long	samples;
	unsigned long		waking;
	u64			bytes_written;
	u64			bytes_transferred;
	u64			bytes_compressed;
};

static __thread struct record_thread *thread;
@@ -1407,8 +1409,13 @@ static size_t zstd_compress(struct perf_session *session, struct mmap *map,
	compressed = zstd_compress_stream_to_records(zstd_data, dst, dst_size, src, src_size,
						     max_record_size, process_comp_header);

	if (map && map->file) {
		thread->bytes_transferred += src_size;
		thread->bytes_compressed  += compressed;
	} else {
		session->bytes_transferred += src_size;
		session->bytes_compressed  += compressed;
	}

	return compressed;
}
@@ -2098,8 +2105,20 @@ static int record__stop_threads(struct record *rec)
	for (t = 1; t < rec->nr_threads; t++)
		record__terminate_thread(&thread_data[t]);

	for (t = 0; t < rec->nr_threads; t++)
	for (t = 0; t < rec->nr_threads; t++) {
		rec->samples += thread_data[t].samples;
		if (!record__threads_enabled(rec))
			continue;
		rec->session->bytes_transferred += thread_data[t].bytes_transferred;
		rec->session->bytes_compressed += thread_data[t].bytes_compressed;
		pr_debug("threads[%d]: samples=%lld, wakes=%ld, ", thread_data[t].tid,
			 thread_data[t].samples, thread_data[t].waking);
		if (thread_data[t].bytes_transferred && thread_data[t].bytes_compressed)
			pr_debug("transferred=%" PRIu64 ", compressed=%" PRIu64 "\n",
				 thread_data[t].bytes_transferred, thread_data[t].bytes_compressed);
		else
			pr_debug("written=%" PRIu64 "\n", thread_data[t].bytes_written);
	}

	return 0;
}