All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: <peterz@infradead.org>, <mingo@redhat.com>, <acme@kernel.org>,
	<mark.rutland@arm.com>, <alexander.shishkin@linux.intel.com>,
	<jolsa@redhat.com>, <namhyung@kernel.org>
Cc: <will@kernel.org>, <ak@linux.intel.com>, <linuxarm@huawei.com>,
	<linux-kernel@vger.kernel.org>, <james.clark@arm.com>,
	<qiangqing.zhang@nxp.com>, John Garry <john.garry@huawei.com>
Subject: [PATCH v2 2/7] perf jevents: Support test events folder
Date: Tue, 17 Mar 2020 19:02:14 +0800	[thread overview]
Message-ID: <1584442939-8911-3-git-send-email-john.garry@huawei.com> (raw)
In-Reply-To: <1584442939-8911-1-git-send-email-john.garry@huawei.com>

With the goal of supporting pmu-events test case, introduce support for a
test events folder.

These test events can be used for testing generation of pmu-event tables
and alias creation for any arch.

When running the pmu-events test case, these test events will be used
as the platform-agnostic events, so aliases can be created per-PMU and
validated against known expected values.

To support the test events, add a "testcpu" entry in pmu_events_map[].
The pmu-events test will be able to lookup the events map for "testcpu",
to verify the generated tables against expected values.

The resultant generated pmu-events.c will now look like the following:

struct pmu_event pme_ampere_emag[] = {
{
	.name = "ldrex_spec",
	.event = "event=0x6c",
	.desc = "Exclusive operation spe...",
	.topic = "intrinsic",
	.long_desc = "Exclusive operation ...",
},
...
};

struct pmu_event pme_test_cpu[] = {
{
	.name = "uncore_hisi_ddrc.flux_wcmd",
	.event = "event=0x2",
	.desc = "DDRC write commands. Unit: hisi_sccl,ddrc ",
	.topic = "uncore",
	.long_desc = "DDRC write commands",
	.pmu = "hisi_sccl,ddrc",
},
{
	.name = "unc_cbo_xsnp_response.miss_eviction",
	.event = "umask=0x81,event=0x22",
	.desc = "Unit: uncore_cbox A cross-core snoop resulted ...",
	.topic = "uncore",
	.long_desc = "A cross-core snoop resulted from L3 ...",
	.pmu = "uncore_cbox",
},
{
	.name = "eist_trans",
	.event = "umask=0x0,period=200000,event=0x3a",
	.desc = "Number of Enhanced Intel SpeedStep(R) ...",
	.topic = "other",
},
{
	.name = 0,
},
};

struct pmu_events_map pmu_events_map[] = {
...
{
	.cpuid = "0x00000000500f0000",
	.version = "v1",
	.type = "core",
	.table = pme_ampere_emag
},
...
{
	.cpuid = "testcpu",
	.version = "v1",
	.type = "core",
	.table = pme_test_cpu,
},
{
	.cpuid = 0,
	.version = 0,
	.type = 0,
	.table = 0,
},
};

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/pmu-events/jevents.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index 27b4da80f751..3343ba27271b 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -764,6 +764,19 @@ static void print_mapping_table_suffix(FILE *outfp)
 	fprintf(outfp, "};\n");
 }
 
+static void print_mapping_test_table(FILE *outfp)
+{
+	/*
+	 * Print the terminating, NULL entry.
+	 */
+	fprintf(outfp, "{\n");
+	fprintf(outfp, "\t.cpuid = \"testcpu\",\n");
+	fprintf(outfp, "\t.version = \"v1\",\n");
+	fprintf(outfp, "\t.type = \"core\",\n");
+	fprintf(outfp, "\t.table = pme_test_cpu,\n");
+	fprintf(outfp, "},\n");
+}
+
 static int process_mapfile(FILE *outfp, char *fpath)
 {
 	int n = 16384;
@@ -841,6 +854,7 @@ static int process_mapfile(FILE *outfp, char *fpath)
 	}
 
 out:
+	print_mapping_test_table(outfp);
 	print_mapping_table_suffix(outfp);
 	fclose(mapfp);
 	free(line);
@@ -1161,6 +1175,22 @@ int main(int argc, char *argv[])
 		goto empty_map;
 	}
 
+	sprintf(ldirname, "%s/test", start_dirname);
+
+	rc = nftw(ldirname, process_one_file, maxfds, 0);
+	if (rc && verbose) {
+		pr_info("%s: Error walking file tree %s rc=%d for test\n",
+			prog, ldirname, rc);
+		goto empty_map;
+	} else if (rc < 0) {
+		/* Make build fail */
+		free_arch_std_events();
+		ret = 1;
+		goto out_free_mapfile;
+	} else if (rc) {
+		goto empty_map;
+	}
+
 	if (close_table)
 		print_events_table_suffix(eventsfp);
 
-- 
2.12.3


  parent reply	other threads:[~2020-03-17 11:06 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-17 11:02 [PATCH v2 0/7] perf test pmu-events case John Garry
2020-03-17 11:02 ` [PATCH v2 1/7] perf jevents: Add some test events John Garry
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for John Garry
2020-03-17 11:02 ` John Garry [this message]
2020-03-17 16:20   ` [PATCH v2 2/7] perf jevents: Support test events folder Jiri Olsa
2020-03-17 16:25     ` John Garry
2020-03-17 17:06       ` Jiri Olsa
2020-03-17 17:42         ` John Garry
2020-03-17 20:41           ` Arnaldo Carvalho de Melo
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for John Garry
2020-03-17 11:02 ` [PATCH v2 3/7] perf pmu: Refactor pmu_add_cpu_aliases() John Garry
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for John Garry
2020-03-17 11:02 ` [PATCH v2 4/7] perf test: Add pmu-events test John Garry
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for John Garry
2020-03-17 11:02 ` [PATCH v2 5/7] perf pmu: Add is_pmu_core() John Garry
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for John Garry
2020-03-17 11:02 ` [PATCH v2 6/7] perf pmu: Make pmu_uncore_alias_match() public John Garry
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for John Garry
2020-03-17 11:02 ` [PATCH v2 7/7] perf test: Test pmu-events aliases John Garry
2020-03-17 16:20   ` Jiri Olsa
2020-03-17 16:41     ` John Garry
2020-03-17 17:07       ` Jiri Olsa
2020-03-19 18:36         ` Arnaldo Carvalho de Melo
2020-03-20  9:24           ` John Garry
2020-03-20  9:30             ` Jiri Olsa
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for John Garry
2020-03-18  7:57 ` [PATCH v2 0/7] perf test pmu-events case Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1584442939-8911-3-git-send-email-john.garry@huawei.com \
    --to=john.garry@huawei.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=james.clark@arm.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=qiangqing.zhang@nxp.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.