Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7354880rwr; Tue, 2 May 2023 13:25:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5J8FNyEescHZpJoTdbvG/9zK8pgA+hbRwSgEgXo7JdmHhPdqG4UDf8Fdmj4Fm7oFMIp5V3 X-Received: by 2002:a05:6a20:1588:b0:f0:ec64:f3db with SMTP id h8-20020a056a20158800b000f0ec64f3dbmr22265616pzj.24.1683059105208; Tue, 02 May 2023 13:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683059105; cv=none; d=google.com; s=arc-20160816; b=xORnYIkaFNyH44BjaLnDmRWWRDJE5sCCP1+ECs2Xd0iFS3pDKl4Q2UecmL8UUdZqQf Z1kQT1eUD6E8ySfAuzOuStW8umutAOluFsUnK5yoRrWUv1cS6mooysdpH1Fb9ccGASgx crRHxQxTEj7R2AdWACRyL3ij0amQ2ynk7h0fla1zVb+ZdvsSaLPfsfAoBU0FTVxH9rYR LCMTinYqqyg0pvrVUX8icNkajVdyRfsN6dtQYndZqnpcO/8LLEeuWW4QNLFoNP8JEJFE irALLiFo1M12sMxupId0yGGEqJN3DTv3KrUSx2cBmLotb156DN4H8Bp+CN5DZsyfgNRM 9kRw== 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=Rld5ybTKQ6TnPbSfs5BNPMPd6l7llksJVQ7eLenv4TY=; b=yL/y+uook8u3vTnaqW66NYKdECAJzjs4ZWkQ00LUMIzJZQknC/BULHdweuNHztJG/g /zB79f4nT8yy0OUpZnP3ZPTbiqyDf1Sk3zU6JmJYWmEBGLOU0mRh+Ea7d43LqUZz3IPh 8C1I0DXhFAMy7fCHTwVvn2cIvk/1R6Gj5LjtIDkf0IyzGgQDehqwJPaFczQ3vxpoGtOk y1elbeMxZj7DX7QYuVpnLe1nmB0DSV0+pgDMOqK/IV/zba3q8gNwvbRDnPkFbtztWzGZ PXKnm8x6EUJ6TcjHUPO9TaSFVwKCEn7BFzrWamZ9aTTuRGAEUUvwuOZG+AutliR/X1oS UpEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=hcUfAjSF; 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 b5-20020a655785000000b0052856cec950si21765890pgr.113.2023.05.02.13.24.39; Tue, 02 May 2023 13:25:05 -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=hcUfAjSF; 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 S229695AbjEBURG (ORCPT + 99 others); Tue, 2 May 2023 16:17:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjEBURE (ORCPT ); Tue, 2 May 2023 16:17:04 -0400 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B2F21FE3 for ; Tue, 2 May 2023 13:16:50 -0700 (PDT) Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-3311833ba3dso153055ab.0 for ; Tue, 02 May 2023 13:16:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683058610; x=1685650610; 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=Rld5ybTKQ6TnPbSfs5BNPMPd6l7llksJVQ7eLenv4TY=; b=hcUfAjSFSEHsDi5Xg7PaULZGb74SHlouCuI7bp5i8RylqblFX+wGW3P697iZfG42kR jPyF+9wT6l28WsF3+oiqXxX6vJqBt1XJKpqj4pguoZamuJ5rXESZco+UL0Y4vBNWwlu7 jFIPH3/Fqo+dmFIN4aOvn1E4JsjZBmAdX8gpcaYHea4F339SSnJ3WmjLtdV/rJZdP6En HKnvCMP7B1Qdd8Dg0CEsrEV/MHWLWlAw8mG9YpsRK+FSVVGT0g8mMgDu21/kKQGe4nHO ZL2DKN3v2kqOtS/h0A2huEr4QZWRpTiXmIL0Z8jsbOUFO0mIY7bGkIqWh/JUF4UsbXAg 9d0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683058610; x=1685650610; 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=Rld5ybTKQ6TnPbSfs5BNPMPd6l7llksJVQ7eLenv4TY=; b=T7T6jxoFBDhb+ByQQG1zUZuiRn/i1xKFy2ZuiMjijDE4xJsIIy8rfJWzgV18xV/qsz 3HjLEREyF94eFdQH6zdf2rdGtRuUoVG5WTJ0M3WasW3urlESfwNyzVe4lNpKwAdW0tDW AmY5uRp1WbBYGimcNaTHFr/8xw644vR9oo7Du3AwHCyaKLZJDMK4EU4JHme0tX1mUXCp dRAe2YcWorUsU3pzkhxpWFR/tCB9fbHb3c4MSzWRGOK18gcb9CDIN/nHkBh6dmQXClgr el9k8Fkvl6ngc9QXBtPrBUL1wOZXVrCbP/hJWeNeiHuzWNTKTOPbyjplESSJ0tI6AY1o rHwA== X-Gm-Message-State: AC+VfDzSzNASrlblxQuvesX58k3QoA1pdVxdjuD9T+eD8wpvkpDd1IxK 7HpUtFY2xbt3RpOSaMIrMqi2aj02WkFIVseiKcYjbQ== X-Received: by 2002:a05:6e02:1c0e:b0:32f:7703:63bb with SMTP id l14-20020a056e021c0e00b0032f770363bbmr46519ilh.19.1683058609755; Tue, 02 May 2023 13:16:49 -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:16:38 -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=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 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. > > 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. > > 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 > > 3. Also, IMHO, using --cputype option to specify _pmu name_ is bit odd. > > > > > 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 > > > > @@ -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. Ok, these changes are just keeping existing functionality. I don't disagree with making these changes but I think we can follow up with them. Or probably just deprecate the option. > > +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. It is trying to be consistent with the event parser: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/too= ls/perf/util/parse-events.y#n326 where uncore is consumed. Fun fact, as numbers are consumed after a PMU name and the underscore is optional, i915 as a PMU can be matched in parsing with a PMU name of just "i". Thanks, Ian