[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YazXabglLVSvO5V4@krava>
Date: Sun, 5 Dec 2021 16:14:49 +0100
From: Jiri Olsa <jolsa@...hat.com>
To: Alexey Bayduraev <alexey.v.bayduraev@...ux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
linux-kernel <linux-kernel@...r.kernel.org>,
Andi Kleen <ak@...ux.intel.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Alexander Antonov <alexander.antonov@...ux.intel.com>,
Alexei Budankov <abudankov@...wei.com>,
Riccardo Mancini <rickyman7@...il.com>
Subject: Re: [PATCH v12 09/16] perf record: Introduce bytes written stats
On Tue, Nov 23, 2021 at 05:08:05PM +0300, Alexey Bayduraev wrote:
> Introduce a function to calculate the total amount of data written
> and use it to support the --max-size option.
>
> Acked-by: Namhyung Kim <namhyung@...nel.org>
> Reviewed-by: Riccardo Mancini <rickyman7@...il.com>
> Tested-by: Riccardo Mancini <rickyman7@...il.com>
> Signed-off-by: Alexey Bayduraev <alexey.v.bayduraev@...ux.intel.com>
> ---
> tools/perf/builtin-record.c | 21 ++++++++++++++++++---
> 1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index ce660691df1d..cd4f74c311e8 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -108,6 +108,7 @@ struct record_thread {
> struct record *rec;
> unsigned long long samples;
> unsigned long waking;
> + u64 bytes_written;
> };
>
> static __thread struct record_thread *thread;
> @@ -191,10 +192,22 @@ static bool switch_output_time(struct record *rec)
> trigger_is_ready(&switch_output_trigger);
> }
>
> +static u64 record__bytes_written(struct record *rec)
> +{
> + int t;
> + u64 bytes_written = rec->bytes_written;
> + struct record_thread *thread_data = rec->thread_data;
> +
> + for (t = 0; t < rec->nr_threads; t++)
> + bytes_written += thread_data[t].bytes_written;
> +
> + return bytes_written;
> +}
> +
> static bool record__output_max_size_exceeded(struct record *rec)
> {
> return rec->output_max_size &&
> - (rec->bytes_written >= rec->output_max_size);
> + (record__bytes_written(rec) >= rec->output_max_size);
> }
>
> static int record__write(struct record *rec, struct mmap *map __maybe_unused,
> @@ -210,13 +223,15 @@ static int record__write(struct record *rec, struct mmap *map __maybe_unused,
> return -1;
> }
>
> - if (!(map && map->file))
> + if (map && map->file)
> + thread->bytes_written += size;
> + else
> rec->bytes_written += size;
ok, that's why ;-) do we actually stil need rec->bytes_written?
can't we count that under synthesizing main thread->bytes_written?
jirka
>
> if (record__output_max_size_exceeded(rec) && !done) {
> fprintf(stderr, "[ perf record: perf size limit reached (%" PRIu64 " KB),"
> " stopping session ]\n",
> - rec->bytes_written >> 10);
> + record__bytes_written(rec) >> 10);
> done = 1;
> }
>
> --
> 2.19.0
>
Powered by blists - more mailing lists