All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Thomas Richter <tmricht@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	brueckner@linux.vnet.ibm.com, schwidefsky@de.ibm.com,
	heiko.carstens@de.ibm.com, jolsa@redhat.com
Subject: Re: [PATCH] perf/report: Report OOM in perf report status line
Date: Fri, 26 Apr 2019 11:16:07 -0300	[thread overview]
Message-ID: <20190426141607.GB23426@kernel.org> (raw)
In-Reply-To: <20190426141032.GA23426@kernel.org>

Em Fri, Apr 26, 2019 at 11:10:32AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Apr 26, 2019 at 11:09:07AM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Tue, Apr 23, 2019 at 12:53:03PM +0200, Thomas Richter escreveu:
> > > An -ENOMEM error is not reported in the GTK GUI.
> > > Instead this error message pops up on the screen:
> > > 
> > > [root@m35lp76 perf]# ./perf  report -i perf.data.error68-1
> > > 
> > > 	Processing events... [974K/3M]
> > > 	Error:failed to process sample
> > > 
> > > 	0xf4198 [0x8]: failed to process type: 68
> > 
> > Thanks, applied to perf/urgent.
> 
> Well, I tried to, now trying to fix this...
> 
> 
> [acme@quaco perf]$ m
> make: Entering directory '/home/acme/git/perf/tools/perf'
>   BUILD:   Doing 'make -j8' parallel build
>   INSTALL  GTK UI
>   INSTALL  trace_plugins
>   CC       /tmp/build/perf/util/session.o
> util/session.c: In function ‘perf_session__process_events’:
> util/session.c:1936:7: error: ‘skip’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    err = skip;
>    ~~~~^~~~~~
> util/session.c:1874:6: note: ‘skip’ was declared here
>   s64 skip;
>       ^~~~
> cc1: all warnings being treated as errors
> mv: cannot stat '/tmp/build/perf/util/.session.o.tmp': No such file or directory
> make[4]: *** [/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/util/session.o] Error 1
> make[3]: *** [/home/acme/git/perf/tools/build/Makefile.build:139: util] Error 2
> make[2]: *** [Makefile.perf:559: /tmp/build/perf/perf-in.o] Error 2
> make[1]: *** [Makefile.perf:215: sub-make] Error 2
> make: *** [Makefile:110: install-bin] Error 2
> make: Leaving directory '/home/acme/git/perf/tools/perf'

So, here is your patch:

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index b17f1c9bc965..e89716175588 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1930,10 +1930,10 @@ reader__process_events(struct reader *rd, struct perf_session *session,

        if (size < sizeof(struct perf_event_header) ||
            (skip = rd->process(session, event, file_pos)) < 0) {
-               pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n",
+               pr_err("%#" PRIx64 " [%#x]: failed to process type: %d [%s]\n",
                       file_offset + head, event->header.size,
-                      event->header.type);
-               err = -EINVAL;
+                      event->header.type, strerror(-skip));
+               err = skip;
                goto out;
        }

[acme@quaco perf]$

What happens if (size < sizeof(struct perf_event_header)) is true? size
will have an undefined value, so the right thing is to have this patch
on top of yours, so that err get, as before, set to -EINVAL when the
size is less than the perf_event_header sizeof:

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index e89716175588..bad5f87ae001 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1928,6 +1928,8 @@ reader__process_events(struct reader *rd, struct perf_session *session,
 
 	size = event->header.size;
 
+	skip = -EINVAL;
+
 	if (size < sizeof(struct perf_event_header) ||
 	    (skip = rd->process(session, event, file_pos)) < 0) {
 		pr_err("%#" PRIx64 " [%#x]: failed to process type: %d [%s]\n",

---

With two Reviewed-by tags, I jumped to quickly at applying, please
compile test next time guys ;-) :-)

- Arnaldo

  reply	other threads:[~2019-04-26 14:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-23 10:53 [PATCH] perf/report: Report OOM in perf report status line Thomas Richter
2019-04-26 14:09 ` Arnaldo Carvalho de Melo
2019-04-26 14:10   ` Arnaldo Carvalho de Melo
2019-04-26 14:16     ` Arnaldo Carvalho de Melo [this message]
2019-04-26 14:44       ` Jiri Olsa
2019-04-26 15:12         ` Arnaldo Carvalho de Melo
2019-05-03  5:55 ` [tip:perf/urgent] perf report: Report OOM in status line in the GTK UI tip-bot for Thomas Richter
  -- strict thread matches above, loose matches on Subject: below --
2019-04-15  9:46 [PATCH] perf/report: Report OOM in perf report status line Thomas Richter
2019-04-15 10:17 ` Hendrik Brueckner

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=20190426141607.GB23426@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=brueckner@linux.vnet.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=tmricht@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.