Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp44984rdd; Wed, 22 Nov 2023 09:02:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtg0QXYrmfCrNSVoGsZUisWOw9Fgv6v77SE08UOABlDmjrPnqLiiWXtf2fzC1Xp1euYl11 X-Received: by 2002:a17:90b:b01:b0:282:e10b:34b6 with SMTP id bf1-20020a17090b0b0100b00282e10b34b6mr2754797pjb.39.1700672533004; Wed, 22 Nov 2023 09:02:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700672532; cv=none; d=google.com; s=arc-20160816; b=vvEqFiLMdcYEGa6vyRZy50EO6HXxkvf0KlTuHSGTp2s6mdszPi63WpJJSWIDeaIX15 VuP7ZQ75slCZTAPQ68ayAVYRkv05gDo08rdfmihoVaOMKNyGbou607np39u0Q+ZZHDB+ vCwNP8WjPnOZ2cj3uaFlJY2LX2G7Gbiv8+u7exMmngt51wHKlZXaCVAjonqMn3AtjCys G2KS9/oI83CBx1gbwLY7YMrvjvZYmNlVRs5d6yRC/la68wBLQzfHuzFTStnNPkxazZV7 ialbmRTtq+r+Lqavk/p0vMONZ/DC8VVIiTrfRhIHO5jpXM+Wnb4bGcvYwTVbi8SBQ3jV mZcQ== 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=Q2ZTg1sahQKBI/4w3s7AGEAAD0RXpuVE+lN1wQkXOvg=; fh=oh7jGrzTHzMG0Hxcwsa5vF70ZSCilhRru5PgkuvY7l0=; b=HHKY+bi25fo5cGIYNRu0As8rkSFjuMPTSZTPALxBMA31tGi7pbZIYn/qYz0Qsfa/7o RPeD67mQ+mozLdshWSPjbard/uCgCEAI3ZeykFIonTJiemirxt3Lpaer4YQAYvftC5Pa B6TRrAyv1Ee3qX4QvvZ8IIL8k72q43Z3Cy4ycl9UxkrWc00cnNvzYJWojGhJunqI2JEc VJ+nup50edCAb3zQV0bFPA7fbQlWuvWcKSVd5tLtzJIqj/Y9cssFeoJnN4TXSRPQuCFu 8UgvwWGgBbE/PEEpw1MyiO4+2LAbbXHH9duFkINW5iEBZTI1bVLDR+hrOcPCkSvYr0qC 2PgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PMxbLrux; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id x8-20020a17090aca0800b0027d60ad5caesi13232pjt.110.2023.11.22.09.02.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 09:02:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PMxbLrux; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2507F806157D; Wed, 22 Nov 2023 09:00:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343647AbjKVQ74 (ORCPT + 99 others); Wed, 22 Nov 2023 11:59:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232077AbjKVQ7y (ORCPT ); Wed, 22 Nov 2023 11:59:54 -0500 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E8801B8 for ; Wed, 22 Nov 2023 08:59:46 -0800 (PST) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-50aba9b8955so3981e87.1 for ; Wed, 22 Nov 2023 08:59:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700672384; x=1701277184; darn=vger.kernel.org; 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=Q2ZTg1sahQKBI/4w3s7AGEAAD0RXpuVE+lN1wQkXOvg=; b=PMxbLruxU9KyLYEBwOFoMcMkY8wwZSmAXsGycjsRxdPh4FzHPTbegXylzv4PsqOfzI 13mgNiWMbONGmQbXV9s+v3rvHNwldZNMB5fU27B2025gOknXZcZAGATstPMJzyjftDFI YP2MjKKsbAzr+ImpyxdICGpx18EdQWotzOeh1OmWlGqAJ+jAR5eOtcjg/qEi0ciYq7f+ FpraJNPNGoDuqFrSZsAgGCWXJy5wm8UHosjTlL3JacN8YDv/4369t7quXR2gTTErNIQo KOKK15Y0SDgwcysFcnFHzmSR69w/HNduadXimZVKJJBwIUWa2Q+CtdJEpm9tqsiSG1IC 47yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700672384; x=1701277184; 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=Q2ZTg1sahQKBI/4w3s7AGEAAD0RXpuVE+lN1wQkXOvg=; b=fd/cpgYX+8rV0vKQOwJo+j7gopNlFlBCuFTxHBawYu7i0xreOx1urBxa35CmB4C4sC /seqkuS8HXPDkGuvaTUtnJkUA88pXv0fspXoz414rtl7FHUYxZMh4lTLyELAZBr4IOhw CwFaXYpNOOVe98GXgyrP6AUMM24ytme6zEhcHXZxQA6VhGEXr0o6iWX5ZjNYCSY8Z9mP I6BRGe4jFiWrxjaTlMPVri/ZHJrg2o9kyHdu96JxvMJ0O4Aq35rLV+y7CRxbVTUg7lA0 Em52mJyOog1o2WTpt53/HWgZPZ0RzpveysN3zrM8W9aJopMi8VxtQVzbnsBDnmplzW5F FWrQ== X-Gm-Message-State: AOJu0YxRvmaesZwsMSY2KidAonoadZtzVgB0Ez5hX/KpltBe8W5etyQ3 +eIzB7G9zKv/qQk1dI97NKFmT8DbMsdVIxdKrPqOjQ== X-Received: by 2002:a05:6512:1585:b0:50a:519d:5a8a with SMTP id bp5-20020a056512158500b0050a519d5a8amr80736lfb.5.1700672384173; Wed, 22 Nov 2023 08:59:44 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Ian Rogers Date: Wed, 22 Nov 2023 08:59:32 -0800 Message-ID: Subject: Re: [REGRESSION] Perf (userspace) broken on big.LITTLE systems since v6.5 To: Arnaldo Carvalho de Melo Cc: Mark Rutland , Marc Zyngier , Hector Martin , Arnaldo Carvalho de Melo , James Clark , linux-perf-users@vger.kernel.org, LKML , Asahi Linux Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 22 Nov 2023 09:00:24 -0800 (PST) On Wed, Nov 22, 2023 at 8:55=E2=80=AFAM Arnaldo Carvalho de Melo wrote: > > Em Wed, Nov 22, 2023 at 08:29:58AM -0800, Ian Rogers escreveu: > > I can look at doing an event parser change like: > > > > ``` > > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-eve= nts.c > > index aa2f5c6fc7fc..9a18fda525d2 100644 > > --- a/tools/perf/util/parse-events.c > > +++ b/tools/perf/util/parse-events.c > > @@ -986,7 +986,8 @@ static int config_term_pmu(struct perf_event_attr *= attr, > > err_str, > > /*help=3D*/NULL); > > return -EINVAL; > > } > > - if (perf_pmu__supports_legacy_cache(pmu)) { > > + if (perf_pmu__supports_legacy_cache(pmu) && > > + !perf_pmu__have_event(pmu, term->val.str)) { > > attr->type =3D PERF_TYPE_HW_CACHE; > > return > > parse_events__decode_legacy_cache(term->config, pmu->type, > > &attr->= config); > > @@ -1004,10 +1005,15 @@ static int config_term_pmu(struct perf_event_at= tr *attr, > > err_str, > > /*help=3D*/NULL); > > return -EINVAL; > > } > > - attr->type =3D PERF_TYPE_HARDWARE; > > - attr->config =3D term->val.num; > > - if (perf_pmus__supports_extended_type()) > > - attr->config |=3D (__u64)pmu->type << PERF_PMU_= TYPE_SHIFT; > > + if (perf_pmu__have_event(pmu, term->val.str)) { > > + /* If the PMU has a sysfs or json event prefer > > it over legacy. ARM requires this. */ > > + term->term_type =3D PARSE_EVENTS__TERM_TYPE_USE= R; > > + } else { > > + attr->type =3D PERF_TYPE_HARDWARE; > > + attr->config =3D term->val.num; > > + if (perf_pmus__supports_extended_type()) > > + attr->config |=3D (__u64)pmu->type << > > PERF_PMU_TYPE_SHIFT; > > + } > > return 0; > > } > > if (term->type_term =3D=3D PARSE_EVENTS__TERM_TYPE_USER || > > ``` > > (note: this is incomplete as term->val.str isn't populated for > > PARSE_EVENTS__TERM_TYPE_HARDWARE) > > Yeah, I had to apply manually as your MUA mangled it, then it didn't > build, had to remove some consts, then there was a struct member > mistake, after all fixed I get to the patch below, but it now segfaults, > probably what you mention... > > root@roc-rk3399-pc:~# strace -e perf_event_open taskset -c 4,5 perf stat = -v -e cycles,armv8_cortex_a53/cycles/,armv8_cortex_a72/cycles/ echo > Using CPUID 0x00000000410fd082 > perf_event_open({type=3DPERF_TYPE_HARDWARE, size=3D0 /* PERF_ATTR_SIZE_??= ? */, config=3D0x7<<32|PERF_COUNT_HW_CPU_CYCLES, sample_period=3D0, sample_= type=3D0, read_format=3D0, disabled=3D1, precise_ip=3D0 /* arbitrary skid *= /, ...}, 0, -1, -1, PERF_FLAG_FD_CLOEXEC) =3D -1 ENOENT (No such file or di= rectory) > --- SIGSEGV {si_signo=3DSIGSEGV, si_code=3DSEGV_MAPERR, si_addr=3DNULL} -= -- > +++ killed by SIGSEGV +++ > Segmentation fault > root@roc-rk3399-pc:~# Right, I have something further along that fails tests. I'll try to send out an RFC today, but given the Intel behavior change =C2=AF\_(=E3=83= =84)_/=C2=AF But Intel don't appear to have an issue having two things called, for example, cycles and them both being a cycles event so they may not care. It is only ARM's PMUs that appear broken in this way. Thanks, Ian > - Arnaldo > > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-event= s.c > index aa2f5c6fc7fc..1e648454cc49 100644 > --- a/tools/perf/util/parse-events.c > +++ b/tools/perf/util/parse-events.c > @@ -976,7 +976,7 @@ static int config_term_pmu(struct perf_event_attr *at= tr, > struct parse_events_error *err) > { > if (term->type_term =3D=3D PARSE_EVENTS__TERM_TYPE_LEGACY_CACHE) = { > - const struct perf_pmu *pmu =3D perf_pmus__find_by_type(at= tr->type); > + struct perf_pmu *pmu =3D perf_pmus__find_by_type(attr->ty= pe); > > if (!pmu) { > char *err_str; > @@ -986,7 +986,8 @@ static int config_term_pmu(struct perf_event_attr *at= tr, > err_str, /*hel= p=3D*/NULL); > return -EINVAL; > } > - if (perf_pmu__supports_legacy_cache(pmu)) { > + if (perf_pmu__supports_legacy_cache(pmu) && > + !perf_pmu__have_event(pmu, term->val.str)) { > attr->type =3D PERF_TYPE_HW_CACHE; > return parse_events__decode_legacy_cache(term->co= nfig, pmu->type, > &attr->c= onfig); > @@ -994,7 +995,7 @@ static int config_term_pmu(struct perf_event_attr *at= tr, > term->type_term =3D PARSE_EVENTS__TERM_TYPE_USER; > } > if (term->type_term =3D=3D PARSE_EVENTS__TERM_TYPE_HARDWARE) { > - const struct perf_pmu *pmu =3D perf_pmus__find_by_type(at= tr->type); > + struct perf_pmu *pmu =3D perf_pmus__find_by_type(attr->ty= pe); > > if (!pmu) { > char *err_str; > @@ -1004,10 +1005,15 @@ static int config_term_pmu(struct perf_event_attr= *attr, > err_str, /*hel= p=3D*/NULL); > return -EINVAL; > } > - attr->type =3D PERF_TYPE_HARDWARE; > - attr->config =3D term->val.num; > - if (perf_pmus__supports_extended_type()) > - attr->config |=3D (__u64)pmu->type << PERF_PMU_TY= PE_SHIFT; > + if (perf_pmu__have_event(pmu, term->val.str)) { > + /* If the PMU has a sysfs or JSON event prefer it= over legacy. ARM requires this. */ > + term->type_term =3D PARSE_EVENTS__TERM_TYPE_USER; > + } else { > + attr->type =3D PERF_TYPE_HARDWARE; > + attr->config =3D term->val.num; > + if (perf_pmus__supports_extended_type()) > + attr->config |=3D (__u64)pmu->type << PERF_PM= U_TYPE_SHIFT; > + } > return 0; > } > if (term->type_term =3D=3D PARSE_EVENTS__TERM_TYPE_USER ||