From patchwork Thu Jun 8 23:23:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 105162 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp612408vqr; Thu, 8 Jun 2023 16:54:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TC3iTd+3cZ1k56hSl/0lqyjdkxkm+u6FNa5j/Emuo5Vsckaap4RpJFtgB+pBh2bBS8qDj X-Received: by 2002:a05:6a20:160d:b0:10b:d70d:f971 with SMTP id l13-20020a056a20160d00b0010bd70df971mr306167pzj.3.1686268469071; Thu, 08 Jun 2023 16:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686268469; cv=none; d=google.com; s=arc-20160816; b=RhWP233SR8tv+gliqQatwfYGD1oN3X47Fg+B7LJDmtKkvI8FlrqvFAEORc9B+WncRz yhMyAL6gylO/PzJmrvDHxLbaDWF5/QL7q1SKO0oK37+0yL1S4+eUcHelPNzqdXlsHbLb 4PCWtMi2fiA8zN9vGR8+JUsa85ap0tStv6xz5USkwFNsE9PSV7B7UGfgj8M4QtxvKfIz qkBExlcDRLRcMIkUCs0Upv4u+LL6UNxuXBnS9Fqnppgr3sVXKxYPUbkegTY12Xf+w6tv JKyFeEbkUNdIhfn/A95yL7jktC5s+YB+EhVsBO1kEj+z7BpwC+JuTBuT8srh5Klhgq0o t4KA== 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=c9n2t88k5l25l+V1epjNXEK63vWDBxvkQoOlMhLNqLg=; b=J8o1I/I81E645LQ4cYgGyxCMVflfOsOOhte32ufpebmlgkmjKtwaMK2CZRwvf+564j Qh3yp4ZG6eUBDYz8bCg/jBCLjcq64DKTbE4V9rRN0/U9MnAgqX9fjv7R05wrJ3M7zuWT TcuHqlxPzNCZrl6hsBWick8k1ZSUmd6FWBjM7L8l3HFXUnugE04XPxb3TYtosT4Rpi2J cLJgqxj/Ue2WPxz+MnGGy6A+0aEP5DzznRl3Ro5O7rCLgK4UynM9nbz1hVNBsiOSu8pv 7bLmnEk8LO6canAgEZUssEr16FpX6a3Bef7/fS9ece1BZk8CybkbX+Ot2ucAJvMQsy6D qNKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=SBSIUhPr; 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 i65-20020a639d44000000b0053ef05fcf1esi1649151pgd.35.2023.06.08.16.54.17; Thu, 08 Jun 2023 16:54:29 -0700 (PDT) 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=20221208 header.b=SBSIUhPr; 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 S237031AbjFHXYI (ORCPT + 99 others); Thu, 8 Jun 2023 19:24:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230018AbjFHXYF (ORCPT ); Thu, 8 Jun 2023 19:24:05 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26A7730D3; Thu, 8 Jun 2023 16:24:04 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-662f0feafb2so894664b3a.1; Thu, 08 Jun 2023 16:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686266643; x=1688858643; 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=c9n2t88k5l25l+V1epjNXEK63vWDBxvkQoOlMhLNqLg=; b=SBSIUhPrRrc7qbYg1YEXXpBH7SlseeKKAdZu5PZyANs9ehltKLx93rcU4K/T2IoW8V VMkOv9UoLOZNzNxhiTKs9hualW+5WmRmRaScKP2n6jRjVmIjxkfazlqRtFKadnOlTT1m 3/1JVx4JnBxwz6hmyhSMT7Psd1DuwnOuslVgjwi5UyteRZEZFcR0F5SkljtKupuq42To QUI3qg96CIHYKLiAPgYzKrwwOekFkiCzqOtmp6RryNbXe5mK++CzHlDBDyo5Jj7qXmsi DR+8pgB7QBxIkehKh5KgI8izK1E5930J73WVWBLdA8e22Q3znZ1E8xEY6TFJBwioic50 YPpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686266643; x=1688858643; 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=c9n2t88k5l25l+V1epjNXEK63vWDBxvkQoOlMhLNqLg=; b=ECjxD05B3fVpA3NjeDIn6pPdf7mKkqoYJ+zX2YJqZzZSvL3ymU8nT4cUbWD9HjkiOE SzhB8MV4dEFqUaHtzJisdN6a83EawGYZe5/hmqfb4G+3FrwRW4nKP1dyW+iP/AAQpDao 0UrchXYaM9w+K0Rvk8IPPpBdgQm4fwintk0+IaF9whT9RaSyAYAKhrw7q4fdT+4RMgBF apcwbb3S3j0dTWf5lZ4G0EGT22JitG8k9mUhNfd3T3JUwzxH3MRKay3V/yW0zKnDchk3 aks8Bnt1tGcSCIy8A+FPEBR5d0O8FuhlHXUqQ18EaEehHApM/ROJhcsaGdUKEhTBodsn blmA== X-Gm-Message-State: AC+VfDxmZA185F8tjTgvjRjtzKTqBnmzbnswNnlBRiPhdS01er+RZ4qO mp8SiWB/mpXg6p7seM1mcec= X-Received: by 2002:a05:6a20:258b:b0:106:5dff:5db5 with SMTP id k11-20020a056a20258b00b001065dff5db5mr3887018pzd.1.1686266643452; Thu, 08 Jun 2023 16:24:03 -0700 (PDT) Received: from bangji.hsd1.ca.comcast.net ([2601:647:6700:7f00:c14c:6e39:cb7d:ad66]) by smtp.gmail.com with ESMTPSA id e18-20020a656792000000b0053f1d55676fsm1618203pgr.2.2023.06.08.16.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 16:24:03 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ian Rogers , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Stephane Eranian Subject: [PATCH 1/3] perf list: Check if libpfm4 event is supported Date: Thu, 8 Jun 2023 16:23:58 -0700 Message-ID: <20230608232400.3056312-2-namhyung@kernel.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230608232400.3056312-1-namhyung@kernel.org> References: <20230608232400.3056312-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,T_SCC_BODY_TEXT_LINE 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?1768180646095388793?= X-GMAIL-MSGID: =?utf-8?q?1768180646095388793?= Some of its event info cannot be used directly due to missing default attributes. Let's check if the event is supported before printing like we do for hw and cache events. Cc: Stephane Eranian Signed-off-by: Namhyung Kim Acked-by: Ian Rogers @google.com> --- tools/perf/util/pfm.c | 58 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/pfm.c b/tools/perf/util/pfm.c index 076aecc22c16..4c1024c343dd 100644 --- a/tools/perf/util/pfm.c +++ b/tools/perf/util/pfm.c @@ -13,6 +13,8 @@ #include "util/pmus.h" #include "util/pfm.h" #include "util/strbuf.h" +#include "util/cpumap.h" +#include "util/thread_map.h" #include #include @@ -123,6 +125,36 @@ int parse_libpfm_events_option(const struct option *opt, const char *str, return -1; } +static bool is_libpfm_event_supported(const char *name, struct perf_cpu_map *cpus, + struct perf_thread_map *threads) +{ + struct perf_pmu *pmu; + struct evsel *evsel; + struct perf_event_attr attr = {}; + bool result = true; + int ret; + + ret = pfm_get_perf_event_encoding(name, PFM_PLM0|PFM_PLM3, + &attr, NULL, NULL); + if (ret != PFM_SUCCESS) + return false; + + pmu = perf_pmus__find_by_type((unsigned int)attr.type); + evsel = parse_events__add_event(0, &attr, name, /*metric_id=*/NULL, pmu); + if (evsel == NULL) + return false; + + evsel->is_libpfm_event = true; + + if (evsel__open(evsel, cpus, threads) < 0) + result = false; + + evsel__close(evsel); + evsel__delete(evsel); + + return result; +} + static const char *srcs[PFM_ATTR_CTRL_MAX] = { [PFM_ATTR_CTRL_UNKNOWN] = "???", [PFM_ATTR_CTRL_PMU] = "PMU", @@ -146,6 +178,8 @@ print_libpfm_event(const struct print_callbacks *print_cb, void *print_state, { int j, ret; char topic[80], name[80]; + struct perf_cpu_map *cpus = perf_cpu_map__empty_new(1); + struct perf_thread_map *threads = thread_map__new_by_tid(0); strbuf_setlen(buf, 0); snprintf(topic, sizeof(topic), "pfm %s", pinfo->name); @@ -185,14 +219,15 @@ print_libpfm_event(const struct print_callbacks *print_cb, void *print_state, ainfo.name, ainfo.desc); } } - print_cb->print_event(print_state, - pinfo->name, - topic, - name, info->equiv, - /*scale_unit=*/NULL, - /*deprecated=*/NULL, "PFM event", - info->desc, /*long_desc=*/NULL, - /*encoding_desc=*/buf->buf); + + if (is_libpfm_event_supported(name, cpus, threads)) { + print_cb->print_event(print_state, pinfo->name, topic, + name, info->equiv, + /*scale_unit=*/NULL, + /*deprecated=*/NULL, "PFM event", + info->desc, /*long_desc=*/NULL, + /*encoding_desc=*/buf->buf); + } pfm_for_each_event_attr(j, info) { pfm_event_attr_info_t ainfo; @@ -215,6 +250,10 @@ print_libpfm_event(const struct print_callbacks *print_cb, void *print_state, print_attr_flags(buf, &ainfo); snprintf(name, sizeof(name), "%s::%s:%s", pinfo->name, info->name, ainfo.name); + + if (!is_libpfm_event_supported(name, cpus, threads)) + continue; + print_cb->print_event(print_state, pinfo->name, topic, @@ -225,6 +264,9 @@ print_libpfm_event(const struct print_callbacks *print_cb, void *print_state, /*encoding_desc=*/buf->buf); } } + + perf_cpu_map__put(cpus); + perf_thread_map__put(threads); } void print_libpfm_events(const struct print_callbacks *print_cb, void *print_state) From patchwork Thu Jun 8 23:23: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: 105175 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp620937vqr; Thu, 8 Jun 2023 17:12:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ygppgV6kAEU+Af5N2jk/uLUhNFUJ0OcWYGpyhwc4zfpomRulEPcL8PoR8BrLLjGHIOK1P X-Received: by 2002:a05:6a00:190b:b0:64f:e997:5107 with SMTP id y11-20020a056a00190b00b0064fe9975107mr12111231pfi.1.1686269541590; Thu, 08 Jun 2023 17:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686269541; cv=none; d=google.com; s=arc-20160816; b=g5hJ/SXLIPR/GU8XDspTJV78qr4PzRMww1/vDQE0srBIDbmDP++xw1y0GlEfWK4pW7 k1iH87Px8Pho1wg5GgoA0ugz0B3SP3aZQd36taVoUDnBkoGZ2Qp1bZ6GkVsJU32OCbD5 lbYFVqwUXhM+o6GH7g0C4cyZe3b3t2RfNegcHUM46UG7abzD6beu38oFo/QNIwN5eJaH H6J2bj513l/rRLoqv7uA+Gc8NrKLL2oe8xaW2irUzaEV3f5YhpEKxPzKsTmhZpTy02fs nCHK2CtWT13E4iOPvKGbjUUpzxZxanOvPr63Ik8Psge9iWJcUBFkRpn5qXjIsZEjzGxf 06gw== 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=kjeLkyzQBXDMmpW+mv6gsgImE+Yu4bQUfqrg+TqZuYQ=; b=rm9Cm95pMV2ExXmcXFsfIVXeFc8txYJAv1qK3THtDHaYpDEE4EE+C/QJJnXG8KD4Eq B4nHRD/cbvUyIKmJwBz2Y6asji9FxgVO+jGtXdDOA1tcBddLq63m4YTikQ0QqK0D2BFo DfU2CzriSLfcX0gshCBv4eOID8k6UayuoxwKU7hUEhyAyyIXu3VNJM2JgC1kqGCQwAdU OSnDic8hvcqbMzAvcJmnNxVjGmNJjWtoUvOFXzzJONs8mMiWktzam98ljbmx46eV2kF8 Zd4H9bWKUkUAaXdWA8bP7i/udt8d7qPvbPP7KHyeYLEM53fcMQZmfAwY4ALI8/g0Y8mM FTaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ibE9O4dY; 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 r30-20020aa7989e000000b0065d39e113cfsi1527041pfl.228.2023.06.08.17.12.09; Thu, 08 Jun 2023 17:12:21 -0700 (PDT) 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=20221208 header.b=ibE9O4dY; 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 S237117AbjFHXYM (ORCPT + 99 others); Thu, 8 Jun 2023 19:24:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235662AbjFHXYF (ORCPT ); Thu, 8 Jun 2023 19:24:05 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B51E30D5; Thu, 8 Jun 2023 16:24:05 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-652dd220d67so1170519b3a.3; Thu, 08 Jun 2023 16:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686266644; x=1688858644; 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=kjeLkyzQBXDMmpW+mv6gsgImE+Yu4bQUfqrg+TqZuYQ=; b=ibE9O4dYS1ra4OHX4kutCOvMuID0Kg1allAnNGKK7d7R/qu9abP0f7h2svtYDkhnMm bdABXieXA739dpn2o0zTSAI/NcVbO6gashW4K3+EaLqhPjZ7nlPCaa5kYKJoKokOBnBK terliYL8Lw+RoQyGSt6I7CkUnbKfM31IgCkrLXF6TwMYtDDbU1A2yWk0OsDHnSBl1tQo XJnrwA0ubqGIeM3nIL97/sC7E5L0vXSC5wXWXw6QlDkdGc3PqKy+JTdEgOoc/ZdqibjV qfEdUgInntX6zr3dnUHX7YM16yzZmGG/uNYwyaV+0v7HabN+o1lJ50dpgR367Qa2LESD Zg2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686266644; x=1688858644; 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=kjeLkyzQBXDMmpW+mv6gsgImE+Yu4bQUfqrg+TqZuYQ=; b=ABVrpVPtxUpHTVgRULyoxpMxJY9hG+215P/TNsxvfqQwczsgxWHUharX7ik2pfQ/VH s55bj0mqKDbKeHI5yhw0Mm8G95sIYNnq3n+6FxNHi9OuYObrVHbi2b56SnCiQkD2cWhn chIT3evKABCWUhIFVXsVH5E3CkP8HQX3zbibbXZKA8nVfqtkL5fVO5w923++IMeVJYnW R76W9yT53E8miOWbNA1sM16lO98e81IyTbRVdsQVMMddmR6a5N6SN3qSw0lN4sS12I2A M4mZ2kIeEAHqxdrGC+eTBVt1Hx84kuBH0y0CFQMQgaSnimuGR0ZoQw/RBwZvae5v+9R1 UfTg== X-Gm-Message-State: AC+VfDwj2PBAWDhit9gAeUCnRl2F+70FGbnpkweJdQ8v4b4uQ5P/5W/s heY2E3apjs1sUdyqraF5mMg= X-Received: by 2002:a05:6a21:7883:b0:10f:be0:4dce with SMTP id bf3-20020a056a21788300b0010f0be04dcemr9864782pzc.8.1686266644383; Thu, 08 Jun 2023 16:24:04 -0700 (PDT) Received: from bangji.hsd1.ca.comcast.net ([2601:647:6700:7f00:c14c:6e39:cb7d:ad66]) by smtp.gmail.com with ESMTPSA id e18-20020a656792000000b0053f1d55676fsm1618203pgr.2.2023.06.08.16.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 16:24:04 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ian Rogers , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Stephane Eranian Subject: [PATCH 2/3] perf list: Check arguments to show libpfm4 events Date: Thu, 8 Jun 2023 16:23:59 -0700 Message-ID: <20230608232400.3056312-3-namhyung@kernel.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230608232400.3056312-1-namhyung@kernel.org> References: <20230608232400.3056312-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,T_SCC_BODY_TEXT_LINE 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?1768181770812490754?= X-GMAIL-MSGID: =?utf-8?q?1768181770812490754?= From: Ian Rogers This is particularly useful for tests. $ perf list pfm Signed-off-by: Ian Rogers Signed-off-by: Namhyung Kim --- tools/perf/builtin-list.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c index 03b5d26b2489..7fec2cca759f 100644 --- a/tools/perf/builtin-list.c +++ b/tools/perf/builtin-list.c @@ -15,6 +15,7 @@ #include "util/pmu.h" #include "util/debug.h" #include "util/metricgroup.h" +#include "util/pfm.h" #include "util/string2.h" #include "util/strlist.h" #include "util/strbuf.h" @@ -457,7 +458,11 @@ int cmd_list(int argc, const char **argv) OPT_END() }; const char * const list_usage[] = { +#ifdef HAVE_LIBPFM + "perf list [] [hw|sw|cache|tracepoint|pmu|sdt|metric|metricgroup|event_glob|pfm]", +#else "perf list [] [hw|sw|cache|tracepoint|pmu|sdt|metric|metricgroup|event_glob]", +#endif NULL }; @@ -539,7 +544,12 @@ int cmd_list(int argc, const char **argv) default_ps.metricgroups = true; default_ps.metrics = false; metricgroup__print(&print_cb, ps); - } else if ((sep = strchr(argv[i], ':')) != NULL) { + } +#ifdef HAVE_LIBPFM + else if (strcmp(argv[i], "pfm") == 0) + print_libpfm_events(&print_cb, ps); +#endif + else if ((sep = strchr(argv[i], ':')) != NULL) { char *old_pmu_glob = default_ps.pmu_glob; default_ps.event_glob = strdup(argv[i]); From patchwork Thu Jun 8 23:24:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 105164 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp612926vqr; Thu, 8 Jun 2023 16:56:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4/mepXwAhRhNlXG5iFMH6hOgdVs/01Tq/FCQ/bCp0NSqmIdwVNW6+ra+aWIfDAtEvXXkeR X-Received: by 2002:a17:90a:303:b0:258:b43d:bdcc with SMTP id 3-20020a17090a030300b00258b43dbdccmr5801pje.8.1686268565522; Thu, 08 Jun 2023 16:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686268565; cv=none; d=google.com; s=arc-20160816; b=zKmisazv36WH5ypVQmf67cNZXOOkNTb8bqxVyUFW+NbbB0b3IzlhOxM5e1YGDpvkfF 9gzo9RJK4XsD3CS7Xsp2x4YEOJ0bq3dCE5HoTTy++lXdRsGhax1Kyv//85mltpsc36fV UVfMvcdxs8+gxTgrrqo5EO0z8WHhftpD0COcZZTLqrOTfy+f2vr2oYC9eV+s54lFwt6a No2j7w2nV18P62MzZBcELbA+5xUaRDHvdG1IRx6Mk/uKzGWDAZf/kr2AiH02pr6U7f1c Ofk0ruiJ5/h9WWG0EfO3LFmjGB3d/sq1tzY5CvXjR7n5uxlDc+w4HD1KUkRPm1Nt3pAc XxuQ== 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=Y7Oi+GH5jDhIbsSZz3UzpQ6ZcXdqQl0c/NxuRLG3Zcw=; b=mataH3Zvx90SnvRYNtSxxcYnoxzSeAG8y1EknAqBn0eQkbg2xJ9RVvoI3PjGs1CAEM t32gsvcztm8D9UfYrGyxHQYzp2Vchfl6zOP311EenRP5bYR+sPEuColwwLDGL411fi/6 KsmSAdRSkWE1il4rmcdlG86cp0p0Nt3pDBi6XS5tRl4eQaOeWvA3nlJM3K3rCPgEmA14 AnLT7ErVw+x/GESAm40Bt4ISnIucU2Ad2ily68umosloNqr5fHGvP7nNXivsPHWpcLBJ Cp+lo0uL0huJRl35VGw769cxrAYX0dnvEfVfxoomCEVk08IbEQav0uezZstJndGL50Yd RO5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=irxIeUO7; 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 j21-20020a17090aeb1500b00259ba3dd7c1si1800430pjz.38.2023.06.08.16.55.53; Thu, 08 Jun 2023 16:56:05 -0700 (PDT) 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=20221208 header.b=irxIeUO7; 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 S237138AbjFHXYP (ORCPT + 99 others); Thu, 8 Jun 2023 19:24:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236869AbjFHXYG (ORCPT ); Thu, 8 Jun 2023 19:24:06 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFA0830D6; Thu, 8 Jun 2023 16:24:05 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6549df4321aso1164375b3a.2; Thu, 08 Jun 2023 16:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686266645; x=1688858645; 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=Y7Oi+GH5jDhIbsSZz3UzpQ6ZcXdqQl0c/NxuRLG3Zcw=; b=irxIeUO7Sd4FnxQuFjTG37xSzBx7D8IgOOOQsFiJAHBjXP1HO6u+yDSa51dmefB0+k XHcS4pexrVO6+m9HkQPk6Q6fRwQ8kSSWD/LGDdCnkN1K0sxp64aWX23tz3WzLoc3LNnH NYyKTcf7zoq6w3/+GA0X5AILWB+41KJL3KL0DX2TdXZb29opIdkUsyOiiJAiCQBxN4lv oUrqpXW7/DWbdjbhNXGAceVfdUIedUuuuljZUmM5l4YW+ksmT/E36a6TKY/pO0R6pvVk khgr9RR4C+RZaLtoscCG1y/R99ot2xLPnMjPzZgO9KSdzNLPEu21nTIsFswLwgEwKlUE rHfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686266645; x=1688858645; 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=Y7Oi+GH5jDhIbsSZz3UzpQ6ZcXdqQl0c/NxuRLG3Zcw=; b=ETblhsc5OJncjrbK8GZPDC7NHxbDQfif3u6Og583CHxINjCCMCgtlrU4Xso8kynFoC BOVqLdaTn4PPDsU8dfdqqhgbwj2rZps9fuJmlUtuaMsrvFrde2T2VGORsmy+ZdfWLoi5 VtGxl6nt+9S626r2KnmxfdiBDecuG+dNOqs9PTwp4dMSOdg2xnucZ76Utta1DhDktObb pPqqwppPfPNPACGgBSWatNHxcdGrdHghOSkvlvXuBLYj/WG53cpLCAomTF3ueVBbNGmF 3B3I0mvXpHTGqEjeAOZsFfQXMdt121uabcYMbVM2JJVdP4N37SIirhyf54lxpLor1OV8 qUWQ== X-Gm-Message-State: AC+VfDwM+KpbIp9TlVfAZgkGmYLivChVFvZVueB2vHrcTcI7QZ5OJ9pI 6eHTeVL0jOLDAPlQg/1KdIU= X-Received: by 2002:a05:6a20:7d90:b0:10a:cb95:5aa3 with SMTP id v16-20020a056a207d9000b0010acb955aa3mr9639139pzj.7.1686266645318; Thu, 08 Jun 2023 16:24:05 -0700 (PDT) Received: from bangji.hsd1.ca.comcast.net ([2601:647:6700:7f00:c14c:6e39:cb7d:ad66]) by smtp.gmail.com with ESMTPSA id e18-20020a656792000000b0053f1d55676fsm1618203pgr.2.2023.06.08.16.24.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 16:24:04 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ian Rogers , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Stephane Eranian Subject: [PATCH 3/3] perf test: Add test of libpfm4 events Date: Thu, 8 Jun 2023 16:24:00 -0700 Message-ID: <20230608232400.3056312-4-namhyung@kernel.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230608232400.3056312-1-namhyung@kernel.org> References: <20230608232400.3056312-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,T_SCC_BODY_TEXT_LINE 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?1768180747579452357?= X-GMAIL-MSGID: =?utf-8?q?1768180747579452357?= From: Ian Rogers $ ./perf test -v 102 102: perf all libpfm4 events test : --- start --- test child forked, pid 3030994 Testing ix86arch::UNHALTED_CORE_CYCLES Testing ix86arch::INSTRUCTION_RETIRED Testing ix86arch::UNHALTED_REFERENCE_CYCLES Testing ix86arch::LLC_REFERENCES Testing ix86arch::LLC_MISSES Testing ix86arch::BRANCH_INSTRUCTIONS_RETIRED Testing ix86arch::MISPREDICTED_BRANCH_RETIRED Testing perf_raw::r0000 Testing icl::UNHALTED_CORE_CYCLES Testing icl::UNHALTED_REFERENCE_CYCLES ... test child finished with 0 ---- end ---- perf all libpfm4 events test: Ok Signed-off-by: Ian Rogers Signed-off-by: Namhyung Kim --- tools/perf/tests/shell/stat_all_pfm.sh | 51 ++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 tools/perf/tests/shell/stat_all_pfm.sh diff --git a/tools/perf/tests/shell/stat_all_pfm.sh b/tools/perf/tests/shell/stat_all_pfm.sh new file mode 100755 index 000000000000..4d004f777a6e --- /dev/null +++ b/tools/perf/tests/shell/stat_all_pfm.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# perf all libpfm4 events test +# SPDX-License-Identifier: GPL-2.0 + +if perf version --build-options | grep HAVE_LIBPFM | grep -q OFF +then + echo "Skipping, no libpfm4 support" + exit 2 +fi + +err=0 +for p in $(perf list --raw-dump pfm) +do + if echo "$p" | grep -q unc_ + then + echo "Skipping uncore event '$p' that may require additional options." + continue + fi + echo "Testing $p" + result=$(perf stat --pfm-events "$p" true 2>&1) + x=$? + if echo "$result" | grep -q "failed to parse event $p : invalid or missing unit mask" + then + continue + fi + if test "$x" -ne "0" + then + echo "Unexpected exit code '$x'" + err=1 + fi + if ! echo "$result" | grep -q "$p" && ! echo "$result" | grep -q "" + then + # We failed to see the event and it is supported. Possibly the workload was + # too small so retry with something longer. + result=$(perf stat --pfm-events "$p" perf bench internals synthesize 2>&1) + x=$? + if test "$x" -ne "0" + then + echo "Unexpected exit code '$x'" + err=1 + fi + if ! echo "$result" | grep -q "$p" + then + echo "Event '$p' not printed in:" + echo "$result" + err=1 + fi + fi +done + +exit "$err"