Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7340858rwr; Tue, 2 May 2023 13:10:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6F7EUxUjubWfTRzzyI1HrBMNfXirUPgIfsqCMW10UTqvBIYS590Qdo32ZGFUw810W58lVB X-Received: by 2002:a17:902:dac6:b0:1aa:f3c4:74ea with SMTP id q6-20020a170902dac600b001aaf3c474eamr8524477plx.53.1683058217992; Tue, 02 May 2023 13:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683058217; cv=none; d=google.com; s=arc-20160816; b=FF4hq8GHIxuAjlyygurdLojFwUqzySkxJQA72PbZpDAfkgIGdB5IXUO4Pe1Xtnb+QX 49PsYJXak4pgpM0T+hHm4e+/Q4+YUnzj2uTwKv2/87XnUWAe8Xr4kR3B2d4zglFt68jN LvhbGMVDbJxYJDbkwDrPe7W2FbSfCq2mh5VTNJjykMpyan4G+uX5le9FgGxJoohyx6vC Xj3c6E3yqrEMBbsRFAjxCQCT3PRQxGCVP3LkHrM5u4MGRx0KKryhEMhsgYp9CqQ/FUJy aquK9GQYTxA+c7Wzun49b3HmvWR1f4bEjM0iPULdswEdpU6OZHnID8bqW3uw/yPc9VbH 5hIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=813DkMObVqAM93FFVGWHCCH8FioK14LS5zdDr6BTj+E=; b=Wp0GE9wR8pNLeijpBWBngTI8A3mnZjcaEdC2sMAYcRuIgIT+yvDK28FGe8+ZmzrW6I L48Z+eWOzEbeN+6Lr9Dd6mpBUlLQ1EyWPVIgFr1AHxF60YExnjVqJ37+EM2aoMnPgK2I 0Q41Y2SOvFLBAtjC8B6YyLh1xPJFDCgBdb0TkulCmUBJywpQJTPYp31vRs0NtiXRV5Hf GgkVmvHeL7C7wrqP4D8PmkaAYTYxMoLzp7EBpU+FQ5z8Fy2pnN4JLAEPD95hjT+F2tsK IgrqEJ3slV3whqomWdVCT4qIjKQpOLUaef4Bn4nq4kLvd/j4pF8GNZgw5vQUxbeYd7cl fQdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=cVkde0VG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y17-20020a17090322d100b001a654cdcce0si29759170plg.103.2023.05.02.13.10.01; Tue, 02 May 2023 13:10:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=cVkde0VG; 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 S229870AbjEBUJ4 (ORCPT + 99 others); Tue, 2 May 2023 16:09:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbjEBUJy (ORCPT ); Tue, 2 May 2023 16:09:54 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A188D19B3 for ; Tue, 2 May 2023 13:09:52 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-32f4e0f42a7so151765ab.1 for ; Tue, 02 May 2023 13:09:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683058192; x=1685650192; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=813DkMObVqAM93FFVGWHCCH8FioK14LS5zdDr6BTj+E=; b=cVkde0VGivBrUYaejgu8ZwEzjZzdCv8XscNE1zxihTCtyTI0zFWw8/OzNlS0Dbu058 8BSnSbUjxGlo4P4lSdJNtMpVbjB0Zca3vycKWBz1Lox9WKh507yA9cXnJoPPuvWSMex7 ELj16xq6hCgMI56ZdU500t4N8smU+oyF5JU/s9vyaHNAwO1jsyfaMxY6W4oRFTv69wUw aLbFp/jFV12V2f1mgpHKBsj/JEO02gssz9BKxoDp6rBx85vOtY46KlKw/AkpdPAVkVC2 T2aGL096XyISN13XS+SWE489dZb0hrteWMumdXlsk/NdU8GB5eeQkCnMrQ5M73Q6KERf cZmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683058192; x=1685650192; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=813DkMObVqAM93FFVGWHCCH8FioK14LS5zdDr6BTj+E=; b=LQ7NEQa/X/3584r2IJH4Plou6i09Ps7Cn9RQCUm27IoT5dYLDphSvP8QRL6C8gOfLv xIrjiZxVFQUOYnRP1nbr4tsTf3h/pVI1NP36WQ1cSuNU8KvS2rmqTmsrjYfHvnlK4Jx1 4qczZrEI6zYiFD4fFc33xH3s+S/sQ8MbIzDtRMw1KY8o4LQRlDRPudGALJZXeuxt4RgN QcyBYwi+M4R/WQNmHPTHnKWV9oBL9Sb51C/JW0hEyXwF59WIQlqtWaKnmMVY17+wORV8 S8GlJ4rDf+eBfobPnNfcqIG8/vo2Oo2zTgprl9VR1a562ziY10O+MJPh/dGxvXEiKKOA NiVQ== X-Gm-Message-State: AC+VfDzpVr69VGLsI1mZh8FDp5d8PJ/3xTZDy5fmR3xOZYUTanFILWir Omut3zojx3ALQJnC92GLiSibVUFdOqGT2LHuUqp01g== X-Received: by 2002:a05:6e02:1aa7:b0:32f:7715:4482 with SMTP id l7-20020a056e021aa700b0032f77154482mr74904ilv.4.1683058191787; Tue, 02 May 2023 13:09:51 -0700 (PDT) MIME-Version: 1.0 References: <20230429053506.1962559-1-irogers@google.com> <20230429053506.1962559-33-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Tue, 2 May 2023 13:09:40 -0700 Message-ID: Subject: Re: [PATCH v3 32/46] perf stat: Make cputype filter generic To: Ravi Bangoria Cc: Arnaldo Carvalho de Melo , Kan Liang , Ahmad Yasin , Peter Zijlstra , Ingo Molnar , Stephane Eranian , Andi Kleen , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Florian Fischer , Rob Herring , Zhengjun Xing , John Garry , Kajol Jain , Sumanth Korikkar , Thomas Richter , Tiezhu Yang , Leo Yan , Yang Jihong , James Clark , Suzuki Poulouse , Kang Minchul , Athira Rajeev , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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 On Tue, May 2, 2023 at 3:52=E2=80=AFAM Ravi Bangoria wrote: > > On 29-Apr-23 11:04 AM, Ian Rogers wrote: > > Rather than limit the --cputype argument for "perf list" and "perf > > stat" to hybrid PMUs of just cpu_atom and cpu_core, allow any PMU. > > I've couple of doubts: > > 1. Can you please explain intention to do this esp for perf list. Since, = IIUC, > `perf list --unit` option provide the same functionality. I agree with you. The option already exists and I think we should just move this option to being deprecated/hidden: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/too= ls/lib/subcmd/parse-options.h#n46 > 2. Since we are already specifying pmu name for non-standerd/arch-specifi= c > events like `pmu/attributes/`, I'm not sure where `perf stat --cputype= =3Dpmu` > is useful. Can you please explain perf stat usability aspect for non-h= ybrid > pmus. Completely agreed. This patch series is trying to remove the duplicated code introduced by the hybrid changes. In this case I didn't want to remove an option, and potentially break users of that option, as part of fixing things up. A lot of what you are saying here I added as comments to the original patch series. > 3. What am I missing here: > > $ sudo ./perf stat --cputype=3Damd_df -e amd_l3/event=3D0x4,umask=3D0x= ff/ -C 0 -- sleep 1 > Performance counter stats for 'CPU(s) 0': > > 108,267 amd_l3/event=3D0x4,umask=3D0xff/ > > 1.061290167 seconds time elapsed The cputype applies to wildcard-ed events. So on hybrid: $ perf stat -e cycles true will open cycles on cpu_atom and cpu_core, the parse_events__filter_pmu function is used skip PMUs based on cputype. > 3. Also, IMHO, using --cputype option to specify _pmu name_ is bit odd. Right, when the "feature" was added I would have preferred it as PMU rather than CPU. > > > > Note, that if cpu_atom isn't mounted but a filter of cpu_atom is > > requested, then this will now fail. As such a filter would never > > succeed, no events can come from that unmounted PMU, then this > > behavior could never have been useful and failing is clearer. > > I'm hitting a segfault if I use non-existing pmu: > > $ sudo ./perf list --cputype=3Drandom > WARNING: cputype is not supported! > Segmentation fault Will fix in v4. The warning should be fatal/exit rather than try to read the PMU's name. Thanks, Ian > > @@ -443,8 +443,8 @@ int cmd_list(int argc, const char **argv) > > "Print information on the perf event names an= d expressions used internally by events."), > > OPT_BOOLEAN(0, "deprecated", &default_ps.deprecated, > > "Print deprecated events."), > > - OPT_STRING(0, "cputype", &hybrid_name, "hybrid cpu type", > > - "Limit PMU or metric printing to the given hyb= rid PMU (e.g. core or atom)."), > > + OPT_STRING(0, "cputype", &cputype, "cpu type", > > + "Limit PMU or metric printing to the given PMU= (e.g. cpu, core or atom)."), > > man perf-list does not describe --cputype. I think we should add it as pa= rt > of this patch? > > Similarly, man perf-stat also needs to be updated. > > > > +const struct perf_pmu *perf_pmus__pmu_for_pmu_filter(const char *str) > > +{ > > + struct perf_pmu *pmu =3D NULL; > > + > > + while ((pmu =3D perf_pmu__scan(pmu)) !=3D NULL) { > > + if (!strcmp(pmu->name, str)) > > + return pmu; > > + /* Ignore "uncore_" prefix. */ > > + if (!strncmp(pmu->name, "uncore_", 7)) { > > + if (!strcmp(pmu->name + 7, str)) > > + return pmu; > > Any specific reason to ignore "uncore_"? IMHO, ignoring prefix of some > pmus and not of others is bit confusing for naive user.