public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: jsun4 <jiwei.sun@windriver.com>,
	acme@redhat.com, arnaldo.melo@gmail.com,
	linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com,
	mpetlan@redhat.com, namhyung@kernel.org, a.p.zijlstra@chello.nl,
	adrian.hunter@intel.com, Richard.Danter@windriver.com,
	jiwei.sun.bj@qq.com
Subject: Re: [PATCH v5] perf record: Add support for limit perf output file size
Date: Thu, 7 Nov 2019 08:13:56 -0300	[thread overview]
Message-ID: <20191107111356.GA23651@kernel.org> (raw)
In-Reply-To: <20191101081300.GA2172@krava>

Em Fri, Nov 01, 2019 at 09:13:00AM +0100, Jiri Olsa escreveu:
> On Tue, Oct 22, 2019 at 04:09:01PM +0800, jsun4 wrote:
> > The patch adds a new option to limit the output file size, then based
> > on it, we can create a wrapper of the perf command that uses the option
> > to avoid exhausting the disk space by the unconscious user.
> > 
> > In order to make the perf.data parsable, we just limit the sample data
> > size, since the perf.data consists of many headers and sample data and
> > other data, the actual size of the recorded file will bigger than the
> > setting value.
> > 
> > Testing it:
> > 
> >  # ./perf record -a -g --max-size=10M
> >  Couldn't synthesize bpf events.
> >  [ perf record: perf size limit reached (10249 KB), stopping session ]
> >  [ perf record: Woken up 32 times to write data ]
> >  [ perf record: Captured and wrote 10.133 MB perf.data (71964 samples) ]
> > 
> >  # ls -lh perf.data
> >  -rw------- 1 root root 11M Oct 22 14:32 perf.data
> > 
> >  # ./perf record -a -g --max-size=10K
> >  [ perf record: perf size limit reached (10 KB), stopping session ]
> >  Couldn't synthesize bpf events.
> >  [ perf record: Woken up 0 times to write data ]
> >  [ perf record: Captured and wrote 1.546 MB perf.data (69 samples) ]
> > 
> >  # ls -l perf.data
> >  -rw------- 1 root root 1626952 Oct 22 14:36 perf.data
> > 
> > Signed-off-by: Jiwei Sun <jiwei.sun@windriver.com>
> > ---
> > v5 changes:
> >   - Change the output format like [ perf record: perf size limit XX ]
> >   - change the killing perf way from "raise(SIGTERM)" to set "done == 1"
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>

So, had to add this on top to fix the build on multiple building
environments, rec->bytes_written is an u64, so we must use PRIu64 or
else get errors like:

  builtin-record.c: In function 'record__write':
  builtin-record.c:150:5: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'u64' [-Werror=format=]
       rec->bytes_written >> 10);
       ^
    CC       /tmp/build/pe


- Arnaldo

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index b9ddfcda9611..b95c000c1ed9 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -145,7 +145,7 @@ static int record__write(struct record *rec, struct mmap *map __maybe_unused,
 	rec->bytes_written += size;
 
 	if (record__output_max_size_exceeded(rec) && !done) {
-		fprintf(stderr, "[ perf record: perf size limit reached (%lu KB),"
+		fprintf(stderr, "[ perf record: perf size limit reached (%" PRIu64 " KB),"
 				" stopping session ]\n",
 				rec->bytes_written >> 10);
 		done = 1;

  parent reply	other threads:[~2019-11-07 11:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-22  8:09 [PATCH v5] perf record: Add support for limit perf output file size jsun4
2019-11-01  2:47 ` Jiwei Sun
2019-11-01  8:13 ` Jiri Olsa
2019-11-06 18:58   ` Arnaldo Carvalho de Melo
2019-11-07 11:13   ` Arnaldo Carvalho de Melo [this message]
2019-11-08  1:39     ` Jiwei Sun
2019-11-12 11:17 ` [tip: perf/core] " tip-bot2 for Jiwei Sun

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=20191107111356.GA23651@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=Richard.Danter@windriver.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jiwei.sun.bj@qq.com \
    --cc=jiwei.sun@windriver.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpetlan@redhat.com \
    --cc=namhyung@kernel.org \
    /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