From patchwork Thu Mar 2 04:12:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 63190 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4033092wrd; Wed, 1 Mar 2023 20:14:40 -0800 (PST) X-Google-Smtp-Source: AK7set9rYAeLYfP3vBzYCuO9xYkmMDheMlZ6wdg8gTfEq7PvncsaueJ/zgCOzYywn4sPuDJNvxgp X-Received: by 2002:a05:6a20:c502:b0:cc:395f:e1ed with SMTP id gm2-20020a056a20c50200b000cc395fe1edmr8791353pzb.22.1677730480307; Wed, 01 Mar 2023 20:14:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677730480; cv=none; d=google.com; s=arc-20160816; b=Jj6iGi1i2sJPr1icuj0bp5zK5uTVplPZPme4SokvTq+Q3KNSwfwWgnjfnDGNcH4kDX IJ32+e+dH7KTsHcpnZBIR3plJ8nT36FQsLdXoziNcIqNBMvhYwo455Nzrz4CIAsO5/t8 JBZWn0HBb7cT4s1mnjpmT2LGBeaCwsT309Fc2gXdbPqTcqV3pT3dYSgsSbz3S7lWIDNO 5RpY5yM1wnGVdIxWz73q5VchGnKJW9zTGtwUdgERwqT0rGkzzkW0JK8Gu48HAYShnLDi VYDf7oWBtlvFsV6EGCvg+yrXQVC2d1PVkPGlJ5iZOJlvRbxLZE3Aw+JsVhEYCVunkso0 wEsw== 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=+HlToJfehRhwifEwaYoS40OI/SsPSnYmXMj6fUkz2Ls=; b=svWmOy+CF4mCpu3wd2S1pgmW7aEPSOCzOSXi55Lnec8dp/Vks79zUAlRP0L+vltrL2 b5iySbqaL6KyOk7Vym4iOyvvJBKJ1VyYvq0zvaX54LxS9BfP4bbEqjpKcJHXjhxWxkVy Ox52+2PSOpZXkByfYQOk3lA6+j0EnDT97n67TJpqCyLeamp0qvhBlAUlWdIX8vnmErQE 15b+hVuM0j3PpXS6x0FUF4jkLY7s3/El+sMUYJqeJrO1BzwOOJhFBrrbLeLkLOMeIbwF u7l/yjCDxX9AmkjwpM1zq3dZLSEGczWhOtCHZMGjs064lg1U6na7Zr6Fx9h1+V/9gD2E hQVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qevYgswA; 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 k191-20020a6384c8000000b004fb9c2c58cfsi14777321pgd.418.2023.03.01.20.14.27; Wed, 01 Mar 2023 20:14:40 -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=qevYgswA; 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 S229788AbjCBEMx (ORCPT + 99 others); Wed, 1 Mar 2023 23:12:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229779AbjCBEMq (ORCPT ); Wed, 1 Mar 2023 23:12:46 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BA924AFD9 for ; Wed, 1 Mar 2023 20:12:44 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id 66-20020a250245000000b00a53c1100d72so2754718ybc.0 for ; Wed, 01 Mar 2023 20:12:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677730363; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=+HlToJfehRhwifEwaYoS40OI/SsPSnYmXMj6fUkz2Ls=; b=qevYgswAKLTMJHEpZ1D1rEx/wavZ8kB2WNYP1lCXw7WBpA/nHbKIZmNSPWC5ob4DhT 7k0KxAShaTJ0mwzvG4+i02UJBYmj3XZd3TsitdcsrP90PomolW/s/Y83V0G+ZDuBh17F f78faMJJN1lWF4bzwdBtmeqxtDMrxn4iH3Mz26EZKZnYYyKHx5iaTdsBtRR2zABdiCAp qG+tHXcvei5IJNJBmGJlTkfoiQ9i8/DhuB0cSa9GRLJJOBDNHdBUvZ8sTyH5hMRQAsKR UKZLkeojPJAr/7Rv9h7xHt6ErpJHb60esoMn4Mcja/SYSXOxysgXYSC8ASWEXi1xzWU1 Ig9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677730363; 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=+HlToJfehRhwifEwaYoS40OI/SsPSnYmXMj6fUkz2Ls=; b=etgslwY2vJg00Czr/fzQ363MYjFVcIwQkezGk2Q8pU2V9fD2rYN8sg+aYtgO9NEMbw jmHAqWXsPQl0LV6s5ZyiM7grKDhwqjH+e8soVGiLGZCwLgPEg4bw9f7AZtc7kwIGEwGE AgrnTeqIXuVD/ICzPTtdMypwUW7SRZDXgtDcufCT2GuLe93V75oscxqQh5DskWaGpxjQ WMM6+Fda7MsfBsn5zb2dH4QJ4cO0yM8B5//V2d76Jojr7LZYgM34kMxRtl5b1Rp7HhHw 1EpE4GHWQDxwiJCTunkVtmIC1p9aiZsbier64CA8cYgrrT2l1SzBIGT866Am1YZMvV1+ o1ZA== X-Gm-Message-State: AO0yUKVJLy7RZ/NHvkZ4PB0imh0EE27saf0V8IEBTIV/hCbmdFEZpWVn pxbTfIJb3AtlCcrYY5YOY1cpdtT0Vtqx X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:bdf9:f5cb:d05:c4d5]) (user=irogers job=sendgmr) by 2002:a5b:98d:0:b0:a59:4709:c785 with SMTP id c13-20020a5b098d000000b00a594709c785mr13ybq.678.1677730362957; Wed, 01 Mar 2023 20:12:42 -0800 (PST) Date: Wed, 1 Mar 2023 20:12:02 -0800 In-Reply-To: <20230302041211.852330-1-irogers@google.com> Message-Id: <20230302041211.852330-2-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 01/10] libperf evlist: Avoid a use of evsel idx 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=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?1759227916364944803?= X-GMAIL-MSGID: =?utf-8?q?1759227916364944803?= Setting the leader iterates the list, so rather than use idx (which may be changed through list reordering) just count the elements and set afterwards. Signed-off-by: Ian Rogers --- tools/lib/perf/evlist.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c index 61b637f29b82..2d6121e89ccb 100644 --- a/tools/lib/perf/evlist.c +++ b/tools/lib/perf/evlist.c @@ -687,15 +687,14 @@ perf_evlist__next_mmap(struct perf_evlist *evlist, struct perf_mmap *map, void __perf_evlist__set_leader(struct list_head *list, struct perf_evsel *leader) { - struct perf_evsel *first, *last, *evsel; - - first = list_first_entry(list, struct perf_evsel, node); - last = list_last_entry(list, struct perf_evsel, node); - - leader->nr_members = last->idx - first->idx + 1; + struct perf_evsel *evsel; + int n = 0; - __perf_evlist__for_each_entry(list, evsel) + __perf_evlist__for_each_entry(list, evsel) { evsel->leader = leader; + n++; + } + leader->nr_members = n; } void perf_evlist__set_leader(struct perf_evlist *evlist) From patchwork Thu Mar 2 04:12:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 63194 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4033440wrd; Wed, 1 Mar 2023 20:15:48 -0800 (PST) X-Google-Smtp-Source: AK7set+49JZHx1ddtjX2/r1kyVVs0rArNlcYp4yNeg5yCT/TzXYLZjpBA1Wlm3gMT5A+PqKHcbzq X-Received: by 2002:a17:90b:3b47:b0:233:c301:32b0 with SMTP id ot7-20020a17090b3b4700b00233c30132b0mr10008125pjb.10.1677730548348; Wed, 01 Mar 2023 20:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677730548; cv=none; d=google.com; s=arc-20160816; b=DH7VL8yl/V8CsyMYOeFuMaa7DlZk6/27xCx+0Y3y9dJum71Gm4G1b6dCG7t/fv/7LS sZqQbl9hu5YjcKmvi57N6dAq66oI4CARikEGpuJNjKriPezW3sXnnUWI0Np5vqL3z2rZ yPCm3xqcJauXPPcLheZ1ftKWVDSDXfh+18aL1cq6OBcxMj9E36cN2Tu5R+mSDGafAihI Ip9sCfUysha++DSYX2anizUn06c5oVUmq4d77bFiPgZh5o5zxnaWP0uP1560NzE/H48c aJMnhFr2s5C4+rFR5alzpL36S09OVFrq7Tr/PM3iEMftF352jwfBF09NP+kEqWxEQPWO gJAA== 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=pbWEbRbutsNUN5sTWrzxwdPi+ofZdxqM4XD/ZOPKz9c=; b=u24dSl6yi2KC1hP2n+nW61yJdwZiaL/xybP9C7DtdSuVgpjwtp9vcXi7X6NKgczKkY PBXomRLn+LPXWfOnr2/iRL4HTeQJ5YL08LSEqlTKeWR3dmO/qgZLuh7C8R7/ssXAFbYb wT7laP34i//ZttZLTM4XG41kc2MQqp9evK6qz8tvShdW7YnhblYMvmhEydz4RaSYUm8J xXPx9YBU1C3HKfjt8ygPIeLLaCc1ITn5NE2exX47EJcEAw/q5EUuJKlzRD8z4m3w9oun STOlekhqHO/koEa1BaeKfRqKCTeBQvaYmeDAHbu4a1JmtPy9uIJ4XD8+rSMJXGGWZNiX 2Z7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=dk0jI3kO; 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 j2-20020a17090ae60200b00233ca49c5a7si1327680pjy.17.2023.03.01.20.15.34; Wed, 01 Mar 2023 20:15:48 -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=dk0jI3kO; 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 S229789AbjCBENJ (ORCPT + 99 others); Wed, 1 Mar 2023 23:13:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229766AbjCBEM4 (ORCPT ); Wed, 1 Mar 2023 23:12:56 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54DED1FDD for ; Wed, 1 Mar 2023 20:12:52 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-536bbaeceeaso300753507b3.11 for ; Wed, 01 Mar 2023 20:12:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677730371; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=pbWEbRbutsNUN5sTWrzxwdPi+ofZdxqM4XD/ZOPKz9c=; b=dk0jI3kOiQBk9W2lLqgz+VaudhSa/CCW/ODrtT0tyOePHBKtrFJUvQQAPYg6319gFj sz5ylm1roUVU+84JZuR3TdmJMWSoidy3zxMl828qu0O7jAl50dfWP3fpeFzU3fZev7zZ QpoIXKETiuB3T2AmvOc3T6030jPbIOTsD1ilLyBawehp3KaYHpyXo8WjOqr97i5geWqW VYUVc1WRgySWJ+uJ1lKoZ6XTkeauHlREYHJNO+DHvrBsM1VwXoQ8Gp4pZ1P4elO8OJvu IJO1v1wrTVgOew5IoHZBIE4gcSLR3gUE481C+y0Wcta5ENi0HPMBwWyvcimxlDMs3j37 2SYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677730371; 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=pbWEbRbutsNUN5sTWrzxwdPi+ofZdxqM4XD/ZOPKz9c=; b=IFG9ckBr8peSxALuu63B5s52Ow0tn7nHB8f1rttftc1Vz3i2dtr/0Dcr9K5i1CWgtS xpS1S2llxHv5JSPfglyLSbjetskX5JSN+4vbOBw5WsFYmv0Z3b+7riZw/FIKI7zh+PB9 LCMRF9Xrs66mD+pgzDh8tT2TveXt8CFzHvEHInabCSNg3cpJfDfzCHmRAbS79BF7Msd3 lHqoSwTjKWLcG06fNtNY66OLqiIHyDKgjuhqhUpXDqip/ZKthlXSKQ6584Hn+m6uaxUe FIYao0BMd44pePHLh7pT0ocoWwmClmuB9jszinAM+3ImG0Cko7gBltNzZQmsw2EAOuOp Etkg== X-Gm-Message-State: AO0yUKXDYsLVrm5m3mx3JkAaGAct0MLLJV4Wkj9z//AigIS7WxZtNiEh AIlRxVu31fGal+2A89ae6mkRT8PvpY88 X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:bdf9:f5cb:d05:c4d5]) (user=irogers job=sendgmr) by 2002:a0d:f786:0:b0:539:2d32:9f97 with SMTP id h128-20020a0df786000000b005392d329f97mr13ywf.298.1677730370827; Wed, 01 Mar 2023 20:12:50 -0800 (PST) Date: Wed, 1 Mar 2023 20:12:03 -0800 In-Reply-To: <20230302041211.852330-1-irogers@google.com> Message-Id: <20230302041211.852330-3-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 02/10] perf stat: Don't remove all grouped events when CPU maps disagree 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=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?1759227987721931614?= X-GMAIL-MSGID: =?utf-8?q?1759227987721931614?= If the events in an evlist's CPU map differ then the entire group is removed. For example: ``` $ perf stat -e '{imc_free_running/data_read/,imc_free_running/data_write/,cs}' -a sleep 1 WARNING: grouped events cpus do not match, disabling group: anon group { imc_free_running/data_read/, imc_free_running/data_write/, cs } ``` Change the behavior so that just the events not matching the leader are removed. So in the example above, just 'cs' will be removed. Modify the warning so that it is produced once for each group, rather than once for the entire evlist. Shrink the scope and size of the warning text buffer. Signed-off-by: Ian Rogers --- tools/perf/builtin-stat.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index d70b1ec88594..5c12ae5efce5 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -181,14 +181,13 @@ static bool cpus_map_matched(struct evsel *a, struct evsel *b) static void evlist__check_cpu_maps(struct evlist *evlist) { - struct evsel *evsel, *pos, *leader; - char buf[1024]; + struct evsel *evsel, *warned_leader = NULL; if (evlist__has_hybrid(evlist)) evlist__warn_hybrid_group(evlist); evlist__for_each_entry(evlist, evsel) { - leader = evsel__leader(evsel); + struct evsel *leader = evsel__leader(evsel); /* Check that leader matches cpus with each member. */ if (leader == evsel) @@ -197,19 +196,26 @@ static void evlist__check_cpu_maps(struct evlist *evlist) continue; /* If there's mismatch disable the group and warn user. */ - WARN_ONCE(1, "WARNING: grouped events cpus do not match, disabling group:\n"); - evsel__group_desc(leader, buf, sizeof(buf)); - pr_warning(" %s\n", buf); - + if (warned_leader != leader) { + char buf[200]; + + pr_warning("WARNING: grouped events cpus do not match.\n" + "Events with CPUs not matching the leader will " + "be removed from the group.\n"); + evsel__group_desc(leader, buf, sizeof(buf)); + pr_warning(" %s\n", buf); + warned_leader = leader; + } if (verbose > 0) { + char buf[200]; + cpu_map__snprint(leader->core.cpus, buf, sizeof(buf)); pr_warning(" %s: %s\n", leader->name, buf); cpu_map__snprint(evsel->core.cpus, buf, sizeof(buf)); pr_warning(" %s: %s\n", evsel->name, buf); } - for_each_group_evsel(pos, leader) - evsel__remove_from_group(pos, leader); + evsel__remove_from_group(evsel, leader); } } From patchwork Thu Mar 2 04:12:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 63191 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4033198wrd; Wed, 1 Mar 2023 20:15:00 -0800 (PST) X-Google-Smtp-Source: AK7set8q9Zpkf7vnvA60afV2eshko++q/vm8ol5ADIYr8pj6i0bGMVyVuNoF3tAI3N4Vh1p4LVUW X-Received: by 2002:a17:90b:3a87:b0:237:161e:33bc with SMTP id om7-20020a17090b3a8700b00237161e33bcmr10096164pjb.16.1677730500486; Wed, 01 Mar 2023 20:15:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677730500; cv=none; d=google.com; s=arc-20160816; b=rNCwfZcchjUJFyqESYILl6a0KmvROwy4HLappWoKnWStia7JGhST3DVsUzQ3a/Yj+o q8qpYJn5QxRs+TDUcoVqzHlhQPHfd31+31VgeCU5QE4U1Hu9zV5nqnZabtLmbOAtkWQY lQ3M1XxmTjxybrQ7fagdsNq96RrzbIfps5n9wnxgHHwnNMfykeBbmTaPjxa5ypv8YiKc M/D+rkiP7L+VQnpB+F3OtNU5Ci3abaAh37JXDAiSIOrGSq7jXFGdbIZypHJm3yyMBCMV hj7HLLSPK++LI3lVAOVliCykq/ZakkocmMH8iemFh5I2XWmG/qTD+jrd9jyhUrjk0O99 St1g== 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=6p++g9ByZAXMS3Dvltn2JIvavdr7joQqdokiBOJiUtQ=; b=rD/Mg0saHLFy6MM9horzNBhiIKIMkuiN8YhLpPNhcdyDFRDq9741xdDdwImO0XGKLv Ofbs5rvah8ErW+D2T4HaxB4kXkm9sTTB2Z9gvprkLLGgviEWrMd4rRzptdno75TEUbt9 P/4U9JSYo+hWyB6QX1OgwEVCrzRKiXkZjn688WKKx4zS/+V7aqlDSDHD1N844/LGD7V0 Ej5zFWIRtIL970Sl1kjJI0cs6DoyyKk5QY/gPIFUE7um9zUvFjkS2fI6wn4lWdUYGpVj RW64DIfzRhSOi3VFD32lli6q+J0b8j3wGaqBYnNEavMeWVYlZ3liTM4qt+6h4u5opnLX UZYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qhQeVnOH; 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 j2-20020a17090adc8200b0022c0049ab90si1310006pjv.95.2023.03.01.20.14.46; Wed, 01 Mar 2023 20:15:00 -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=qhQeVnOH; 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 S229851AbjCBENQ (ORCPT + 99 others); Wed, 1 Mar 2023 23:13:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229864AbjCBENG (ORCPT ); Wed, 1 Mar 2023 23:13:06 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C41D62ED71 for ; Wed, 1 Mar 2023 20:13:03 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-538116920c3so300740977b3.15 for ; Wed, 01 Mar 2023 20:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677730379; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6p++g9ByZAXMS3Dvltn2JIvavdr7joQqdokiBOJiUtQ=; b=qhQeVnOHT2BT7pic+pk3JZ4w8BJBvzwsXc7rELny5/AvmuDbl8L8m/9wQdEZbB/mor y8TyENCjW7SElSN8lQsKc2GZw71FtlNTvsy20UTGRX+aQuD0Lpbjie2oCldNDKOJPUkP AqnEiJKnc4uCb1wxgEoqDX/E7yf+aSVGur0xN8NGX08f5tMIUldUVoYEAWsdADKukm5o AGp8dZr13hJp/9qHX77kLUed1YdGKRCAws+HL0VtaqjqYhTGUP289mhg6q1hE9q8nQYv q1AGAvSSqvodsspwbFCfCMr7RXv0V2W19Xb8csNp2n9OLoxwp+qkTcwWPxBUZRnxC98x Sp3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677730379; 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=6p++g9ByZAXMS3Dvltn2JIvavdr7joQqdokiBOJiUtQ=; b=UriY3I3HPc3zTM9HvoyGWD7G0q4Tb6id5YZkr+vQXjZuxHWFZPhxv9WQTxxss5Eqba 7cTvipYZvj9KBQw/omiIOyn4FmHzuJHaellsE//rG23Y9RfkcH62VCEzbybJL5zW5QMg /t9T3pR9vOYnxZSTlaUUZvWUNdBw0OCOOwHA8eN6Xsnip7cNCevbS7Ztmr6un8RSel6L q9STDHHO5aQKL+gJrJVF2pZyApPthPz9nhaoodqO+6CV5B4Iz5v3hM+g2qlJZK5TwNQn YvIPE7xSyrM8ihbzO0plE67Y++esvH3bd2WHe23Ys7td2uXpYfAwtRjFA6QDREl1A/ky Vggg== X-Gm-Message-State: AO0yUKXYjXNzQa7YkyScbHQitD7JXrIddDAkfkSymh4t9QTAcgD84Krg bp3+pjJxW8wCUXKyCgW6F2bt2wbuMaI7 X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:bdf9:f5cb:d05:c4d5]) (user=irogers job=sendgmr) by 2002:a25:8c0b:0:b0:a20:11a9:bd4a with SMTP id k11-20020a258c0b000000b00a2011a9bd4amr3801540ybl.0.1677730378917; Wed, 01 Mar 2023 20:12:58 -0800 (PST) Date: Wed, 1 Mar 2023 20:12:04 -0800 In-Reply-To: <20230302041211.852330-1-irogers@google.com> Message-Id: <20230302041211.852330-4-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 03/10] perf record: Early auxtrace initialization before event parsing 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?1759227937337543597?= X-GMAIL-MSGID: =?utf-8?q?1759227937337543597?= This allows event parsing to use the evsel__is_aux_event function, which is important when determining event grouping. Signed-off-by: Ian Rogers --- tools/perf/arch/x86/util/auxtrace.c | 17 +++++++++++++---- tools/perf/builtin-record.c | 6 ++++++ tools/perf/util/auxtrace.h | 2 ++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/tools/perf/arch/x86/util/auxtrace.c b/tools/perf/arch/x86/util/auxtrace.c index 3da506e13f49..de1e4842ea2e 100644 --- a/tools/perf/arch/x86/util/auxtrace.c +++ b/tools/perf/arch/x86/util/auxtrace.c @@ -15,6 +15,19 @@ #include "../../../util/intel-bts.h" #include "../../../util/evlist.h" +void auxtrace__early_init(void) +{ + struct perf_pmu *intel_pt_pmu; + struct perf_pmu *intel_bts_pmu; + + intel_pt_pmu = perf_pmu__find(INTEL_PT_PMU_NAME); + if (intel_pt_pmu) + intel_pt_pmu->auxtrace = true; + intel_bts_pmu = perf_pmu__find(INTEL_BTS_PMU_NAME); + if (intel_bts_pmu) + intel_bts_pmu->auxtrace = true; +} + static struct auxtrace_record *auxtrace_record__init_intel(struct evlist *evlist, int *err) @@ -26,11 +39,7 @@ struct auxtrace_record *auxtrace_record__init_intel(struct evlist *evlist, bool found_bts = false; intel_pt_pmu = perf_pmu__find(INTEL_PT_PMU_NAME); - if (intel_pt_pmu) - intel_pt_pmu->auxtrace = true; intel_bts_pmu = perf_pmu__find(INTEL_BTS_PMU_NAME); - if (intel_bts_pmu) - intel_bts_pmu->auxtrace = true; evlist__for_each_entry(evlist, evsel) { if (intel_pt_pmu && evsel->core.attr.type == intel_pt_pmu->type) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 8374117e66f6..a0870c076dc0 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -3940,6 +3940,10 @@ static int record__init_thread_masks(struct record *rec) return ret; } +__weak void auxtrace__early_init(void) +{ +} + int cmd_record(int argc, const char **argv) { int err; @@ -3985,6 +3989,8 @@ int cmd_record(int argc, const char **argv) if (err) return err; + auxtrace__early_init(); + argc = parse_options(argc, argv, record_options, record_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (quiet) diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 29eb82dff574..49a86aa6ac94 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -457,6 +457,8 @@ struct addr_filters { struct auxtrace_cache; +void auxtrace__early_init(void); + #ifdef HAVE_AUXTRACE_SUPPORT u64 compat_auxtrace_mmap__read_head(struct auxtrace_mmap *mm); From patchwork Thu Mar 2 04:12:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 63195 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4033501wrd; Wed, 1 Mar 2023 20:15:57 -0800 (PST) X-Google-Smtp-Source: AK7set9TEHOXoBXVEVj35/NdsiKPzJR8XorKndJ7q6NThf1QTSP5xP2hlG8jvA4gPCUGSNCZwl8n X-Received: by 2002:a17:902:d4cb:b0:19c:d23e:5298 with SMTP id o11-20020a170902d4cb00b0019cd23e5298mr9589356plg.68.1677730557449; Wed, 01 Mar 2023 20:15:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677730557; cv=none; d=google.com; s=arc-20160816; b=dIIsU0FJRwlApOjpkBJMRAp/c7/+z2+3kXXIoqWqTz5T7FL3z+L4mPm/xYpPhRFkQO 040/9twq6emlWPYNPyk9zSjQdM90ruoFUZgj9v41q3l2/I8RYf6dOXQUli7DjTPVFre5 eiAwzmIGgSB1ogRSezsnMJu73/8J6wXOvDIAvUn2asuKgmIhSXzgnkJGCxUB+TcxVMw+ 2bivl1BpQS+ckJNp6Y2FnAlFzW/K8SFvYcF1Em3kJ8oJIZOi8I44XKDjtdmMa/i/3BKx ssM8gZo+e3+Lk22wzXhc+T0gXW8zhX7VTor++VGC/ohztaBtlJXqKXGFJ/hEcscNbehn I1iQ== 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=bygd021PGnvtCwZIuzbnz2JBaDd2eMkon8HHUjvbNBU=; b=igcU5I5yusJ5HRN9LfEqj2WgjDA6zCSV2r2xyx+hCB+osWZj+HIbAid4FCYvkgTBqJ PZ4j8u/lzOVb+5HbBgFbaCGQL5nhKok3OzeppPEcbUAofF/8jPbGolcHykDNvKp5oB3k 15gg9m0WbWUr1B/w1OkGDhgVqwDB2MQNSdwhtVGMzVgHjtv3nYqftyz24PdPs6XuexpX uu1vc4q4XH/2kedQW6PeOLSKOfvrv7oQXMgamRIjtbRBDEQnPo6IP3bB9nFQLXrNqw5j 6P7U98ngbZp+4cTCk1CNyPQzpvqelWnpXpCJFy/5NRQKvquA2WPqddWtEpJLK8lVwSvp Qcrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jwsnSTAp; 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 kf15-20020a17090305cf00b001893c960ac9si13212835plb.533.2023.03.01.20.15.44; Wed, 01 Mar 2023 20:15:57 -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=jwsnSTAp; 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 S229904AbjCBEN3 (ORCPT + 99 others); Wed, 1 Mar 2023 23:13:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229810AbjCBENO (ORCPT ); Wed, 1 Mar 2023 23:13:14 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BA173D90F for ; Wed, 1 Mar 2023 20:13:09 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-536bbaeceeaso300758387b3.11 for ; Wed, 01 Mar 2023 20:13:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677730387; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=bygd021PGnvtCwZIuzbnz2JBaDd2eMkon8HHUjvbNBU=; b=jwsnSTAptQEZ+jP/eZLmspl0xIsJe4Ftvxsrx2655NshVyHk0nvMJKzqMAO8uwAaMZ YzXH5j+Ry0qbX5IAelfZwag959M0gTt5sGJD5Aj5jrgw37YgWNbr7caJTaBDd7eqV9F2 y0BsqnWBqjdsG4+BCUxegbg4m973P4Y6F0qKWSi7DHy8+MuYeySbMMDiTRU4XMgvHRnR eShvW3gMcn8ngmfCIU2lNn2KKlFboCHFpEIkaC/W7E82xpYRNvsUTxunVgypc/EsWL7K jNgXtro+oTpJ7KFtu0/EBQ8/bT7bLQBfvDOsq/lQbKeAitZgMbHNqKYFQp5Jgl2sDosN inMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677730387; 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=bygd021PGnvtCwZIuzbnz2JBaDd2eMkon8HHUjvbNBU=; b=PI+zZVrZzU9iFI1Kv5kag7/7rLU63RT6pYYO1dQjRMQba99gybBD/CjzK5iMRm/6CA hrC+aSwdmSfPe2Ui38wlcrJQWKNVCZMKFipdZ9EJ0GYlz1nbE1QaRIANNeF5a9U71Dd6 /YsrTEeBsGQCWkKiJLyEmQUPAJZy+AKdRlWFlbYvxBV0I5NiNL31QZVLuFpy+G+PyAce belHfzUvtImQ0n+hNfksIi5NVVn5UnPayI0yqGKOWTognWj2clPj8Y0R3CFQnh19hn1/ C4m/Y5KUgs60vuX1/7AxdlWE8IdN9STsHDflUNxMxEpxVOUo/CqO87v/u/7fzvyWj6NA B7cg== X-Gm-Message-State: AO0yUKWCCNYUznYvuSKyTzX8dmWrfi3Hi0ceoumNIRb24GUWXJ7q6AUJ IMqgcMKcOsTac0XIO7DwziEAEZ6nNxvD X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:bdf9:f5cb:d05:c4d5]) (user=irogers job=sendgmr) by 2002:a05:6902:4d1:b0:ab8:1ed9:cfd2 with SMTP id v17-20020a05690204d100b00ab81ed9cfd2mr3932135ybs.5.1677730387009; Wed, 01 Mar 2023 20:13:07 -0800 (PST) Date: Wed, 1 Mar 2023 20:12:05 -0800 In-Reply-To: <20230302041211.852330-1-irogers@google.com> Message-Id: <20230302041211.852330-5-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 04/10] perf stat: Modify the group test 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?1759227996592061731?= X-GMAIL-MSGID: =?utf-8?q?1759227996592061731?= Previously nr_members would be 0 for an event with no group. The previous change made that count 1, the event is its own leader without a group. Make the find_stat logic consistent with this, an improvement suggested by Namhyung Kim. Suggested-by: Namhyung Kim Signed-off-by: Ian Rogers --- tools/perf/util/stat-shadow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index ef85f1ae1ab2..eeccab6751d7 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -163,7 +163,7 @@ static double find_stat(const struct evsel *evsel, int aggr_idx, enum stat_type continue; /* Ignore evsels that are part of different groups. */ - if (evsel->core.leader->nr_members && + if (evsel->core.leader->nr_members > 1 && evsel->core.leader != cur->core.leader) continue; /* Ignore evsels with mismatched modifiers. */ From patchwork Thu Mar 2 04:12:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 63196 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4033560wrd; Wed, 1 Mar 2023 20:16:08 -0800 (PST) X-Google-Smtp-Source: AK7set/GU0R7AtW0HTNeRt4qYFmTfe5n0PDvHtogAbaHedUEOtO8iXUWBrR+kDw6mqshN/mBw7dg X-Received: by 2002:a17:902:cf4d:b0:19c:c2c4:a0f2 with SMTP id e13-20020a170902cf4d00b0019cc2c4a0f2mr6995041plg.26.1677730567988; Wed, 01 Mar 2023 20:16:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677730567; cv=none; d=google.com; s=arc-20160816; b=LH7NiXrTttx9gflKW3Ua9KLiHfShaaxu3GE8jnuiSLtlqc3hhNExcfyGqYVNaYTs6w 7VXtfixgz/5SnUhAYDbcadb4mpgOQd5Vkf8i+hwy/72vYlk2GNSXe/mcrwaveQz7Pigg DFYz01f1P6/AbfDOY468eZrJCx6ckKd6yK6Hf4ilskXw3X9p6uNz0XzpK/mjEhoqQ77q EH4L0MHYXMOdJatKugmchZ378gVHXIAnno7/311iR5wkHCUCLdcINazQB1+LNTz7t/ZS xNlHhyJESdlKXJQvM8p2BAGok+oZcFZRz9u7KnnpzfN4ZYb/dU9Odbmeh4Tcp6CsLQtP Wgag== 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=jg6IMjGjrVTTIu+EnMv4tDRbAkAbegs9QpsJAAuMpXw=; b=GaE0k25oAVoktS/8sjS9KbDPv4S9nAFF/EUWRaFBosDcUKzdLAEOWx12biUVJH0lem PHx2SnYq22F+/xhpU2CUHVEeHt1yHFwZ9P8u1NZWVft9udeJtny3XUgP/F0XBJVTRKz0 175Qmgi7Dy/PfWIVbjUELb2F7MpSb3yVh/4LXL6WanC258VzFVpDNOYKCH0m6YEJ0PYH pEt7dy98KYpENQLdCXhH/N6MwULo17/Oi+KPQo4Rq2CtPehABviQGIVdO/6KX7i9B9Ij zkhWhpG7MZ00itKNt35FZhDeavHjEaizIDGazOT9tacZGo84Z9M8/k5LqggN2gW500A4 HkbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=QdXTTG18; 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 kk12-20020a170903070c00b0019a826d304dsi13407915plb.633.2023.03.01.20.15.55; Wed, 01 Mar 2023 20:16:07 -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=QdXTTG18; 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 S229723AbjCBENv (ORCPT + 99 others); Wed, 1 Mar 2023 23:13:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbjCBENY (ORCPT ); Wed, 1 Mar 2023 23:13:24 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 337333E61A for ; Wed, 1 Mar 2023 20:13:16 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id 204-20020a2514d5000000b00a3637aea9e1so2810706ybu.17 for ; Wed, 01 Mar 2023 20:13:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677730395; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=jg6IMjGjrVTTIu+EnMv4tDRbAkAbegs9QpsJAAuMpXw=; b=QdXTTG18tvoaUzogomQ8IIMRWYDh50wm0SYSRSBjt8mOk3Mpeny67Ubc1ihJTdykF8 DtsvcjA0gRqZZnG16lTL7kpIw2xBrixZQg237a4JC+rVUDSl1eclwqN7PIGj5SZ8aukh t7JcobuwABd+/XgGeYwksYa6zcuizId/cCnYnNQPmHVfoTwZ0VKPTvotFmiSTvPAEuGP 8n8okejR1xp5fh4wrNO4fO//Y/xur6xE4Fdpnt9WuAfgs6/qI449eCWr6bYjdizl0xfb d3bfq4fZCS5zkNYCp5TtB/sk+gJ2z5KLFtvcpqkZ87TerCmAdJFwyBedv1rl/BvC73ck NwoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677730395; 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=jg6IMjGjrVTTIu+EnMv4tDRbAkAbegs9QpsJAAuMpXw=; b=ZTLBwQEgIMX8H9R1WzlPJ6hvsbBuei4mRb8mliBa2jfHy7Hh+lBLI+Gdus3MuEwkvc z2YFAlTAZ0X1HOAVNSzPXqHNroM6HC/on6bv2RPD+T255bGaQHRolLvUvuSsyb9t/3/G 0HT28eunHXZNoXhZfoO4D5IcaTnq9fLn6cSkbLeabyHs08noDViB0ciNUEkilL7RjMXX aiw9RuIA8Rg4Oi8xa4IqVOa+1ifOi0KpDWbDWfW7qzR0XZHfE8Q6LCr2glKUKiTjgSdn +yRF8h3EBmvAZTxOcEK4nH53syLdF8EMzG4SEAw1nNIrBOgkrynJjZms/E/fXNvPfHE3 vW5g== X-Gm-Message-State: AO0yUKX5sZad4iUJF2TceivYVAhOe0kzGNn2RwOaYngWUl3S0gckn+H4 z+yb5630+kyuYSF7ie9wxmoJIcX6pAZO X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:bdf9:f5cb:d05:c4d5]) (user=irogers job=sendgmr) by 2002:a25:fb0e:0:b0:ad0:a82:7ef2 with SMTP id j14-20020a25fb0e000000b00ad00a827ef2mr900496ybe.8.1677730394822; Wed, 01 Mar 2023 20:13:14 -0800 (PST) Date: Wed, 1 Mar 2023 20:12:06 -0800 In-Reply-To: <20230302041211.852330-1-irogers@google.com> Message-Id: <20230302041211.852330-6-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 05/10] perf evsel: Limit in group test to CPUs 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?1759228008150596135?= X-GMAIL-MSGID: =?utf-8?q?1759228008150596135?= Don't just match on the event name, restict based on the PMU too. Signed-off-by: Ian Rogers --- tools/perf/arch/x86/util/evsel.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/arch/x86/util/evsel.c b/tools/perf/arch/x86/util/evsel.c index ea3972d785d1..580b0a172136 100644 --- a/tools/perf/arch/x86/util/evsel.c +++ b/tools/perf/arch/x86/util/evsel.c @@ -61,6 +61,9 @@ bool arch_evsel__must_be_in_group(const struct evsel *evsel) if (!evsel__sys_has_perf_metrics(evsel)) return false; + if (evsel->pmu_name && strncmp(evsel->pmu_name, "cpu", 3)) + return false; + return evsel->name && (strcasestr(evsel->name, "slots") || strcasestr(evsel->name, "topdown")); From patchwork Thu Mar 2 04:12:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 63192 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4033361wrd; Wed, 1 Mar 2023 20:15:34 -0800 (PST) X-Google-Smtp-Source: AK7set8baHK9YaMXpfZywuaK2KtpzA46y/jItucD9yg+FoYdpSq5wrIioDq2E4FjpDKniys45cvf X-Received: by 2002:a05:6a20:918a:b0:cd:1b71:5190 with SMTP id v10-20020a056a20918a00b000cd1b715190mr9715508pzd.1.1677730533875; Wed, 01 Mar 2023 20:15:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677730533; cv=none; d=google.com; s=arc-20160816; b=OvKoXmu8yz+0+aATJm+yBvOKceEfhxTAqG432O7MtLyzufcKoe4RKLrkInfw6sLkFe wVNEF0v6AYLBI6k6vcVYS5l4C90TLy8Rj2Wr2wzM9m47upaXfRMWh9wWrtwhelDY2KzU Xyv0vLnzf1F1tEJFK4oIjkD7XTdWeopl9ghkXjrccjGHvlVakdMk38xKWCoQq6rIc9bS KzsvuTst9AWjQGBTXbWzL+USfVCw/8d6GdZpafcs5PVIsTcs1JxivsxhoyKn7HWYDPqL B7uBWfboAAwvfY5q3sKs4Bef9I5RXwlD5Im/YedsX2HKL+UGYOg7L7jpRCNNQgtnpG30 gUsQ== 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=LO/fXR3d0HBdbn73nzsVmC5djU2rebKQYcjeddZt4gc=; b=AtPWKW13Pb9bUZNJ8OqBk6ZaMSUCu9zAFOvSQA6CGiac1QJl1zHeM18hb8cBggRQyK +Jo22RapJxtkbl0UUh8vivJVXXnSk4WJNgDBwI/BVLGOK0b/SM2efYhIF9A7txFKwk9y t5tuGtq/Ck/4I5wIqtQlKgXjPoVu5IMRI7/vdaQcp56+poORTZyvPwQdVNOa4sJ4LcS8 wIatgEl5jtnkzQj+pYLWH7gmt/08agOEm6KFm9o9oypxGPy3MhtEI1gPagz65M3TRCfH zu5+Bg48X3cBy3WD/GRS3qTYIb7m4iPAhLNt7Xka5sAeb2QSwsxVrsHdivVv0hIPAc9k j6Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=tM9qYoUE; 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 c12-20020aa7952c000000b005924b9f5b9dsi13296029pfp.333.2023.03.01.20.15.20; Wed, 01 Mar 2023 20:15:33 -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=tM9qYoUE; 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 S229921AbjCBEOV (ORCPT + 99 others); Wed, 1 Mar 2023 23:14:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229912AbjCBENc (ORCPT ); Wed, 1 Mar 2023 23:13:32 -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 E1EAA9770 for ; Wed, 1 Mar 2023 20:13:24 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-53700262a47so297050487b3.4 for ; Wed, 01 Mar 2023 20:13:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677730403; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LO/fXR3d0HBdbn73nzsVmC5djU2rebKQYcjeddZt4gc=; b=tM9qYoUEaaXREEFmacTnEmStmZ6agaAgsp+JnFwMQP9QMIU5gPctUEa6FHUHwTD4VK O3eKrk4jmGXeNg/FegWcldmwH+YFGpkdZ9ytrLMYyikj6hdcrq9UymZ6eQyXlIbrzxsn GCQle6+2Q3wvk6ZhgsGbacwHXuBwR3TZF+oO0qROO7CG5EYuItSCzRSWfmRNEMlncNlm jb6kNoJu3Th5uhvBJvtG5yhbirR55i+E8aMt9H+o42+fFmXKPZOMFFU6djQ5eq5OvNEL OTaFbaZnY2dDIs9Vm8x6ZY3zqtysUq2dCm8oqbMGmZFFiivIQVlSFFsHv3gq9rGHe4oD +uVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677730403; 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=LO/fXR3d0HBdbn73nzsVmC5djU2rebKQYcjeddZt4gc=; b=Y26RMKZdwdCp5WlsmNLtU18L3aDI0klFmB6T8KtvwCmgPSgLekXvi4QmjRdcEn/QnS mBlYIwJQl4oapsiY7kJIccMtp0Ju+UBMFdmUlcvfJfHMpJHViW0CjGbwkRSYv44ktMBq eqGw835ffjE6tpMgpTwy0nExU7apDrPJj/glFzBDcEQi9hzNxNbDJU7izSasnwdCLeDA HDsUO9Xnmc4a7YkrVdHz1fS/pZdD1qYyvn/TZFmQ4bOisfAxqHCLoFuSAwi0Wq3DX6I3 aY42Hyc6cmJz7c19GFExygK0d4PlFo8v+dmIZ41aMbu1YB652491gZcgGzQNZoCva67l QOiQ== X-Gm-Message-State: AO0yUKXghYkp/5ZLjFm0xjCqrWYLhnyoSQ0a4+RChYl0MhZ2xEBxA2a/ 9Ykz9k5HTRlYvRizO7l52AAsZt81PLYn X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:bdf9:f5cb:d05:c4d5]) (user=irogers job=sendgmr) by 2002:a05:6902:4b:b0:a09:314f:a3ef with SMTP id m11-20020a056902004b00b00a09314fa3efmr4717618ybh.12.1677730402765; Wed, 01 Mar 2023 20:13:22 -0800 (PST) Date: Wed, 1 Mar 2023 20:12:07 -0800 In-Reply-To: <20230302041211.852330-1-irogers@google.com> Message-Id: <20230302041211.852330-7-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 06/10] perf evsel: Allow const evsel for certain accesses 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?1759227972165433971?= X-GMAIL-MSGID: =?utf-8?q?1759227972165433971?= List sorting, added later to evlist, passes const elements requiring helper functions to also be const. Make the argument to evsel__find_pmu, evsel__is_aux_event and evsel__leader const. Signed-off-by: Ian Rogers --- tools/perf/util/evsel.c | 2 +- tools/perf/util/evsel.h | 6 +++--- tools/perf/util/pmu.c | 6 +++--- tools/perf/util/python.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 51e8ce6edddc..2dc2c24252bb 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -3139,7 +3139,7 @@ bool evsel__is_hybrid(const struct evsel *evsel) return evsel->pmu_name && perf_pmu__is_hybrid(evsel->pmu_name); } -struct evsel *evsel__leader(struct evsel *evsel) +struct evsel *evsel__leader(const struct evsel *evsel) { return container_of(evsel->core.leader, struct evsel, core); } diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 814a49ebb7e3..676c499323e9 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -212,8 +212,8 @@ int evsel__object_config(size_t object_size, int (*init)(struct evsel *evsel), void (*fini)(struct evsel *evsel)); -struct perf_pmu *evsel__find_pmu(struct evsel *evsel); -bool evsel__is_aux_event(struct evsel *evsel); +struct perf_pmu *evsel__find_pmu(const struct evsel *evsel); +bool evsel__is_aux_event(const struct evsel *evsel); struct evsel *evsel__new_idx(struct perf_event_attr *attr, int idx); @@ -505,7 +505,7 @@ int evsel__store_ids(struct evsel *evsel, struct evlist *evlist); void evsel__zero_per_pkg(struct evsel *evsel); bool evsel__is_hybrid(const struct evsel *evsel); -struct evsel *evsel__leader(struct evsel *evsel); +struct evsel *evsel__leader(const struct evsel *evsel); bool evsel__has_leader(struct evsel *evsel, struct evsel *leader); bool evsel__is_leader(struct evsel *evsel); void evsel__set_leader(struct evsel *evsel, struct evsel *leader); diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 43b6182d96b7..45d9b8e28e16 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -988,7 +988,7 @@ struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu) return NULL; } -struct perf_pmu *evsel__find_pmu(struct evsel *evsel) +struct perf_pmu *evsel__find_pmu(const struct evsel *evsel) { struct perf_pmu *pmu = NULL; @@ -1000,11 +1000,11 @@ struct perf_pmu *evsel__find_pmu(struct evsel *evsel) break; } - evsel->pmu = pmu; + ((struct evsel *)evsel)->pmu = pmu; return pmu; } -bool evsel__is_aux_event(struct evsel *evsel) +bool evsel__is_aux_event(const struct evsel *evsel) { struct perf_pmu *pmu = evsel__find_pmu(evsel); diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 42e8b813d010..ab48ffbb6448 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -83,7 +83,7 @@ const char *perf_env__arch(struct perf_env *env __maybe_unused) * far, for the perf python binding known usecases, revisit if this become * necessary. */ -struct perf_pmu *evsel__find_pmu(struct evsel *evsel __maybe_unused) +struct perf_pmu *evsel__find_pmu(const struct evsel *evsel __maybe_unused) { return NULL; } 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) From patchwork Thu Mar 2 04:12:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 63197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4033657wrd; Wed, 1 Mar 2023 20:16:24 -0800 (PST) X-Google-Smtp-Source: AK7set9sYMIauna36DjQlDXGxUvxuCgkrtHsX2Tnw8M0APdP0k+mwBCBeoXuo77XO4JBwf6+fYQo X-Received: by 2002:a17:902:c1d2:b0:19c:e484:b45 with SMTP id c18-20020a170902c1d200b0019ce4840b45mr9135979plc.27.1677730584563; Wed, 01 Mar 2023 20:16:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677730584; cv=none; d=google.com; s=arc-20160816; b=Y54VM2IPOREZwC+5CGnQH22RAQERI/vXfhRcnhhhvRxfpRxcF3nNL6i+qdTsM9905y zAUlKJMykICuciEqm7c4TovS0jgAa87dUt9TyCuN8G8oz2xXJ6IMqyN8njUFIsv0J1wy t6Qk+43Vnwact8K2PFb3krqVjuBfPrF6oa5/NX9brKC4bIL/swxPRl0gwm7yUIcHZyBn HT1qzGFR9ltxjpYH/pwog34M7sjH8UxQK+k5Sf27cqxl0qb6PObOrSdc27s0kqjXcV0t gdx3D8NhrO5QFAwCG91sgfvXWMqGA0h9pD4SDzOQCbdC1SvUjZjvegyTH2ZewivQ/4ci /aSg== 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=s8e2GbMOJCiKu31bRYD395XKtu1B0wMiO24x2A+fRDY=; b=tYOTHQNeFHy2PggM01GdY/lqo3X7JH+ps+n6l9+LMZYfA8ZEDuYX8Ly5bSpuu0Nl/j 3xL1YIm2pA+XZD/8i5v/zH/lqilTJRo2S93yDtz4lNXwvcazPERbefuGkHwKfO7Xggzv ShD8TEhB8f6KX3EjUkXsgI80JWW1X4IiuP9RQcXwLqqMyuYvJRTf4/D25GgoxLrs7TZa hQjvDyP3UY9v2CywFA786NQwAYF/UXsco3nWJ1gHKofr09qj1o5l1C4xMWCl/q2PB62Y k/ltI+VKVSfnxDIYlF8acTM3JcECQ0rhOJRpxAASxEcKIs0RxblnLDs73jA5BtvBVUgy 36pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Aqy8a7r8; 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 n5-20020a170902d2c500b0019d20f7db09si10108947plc.597.2023.03.01.20.16.11; Wed, 01 Mar 2023 20:16:24 -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=Aqy8a7r8; 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 S229608AbjCBEOw (ORCPT + 99 others); Wed, 1 Mar 2023 23:14:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229962AbjCBENo (ORCPT ); Wed, 1 Mar 2023 23:13:44 -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 6E6774608A for ; Wed, 1 Mar 2023 20:13:42 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-536bbaeceeaso300768047b3.11 for ; Wed, 01 Mar 2023 20:13:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677730418; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=s8e2GbMOJCiKu31bRYD395XKtu1B0wMiO24x2A+fRDY=; b=Aqy8a7r86cYMeWfSGW4ApM7jCJHRfZfX6lC7MGITzZBZFk8BccoaKzvaKBEOPPT5OB nfNFTcCbajzSA10N/Bsznosyz9V/I9PYHFY9iZkv53xckgR/vBLv5Fa/n5EpjzYEQb9f N2ZFXeSQynryaBhzqg7m331cZpt+UsWZ/SfXSv+K2XoHzrVEOAoMDlquiKBgqS2D7vd7 QjAxm3DeeXtAAMqkHttbbFO9w37uv3BPpYUfH5sHFjXV4qM64d4gN3eiG+RyJu+jRI86 DUuwNpdvxXEixmNLix17/YVV2lXeT9dnMhiadzZf2JDJCvh+GCfhGf2TKTN+H+NTHG+B oc5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677730418; 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=s8e2GbMOJCiKu31bRYD395XKtu1B0wMiO24x2A+fRDY=; b=MEHdTc9NFRuGpeWnb4mf22/V0cvZEqM0Pmk4W/P/IjfE8AhfJyqoWZGoxyQx4iXjED 7ZK5s1bOiL0pGXeA62kw+FCli6NH7YzmFEIMUCix8UV4KTNiaQOagUfP7bpfD3ijsTuO MC4XcZ6RouX995DrqhpjkrVwcpDOHv4wwxDDB1zrxJ2Ojs9GWY6Ogh5nai8WZa1MzwEv RAKxLRKUypFj75vQdF3ku7aGVkOr+v4286nunhzeAX6SDiwa06X6fP909ftupD41GZdu +xjE38skfYh2diTJggPLKqoj324tQD916hTTu0QEEUwJ98fn2P4B3vFb9VhYPH8cm1Ju 6crQ== X-Gm-Message-State: AO0yUKULpqPQGz2U/1UcTJ26Fg0empvAvP5ioGbOghVAvh39utSERtw7 pTf3FjcQ4YImNzmZ01bXyOxqkFe7QQM7 X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:bdf9:f5cb:d05:c4d5]) (user=irogers job=sendgmr) by 2002:a05:6902:88:b0:a27:3ecd:6 with SMTP id h8-20020a056902008800b00a273ecd0006mr532396ybs.1.1677730418420; Wed, 01 Mar 2023 20:13:38 -0800 (PST) Date: Wed, 1 Mar 2023 20:12:09 -0800 In-Reply-To: <20230302041211.852330-1-irogers@google.com> Message-Id: <20230302041211.852330-9-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 08/10] perf parse-events: Pass ownership of the group 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=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?1759228025112672782?= X-GMAIL-MSGID: =?utf-8?q?1759228025112672782?= Pass ownership of the group name rather than copying and freeing the original. This saves a memory allocation and copy. Signed-off-by: Ian Rogers --- tools/perf/util/parse-events.c | 3 ++- tools/perf/util/parse-events.y | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 0336ff27c15f..1be454697d57 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1761,6 +1761,7 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list, handled: ret = 1; + free(name); out: free(leaders); return ret; @@ -1786,7 +1787,7 @@ void parse_events__set_leader(char *name, struct list_head *list, leader = arch_evlist__leader(list); __perf_evlist__set_leader(list, &leader->core); - leader->group_name = name ? strdup(name) : NULL; + leader->group_name = name; list_move(&leader->core.node, list); } diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index be8c51770051..541b8dde2063 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -202,8 +202,8 @@ PE_NAME '{' events '}' struct list_head *list = $3; inc_group_count(list, _parse_state); + /* Takes ownership of $1. */ parse_events__set_leader($1, list, _parse_state); - free($1); $$ = list; } | From patchwork Thu Mar 2 04:12:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 63198 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4034388wrd; Wed, 1 Mar 2023 20:18:53 -0800 (PST) X-Google-Smtp-Source: AK7set9ESP0DMQL5zJWfuW9jwO3pf2utn2fZKJDliqP5POUyfJhkCjgLf5+rx9zGTStHYcd8sKDH X-Received: by 2002:a05:6a20:4f91:b0:cc:beae:c2c2 with SMTP id gh17-20020a056a204f9100b000ccbeaec2c2mr7821777pzb.1.1677730733004; Wed, 01 Mar 2023 20:18:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677730732; cv=none; d=google.com; s=arc-20160816; b=e0c+0HEYQV0eBJIZc5TyJifOxrjCk66cMz+cKpR5D6yVRC7Jpi/hUd4LOlUqavi20X I6nKSHbsSvAA0FR3EjGS++Vz/YDHL4aWyKFHODai+zg4GDJfqFPszN7OgaXyf9aEkegH VxiE4qC+W4NXk5vTvKZmpDvC4GfRaAzonQPL4Lezm9lp/vpQD0iUKLgMWeXea6UPhUhX udqRAF2tT22+rnjr/5EmkqCKqJ9iG2KRKEa6JDbu2x5k8gOuhh/IJ7km47YcIaYce8PZ F+TY43YAt19WQrF5ksabt/ltJEIdNieNW4HbeqnsbQGQ1i9CYcAXaAkBoDx01AoVwnnA MoCA== 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=ysF7fSVOdkd9F2OqjxyLKRww6cDwEcTzClWqBsIs+Tw=; b=0mVTnj18iIAvmYM410EhqympexfzpLqQo1MofhGm9dFK4vRHIgpKdHBaGAOS38iT+H QhbMtNC1KMnfgpQwQ2fxobTIOBG/WchQTUV7b9VEc5rATU5/0n5j6EtJ1XqDLenv+5N/ NDobBWcLplRgLYrPMl/VFA2GJcrhiVi9BfzpJ1pEm6zRZDTGZJa1kQ0Y0pPejxf3Jhi9 YDu57VXHqVzQ6Pe2TZxD0ADQgQN7f8BCnKR/L6zRdNWym/Ykmeq6IwJXeyZoQzh5M3L3 vdMwoz3pM/divk/pVwmV0HmDdd4aZliCO0koTKaxOGzg6RE7Y9v9VtPvL0IRpPPZeHkw 5ejg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Tl1gExRl; 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 d20-20020a056a00199400b005a9107d6871si14751855pfl.220.2023.03.01.20.18.34; Wed, 01 Mar 2023 20:18:52 -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=Tl1gExRl; 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 S229872AbjCBEOz (ORCPT + 99 others); Wed, 1 Mar 2023 23:14:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbjCBEN6 (ORCPT ); Wed, 1 Mar 2023 23:13:58 -0500 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 AAD8D410B8 for ; Wed, 1 Mar 2023 20:13:47 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id a137-20020a25ca8f000000b0091b90b20cd9so2773463ybg.6 for ; Wed, 01 Mar 2023 20:13:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677730426; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ysF7fSVOdkd9F2OqjxyLKRww6cDwEcTzClWqBsIs+Tw=; b=Tl1gExRlOZMnj2rtxGHtP+zBnu/S6kxjH/oYPTJm9f21r6DdJEKjnuV48luLAJKH0e JZ8AAX93mh5Jl1TemEGkVQmuH6v0yOMknnoMV9XG8ZLR8LROeQVdvBoYa0UQK3h6Rx39 h1vF8D0h9topFkdnF8PTpLNtjWLsl+HFJIEnz20pgjZ8DDZH4z8X2ZeVn0sq6l5OHdDh kXuEw5o/TlT7DoRb4xvudlrqvYRbhmJ3CflGJdOml0sdzgqJI46CtVpk/2OQzeBoALrf TYR1uHt8BXT1pgJ73o8InNn9tIKC8OnIiQawZ55dnEDKIwrKrBUnzuzOv1Yl3qqEXnfD 72yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677730426; 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=ysF7fSVOdkd9F2OqjxyLKRww6cDwEcTzClWqBsIs+Tw=; b=LUPBpU/hSDJO/Pq5dlRMH2jcw5Ua7EKv01EMKFNPezoVlD7vjhfaum2/XRajQsmMmE mjnlEHhFuRmNH6yROzQOcN+aEp1R/+dy6bNezq10PZCSEg8qOAwSgKAh2cMZmp1bBU6z 1aMR+4SEvPb3+bsuAln8Cvg8Zyyge7PGibds91DMn1SGZAjPtg+tklQgTVfSFBInqzSU o2r5zyiZtLe9LWiiSCPHcus646ve05+fMzpaU+XI2nwEyry0HXzSc5V5ICNygtcNciq9 b0+xKODhvA98fhxg1CwKJ+l9tpOWTwc7kfUmm092xW2XiJwQlWxX/nUPWNeZt6Qsr+X6 ABNw== X-Gm-Message-State: AO0yUKVhHrWoPy/TBMxmQCDXy0xRL2cUjdnqkQbIf9wxpxefz1eHAyFU +s2oaj9uoCqfrYmNScnXIk8TEFCec8uN X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:bdf9:f5cb:d05:c4d5]) (user=irogers job=sendgmr) by 2002:a5b:683:0:b0:a09:32fb:be73 with SMTP id j3-20020a5b0683000000b00a0932fbbe73mr3568528ybq.0.1677730426349; Wed, 01 Mar 2023 20:13:46 -0800 (PST) Date: Wed, 1 Mar 2023 20:12:10 -0800 In-Reply-To: <20230302041211.852330-1-irogers@google.com> Message-Id: <20230302041211.852330-10-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 09/10] perf parse-events: Sort and group parsed events 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?1759228181039615992?= X-GMAIL-MSGID: =?utf-8?q?1759228181039615992?= This change is intended to be a no-op for most current cases, the default sort order is the order the events were parsed. Where it varies is in how groups are handled. Previously an uncore and core event that are grouped would most often cause the group to be removed: ``` $ perf stat -e '{instructions,uncore_imc_free_running_0/data_total/}' -a sleep 1 WARNING: grouped events cpus do not match, disabling group: anon group { instructions, uncore_imc_free_running_0/data_total/ } ... ``` However, when wildcards are used the events should be re-sorted and re-grouped in parse_events__set_leader, but this currently fails for simple examples: ``` $ perf stat -e '{uncore_imc_free_running/data_read/,uncore_imc_free_running/data_write/}' -a sleep 1 Performance counter stats for 'system wide': MiB uncore_imc_free_running/data_read/ MiB uncore_imc_free_running/data_write/ 1.000996992 seconds time elapsed ``` A futher failure mode, fixed in this patch, is to force topdown events into a group. This change moves sorting the evsels in the evlist after parsing. It requires parsing to set up groups. First the evsels are sorted respecting the existing groupings and parse order, but also reordering to ensure evsels of the same PMU and group appear together. So that software and aux events respect groups, their pmu_name is taken from the group leader. The sorting is done with list_sort removing a memory allocation. After sorting a pass is done to correct the group leaders and for topdown events ensuring they have a group leader. This fixes the problems seen before: ``` $ perf stat -e '{uncore_imc_free_running/data_read/,uncore_imc_free_running/data_write/}' -a sleep 1 Performance counter stats for 'system wide': 727.42 MiB uncore_imc_free_running/data_read/ 81.84 MiB uncore_imc_free_running/data_write/ 1.000948615 seconds time elapsed ``` As well as making groups not fail for cases like: ``` $ perf stat -e '{imc_free_running_0/data_total/,imc_free_running_1/data_total/}' -a sleep 1 Performance counter stats for 'system wide': 256.47 MiB imc_free_running_0/data_total/ 256.48 MiB imc_free_running_1/data_total/ 1.001165442 seconds time elapsed ``` Signed-off-by: Ian Rogers --- tools/perf/arch/x86/util/evlist.c | 39 ++--- tools/perf/util/evlist.h | 2 +- tools/perf/util/parse-events.c | 240 +++++++++++++++--------------- tools/perf/util/parse-events.h | 3 +- tools/perf/util/parse-events.y | 4 +- 5 files changed, 136 insertions(+), 152 deletions(-) diff --git a/tools/perf/arch/x86/util/evlist.c b/tools/perf/arch/x86/util/evlist.c index 8a7ae4162563..d4193479a364 100644 --- a/tools/perf/arch/x86/util/evlist.c +++ b/tools/perf/arch/x86/util/evlist.c @@ -65,29 +65,22 @@ int arch_evlist__add_default_attrs(struct evlist *evlist, return ___evlist__add_default_attrs(evlist, attrs, nr_attrs); } -struct evsel *arch_evlist__leader(struct list_head *list) +int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs) { - struct evsel *evsel, *first, *slots = NULL; - bool has_topdown = false; - - first = list_first_entry(list, struct evsel, core.node); - - if (!topdown_sys_has_perf_metrics()) - return first; - - /* If there is a slots event and a topdown event then the slots event comes first. */ - __evlist__for_each_entry(list, evsel) { - if (evsel->pmu_name && !strncmp(evsel->pmu_name, "cpu", 3) && evsel->name) { - if (strcasestr(evsel->name, "slots")) { - slots = evsel; - if (slots == first) - return first; - } - if (strcasestr(evsel->name, "topdown")) - has_topdown = true; - if (slots && has_topdown) - return slots; - } + if (topdown_sys_has_perf_metrics() && + (!lhs->pmu_name || !strncmp(lhs->pmu_name, "cpu", 3))) { + /* Ensure the topdown slots comes first. */ + if (strcasestr(lhs->name, "slots")) + return -1; + if (strcasestr(rhs->name, "slots")) + return 1; + /* Followed by topdown events. */ + if (strcasestr(lhs->name, "topdown") && !strcasestr(rhs->name, "topdown")) + return -1; + if (!strcasestr(lhs->name, "topdown") && strcasestr(rhs->name, "topdown")) + return 1; } - return first; + + /* Default ordering by insertion index. */ + return lhs->core.idx - rhs->core.idx; } diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 01fa9d592c5a..d89d8f92802b 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -119,7 +119,7 @@ int arch_evlist__add_default_attrs(struct evlist *evlist, #define evlist__add_default_attrs(evlist, array) \ arch_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array)) -struct evsel *arch_evlist__leader(struct list_head *list); +int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs); int evlist__add_dummy(struct evlist *evlist); struct evsel *evlist__add_aux_dummy(struct evlist *evlist, bool system_wide); diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 1be454697d57..d6eb0a54dd2d 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include #include #include @@ -1655,125 +1656,7 @@ int parse_events__modifier_group(struct list_head *list, return parse_events__modifier_event(list, event_mod, true); } -/* - * Check if the two uncore PMUs are from the same uncore block - * The format of the uncore PMU name is uncore_#blockname_#pmuidx - */ -static bool is_same_uncore_block(const char *pmu_name_a, const char *pmu_name_b) -{ - char *end_a, *end_b; - - end_a = strrchr(pmu_name_a, '_'); - end_b = strrchr(pmu_name_b, '_'); - - if (!end_a || !end_b) - return false; - - if ((end_a - pmu_name_a) != (end_b - pmu_name_b)) - return false; - - return (strncmp(pmu_name_a, pmu_name_b, end_a - pmu_name_a) == 0); -} - -static int -parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list, - struct parse_events_state *parse_state) -{ - struct evsel *evsel, *leader; - uintptr_t *leaders; - bool is_leader = true; - int i, nr_pmu = 0, total_members, ret = 0; - - leader = list_first_entry(list, struct evsel, core.node); - evsel = list_last_entry(list, struct evsel, core.node); - total_members = evsel->core.idx - leader->core.idx + 1; - - leaders = calloc(total_members, sizeof(uintptr_t)); - if (WARN_ON(!leaders)) - return 0; - - /* - * Going through the whole group and doing sanity check. - * All members must use alias, and be from the same uncore block. - * Also, storing the leader events in an array. - */ - __evlist__for_each_entry(list, evsel) { - - /* Only split the uncore group which members use alias */ - if (!evsel->use_uncore_alias) - goto out; - - /* The events must be from the same uncore block */ - if (!is_same_uncore_block(leader->pmu_name, evsel->pmu_name)) - goto out; - - if (!is_leader) - continue; - /* - * If the event's PMU name starts to repeat, it must be a new - * event. That can be used to distinguish the leader from - * other members, even they have the same event name. - */ - if ((leader != evsel) && - !strcmp(leader->pmu_name, evsel->pmu_name)) { - is_leader = false; - continue; - } - - /* Store the leader event for each PMU */ - leaders[nr_pmu++] = (uintptr_t) evsel; - } - - /* only one event alias */ - if (nr_pmu == total_members) { - parse_state->nr_groups--; - goto handled; - } - - /* - * An uncore event alias is a joint name which means the same event - * runs on all PMUs of a block. - * Perf doesn't support mixed events from different PMUs in the same - * group. The big group has to be split into multiple small groups - * which only include the events from the same PMU. - * - * Here the uncore event aliases must be from the same uncore block. - * The number of PMUs must be same for each alias. The number of new - * small groups equals to the number of PMUs. - * Setting the leader event for corresponding members in each group. - */ - i = 0; - __evlist__for_each_entry(list, evsel) { - if (i >= nr_pmu) - i = 0; - evsel__set_leader(evsel, (struct evsel *) leaders[i++]); - } - - /* The number of members and group name are same for each group */ - for (i = 0; i < nr_pmu; i++) { - evsel = (struct evsel *) leaders[i]; - evsel->core.nr_members = total_members / nr_pmu; - evsel->group_name = name ? strdup(name) : NULL; - } - - /* Take the new small groups into account */ - parse_state->nr_groups += nr_pmu - 1; - -handled: - ret = 1; - free(name); -out: - free(leaders); - return ret; -} - -__weak struct evsel *arch_evlist__leader(struct list_head *list) -{ - return list_first_entry(list, struct evsel, core.node); -} - -void parse_events__set_leader(char *name, struct list_head *list, - struct parse_events_state *parse_state) +void parse_events__set_leader(char *name, struct list_head *list) { struct evsel *leader; @@ -1782,13 +1665,9 @@ void parse_events__set_leader(char *name, struct list_head *list, return; } - if (parse_events__set_leader_for_uncore_aliase(name, list, parse_state)) - return; - - leader = arch_evlist__leader(list); + leader = list_first_entry(list, struct evsel, core.node); __perf_evlist__set_leader(list, &leader->core); leader->group_name = name; - list_move(&leader->core.node, list); } /* list_event is assumed to point to malloc'ed memory */ @@ -2245,6 +2124,117 @@ static int parse_events__with_hybrid_pmu(struct parse_events_state *parse_state, return ret; } +__weak int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs) +{ + /* Order by insertion index. */ + return lhs->core.idx - rhs->core.idx; +} + +static int evlist__cmp(void *state, const struct list_head *l, const struct list_head *r) +{ + const struct perf_evsel *lhs_core = container_of(l, struct perf_evsel, node); + const struct evsel *lhs = container_of(lhs_core, struct evsel, core); + const struct perf_evsel *rhs_core = container_of(r, struct perf_evsel, node); + const struct evsel *rhs = container_of(rhs_core, struct evsel, core); + int *leader_idx = state; + int lhs_leader_idx = *leader_idx, rhs_leader_idx = *leader_idx, ret; + const char *lhs_pmu_name, *rhs_pmu_name; + + /* + * First sort by grouping/leader. Read the leader idx only if the evsel + * is part of a group, as -1 indicates no group. + */ + if (lhs_core->leader != lhs_core || lhs_core->nr_members > 1) + lhs_leader_idx = lhs_core->leader->idx; + if (rhs_core->leader != rhs_core || rhs_core->nr_members > 1) + rhs_leader_idx = rhs_core->leader->idx; + + if (lhs_leader_idx != rhs_leader_idx) + return lhs_leader_idx - rhs_leader_idx; + + /* Group by PMU. Groups can't span PMUs. */ + lhs_pmu_name = evsel__pmu_name(lhs); + rhs_pmu_name = evsel__pmu_name(rhs); + ret = strcmp(lhs_pmu_name, rhs_pmu_name); + if (ret) + return ret; + + /* Architecture specific sorting. */ + return arch_evlist__cmp(lhs, rhs); +} + +static void parse_events__sort_events_and_fix_groups(struct list_head *list) +{ + int idx = -1; + struct evsel *pos, *cur_leader = NULL; + struct perf_evsel *cur_leaders_grp = NULL; + + /* + * Compute index to insert ungrouped events at. Place them where the + * first ungrouped event appears. + */ + list_for_each_entry(pos, list, core.node) { + const struct evsel *pos_leader = evsel__leader(pos); + + if (pos != pos_leader || pos->core.nr_members > 1) + continue; + + idx = pos->core.idx; + break; + } + + /* Sort events. */ + list_sort(&idx, list, evlist__cmp); + + /* + * Recompute groups, splitting for PMUs and adding groups for events + * that require them. + */ + idx = 0; + list_for_each_entry(pos, list, core.node) { + const struct evsel *pos_leader = evsel__leader(pos); + const char *pos_pmu_name = evsel__pmu_name(pos); + const char *cur_leader_pmu_name, *pos_leader_pmu_name; + bool force_grouped = arch_evsel__must_be_in_group(pos); + + /* Reset index and nr_members. */ + pos->core.idx = idx++; + pos->core.nr_members = 0; + + /* + * Set the group leader respecting the given groupings and that + * groups can't span PMUs. + */ + if (!cur_leader) + cur_leader = pos; + + cur_leader_pmu_name = evsel__pmu_name(cur_leader); + if ((cur_leaders_grp != pos->core.leader && !force_grouped) || + strcmp(cur_leader_pmu_name, pos_pmu_name)) { + /* Event is for a different group/PMU than last. */ + cur_leader = pos; + /* + * Remember the leader's group before it is overwritten, + * so that later events match as being in the same + * group. + */ + cur_leaders_grp = pos->core.leader; + } + pos_leader_pmu_name = evsel__pmu_name(pos_leader); + if (strcmp(pos_leader_pmu_name, pos_pmu_name) || force_grouped) { + /* + * Event's PMU differs from its leader's. Groups can't + * span PMUs, so update leader from the group/PMU + * tracker. + */ + evsel__set_leader(pos, cur_leader); + } + } + list_for_each_entry(pos, list, core.node) { + pos->core.leader->nr_members++; + } +} + int __parse_events(struct evlist *evlist, const char *str, struct parse_events_error *err, struct perf_pmu *fake_pmu) { @@ -2266,6 +2256,8 @@ int __parse_events(struct evlist *evlist, const char *str, return -1; } + parse_events__sort_events_and_fix_groups(&parse_state.list); + /* * Add list to the evlist even with errors to allow callers to clean up. */ diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index 428e72eaafcc..22fc11b0bd59 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -200,8 +200,7 @@ int parse_events_copy_term_list(struct list_head *old, enum perf_pmu_event_symbol_type perf_pmu__parse_check(const char *name); -void parse_events__set_leader(char *name, struct list_head *list, - struct parse_events_state *parse_state); +void parse_events__set_leader(char *name, struct list_head *list); void parse_events_update_lists(struct list_head *list_event, struct list_head *list_all); void parse_events_evlist_error(struct parse_events_state *parse_state, diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 541b8dde2063..90d12f2bc8be 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -203,7 +203,7 @@ PE_NAME '{' events '}' inc_group_count(list, _parse_state); /* Takes ownership of $1. */ - parse_events__set_leader($1, list, _parse_state); + parse_events__set_leader($1, list); $$ = list; } | @@ -212,7 +212,7 @@ PE_NAME '{' events '}' struct list_head *list = $2; inc_group_count(list, _parse_state); - parse_events__set_leader(NULL, list, _parse_state); + parse_events__set_leader(NULL, list); $$ = list; } From patchwork Thu Mar 2 04:12:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 63199 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4034763wrd; Wed, 1 Mar 2023 20:20:09 -0800 (PST) X-Google-Smtp-Source: AK7set9NHvJVNnJZgt5Xa+0PZqcVbL1nfstQSlDbRaKcJ+nCMsOyEIW1dyDPKelzDp1JpHVGTAlN X-Received: by 2002:a05:6a20:3d8c:b0:cc:f39:5094 with SMTP id s12-20020a056a203d8c00b000cc0f395094mr10830530pzi.30.1677730809230; Wed, 01 Mar 2023 20:20:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677730809; cv=none; d=google.com; s=arc-20160816; b=o2Vml475c6H0n+yQQMcjQDWRTG2wV0g3GOer++xrQB/oWSRzkYTMUZqeRGnlJb34Wj RdRnYsB1PrVsH8UnpfTxHoO7hd8vmcH+DFtEiz7in+b29LkIe43Qu8WzCEuneU0d6Iv7 wwPdLrS3XK7GZfRUTXWcI7u/+j3FfoxmPbaVBktih7rzls05uzEIijJaK8jOB1wfAbaS dYLl+MJceZmYnSPu839MSFRM0xro1fT0aSzpdciekfJrScUoqocCMQ4SioemWgxX+GZr bwv1CiyfmJ6w8xENenAoeGCovx/tE6X3ZHXbgrs2zZp4cbYwMspY3yESvlN/Qgyygamp UYGQ== 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=edRZozQBIL0WlfafeNLLWxRrsV4anV+EoxBdmB1IrUI=; b=J9sILOwLTEP2WIx6wsMWL16LJI/34RaeLJu+XPxHmzGWoa+Mhjixp9kc4vT2bseEWx bTC2ko4MRCjI9cUZLYtZzHpYmf82VnSUfdArNCdEbOSqzovjx2MOUQnBxP8iVG7WsD3j nJUB2fUS5eZUdkSRb0f9M2cmFwPbRFhFR0g5QaaJcYiEttszrhd4PR5a2D3XWncs+Zbd qmq/rpcjhMFoLuUy5HIsT2QD6zuUIEQ0Z+IL0sLOYgeOysf5iIyabWFG5HrcqpMMjCpM toAykdaBFElCQX5kyYgFPoXH77Bzx+zBbImMpBGWNLt8uyvlcPOOgqrr7hgte2Ay7f5Q jqhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Zgfun8Qg; 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 x129-20020a636387000000b004fcc0120074si14076266pgb.161.2023.03.01.20.19.55; Wed, 01 Mar 2023 20:20:09 -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=Zgfun8Qg; 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 S229943AbjCBEPY (ORCPT + 99 others); Wed, 1 Mar 2023 23:15:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbjCBEOj (ORCPT ); Wed, 1 Mar 2023 23:14:39 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D38614FA88 for ; Wed, 1 Mar 2023 20:14:05 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-536cb268ab8so304722037b3.17 for ; Wed, 01 Mar 2023 20:14:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677730442; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=edRZozQBIL0WlfafeNLLWxRrsV4anV+EoxBdmB1IrUI=; b=Zgfun8QgnPZ+Nr/wCJafylCn0XSjYqgFUdlDHJO5cnTR1+b1ZCQZiYGq9UW8k9FyKS tHG8x2ePXnPC9SgiV4oCVFSB3tf1IcZkl0V6w2y9YNvCzNT/oDDTrh05HwJ5yqenfyS2 D+Ej5lO+Je/Clb4lSWjSPfFhYLb/5/YcAX2xUt0pKvbw3Bsy2PKgzfkVq9agFvrhMjQ4 HLk6X0knBvDkY+Vve+qw4XtKybCGqxpMnEg4/Sp74fd2N0I6ocEs7J0nbhrvVfDzsBm4 qQZ9rWmjhw6JggL/4gIWcTu+Nx3tCkwloMbV1StkBOlhfyllHLDKIbpOGI1IdTuEuzUI Q/uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677730442; 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=edRZozQBIL0WlfafeNLLWxRrsV4anV+EoxBdmB1IrUI=; b=q31gVmziw3SS2DBdhWeA+OQI75sZI9PFPxMlZctjIYWa9envlTOt+c9kCHFF38q1dM UGb1E4sx3A58LGTmYyqH42KfbRlnFkUielY9+7SAsIRUy02k3yn9vgsHmmUr0HtBtG3k R+dggz/3BXC9qPz+oWtMmlQmbh8bVsJ/y2NF0s/R2v6frJjS49xbQ0jQ+Pw3JJttIfRM A3ur+f0cn5XLiJkUGL8UzHHeK8E3z1H2hotFfZJv7TPG4cYQVx1ujLKRoqdIWmsJ0pAc hJaGPrZhB06XEePOSiOcgz1xcs+HTa9qexLV3EbzDMXIF+9WNazhBUqLXjUoZCLLaVlc q+XQ== X-Gm-Message-State: AO0yUKXE88gO26CSvPOMUg48lSOjbWZmuWk5mzQ0QwuV6/Wu8/yvlSgV j6JmgPaKqdrdoRc87PcEN/FYRoPehrVk X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:bdf9:f5cb:d05:c4d5]) (user=irogers job=sendgmr) by 2002:a5b:744:0:b0:914:fc5e:bbec with SMTP id s4-20020a5b0744000000b00914fc5ebbecmr3944683ybq.13.1677730442368; Wed, 01 Mar 2023 20:14:02 -0800 (PST) Date: Wed, 1 Mar 2023 20:12:11 -0800 In-Reply-To: <20230302041211.852330-1-irogers@google.com> Message-Id: <20230302041211.852330-11-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 10/10] perf evsel: Remove use_uncore_alias 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?1759228260859755805?= X-GMAIL-MSGID: =?utf-8?q?1759228260859755805?= This flag used to be used when regrouping uncore events in particular due to wildcard matches. This is now handled by sorting evlist and so the flag is redundant. Signed-off-by: Ian Rogers --- tools/perf/util/evsel.c | 1 - tools/perf/util/evsel.h | 1 - tools/perf/util/parse-events.c | 12 +++--------- tools/perf/util/parse-events.h | 3 +-- tools/perf/util/parse-events.y | 11 +++++++---- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 9c6b486f8bd4..5446128be03b 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -458,7 +458,6 @@ struct evsel *evsel__clone(struct evsel *orig) evsel->per_pkg = orig->per_pkg; evsel->percore = orig->percore; evsel->precise_max = orig->precise_max; - evsel->use_uncore_alias = orig->use_uncore_alias; evsel->is_libpfm_event = orig->is_libpfm_event; evsel->exclude_GH = orig->exclude_GH; diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 72121194d3b1..9a8d08fcad1c 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -89,7 +89,6 @@ struct evsel { bool per_pkg; bool percore; bool precise_max; - bool use_uncore_alias; bool is_libpfm_event; bool auto_merge_stats; bool collect_stat; diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index d6eb0a54dd2d..ac7709c1c5b7 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1445,15 +1445,13 @@ static int parse_events__inside_hybrid_pmu(struct parse_events_state *parse_stat int parse_events_add_pmu(struct parse_events_state *parse_state, struct list_head *list, char *name, struct list_head *head_config, - bool auto_merge_stats, - bool use_alias) + bool auto_merge_stats) { struct perf_event_attr attr; struct perf_pmu_info info; struct perf_pmu *pmu; struct evsel *evsel; struct parse_events_error *err = parse_state->error; - bool use_uncore_alias; LIST_HEAD(config_terms); pmu = parse_state->fake_pmu ?: perf_pmu__find(name); @@ -1488,8 +1486,6 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, memset(&attr, 0, sizeof(attr)); } - use_uncore_alias = (pmu->is_uncore && use_alias); - if (!head_config) { attr.type = pmu->type; evsel = __add_event(list, &parse_state->idx, &attr, @@ -1499,7 +1495,6 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, /*cpu_list=*/NULL); if (evsel) { evsel->pmu_name = name ? strdup(name) : NULL; - evsel->use_uncore_alias = use_uncore_alias; return 0; } else { return -ENOMEM; @@ -1560,7 +1555,6 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, evsel->use_config_name = true; evsel->pmu_name = name ? strdup(name) : NULL; - evsel->use_uncore_alias = use_uncore_alias; evsel->percore = config_term_percore(&evsel->config_terms); if (parse_state->fake_pmu) @@ -1622,7 +1616,7 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state, parse_events_copy_term_list(head, &orig_head); if (!parse_events_add_pmu(parse_state, list, pmu->name, orig_head, - true, true)) { + /*auto_merge_stats=*/true)) { pr_debug("%s -> %s/%s/\n", str, pmu->name, alias->str); ok++; @@ -1634,7 +1628,7 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state, if (parse_state->fake_pmu) { if (!parse_events_add_pmu(parse_state, list, str, head, - true, true)) { + /*auto_merge_stats=*/true)) { pr_debug("%s -> %s/%s/\n", str, "fake_pmu", str); ok++; } diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index 22fc11b0bd59..fdac44dc696b 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -183,8 +183,7 @@ int parse_events_add_breakpoint(struct list_head *list, int *idx, int parse_events_add_pmu(struct parse_events_state *parse_state, struct list_head *list, char *name, struct list_head *head_config, - bool auto_merge_stats, - bool use_alias); + bool auto_merge_stats); struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr, const char *name, const char *metric_id, diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 90d12f2bc8be..f1b153c72d67 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -313,7 +313,7 @@ event_pmu_name opt_pmu_config list = alloc_list(); if (!list) CLEANUP_YYABORT; - if (parse_events_add_pmu(_parse_state, list, $1, $2, false, false)) { + if (parse_events_add_pmu(_parse_state, list, $1, $2, /*auto_merge_stats=*/false)) { struct perf_pmu *pmu = NULL; int ok = 0; @@ -330,8 +330,10 @@ event_pmu_name opt_pmu_config !perf_pmu__match(pattern, pmu->alias_name, $1)) { if (parse_events_copy_term_list(orig_terms, &terms)) CLEANUP_YYABORT; - if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true, false)) + if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, + /*auto_merge_stats=*/true)) { ok++; + } parse_events_terms__delete(terms); } } @@ -407,7 +409,8 @@ PE_PMU_EVENT_FAKE sep_dc if (!list) YYABORT; - err = parse_events_add_pmu(_parse_state, list, $1, NULL, false, false); + err = parse_events_add_pmu(_parse_state, list, $1, /*head_config=*/NULL, + /*auto_merge_stats=*/false); free($1); if (err < 0) { free(list); @@ -425,7 +428,7 @@ PE_PMU_EVENT_FAKE opt_pmu_config if (!list) YYABORT; - err = parse_events_add_pmu(_parse_state, list, $1, $2, false, false); + err = parse_events_add_pmu(_parse_state, list, $1, $2, /*auto_merge_stats=*/false); free($1); parse_events_terms__delete($2); if (err < 0) {