All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: dsahern@gmail.com, changbin.du@intel.com, jolsa@kernel.org,
	acme@redhat.com, wangnan0@huawei.com, jolsa@redhat.com,
	namhyung@kernel.org, yao.jin@linux.intel.com, mingo@kernel.org,
	linux-kernel@vger.kernel.org, tglx@linutronix.de,
	ak@linux.intel.com, hpa@zytor.com, peterz@infradead.org
Subject: [tip:perf/urgent] perf tools: Check wether the eBPF file exists in event parsing
Date: Fri, 20 Oct 2017 00:19:31 -0700	[thread overview]
Message-ID: <tip-29479bfe83bafb8aa37f36ca132ee8349d11da0c@git.kernel.org> (raw)
In-Reply-To: <20171013083736.15037-9-jolsa@kernel.org>

Commit-ID:  29479bfe83bafb8aa37f36ca132ee8349d11da0c
Gitweb:     https://git.kernel.org/tip/29479bfe83bafb8aa37f36ca132ee8349d11da0c
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Fri, 13 Oct 2017 10:37:35 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 13 Oct 2017 16:45:04 -0300

perf tools: Check wether the eBPF file exists in event parsing

Adding the check wether the eBPF file exists, to consider it
as eBPF input file. This way we can differentiate eBPF events
from events that end up with same suffix as eBPF file.

Before:

  $ perf stat -e 'cpu/uops_executed.core/'  true
  bpf: builtin compilation failed: -95, try external compiler
  WARNING:        unable to get correct kernel building directory.
  Hint:   Set correct kbuild directory using 'kbuild-dir' option in [llvm]
          section of ~/.perfconfig or set it to "" to suppress kbuild
          detection.

  event syntax error: 'cpu/uops_executed.core/'
                       \___ Failed to load cpu/uops_executed.c from source: 'version' section incorrect or lost

After:

  $ perf stat -e 'cpu/uops_executed.core/'  true

   Performance counter stats for 'true':

             181,533      cpu/uops_executed.core/:u

         0.002795447 seconds time elapsed

If user makes type in the eBPF file, we prioritize the event syntax
and show following warning:

  $ perf stat -e 'krava.c//'  true
  event syntax error: 'krava.c//'
                       \___ Cannot find PMU `krava.c'. Missing kernel support?

Reported-and-Tested-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Changbin Du <changbin.du@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20171013083736.15037-9-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/parse-events.l | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index c42edea..dcfdafd 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -8,6 +8,9 @@
 
 %{
 #include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 #include "../perf.h"
 #include "parse-events.h"
 #include "parse-events-bison.h"
@@ -53,9 +56,8 @@ static int str(yyscan_t scanner, int token)
 	return token;
 }
 
-static bool isbpf(yyscan_t scanner)
+static bool isbpf_suffix(char *text)
 {
-	char *text = parse_events_get_text(scanner);
 	int len = strlen(text);
 
 	if (len < 2)
@@ -68,6 +70,17 @@ static bool isbpf(yyscan_t scanner)
 	return false;
 }
 
+static bool isbpf(yyscan_t scanner)
+{
+	char *text = parse_events_get_text(scanner);
+	struct stat st;
+
+	if (!isbpf_suffix(text))
+		return false;
+
+	return stat(text, &st) == 0;
+}
+
 /*
  * This function is called when the parser gets two kind of input:
  *

  reply	other threads:[~2017-10-20  7:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-13  8:37 [PATCH 0/9] perf tools: Assorted fixes Jiri Olsa
2017-10-13  8:37 ` [PATCH 1/9] perf tools: Fix crash in perf_hpp__reset_output_field Jiri Olsa
2017-10-20  7:18   ` [tip:perf/urgent] perf hists: Fix crash in perf_hpp__reset_output_field() tip-bot for Jiri Olsa
2017-10-13  8:37 ` [PATCH 2/9] perf tools: Add extra integrity checks to fmt_free Jiri Olsa
2017-10-20  7:19   ` [tip:perf/urgent] perf hists: Add extra integrity checks to fmt_free() tip-bot for Jiri Olsa
2017-10-13  8:37 ` [PATCH 3/9] perf tools: Rename struct perf_data_file to perf_data Jiri Olsa
2017-10-13  8:37 ` [PATCH 4/9] perf tools: Add struct perf_data_file Jiri Olsa
2017-10-13  8:37 ` [PATCH 5/9] perf tools: Add perf_data_file__write function Jiri Olsa
2017-10-13  8:37 ` [PATCH 6/9] perf stat: Move the shadow stats scale computation in perf_stat__update_shadow_stats Jiri Olsa
2017-10-13  8:37 ` [PATCH 7/9] perf stat: Make --per-thread update shadow stats to show metrics Jiri Olsa
2017-10-13  8:37 ` [PATCH 8/9] perf tools: Check wether the eBPF file exists in event parsing Jiri Olsa
2017-10-20  7:19   ` tip-bot for Jiri Olsa [this message]
2017-10-13  8:37 ` [PATCH 9/9] perf tools: Unwind properly location after REJECT Jiri Olsa
2017-10-13 19:50   ` Arnaldo Carvalho de Melo
2017-10-24 12:51     ` [PATCHv2 " Jiri Olsa
2017-10-25 14:07       ` 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=tip-29479bfe83bafb8aa37f36ca132ee8349d11da0c@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=changbin.du@intel.com \
    --cc=dsahern@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=wangnan0@huawei.com \
    --cc=yao.jin@linux.intel.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.