From patchwork Wed Mar 8 08:17:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 66075 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp207152wrd; Wed, 8 Mar 2023 00:25:54 -0800 (PST) X-Google-Smtp-Source: AK7set9HlXhD3P35MKsyOpFh8A9pvUxriYyoULoBEmz7rNqlo79QWwmAuvhonzS57Afs8hCAs85x X-Received: by 2002:a62:5401:0:b0:5e2:da34:4aaf with SMTP id i1-20020a625401000000b005e2da344aafmr13280153pfb.4.1678263953773; Wed, 08 Mar 2023 00:25:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678263953; cv=none; d=google.com; s=arc-20160816; b=XhOSUw16/rFpXbEu8WNCy92PIwaLo8OWGnr3OXkvPU1LCWwpMwVXSu0j5wzX5xKHXE UlwUYXenlG0BCE1dM/kjZt0rOW+Uj1ObfrrEOFiAKsIyezeE4HzL3Z+/4r4PYMsUY6Td MSlBLjQQpl1VGHtz6ig/vxHLvDhtrM860SNGMSw68vTp7VzxpO4FKqmMZT7j/u9p5dDJ 1eAu1F11I1S6yc9tZLyBtGszmjA8BTbYlMwt29US5NIREH8d25+UdvppWVNjovAqRzCb YC/DgWQ9uy67IjJ+PgJzwu3lH6QQNJW70q1Ri5Joh40sjs0xCI1IQ5MXOyi4LbDka2yf WKGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=NBVnqvPJIWvW8Q6RkCDyc/WyuejWqbt8BpFQxOyzWTY=; b=HLZeKrV32iwTkCqenYuZ8FvR+iTSNATyoC0eSRtavglZdPWUu8/payDhQ1j5T3x6h2 UK8O4Q5ctVwE7G+J1J9zUSzrTbtdrnngK+SuWzqfDI+D0ipStI5K0ovrH2rRr04yIuE3 ghQpKwg6bVZmpow499TuPZpyOSawpzRXtKnfv3CU7ldOaXDFi8QfxCcEvUlXN9ddevmp FqSxzgvOmCo01ZYe9P38JQVgGdd60IjZ94bVIzfBQVitpjYeaxy1Mjmcvt9+1wf95L0A 5dsZiMaDDNlxUchjgAg0LQ5oZKxtei08e9VXgegb55/uGLG9iJitxmo53yN2cM/+ex9H K98g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Dd5AtqIx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j31-20020a63231f000000b004df5fe7a161si13544252pgj.660.2023.03.08.00.25.40; Wed, 08 Mar 2023 00:25:53 -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=@google.com header.s=20210112 header.b=Dd5AtqIx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbjCHITL (ORCPT + 99 others); Wed, 8 Mar 2023 03:19:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230108AbjCHISr (ORCPT ); Wed, 8 Mar 2023 03:18:47 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96D39A3348 for ; Wed, 8 Mar 2023 00:18:34 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-536af109f9aso163948007b3.13 for ; Wed, 08 Mar 2023 00:18:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678263513; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=NBVnqvPJIWvW8Q6RkCDyc/WyuejWqbt8BpFQxOyzWTY=; b=Dd5AtqIxiqrKsdgITUYGy2qdvIWIn7hXGg3AystvVuMH0hMFS4fltx0yn1PeTZ765O qs2MIFkZAd7KlrTcReMU0ShQYFbUF/72oakyl5cRJCKwpE1Q0ZuQVghBUkNPooxs6O91 UciQ8fl+tMAT5weLM5rKPkrqZSm59V7ag5o19Oa8TxqwYmDQ+1dTciodHMlEd9f0EoTW rG7IpJNhJGzZzMM4GzyCLE/h7vh3m6ASkjAM+Q/YUJdSg6osNREONSmSZROS+0Fe9B2h Iy+OjU/WgANSB0TVouA8ZGbON99vA4ny+yRgRvV5xsYfHZr9j/ZRpCpSC94pIKJebPah 8mJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678263513; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NBVnqvPJIWvW8Q6RkCDyc/WyuejWqbt8BpFQxOyzWTY=; b=vShaJYjwDhb73zlKLi14/66ehtDX6U6efa5zdm2jN0e7eyPVyQ5Bjr/WN/Z0xoNIbH H68EjQBo4h+E7Omk5DunJcD8vB3/qCBTCTzUiGokXAnTAW10/naPQKD5qzI3NZMAXGI4 tRXEey6/bS+FwopE+NN0WPuN5xn0f61J1jAT5/QyCxZ+xxdfzGVqFvl3fsSL7GRR6p+F E0Q93aI4EMklikQl9wXb1za8bC1JG/hhxLdWdqnKn68WDFbaEbyJ49by78+W7bzX9fW/ WkG99xWvdbeAWe+Z5kBXuwl21kj1Vui7hFAUicyjsceFVM7nQN+iKJvffhqLeMLWRW8b bzsg== X-Gm-Message-State: AO0yUKWhaCeTGNYOooChcdFWaCPpAJC/abrecI6oIl5GhcWgzY6xRX8h +ZxcEIZaurl+FRRgQbxd64svhXT6KC9N X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:9a99:fbc4:7488:8b5f]) (user=irogers job=sendgmr) by 2002:a05:6902:10e:b0:98e:6280:74ca with SMTP id o14-20020a056902010e00b0098e628074camr8504481ybh.1.1678263513764; Wed, 08 Mar 2023 00:18:33 -0800 (PST) Date: Wed, 8 Mar 2023 00:17:26 -0800 In-Reply-To: <20230308081731.1887278-1-irogers@google.com> Message-Id: <20230308081731.1887278-7-irogers@google.com> Mime-Version: 1.0 References: <20230308081731.1887278-1-irogers@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Subject: [PATCH v3 06/11] perf evsel: Add function to compute group PMU name From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Mark Rutland , Adrian Hunter , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Kan Liang , Zhengjun Xing , Ravi Bangoria , "Steinar H. Gunderson" , Qi Liu , Kim Phillips , Florian Fischer , James Clark , Suzuki Poulouse , Sean Christopherson , Leo Yan , John Garry , Kajol Jain , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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?1759787303431214482?= X-GMAIL-MSGID: =?utf-8?q?1759787303431214482?= The computed name respects software events and aux event groups, such that the pmu_name is changed to be that of the aux event leader or group leader for software events. This is done as a later change will split events that are in different PMUs into different groups. Signed-off-by: Ian Rogers --- tools/perf/util/evsel.c | 24 ++++++++++++++++++++++++ tools/perf/util/evsel.h | 1 + 2 files changed, 25 insertions(+) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 2dc2c24252bb..51d9650267d0 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -821,6 +821,30 @@ const char *evsel__name(struct evsel *evsel) return "unknown"; } +const char *evsel__group_pmu_name(const struct evsel *evsel) +{ + const struct evsel *leader; + + /* If the pmu_name is set use it. pmu_name isn't set for CPU and software events. */ + if (evsel->pmu_name) + return evsel->pmu_name; + /* + * Software events may be in a group with other uncore PMU events. Use + * the pmu_name of the group leader to avoid breaking the software event + * out of the group. + * + * Aux event leaders, like intel_pt, expect a group with events from + * other PMUs, so substitute the AUX event's PMU in this case. + */ + leader = evsel__leader(evsel); + if ((evsel->core.attr.type == PERF_TYPE_SOFTWARE || evsel__is_aux_event(leader)) && + leader->pmu_name) { + return leader->pmu_name; + } + + return "cpu"; +} + const char *evsel__metric_id(const struct evsel *evsel) { if (evsel->metric_id) diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 676c499323e9..d26745ca6147 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -280,6 +280,7 @@ int arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size); int __evsel__hw_cache_type_op_res_name(u8 type, u8 op, u8 result, char *bf, size_t size); const char *evsel__name(struct evsel *evsel); +const char *evsel__group_pmu_name(const struct evsel *evsel); const char *evsel__metric_id(const struct evsel *evsel); static inline bool evsel__is_tool(const struct evsel *evsel)