From patchwork Thu Mar 2 04:12:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 6012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4033069wrd; Wed, 1 Mar 2023 20:14:36 -0800 (PST) X-Google-Smtp-Source: AK7set+O17nxNmdbrP5yWRMcpmsQ0ZiICMHmNsz/ELdARab90e+HfRSoEHUpKKK1Y23rJSMkPL+x X-Received: by 2002:a62:5290:0:b0:5a8:4bf8:1752 with SMTP id g138-20020a625290000000b005a84bf81752mr6557023pfb.32.1677730476522; Wed, 01 Mar 2023 20:14:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677730476; cv=none; d=google.com; s=arc-20160816; b=H9FeX7GwBDqgLIBa0l9zN7SG6ExB1d48PYF5+Yqdu7QwhA3IrwqXwAE1shbJg7dprr AA9+3GzjBktGgVStDXSQ+I5PynNqbcniG59TmWJ0kfCHPqFIjt1x7a9tDmYZoluhrXRc 4NxNl8D/C6D2QY8w497gJcQ601MENXLiCMG9cPWCiLzSQU+oB77vTHtcQcsRKnBF3uAQ 2wFlHRKf42RG8NeOU5OBY4n270JW5hocs3dYobjy4lr+Vk+US7PBfRSDQ9mBBDsBqDgi LxJL9W5rIY9TABtBH2i+PFnyM2v1JqJrPXZQe5nLtub+IobjXAy3bgLamsXrmraL37nw Kk3g== 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:mime-version:message-id:date :dkim-signature; bh=9LAF/AgK1HRYrzi87aj0ZroDBvPnZklwy00LEUIfbuo=; b=ZQtZ6/GMFaAXzffuiafd3scbqRTRzfoIn2g8JH3B5uRr9cvgKb/h78RModvAjkU3lP JBmtYBdbeoXH3jexBZ9DXFn/ViERE1tz/IIbelTYHwI8JhMXfDvqptp2lIoPC9YCke/+ K6f8y6Yoj7jY97s3E/cuACOd3v4DWJrqZUP4NEk5PH1R5cacw+8ypgTD9V7+Zhzhr13f Pqu18KYg9o4smyQ/uwfLEdkWxsg7AURocXqZ1ojt7ukx6n5A6cW7nKNLTQLMlJbmjqCC 5LzQbA4x4v2D0ey8VmVXbX6Yrpx3EarFgTda/2kZYxcmVRQ20VUb9EJLo8N9HtFVf4GG KeXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=CPfp8goI; 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 w126-20020a623084000000b005a8c65d57a0si13172209pfw.257.2023.03.01.20.14.23; Wed, 01 Mar 2023 20:14:36 -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=CPfp8goI; 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 S229470AbjCBEMk (ORCPT + 99 others); Wed, 1 Mar 2023 23:12:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjCBEMi (ORCPT ); Wed, 1 Mar 2023 23:12:38 -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 0DC6444A4 for ; Wed, 1 Mar 2023 20:12:37 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id o3-20020a257303000000b00a131264017aso2814072ybc.20 for ; Wed, 01 Mar 2023 20:12:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677730356; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=9LAF/AgK1HRYrzi87aj0ZroDBvPnZklwy00LEUIfbuo=; b=CPfp8goIzicDcS9LgF3shufrgSj4gAVtdqdQCkjveYkYtd+xXUW+MJN1gUC6qCnokc dP2+dLPHZzpcAhqmyCXrs+xxDsCscpum0pL8YvQPgdmHg39/KqCrdL+ioIV2nfASnBom xFPsZxfRSH5T2O4DJXDWqANz7sD2FvuWUZRmb/EBXTwIWIflLLJCu0Zuz29s6qRGmHeT aMVVtMkuxHYaXQR0GXY7bKELBtXj/GSGddlEn9Ci60/AAsZ9N0hyIDlQap3yMp2tgDWF 2FAT03oYpxxWd1cU1lrNJFotT/4srvQkpLyyZ5gdruq9Uu6ulMtFB4ltT5zPBe6y9JMk LpWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677730356; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=9LAF/AgK1HRYrzi87aj0ZroDBvPnZklwy00LEUIfbuo=; b=dA6wmPw43pSXOdBPHa5Bj6cppm6bVTuifUn0udpWweqln6J8N4953MzILtwu/1cnlb I0120DscI6pu+dqZ8H/Elia6Zc/kFdnlFK7cG7sTXhQdBw2Oxm8Zy2IbemLpFfaQqk3l mF6CQ3taGua7+bJ2+1s+T+rzfoN+hP6ORzcjWzMTjGLLtCv+U5qixkgbaJkcptQ4eMyZ /JesJ8lye+9bMIuSrosAlFM/gXf3u5jas91BGEsrk+5yMKEp+l9bcWCbZM4XPWItGD6t cWNvpBJCx5V9c5z2f+zt3NVMb8wu+IuqS17oe7VeYOKnsvEOClHZPMpK2QnA0NxvOZUH sbbw== X-Gm-Message-State: AO0yUKXr7AdYxoXjR1VjRfVyPVJ39e7s+t+dOToueWfg4j2WpveXlXrQ 9rysMjWxLzmnmyH9IbMtG0919VgbEFJ+ X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:bdf9:f5cb:d05:c4d5]) (user=irogers job=sendgmr) by 2002:a81:ac61:0:b0:53c:7047:14c4 with SMTP id z33-20020a81ac61000000b0053c704714c4mr2497162ywj.8.1677730356300; Wed, 01 Mar 2023 20:12:36 -0800 (PST) Date: Wed, 1 Mar 2023 20:12:01 -0800 Message-Id: <20230302041211.852330-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.39.2.722.g9855ee24e9-goog Subject: [PATCH v1 00/10] Better fixes for grouping of 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?1759227911691523937?= X-GMAIL-MSGID: =?utf-8?q?1759227911691523937?= The rules for grouping events has grown more complex. Topdown events must be grouped, but flags like --metric-no-group and flags on metrics don't respect this. Uncore events may be expanded using wild cards for PMU names, but then the events need reordering so the group members are adjacent. Rather than fixing metrics, this change fixes the main event parsing code to first sort and then regroup evsels. As this is shared functionality changes to it should cause concern. The change is done with the intent of simplifying and making more robust the grouping logic, examples are given. If additional changes are necessary, they are most likely necessary to the evsel__pmu_name logic as the code avoids breaking groups that are on the same PMU. The pmu_name is tweaked in the case of software and aux events, that use groups in a slightly different manner to conventional events. The code was manually tested as well as passing perf test on a Intel tigerlake CPU with intel-pt. Ian Rogers (10): libperf evlist: Avoid a use of evsel idx perf stat: Don't remove all grouped events when CPU maps disagree perf record: Early auxtrace initialization before event parsing perf stat: Modify the group test perf evsel: Limit in group test to CPUs perf evsel: Allow const evsel for certain accesses perf evsel: Add function to compute pmu_name perf parse-events: Pass ownership of the group name perf parse-events: Sort and group parsed events perf evsel: Remove use_uncore_alias tools/lib/perf/evlist.c | 13 +- tools/perf/arch/x86/util/auxtrace.c | 17 +- tools/perf/arch/x86/util/evlist.c | 39 ++--- tools/perf/arch/x86/util/evsel.c | 3 + tools/perf/builtin-record.c | 6 + tools/perf/builtin-stat.c | 24 ++- tools/perf/util/auxtrace.h | 2 + tools/perf/util/evlist.h | 2 +- tools/perf/util/evsel.c | 27 ++- tools/perf/util/evsel.h | 8 +- tools/perf/util/parse-events.c | 253 +++++++++++++--------------- tools/perf/util/parse-events.h | 6 +- tools/perf/util/parse-events.y | 17 +- tools/perf/util/pmu.c | 6 +- tools/perf/util/python.c | 2 +- tools/perf/util/stat-shadow.c | 2 +- 16 files changed, 228 insertions(+), 199 deletions(-)