Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp378682rwr; Wed, 26 Apr 2023 00:08:35 -0700 (PDT) X-Google-Smtp-Source: AKy350bjKqFCdRHrGkfb5uXsS0tbUpVKSv16yr26UGLPcbwXkg189LI6oPofhF9IlKlhH02QDJoH X-Received: by 2002:a17:90b:1bc2:b0:24b:6301:17ce with SMTP id oa2-20020a17090b1bc200b0024b630117cemr17472505pjb.39.1682492915179; Wed, 26 Apr 2023 00:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682492915; cv=none; d=google.com; s=arc-20160816; b=PELr9P+rP4FLiQEhOw3juUUpZxdJlCVX7SwBHq7YJd4TJoWbzTRaJ765oWe8FH6R9i Y+JPoie+y4lV2AC6gs4KeKOTdvhRqs8luDZlvakANn4aDLIwZA77ubZ7OnQVHjr63+7X ensEYpwGc1KnFLl9BlSPg2BKRAMz17Vy1Y65xdmviAg3DW/quJCe5Ob1B4+YuiE9ebK3 RIVhy4cAVUw+rwK6TpT5HS3tp6BXpmk7itUwGV4NsSh3UOvJYWTN8K4G4yTymloCFdes +LbuWIXhr8EtGgXuRu/87GVxsi/ZeXehwYzBFvx8kbekqUPOgZ4RH9QLHOAMiKWhrcXs c37A== 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=Y7D6E0hATCK7e1RhJ0eODuZwXaDaxrE5gp17wu1kd6s=; b=giE4q4WevC/WPRcxsSGYapPsaYRJKamANotd4XeTNaU1Vb/JKg/o/iI8IMpMa2SBgA UjBJe6QfdiG64CpSR/1fUY3qAhQB1kMfTHavSEQfIy+JWKIN7bQWpK6Kne55X0RDF19n 1rS1ZBQQkA4b83ZhzhM1qC+crhKVYJ9QW/+eqgtMaRkfvDGwv20kKaKr8IReoIXxpEd6 Vf0OpYHFXs0JkhShwq1/UPATIPgHSxl2E/96icNbSIZkb33E5BPmFkFUHQbGwPvoEajM 2bQ1RnuWFuTCOqACJzpFGUErHIidBg1u1EcMuISUISyO/fktF/siEqVEuUGCHIMM7uzZ sHZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=z8cQGxhe; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bk13-20020a056a02028d00b00524d4b572e9si13140458pgb.370.2023.04.26.00.08.17; Wed, 26 Apr 2023 00:08:35 -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=@google.com header.s=20221208 header.b=z8cQGxhe; 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 S239676AbjDZHFE (ORCPT + 99 others); Wed, 26 Apr 2023 03:05:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239825AbjDZHEd (ORCPT ); Wed, 26 Apr 2023 03:04:33 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A55F444B6 for ; Wed, 26 Apr 2023 00:03:28 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-b8f6d2ac543so12895980276.2 for ; Wed, 26 Apr 2023 00:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682492595; x=1685084595; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Y7D6E0hATCK7e1RhJ0eODuZwXaDaxrE5gp17wu1kd6s=; b=z8cQGxheu+DMJewQ2FHIqzYoSrvavrXIpAjOk3OS7CyyD3f40naRFY2J1LOvx6/Olu 72ly0G9EqB3PLNEOq9FCvlTDcUJ1R/fkMYCLRPrsDqLYoYAH6BTKJZDvtMCGJCxG23E4 i0P+JuxZLXbDZKD0cgCL2LbTfUUZYkZ82sG2JJhTnjvfpNKCif6FcazANU7z9eGrr/x0 JBMIq2XeXcEgbZNj7zX6vLJP2ifBUyjAFmTmv0SyFhxb9tpR5+OjrH2+uPPoqvTGGxu9 Z1c2vJFlZJWZIgPY3TXADvtWEUC0fy/87G4P5rxESEzNkwoqXNczxtk54CE/wBuNdVOQ T0ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682492595; x=1685084595; 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=Y7D6E0hATCK7e1RhJ0eODuZwXaDaxrE5gp17wu1kd6s=; b=To1V71jwWuu4x3KCgAM7Qrb+6eG7t/SlsWcfdRdEav/kQu5xPPvOmPLBk5pv9Id+ri 84V7O82o7sblEpSssDGpvNDNqgYkb/8N8LeoOzGig1CuBoDPyzljNNnFL8Nb5TbT+/Y6 vLAIWZ1UsUyDBQk2aU3wpuzgmu0M2mjyfpI6Ov0EY7hlPBzjFajYqc8Tc5MnFaNuP6Ll pE5LOITeeSAaBjzYubxAxd2CLkZVs2fuA0RY7QQ0LilAJf1Kp4UdYROmvN5Gfv5IWqoK hP/7BRcb5N+mDIk7FbckZ0/ApiWOLFAHCzkczLFcMlAvb0Grx4b277Si+1XMiE1UNoAy FA5g== X-Gm-Message-State: AAQBX9cF6EJoYNGxtoR+7cPFQ/BznQXcXq79eBztxDeKk8L/sNWoKKBV TrtrpmnEkidnwhmUj3GCvxMjGb4hrCuX X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:144f:e890:2b29:48d9]) (user=irogers job=sendgmr) by 2002:a25:d0c7:0:b0:b97:2ecf:ff6d with SMTP id h190-20020a25d0c7000000b00b972ecfff6dmr11079097ybg.5.1682492595218; Wed, 26 Apr 2023 00:03:15 -0700 (PDT) Date: Wed, 26 Apr 2023 00:00:27 -0700 In-Reply-To: <20230426070050.1315519-1-irogers@google.com> Message-Id: <20230426070050.1315519-18-irogers@google.com> Mime-Version: 1.0 References: <20230426070050.1315519-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog Subject: [PATCH v1 17/40] perf evsel: Modify group pmu name for software events From: Ian Rogers To: Arnaldo Carvalho de Melo , Kan Liang , Ahmad Yasin , Peter Zijlstra , Ingo Molnar , Stephane Eranian , Andi Kleen , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Florian Fischer , Rob Herring , Zhengjun Xing , John Garry , Kajol Jain , Sumanth Korikkar , Thomas Richter , Tiezhu Yang , Ravi Bangoria , Leo Yan , Yang Jihong , James Clark , Suzuki Poulouse , Kang Minchul , Athira Rajeev , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ian Rogers Content-Type: text/plain; charset="UTF-8" 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,T_SCC_BODY_TEXT_LINE,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 If we have a group of {cycles,faults} then we need the faults software event to appear to be on the same PMU as cycles so that we don't split the group in parse_events__sort_events_and_fix_groups. This case is relatively easy as cycles is the leader and will have a PMU name. In the reverse case, {faults,cycles} we still need faults to appear to have the PMU name of cycles but the old behavior is just to return "cpu". For hybrid this fails as cycles will be on "cpu_core" or "cpu_atom", causing faults to be split into a different group. Change the behavior for software events so that the whole group is searched for the named PMU. Signed-off-by: Ian Rogers --- tools/perf/util/evsel.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 1cd04b5998d2..63522322e118 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -829,23 +829,26 @@ bool evsel__name_is(struct evsel *evsel, const char *name) const char *evsel__group_pmu_name(const struct evsel *evsel) { - const struct evsel *leader; + struct evsel *leader, *pos; /* 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. + * the pmu_name of the first non-software event 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; + if (evsel->core.attr.type == PERF_TYPE_SOFTWARE || evsel__is_aux_event(leader)) { + /* Starting with the leader, find the first event with a named PMU. */ + for_each_group_evsel(pos, leader) { + if (pos->pmu_name) + return pos->pmu_name; + } } return "cpu"; -- 2.40.1.495.gc816e09b53d-goog