From patchwork Thu Mar 2 04:12:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 63193 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4033393wrd; Wed, 1 Mar 2023 20:15:39 -0800 (PST) X-Google-Smtp-Source: AK7set9T/R5NLie3hQ8aJw3jdBklSmgxvvwx11rMPxhySip4MLbOuzetwnBDlwKv0tAQrQ2HuDe+ X-Received: by 2002:aa7:9e1d:0:b0:5aa:72c6:4a7d with SMTP id y29-20020aa79e1d000000b005aa72c64a7dmr8142142pfq.16.1677730538780; Wed, 01 Mar 2023 20:15:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677730538; cv=none; d=google.com; s=arc-20160816; b=SvYNJPJ+NICr21DlRoiMnz/CvM+sOpm/ZilNpxfT27YiPkodeIKEPbx4EUe7jL2rGu Ndv0O1fANHbcg5Y+HVPVqzrC8Sqb1VYdfBnTVgEb/WEtZfw9iwPm0M0thXExWA7b/O5r U8aZ4Oq01VkEkxfM/pl2ObvjCYDPJLXIoHxdEQILCjliQ31LOOgvzRco1QpXTGyf5GBU NMZCjgRv7ABXNPjRgFeHdxFE6n5xb9DJmJG+xsAhw3snefqBIEDId4kPkq/9DeJUSNH2 wfS+NH1mGO1gSG6eCwV9okBvcM+Rkyt5CY/81XwlFYpA5MiryPA1EvVA3wHWOMORW6F/ kvRw== 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=/xN8iuJv1MwmAnYiwxUStUWtntqNOPw9NdTU5dZ4INM=; b=ggOOKD72JZgp7qKH36krMhlmY4jGvQ+qnTNycryeb/PXgb0RcIWuTO5kD4eHtCvaGu 9qqf69V8NpJfLtqiXEhA2umTN90dGxt5zZYXIhDif3B4ODH51C1sgSL4nb/O4Ie/1c9Y ZdmrklSb/v7o5UnURuQV2Oz14gJQJeBbYbBXV5M0I91juqunLg8QwPXlpsI/Qcv0WIgi 4+FjyGazaDozhED65/zqX0Ghrnu1VSN+40xKA+xtoYD517MhnMmjnVAXd9NodSAUpJtc r1gU9/EJRIg6iymX6dAEbrqZ6PdxVwHra3FlU3dva+RAqsUdfFbLeqMHOniG2VGawfAB Btng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=AvkU0jrk; 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 q10-20020a056a00088a00b005ffd6637866si7244228pfj.208.2023.03.01.20.15.25; Wed, 01 Mar 2023 20:15:38 -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=AvkU0jrk; 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 S229823AbjCBEOZ (ORCPT + 99 others); Wed, 1 Mar 2023 23:14:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbjCBENf (ORCPT ); Wed, 1 Mar 2023 23:13:35 -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 5C0C1469D for ; Wed, 1 Mar 2023 20:13:31 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-536c039f859so304656987b3.21 for ; Wed, 01 Mar 2023 20:13:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677730410; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=/xN8iuJv1MwmAnYiwxUStUWtntqNOPw9NdTU5dZ4INM=; b=AvkU0jrks7LC3k+CG51zaJjxNiUmWOkBDUXwqMuaTkpPnvWrtSWjLG+i9D6LB3phPJ dd+Jyg27C0Ak5OqjBpy/965D6LNvaRQxe3AJO4JJFFdJ11PEuAi2/KtZQh8nVDK2bLY+ M2jL2FLqYS5Nr7K3JAP3yzvJYIPFR42JsGjoAFwAJJuzkTVRACFJ6N4Kl65cL+D1Bafy f77PtaJ2NzAR9HmuH0Fr2FROhhNQKBqapDIpRzyXHxQTbqMpV3k3apHOLV0Dy6FjyUCW xGxWDZ2Hm1mnixNeJddZyJcY3Xfq9ICe1bS+SUaFLBKpLz4fnuX20UdQu6vwcshlyimJ l5lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677730410; 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=/xN8iuJv1MwmAnYiwxUStUWtntqNOPw9NdTU5dZ4INM=; b=QAY98xr2LCnoQW9UGpMxSXk3C0N2IkK7y1K2YhRxR4Vy2bHBK78WG43xN/6mL/MIur 6XpA3q1XmvoXz+xj8hvYjxHvFzNwZcJ9AAAriKkKWzso+VzI8cXGjUGSEaO0DTgqQdxX oPovKm0AvF6ng5p34O6bVMU3jNJTGrsdaoX3NvS1WNvoUTmq06Pq26dm6T+NtSZLwO3z OGxbccQPmXr1wepCYYVLn+dRF9sAbq6yFsRvWB1dOUIXTLU82pKHIALb3lqpscTVDDmg KDbufGwBY+0I17UZ5TAoCIeA4H+PfyNWSrTOGww9nJJ+iOrCHCsaJOHX3znUtL4J1Tgp JhwA== X-Gm-Message-State: AO0yUKVTqGsgD2FXNd3JGU1PBuIzJY+LnBe/6I4Az+9WBaL6UpGs705b U8xqtNaCjnEyuZcvR/e6C6Wxl3Uxz030 X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:bdf9:f5cb:d05:c4d5]) (user=irogers job=sendgmr) by 2002:a81:4515:0:b0:534:eef8:caa9 with SMTP id s21-20020a814515000000b00534eef8caa9mr5430233ywa.8.1677730410545; Wed, 01 Mar 2023 20:13:30 -0800 (PST) Date: Wed, 1 Mar 2023 20:12:08 -0800 In-Reply-To: <20230302041211.852330-1-irogers@google.com> Message-Id: <20230302041211.852330-8-irogers@google.com> Mime-Version: 1.0 References: <20230302041211.852330-1-irogers@google.com> X-Mailer: git-send-email 2.39.2.722.g9855ee24e9-goog Subject: [PATCH v1 07/10] perf evsel: Add function to compute pmu_name From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Kan Liang , Zhengjun Xing , Ravi Bangoria , Adrian Hunter , "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=ham 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?1759227977458585931?= X-GMAIL-MSGID: =?utf-8?q?1759227977458585931?= The computed pmu_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..9c6b486f8bd4 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__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..72121194d3b1 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__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)