public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Andi Kleen <ak@linux.intel.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Alexander Antonov <alexander.antonov@linux.intel.com>,
	Alexei Budankov <abudankov@huawei.com>,
	Riccardo Mancini <rickyman7@gmail.com>
Subject: Re: [PATCH v12 09/16] perf record: Introduce bytes written stats
Date: Sun, 5 Dec 2021 16:14:49 +0100	[thread overview]
Message-ID: <YazXabglLVSvO5V4@krava> (raw)
In-Reply-To: <b235542dee6bfaa8966dabf124ec4b7c0b2dc9f9.1637675515.git.alexey.v.bayduraev@linux.intel.com>

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@kernel.org>
> Reviewed-by: Riccardo Mancini <rickyman7@gmail.com>
> Tested-by: Riccardo Mancini <rickyman7@gmail.com>
> Signed-off-by: Alexey Bayduraev <alexey.v.bayduraev@linux.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
> 


  reply	other threads:[~2021-12-05 15:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-23 14:07 [PATCH v12 00/16] Introduce threaded trace streaming for basic perf record operation Alexey Bayduraev
2021-11-23 14:07 ` [PATCH v12 01/16] perf record: Introduce thread affinity and mmap masks Alexey Bayduraev
2021-12-05 15:13   ` Jiri Olsa
2021-12-20 10:37     ` Bayduraev, Alexey V
2021-11-23 14:07 ` [PATCH v12 02/16] tools lib: Introduce fdarray duplicate function Alexey Bayduraev
2021-11-23 14:07 ` [PATCH v12 03/16] perf record: Introduce thread specific data array Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 04/16] perf record: Introduce function to propagate control commands Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 05/16] perf record: Introduce thread local variable Alexey Bayduraev
2021-12-05 15:14   ` Jiri Olsa
2021-12-20  9:49     ` Bayduraev, Alexey V
2021-11-23 14:08 ` [PATCH v12 06/16] perf record: Stop threads in the end of trace streaming Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 07/16] perf record: Start threads in the beginning " Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 08/16] perf record: Introduce data file at mmap buffer object Alexey Bayduraev
2021-12-05 15:14   ` Jiri Olsa
2021-11-23 14:08 ` [PATCH v12 09/16] perf record: Introduce bytes written stats Alexey Bayduraev
2021-12-05 15:14   ` Jiri Olsa [this message]
2021-12-06 11:22     ` Bayduraev, Alexey V
2021-11-23 14:08 ` [PATCH v12 10/16] perf record: Introduce compressor at mmap buffer object Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 11/16] perf record: Introduce data transferred and compressed stats Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 12/16] perf record: Introduce --threads command line option Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 13/16] perf record: Extend " Alexey Bayduraev
2021-12-05 15:13   ` Jiri Olsa
2021-12-05 15:14   ` Jiri Olsa
2021-12-05 15:14   ` Jiri Olsa
2021-12-05 15:14   ` Jiri Olsa
2021-11-23 14:08 ` [PATCH v12 14/16] perf record: Implement compatibility checks Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 15/16] perf session: Load data directory files for analysis Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 16/16] perf report: Output data file name in raw trace dump Alexey Bayduraev
2021-12-05 15:15 ` [PATCH v12 00/16] Introduce threaded trace streaming for basic perf record operation Jiri Olsa
2021-12-09 17:56   ` Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YazXabglLVSvO5V4@krava \
    --to=jolsa@redhat.com \
    --cc=abudankov@huawei.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.antonov@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexey.v.bayduraev@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rickyman7@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox