From patchwork Wed Jan 4 06:44:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 38771 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp5000049wrt; Tue, 3 Jan 2023 22:46:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXv7065FbCs8qutdzPFst7mVwrg0RNApj3ehF645gVgL6+sbvTVJCbjJkaXX3Edjxz/fQ9Bg X-Received: by 2002:a62:1c52:0:b0:581:f654:a37d with SMTP id c79-20020a621c52000000b00581f654a37dmr18140301pfc.17.1672814762927; Tue, 03 Jan 2023 22:46:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672814762; cv=none; d=google.com; s=arc-20160816; b=Q0hTic1wdzMdPUXqBIR/hZHVU5xOMQtXgbdEldi7xTxhUW1uROGjPPTfxRvCWGBVo4 OHwZSs82wvzb8LbqAcaAdkOJ162NGmVURaPcikpFaESNMqSGdA7dxzRkiDqef0g4hr16 tmdq71SlC47FvZ3C+dZibywWv4LuK3NHLZ189oHkKOixzW/m2gEe89XwjFtDe/Wiq4Jm 6O8aly5ynO+hydWVlWhlNI3AyQX3bI2oNBo77P4zoKhd6o1uEA5o2revDVUVXcdjfdHC cR6Jzf+0ZTKwyebIJRgjUclRYRcIfyLiag0a5hw+jD8njsnm5scab8pIDwEfdf+kKSzt iQqQ== 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=4cgcHCT3G9N5bTmGeqZ7j5U+CmWU3a6ei0Q30f2GNqI=; b=1KvrKoRpJiA5LLNoCVp/kgbGXFZK8sqkGJOmSrHhBmx0Wx990LA3KXy3FLweEc7aNA fZoSS6TEhBa/0aM/yFX1F0OyLR3EtFdXgPY4D8hT9puGH5b0PTqi6WLUuFEiOFUPlV3/ uKnci41kjcobYLyBn4a8GErRHSevq9oreJSzNUYYO1y2jcJDKtedCVxBaePd5F6rB8WW k+VcnPXodmMHz3SjVnjjjnw0HyhX7Y4hKrpQ4/Osj6Y9BRbf24zF4cOzKak8ndm29d9x 9SU1ug3O/qwYpiu2rqozBXwSJTZJstFwafye37AJOpGyjhvxmlnq3xoeTdLMcH6eV+8B w2IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="H4XigTn/"; 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 205-20020a6218d6000000b0057fadf9ef57si24208558pfy.254.2023.01.03.22.45.50; Tue, 03 Jan 2023 22:46:02 -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="H4XigTn/"; 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 S233604AbjADGoj (ORCPT + 99 others); Wed, 4 Jan 2023 01:44:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233309AbjADGoL (ORCPT ); Wed, 4 Jan 2023 01:44:11 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 149232E5; Tue, 3 Jan 2023 22:44:11 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id a30so6550984pfr.6; Tue, 03 Jan 2023 22:44:11 -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=4cgcHCT3G9N5bTmGeqZ7j5U+CmWU3a6ei0Q30f2GNqI=; b=H4XigTn/KLhd6ZcA1McBlsmhzTWkRx7D+UVTw8GwUYTqFDz3RaJToZj0GC9EQNCsl9 7hNBQ2S0GOYoQYJyZJTz/KLsD0RZwG9XIwHf+5VTu8lx0+YA2LP3u5zumDRUAsf1Qnyi FUJZgIGolIhocllM3NyrARFA/PJ2naa4TT4ipJTu4Rv76MOyU6HVPuG8ZEEiBB08wqTz gRjKhdzIZVBcH6hgWIYohNzA7Dz20vBQet+V4U0eZ6bDH3kZmJSbMAJKOYViwYeuIffU 6VR1ypLTxSiAZ40307j6IfxmskOQHHQSOkjfhSWVUgPZO7ND9PTfAbUq7RJBL7tPmxHr d99w== 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=4cgcHCT3G9N5bTmGeqZ7j5U+CmWU3a6ei0Q30f2GNqI=; b=AXt0keKTznIBlU5DvsUcVCV8G3PTb9OC/LM9oMlgyyKcUTjAGtQqQzFu0fiCwsyupx a5RHzeHPrN6gzEoxNKJsKGW2MBN6uMveUS5wcylnzSlIfl+afO5TlfrWbLl8eqDe8lQG G3W8uHbqXGMGDdT7BnyZO4u6yT22HR0KjQOG3q9g1pwEWtvhO2MRxO20iTWr48nzloKy sC0hcF3rpDtVNMbs4lfkVOOclLu10B5NzNzovV7fTBKf8v5eKwbG1GN2sjCJvXCO01BE I/2e55Zwpr/DqEjt69dNxx1SIJrpeJT/iqp/wBmaMI+yQwvdJNlWQCMhRUTBn/iBP6Ow TlTw== X-Gm-Message-State: AFqh2kqzQHTvcYuzO/RgryoW6RZINTZSEWzapro/8vbqxATvzSCKT5S/ UYz6FM4uSPRk3CNYMdnZqWY= X-Received: by 2002:a62:32c3:0:b0:580:f1b0:2211 with SMTP id y186-20020a6232c3000000b00580f1b02211mr32038887pfy.18.1672814650468; Tue, 03 Jan 2023 22:44:10 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 22:44:09 -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 3/4] perf bpf_counter: Handle unsupported cgroup events Date: Tue, 3 Jan 2023 22:44:01 -0800 Message-Id: <20230104064402.1551516-4-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?1754073412834013078?= X-GMAIL-MSGID: =?utf-8?q?1754073412834013078?= When --for-each-cgroup option is used, it failed when any of events is not supported and it exited immediately. This is not how perf stat handles the unsupported events. Let's ignore the failure and proceed with others. Before: $ sudo ./perf stat -a --bpf-counters -e L1-icache-loads,L1-dcache-loads \ > --for-each-cgroup system.slice,user.slice sleep 1 Failed to open first cgroup events After: $ sudo ./perf stat -a --bpf-counters -e L1-icache-loads,L1-dcache-loads \ > --for-each-cgroup system.slice,user.slice sleep 1 Performance counter stats for 'system wide': L1-icache-loads system.slice 29,892,418 L1-dcache-loads system.slice L1-icache-loads user.slice 52,497,220 L1-dcache-loads user.slice Fixes: 944138f048f7d ("perf stat: Enable BPF counter with --for-each-cgroup") Signed-off-by: Namhyung Kim --- tools/perf/util/bpf_counter_cgroup.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/bpf_counter_cgroup.c b/tools/perf/util/bpf_counter_cgroup.c index 3c2df7522f6f..1c82377ed78b 100644 --- a/tools/perf/util/bpf_counter_cgroup.c +++ b/tools/perf/util/bpf_counter_cgroup.c @@ -116,27 +116,19 @@ static int bperf_load_program(struct evlist *evlist) /* open single copy of the events w/o cgroup */ err = evsel__open_per_cpu(evsel, evsel->core.cpus, -1); - if (err) { - pr_err("Failed to open first cgroup events\n"); - goto out; - } + if (err == 0) + evsel->supported = true; map_fd = bpf_map__fd(skel->maps.events); perf_cpu_map__for_each_cpu(cpu, j, evsel->core.cpus) { int fd = FD(evsel, j); __u32 idx = evsel->core.idx * total_cpus + cpu.cpu; - err = bpf_map_update_elem(map_fd, &idx, &fd, - BPF_ANY); - if (err < 0) { - pr_err("Failed to update perf_event fd\n"); - goto out; - } + bpf_map_update_elem(map_fd, &idx, &fd, BPF_ANY); } evsel->cgrp = leader_cgrp; } - evsel->supported = true; if (evsel->cgrp == cgrp) continue;