From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C129DC77B73 for ; Thu, 27 Apr 2023 19:39:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343617AbjD0TjG (ORCPT ); Thu, 27 Apr 2023 15:39:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244200AbjD0TjF (ORCPT ); Thu, 27 Apr 2023 15:39:05 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64B1E213A; Thu, 27 Apr 2023 12:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682624344; x=1714160344; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=gAZ1EG7SDVbzwqKuwmJG1508A0ja1sgvVPDk5S/JuME=; b=TRfaxdLNvcanfpUmv6a39yyac3kIoLKsWT4vwibl86M5swFDxHcJcWmB tiToxRPqENkWdcEqkAVrXoYcaLe6f9EIbvwDZHP0StOE6uTLXqIdNZT/G zXzDqmliKaKLpzBBuJ1qqqTVbknwj1gDuwc6fot7fCxsn6O0BxIf8ApVg HqyMiQIQhbRsGzcZwGnEO1pZt+i8zYo/4bXNci0IVD5rbIPRGKRBUK99m 2HD/XFT3VlBAtjVnsWY7PMScWZTviTrm/AT2erYIzDUM18mpx5PTXynLV 2ki1ckEgr2HULSeU5L4RW/rW47UImfa5DXO6JyoX3WwZ9eztH7NuVtreM A==; X-IronPort-AV: E=McAfee;i="6600,9927,10693"; a="410609764" X-IronPort-AV: E=Sophos;i="5.99,232,1677571200"; d="scan'208";a="410609764" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2023 12:39:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10693"; a="725063041" X-IronPort-AV: E=Sophos;i="5.99,232,1677571200"; d="scan'208";a="725063041" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP; 27 Apr 2023 12:39:02 -0700 Received: from [10.209.41.222] (kliang2-mobl1.ccr.corp.intel.com [10.209.41.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id CD829580377; Thu, 27 Apr 2023 12:38:58 -0700 (PDT) Message-ID: <05b7b1cf-0b77-0e0f-8d02-1c26016fa7d8@linux.intel.com> Date: Thu, 27 Apr 2023 15:38:57 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v1 08/40] perf test: Test more sysfs events Content-Language: en-US To: Ian Rogers , 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 References: <20230426070050.1315519-1-irogers@google.com> <20230426070050.1315519-9-irogers@google.com> From: "Liang, Kan" In-Reply-To: <20230426070050.1315519-9-irogers@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org 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 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-events.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, int 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 = stat(path, &st); > - if (ret) { > - pr_debug("omitting PMU cpu events tests: %s\n", path); > - return TEST_OK; > - } > + struct perf_pmu *pmu; > + int ret = TEST_OK; > > - dir = 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 = TEST_OK; > - while ((ent = readdir(dir))) { > - struct evlist_test e = { .name = 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 directly */ > - if (strchr(ent->d_name, '.')) > + err = stat(path, &st); > + if (err) { > + pr_debug("skipping PMU %s events tests: %s\n", pmu->name, path); > + ret = combine_test_results(ret, TEST_SKIP); > continue; > - > - snprintf(name, sizeof(name), "cpu/event=%s/u", ent->d_name); > - > - e.name = name; > - e.check = test__checkevent_pmu_events; > - > - test_ret = test_event(&e); > - if (test_ret != TEST_OK) { > - pr_debug("Test PMU event failed for '%s'", name); > - ret = combine_test_results(ret, test_ret); > } > /* > * Names containing '-' are recognized as prefixes and suffixes > @@ -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=%s/u", ent->d_name, ent->d_name); > - e.name = name; > - e.check = test__checkevent_pmu_events_mix; > - test_ret = test_event(&e); > - if (test_ret != TEST_OK) { > - pr_debug("Test PMU event failed for '%s'", name); > - ret = combine_test_results(ret, test_ret); > + dir = opendir(path); > + if (!dir) { > + pr_debug("can't open pmu event dir: %s\n", path); > + ret = combine_test_results(ret, TEST_SKIP); > + continue; > } > - } > > - closedir(dir); > + while ((ent = readdir(dir))) { > + struct evlist_test e = { .name = NULL, }; > + char name[2 * NAME_MAX + 1 + 12 + 3]; > + int test_ret; > + > + /* Names containing . are special and cannot be used directly */ > + if (strchr(ent->d_name, '.')) > + continue; > + > + snprintf(name, sizeof(name), "%s/event=%s/u", pmu->name, ent->d_name); > + > + e.name = name; > + e.check = test__checkevent_pmu_events; > + > + test_ret = test_event(&e); > + if (test_ret != TEST_OK) { > + pr_debug("Test PMU event failed for '%s'", name); > + ret = combine_test_results(ret, test_ret); > + } > + > + if (!is_pmu_core(pmu->name)) > + continue; > + > + snprintf(name, sizeof(name), "%s:u,%s/event=%s/u", ent->d_name, pmu->name, ent->d_name); > + e.name = name; > + e.check = test__checkevent_pmu_events_mix; > + test_ret = test_event(&e); > + if (test_ret != TEST_OK) { > + pr_debug("Test PMU event failed for '%s'", name); > + ret = combine_test_results(ret, test_ret); > + } > + } > + > + closedir(dir); > + } > return ret; > } >