linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>, Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	linux-perf-users@vger.kernel.org,
	Song Liu <songliubraving@fb.com>,
	bpf@vger.kernel.org
Subject: [PATCH 1/4] perf bpf_counter: Add more error messages for bperf
Date: Tue,  3 Jan 2023 22:43:59 -0800	[thread overview]
Message-ID: <20230104064402.1551516-2-namhyung@kernel.org> (raw)
In-Reply-To: <20230104064402.1551516-1-namhyung@kernel.org>

I found perf stat silently exits when it failed in bperf__load().
Let's add some error messages to notify users.

  $ sudo ./perf stat -a --bpf-counters -ddd sleep 1
  bpf_map_update_elem failed: err=-7

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/bpf_counter.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/bpf_counter.c b/tools/perf/util/bpf_counter.c
index eeee899fcf34..7f5cc1aa4903 100644
--- a/tools/perf/util/bpf_counter.c
+++ b/tools/perf/util/bpf_counter.c
@@ -471,8 +471,10 @@ static int bperf__load(struct evsel *evsel, struct target *target)
 
 	if (!all_cpu_map) {
 		all_cpu_map = perf_cpu_map__new(NULL);
-		if (!all_cpu_map)
+		if (!all_cpu_map) {
+			pr_err("failed to create all cpu map\n");
 			return -1;
+		}
 	}
 
 	evsel->bperf_leader_prog_fd = -1;
@@ -493,13 +495,16 @@ static int bperf__load(struct evsel *evsel, struct target *target)
 	err = bpf_map_lookup_elem(attr_map_fd, &evsel->core.attr, &entry);
 	if (err) {
 		err = bpf_map_update_elem(attr_map_fd, &evsel->core.attr, &entry, BPF_ANY);
-		if (err)
+		if (err) {
+			pr_err("updating perf_event_attr map failed: err=%d\n", err);
 			goto out;
+		}
 	}
 
 	evsel->bperf_leader_link_fd = bpf_link_get_fd_by_id(entry.link_id);
 	if (evsel->bperf_leader_link_fd < 0 &&
 	    bperf_reload_leader_program(evsel, attr_map_fd, &entry)) {
+		pr_err("reload leader program failed\n");
 		err = -1;
 		goto out;
 	}
-- 
2.39.0.314.g84b9a713c41-goog


  reply	other threads:[~2023-01-04  6:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04  6:43 [PATCH 0/4] perf bpf_counter: A set of random fixes (v1) Namhyung Kim
2023-01-04  6:43 ` Namhyung Kim [this message]
2023-01-04  6:44 ` [PATCH 2/4] perf bpf_counter: Increase perf_attr_map entries to 32 Namhyung Kim
2023-01-04  6:44 ` [PATCH 3/4] perf bpf_counter: Handle unsupported cgroup events Namhyung Kim
2023-01-04 13:51   ` Arnaldo Carvalho de Melo
2023-01-04  6:44 ` [PATCH 4/4] perf stat: Do not use the same cgroup more than once Namhyung Kim
2023-01-04 14:21   ` Arnaldo Carvalho de Melo
2023-01-04 14:21 ` [PATCH 0/4] perf bpf_counter: A set of random fixes (v1) Arnaldo Carvalho de Melo

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=20230104064402.1551516-2-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=songliubraving@fb.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;
as well as URLs for NNTP newsgroup(s).