From patchwork Wed Jan 4 06:43:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 38770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4999966wrt; Tue, 3 Jan 2023 22:45:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXu7zV9LYrR4K5ZXZo9oB33LX6r+qL1hRyMCa2hFYQxC9uQrilmT/Hbb0kc6wLDgk+vbtmYP X-Received: by 2002:a17:902:da86:b0:189:747e:97cc with SMTP id j6-20020a170902da8600b00189747e97ccmr64358043plx.26.1672814748542; Tue, 03 Jan 2023 22:45:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672814748; cv=none; d=google.com; s=arc-20160816; b=wDEqcc3x7S4Hy1SAGJ8UHnxsJu+yDj0Z7fW53e6wnG9TnZPDSkW745zJCBh6ARNbpF oDNI3kBvh3Gdijt/MdwOr/EA8B/AHhea0ShhgYr46gihWES0rs552UIbaVZbqjXtCuqv 2EwKWOlNjaCK1k/ZFwNJrqf2eF0K7fXY3PU0cEu7mZtR+wyjBTiH89cJXFBKxp5vSQ5C D0RmjRFp+MmIu1MVTyPVBSn1GgKbD8HrItkZJHzCeAqyq/0y+0Gc8jT/cWD+GbpIjoov HYmNlOEd5u+abWv79KRfv64F/EgvyaDod4SHySUH/2nH2mErv8IfnY1ed1J2maV7Xmn2 x5nQ== 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 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.45.36; Tue, 03 Jan 2023 22:45:48 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754073397810993227?= X-GMAIL-MSGID: =?utf-8?q?1754073397810993227?= 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; }