Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1178130rwr; Thu, 27 Apr 2023 13:36:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7lNDXz5HfctGXlWj0vVZkz5VD+aeiB2y3yYWF1F7k36yAcFvIoIi/Ju0TdwvbW0CRvVlHb X-Received: by 2002:a17:902:e191:b0:1a9:8ae7:366a with SMTP id y17-20020a170902e19100b001a98ae7366amr2311901pla.65.1682627773766; Thu, 27 Apr 2023 13:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682627773; cv=none; d=google.com; s=arc-20160816; b=tH9IZ/Oaoiv+yJhgskCfP9s81S5PSMYGksCrhUuKPKpYLCystRXeN25A+5YY7Ibw6N 23se9FlMdhiLEuc7c02Sl8DrdVbnu6KxQC2jM2KHOEuz0WJ1AMLQ4bDx++nA45ehjj8w 0w1NANplY+WQ+bDizjIj0h06YpdAcw2nt7Lnoyw3Z6qJJJnHoRAOwGK9lO8+h3sMu9xI pRZsA5fsIK9UQPQ5P8Nb2t6yTzmUqXrnWVAjcl8rVd8zy6ztKOQQz545SzahEOK6+uFy TQAGCbkHJVjLMvkiewZ7ONOZ5SOUTZQa/R+bFmn2Xu10CtO5rKBJ2bpIoYtNozKUBX4F c7nw== 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=Kj7mX16UBRhDPmlEut7HTPAM0sSWs+YXki+LAoqIX7E=; b=LtpvnFj0RzMSjk3pHMI94MfAzCdtaka/jm5tvi49xA5NRzwrF6PgL6vRjGkOhtdxib 5onGMAB9EkV12pIJqliqh9RSMgWOvVqcdf2ztZEUzuIlr/4wMMAa5xqdOcNqaJWd68XM 6926xBxar0s1j5rf5cdFpHnesuzkRh4/8LjgBzP7hdqv5W+bOpi2ujJWHa720UJ2bJvv AadTnu44ntz8Iw/h9f3UVrWMZcbdMtgmT+DgAat7owZrDTWZ5oN4KmllUQMWT5adtOsT bzP4FnRv8wzqV0SOaZ+h8X8+j7GXVw4mSG2KoePrs35l3gV6Eerxm53LtkmXuYPit9eY Wuow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="eH6ewRn/"; 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 bt3-20020a17090af00300b0023b4483a784si21661768pjb.161.2023.04.27.13.36.00; Thu, 27 Apr 2023 13:36:13 -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="eH6ewRn/"; 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 S1344177AbjD0UYG (ORCPT + 99 others); Thu, 27 Apr 2023 16:24:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344215AbjD0UYE (ORCPT ); Thu, 27 Apr 2023 16:24:04 -0400 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20C421993 for ; Thu, 27 Apr 2023 13:24:03 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-3ef36d814a5so819221cf.0 for ; Thu, 27 Apr 2023 13:24:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682627042; x=1685219042; 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=Kj7mX16UBRhDPmlEut7HTPAM0sSWs+YXki+LAoqIX7E=; b=eH6ewRn/ILP8n0TExs59jAIZxX3LCQuqiOcdy7Dbt+tZz5+ZmwCbUnOko+nhlAKVXB q7q2l6L1LCvxAWB2/EFwnezw7LT2+I8YTCobv7bXDpaAsnVknK4NYWhf/zBs3/hkrIHG WgBw4G9e8cuFDI2qs4w0wy9mmuvJckNWZ4zhHTOvX9DNAbcb0jim2q1chLm0Pffpue0E Qukx+por2CiLdJDMGglqJSOUdiyjfOfEt8XXRsbfsHIM5wzUa6Tp7qp4k7V/34nEYEpg U9w1D5oKEtnuXA1AXNbZsfyuPbE4Ye29qpNr0p5ooMs1lAqEMWo3An5I8daYEis8gjDi 9bHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682627042; x=1685219042; 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=Kj7mX16UBRhDPmlEut7HTPAM0sSWs+YXki+LAoqIX7E=; b=Tg+gG5uTpiRpG8QSELHgu4PT+S7iB2bppaqg0uPXv5Ae/Jot8JdKgwG7GI6RxvlvMH CXW34w4rzghNVUIov2UhhSlr1oZwgULm6tzp9pPOgzCt82FwwoBntbFViI93bC5s8uDK bvKaRJPBju2hDsj3lfbrubP4Tsg5tqTMCBC/yjegXZHvrWcLhSTINjLTcCd4CRrdD9Vt WnVEz5bQTe3FMd7kzvISgGt2lQ2XhLaauMgZcTimwBW+FURXM0vB6FzQq/iwCf2CAcdh JX5DXhif0b1BcFK85cgLuq6FlAQhlzL/RMgxHVAzTQfeZtiO9oS4KbvbGpNHySNCzitY smEg== X-Gm-Message-State: AC+VfDyTtBT4NExPh99sR6s2rp7fmUSQVmT8lp76iEqgwtPcmcKvBooB 7OWg09Q6vSSoZ0uUy5HtiRUITPFafOYygOu+lE2FaA== X-Received: by 2002:a05:622a:198b:b0:3f1:7f39:593b with SMTP id u11-20020a05622a198b00b003f17f39593bmr63203qtc.13.1682627041908; Thu, 27 Apr 2023 13:24:01 -0700 (PDT) MIME-Version: 1.0 References: <20230426070050.1315519-1-irogers@google.com> <20230426070050.1315519-9-irogers@google.com> <05b7b1cf-0b77-0e0f-8d02-1c26016fa7d8@linux.intel.com> In-Reply-To: <05b7b1cf-0b77-0e0f-8d02-1c26016fa7d8@linux.intel.com> From: Ian Rogers Date: Thu, 27 Apr 2023 13:23:50 -0700 Message-ID: Subject: Re: [PATCH v1 08/40] perf test: Test more sysfs events To: "Liang, Kan" Cc: Arnaldo Carvalho de Melo , 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 , Ravi Bangoria , 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 Thu, Apr 27, 2023 at 12:39=E2=80=AFPM Liang, Kan wrote: > > > > On 2023-04-26 3:00 a.m., Ian Rogers wrote: > > Parse events for all PMUs, and not just cpu, in test "Parsing of all > > PMU events from sysfs". > > > > Signed-off-by: Ian Rogers > > Run the test on Cascade Lake and Alder Lake. It looks good. > > Tested-by: Kan Liang Arnaldo found an issue (strchr with an uninitialized value) that I have a fix for in v2 of this. The bug got introduced by trying to separate out the hybrid from the not hybrid changes. Thanks, Ian > Thanks, > Kan > > --- > > tools/perf/tests/parse-events.c | 103 +++++++++++++++++--------------- > > 1 file changed, 55 insertions(+), 48 deletions(-) > > > > diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-e= vents.c > > index 8068cfd89b84..385bbbc4a409 100644 > > --- a/tools/perf/tests/parse-events.c > > +++ b/tools/perf/tests/parse-events.c > > @@ -7,6 +7,7 @@ > > #include "debug.h" > > #include "pmu.h" > > #include "pmu-hybrid.h" > > +#include "pmus.h" > > #include > > #include > > #include "fncache.h" > > @@ -2225,49 +2226,24 @@ static int test_pmu(void) > > > > static int test__pmu_events(struct test_suite *test __maybe_unused, in= t subtest __maybe_unused) > > { > > - struct stat st; > > - char path[PATH_MAX]; > > - struct dirent *ent; > > - DIR *dir; > > - int ret; > > - > > - if (!test_pmu()) > > - return TEST_SKIP; > > - > > - snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/= ", > > - sysfs__mountpoint()); > > - > > - ret =3D stat(path, &st); > > - if (ret) { > > - pr_debug("omitting PMU cpu events tests: %s\n", path); > > - return TEST_OK; > > - } > > + struct perf_pmu *pmu; > > + int ret =3D TEST_OK; > > > > - dir =3D opendir(path); > > - if (!dir) { > > - pr_debug("can't open pmu event dir: %s\n", path); > > - return TEST_FAIL; > > - } > > + perf_pmus__for_each_pmu(pmu) { > > + struct stat st; > > + char path[PATH_MAX]; > > + struct dirent *ent; > > + DIR *dir; > > + int err; > > > > - ret =3D TEST_OK; > > - while ((ent =3D readdir(dir))) { > > - struct evlist_test e =3D { .name =3D NULL, }; > > - char name[2 * NAME_MAX + 1 + 12 + 3]; > > - int test_ret; > > + snprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/= events/", > > + sysfs__mountpoint(), pmu->name); > > > > - /* Names containing . are special and cannot be used dire= ctly */ > > - if (strchr(ent->d_name, '.')) > > + err =3D stat(path, &st); > > + if (err) { > > + pr_debug("skipping PMU %s events tests: %s\n", pm= u->name, path); > > + ret =3D combine_test_results(ret, TEST_SKIP); > > continue; > > - > > - snprintf(name, sizeof(name), "cpu/event=3D%s/u", ent->d_n= ame); > > - > > - e.name =3D name; > > - e.check =3D test__checkevent_pmu_events; > > - > > - test_ret =3D test_event(&e); > > - if (test_ret !=3D TEST_OK) { > > - pr_debug("Test PMU event failed for '%s'", name); > > - ret =3D combine_test_results(ret, test_ret); > > } > > /* > > * Names containing '-' are recognized as prefixes and su= ffixes > > @@ -2282,17 +2258,48 @@ static int test__pmu_events(struct test_suite *= test __maybe_unused, int subtest > > if (strchr(ent->d_name, '-')) > > continue; > > > > - snprintf(name, sizeof(name), "%s:u,cpu/event=3D%s/u", ent= ->d_name, ent->d_name); > > - e.name =3D name; > > - e.check =3D test__checkevent_pmu_events_mix; > > - test_ret =3D test_event(&e); > > - if (test_ret !=3D TEST_OK) { > > - pr_debug("Test PMU event failed for '%s'", name); > > - ret =3D combine_test_results(ret, test_ret); > > + dir =3D opendir(path); > > + if (!dir) { > > + pr_debug("can't open pmu event dir: %s\n", path); > > + ret =3D combine_test_results(ret, TEST_SKIP); > > + continue; > > } > > - } > > > > - closedir(dir); > > + while ((ent =3D readdir(dir))) { > > + struct evlist_test e =3D { .name =3D NULL, }; > > + char name[2 * NAME_MAX + 1 + 12 + 3]; > > + int test_ret; > > + > > + /* Names containing . are special and cannot be u= sed directly */ > > + if (strchr(ent->d_name, '.')) > > + continue; > > + > > + snprintf(name, sizeof(name), "%s/event=3D%s/u", p= mu->name, ent->d_name); > > + > > + e.name =3D name; > > + e.check =3D test__checkevent_pmu_events; > > + > > + test_ret =3D test_event(&e); > > + if (test_ret !=3D TEST_OK) { > > + pr_debug("Test PMU event failed for '%s'"= , name); > > + ret =3D combine_test_results(ret, test_re= t); > > + } > > + > > + if (!is_pmu_core(pmu->name)) > > + continue; > > + > > + snprintf(name, sizeof(name), "%s:u,%s/event=3D%s/= u", ent->d_name, pmu->name, ent->d_name); > > + e.name =3D name; > > + e.check =3D test__checkevent_pmu_events_mix; > > + test_ret =3D test_event(&e); > > + if (test_ret !=3D TEST_OK) { > > + pr_debug("Test PMU event failed for '%s'"= , name); > > + ret =3D combine_test_results(ret, test_re= t); > > + } > > + } > > + > > + closedir(dir); > > + } > > return ret; > > } > >