Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp12841491rwl; Tue, 3 Jan 2023 22:46:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXs9EnRiVfBhUPAgCKKylx+/VmycXXdfu44zNcA+76vMfNF5u5Gfe2J7MnAUOmj7Ziisy92V X-Received: by 2002:a05:6a20:4929:b0:a3:218a:c761 with SMTP id ft41-20020a056a20492900b000a3218ac761mr47597006pzb.5.1672814780276; Tue, 03 Jan 2023 22:46:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672814780; cv=none; d=google.com; s=arc-20160816; b=IuL8eGMr19Cr2gqi77YEERQv/asrMBRVdxtiQLB0siAUf0cuOUgwJwYKXkHnYXp1iA qKc0PuShqkSpacLa0P9GbBD7cR/EYtn7vc/YGI1xW03Huz9vpxN3NNPapOcNGQmFrx2G 9CBwPPPV2voRI2hemRRynPk0EzzkCl9FDjg6Eq27ECZeZ9JBA9UEaDZEd28shDZXMTbN taf7xdqlLkYeBkTKh/EXCSOZfI8J4xtN1uSYdi/rVLCVcBpND30y3IOmMd1J3lySBjKU 7mKweMXJ+4UKff4cNapouinfQW3Ev543hqGOn5fJGO4MHWTgT/wAPYV8SyCpcxzFJEii TyQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=xp5Hj1uOMunUvWIMLUWPDJI/aB8Townrf00dqDCpqV0=; b=tcTXLfazx1gIMCgjM903h39V/LNPMqUdEkf0dfyp7ZmiEzTuyrOuHKqvSBzB9+1pvu AIwQJJ2dG+x7JibzwyATt51UufwT7H7dSg0e1WGXhfzCmsRSyJIeaO+HqLSfqk+cxuZL LQmVUCEf1WPClNi8jJOlCpqedskV2l78h/yi9IfW4MyO2ynTyYLwk0V7ozd0AGyBIfDO ixiYVE5WkipXQXoRoqC+g8GDZ2mT53EdnoGPqs4qeXjrNzlkM/ki6ZGJ6A8mjOH/LaRv FJmLeS/dpcclzjWrVow+/Z62b6SEcXb67AksgUkl1QWFRotYZBIawXDpFNn9pchkWgfY QqMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LkFL3IY5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l2-20020a632502000000b00478bf137d96si34677822pgl.462.2023.01.03.22.46.12; Tue, 03 Jan 2023 22:46:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LkFL3IY5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233583AbjADGoe (ORCPT + 57 others); Wed, 4 Jan 2023 01:44:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233260AbjADGoI (ORCPT ); Wed, 4 Jan 2023 01:44:08 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2392D1157; Tue, 3 Jan 2023 22:44:08 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id v3so21612939pgh.4; Tue, 03 Jan 2023 22:44:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=xp5Hj1uOMunUvWIMLUWPDJI/aB8Townrf00dqDCpqV0=; b=LkFL3IY5NRqL+oGa6Y7xnMopkhn4Ww6YfUfKJd8GzoypjwuYO2qNLNOOUS2sVoEtsV xxm96hfdketMDudUKLcqBH2Ufj3pLbhEjIkTA//n8RILprvvg8r1zrgPtYGnMk9//JLk XJzzcpoWg55qyInfWCpkWUB7ExANRRbI/0k/BFtT4mvBYnMCJeiV8P2KC0HOcUO88Q9u Ok1rrQXTqejGtiGFpFX6BEPVNnc2WHUU2OHhnwMOPELKTUhQzyDFMog8J6W+WWtpdzBZ 8rxrRsLnYfS+lbARtTAvzd7ai4wwk4/80okYyF8WiPfzNADuIgFwIxhpLd4cO1/kcJrn uFdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xp5Hj1uOMunUvWIMLUWPDJI/aB8Townrf00dqDCpqV0=; b=tMQCkbFwWVB62nIvaA1KElf8vm1z/LAQ88xrsPKS3YJtnujy6H3qHwK6OXNfPgRuCQ Tl6ITTiYy3bY0mCR20NUP5GRGUYIh/JWq3Xj9oOeaxHr2BfCWTJcCKeIeGDkMLMsXjRk cF2NOOFx2F3l0HuEIehQ0qkNYdB4HJVTDY4fkYa3OBHnlHW4I0tGI/jfBnAOGA09xCEO RCNEj69lqIM4YKtCKeeltBLO8BmeihPjUt+KR7fYy3+MHo6bdICuZq6BxeSBZBiasrh+ vWMrykGHi3TVoQ2AvTiwDzinhA4IPX5LBNEwqrdStKMxxqrbv4oIHKzC7ftDzQJ+Us7P posA== X-Gm-Message-State: AFqh2ko6jLEROWqa4l6VQzy0zEn5aIePlrcmOVq/ax39apJdX1W8AZHe P9ZBpEY/yrdbJHee7dECHco= X-Received: by 2002:a05:6a00:1a45:b0:582:294d:f465 with SMTP id h5-20020a056a001a4500b00582294df465mr15550932pfv.13.1672814647626; Tue, 03 Jan 2023 22:44:07 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:d1f4:a47f:3a41:e1a2]) by smtp.gmail.com with ESMTPSA id e28-20020a056a0000dc00b00576f7bd92cdsm11829257pfj.14.2023.01.03.22.44.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 22:44:07 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Song Liu , 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 Message-Id: <20230104064402.1551516-2-namhyung@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230104064402.1551516-1-namhyung@kernel.org> References: <20230104064402.1551516-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.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 --- 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