From nobody Fri Nov 29 20:57:25 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CACB3140E30; Sat, 14 Sep 2024 22:09:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351765; cv=none; b=nQ7APDiRKgWkIHh6vbFFKxx4Fx1agY66tqs8eIeraE8WGF+qLDvbiLTVy7TM4Opc3dM7lD4CH2V1Od/J69rix5Ww+D2iS+C25fooDy5Cq9CF4e92QWUayHT3NheqQmuFABlWnK2QpUnhE+hBXGx3daduu6baILvDTyTpudVolD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351765; c=relaxed/simple; bh=ID7nTDyiLnCDwptc8smnIPar3ZoHhkBuewVEg52cVw4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DfU6wg7JrIShvbnhAKXv8+FCfZkuI09sEYYU9N+YdSgQp0r1TjRuRDY8KShmJ81e7AVBEFisM5IJmSExIrMW7cXcARMs46d66a2kqR1AZQubuSzkBaPnOej8aNC6ibsbYPciJOBa0/2AmePCyQBQX4Nmar/M7N6RZ9P7GquEbgg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9E0631691; Sat, 14 Sep 2024 15:09:52 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6B93B3F66E; Sat, 14 Sep 2024 15:09:21 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , James Clark , Mark Rutland , Namhyung Kim , Ian Rogers , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Will Deacon , Mike Leach , Besar Wicaksono , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v2 1/7] perf arm-spe: Rename arm_spe__synth_data_source_generic() Date: Sat, 14 Sep 2024 23:08:55 +0100 Message-Id: <20240914220901.756177-2-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240914220901.756177-1-leo.yan@arm.com> References: <20240914220901.756177-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The arm_spe__synth_data_source_generic() function is invoked when the tool detects that CPUs do not support data source packets and falls back to synthesizing only the memory level. Rename it to arm_spe__synth_memory_level() for better reflecting its purpose. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 4212a8aa0d2c..64a47bd35cfb 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -496,8 +496,8 @@ static void arm_spe__synth_data_source_neoverse(const s= truct arm_spe_record *rec } } =20 -static void arm_spe__synth_data_source_generic(const struct arm_spe_record= *record, - union perf_mem_data_src *data_src) +static void arm_spe__synth_memory_level(const struct arm_spe_record *recor= d, + union perf_mem_data_src *data_src) { if (record->type & (ARM_SPE_LLC_ACCESS | ARM_SPE_LLC_MISS)) { data_src->mem_lvl =3D PERF_MEM_LVL_L3; @@ -534,7 +534,7 @@ static u64 arm_spe__synth_data_source(const struct arm_= spe_record *record, u64 m if (is_neoverse) arm_spe__synth_data_source_neoverse(record, &data_src); else - arm_spe__synth_data_source_generic(record, &data_src); + arm_spe__synth_memory_level(record, &data_src); =20 if (record->type & (ARM_SPE_TLB_ACCESS | ARM_SPE_TLB_MISS)) { data_src.mem_dtlb =3D PERF_MEM_TLB_WK; --=20 2.34.1 From nobody Fri Nov 29 20:57:25 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC262146A9B; Sat, 14 Sep 2024 22:09:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351767; cv=none; b=fHPX1dGbvEgMFrSKCrbs/p6s/KGd3/7hqlrN07oi90ivyHJtxE2rl1qCLnLWbc7C5fel1MLYDvCRM598t/pcWuxmhBF8LF7kbVyqcbPcUAjdzgn/B0+XjFIiUHC72TyWpkL4G6iUHzL52u1JHSv1SLyce4gl46x92axM3HTYdyA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351767; c=relaxed/simple; bh=6KW/ks3Sij+Oxz9y6KMgUgwjwMzWVcL3pmI/9kH35I4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CpGnj9XGWw+xgCzPiid9AQKh+K4jBGS/V9uZYwKMyorxEZbO9lrMhCgOrP2Nmv1g3X5hJWypUF9IQpn3L8jWWIK18fxIN0wvART8y+DbsQqwa96ngIaaZFk2VUVsxRrYrkY5SBC245U0NM1JG4Sfjyv7JwNHBzAJhE7oNMQfSrE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A5D3511FB; Sat, 14 Sep 2024 15:09:54 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 739853F66E; Sat, 14 Sep 2024 15:09:23 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , James Clark , Mark Rutland , Namhyung Kim , Ian Rogers , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Will Deacon , Mike Leach , Besar Wicaksono , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v2 2/7] perf arm-spe: Rename the common data source encoding Date: Sat, 14 Sep 2024 23:08:56 +0100 Message-Id: <20240914220901.756177-3-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240914220901.756177-1-leo.yan@arm.com> References: <20240914220901.756177-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Neoverse CPUs follow the common data source encoding, and other CPU variants can share the same format. Rename the CPU list and data source definitions as common data source names. This change prepares for appending more CPU variants. Signed-off-by: Leo Yan --- .../util/arm-spe-decoder/arm-spe-decoder.h | 18 ++++++------ tools/perf/util/arm-spe.c | 28 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h b/tools/perf= /util/arm-spe-decoder/arm-spe-decoder.h index 1443c28545a9..358c611eeddb 100644 --- a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h +++ b/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h @@ -56,15 +56,15 @@ enum arm_spe_op_type { ARM_SPE_OP_BR_INDIRECT =3D 1 << 17, }; =20 -enum arm_spe_neoverse_data_source { - ARM_SPE_NV_L1D =3D 0x0, - ARM_SPE_NV_L2 =3D 0x8, - ARM_SPE_NV_PEER_CORE =3D 0x9, - ARM_SPE_NV_LOCAL_CLUSTER =3D 0xa, - ARM_SPE_NV_SYS_CACHE =3D 0xb, - ARM_SPE_NV_PEER_CLUSTER =3D 0xc, - ARM_SPE_NV_REMOTE =3D 0xd, - ARM_SPE_NV_DRAM =3D 0xe, +enum arm_spe_common_data_source { + ARM_SPE_COMMON_DS_L1D =3D 0x0, + ARM_SPE_COMMON_DS_L2 =3D 0x8, + ARM_SPE_COMMON_DS_PEER_CORE =3D 0x9, + ARM_SPE_COMMON_DS_LOCAL_CLUSTER =3D 0xa, + ARM_SPE_COMMON_DS_SYS_CACHE =3D 0xb, + ARM_SPE_COMMON_DS_PEER_CLUSTER =3D 0xc, + ARM_SPE_COMMON_DS_REMOTE =3D 0xd, + ARM_SPE_COMMON_DS_DRAM =3D 0xe, }; =20 struct arm_spe_record { diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 64a47bd35cfb..7cde6584b02d 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -413,15 +413,15 @@ static int arm_spe__synth_instruction_sample(struct a= rm_spe_queue *speq, return arm_spe_deliver_synth_event(spe, speq, event, &sample); } =20 -static const struct midr_range neoverse_spe[] =3D { +static const struct midr_range common_ds_encoding_cpus[] =3D { MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1), MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2), MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1), {}, }; =20 -static void arm_spe__synth_data_source_neoverse(const struct arm_spe_recor= d *record, - union perf_mem_data_src *data_src) +static void arm_spe__synth_data_source_common(const struct arm_spe_record = *record, + union perf_mem_data_src *data_src) { /* * Even though four levels of cache hierarchy are possible, no known @@ -443,17 +443,17 @@ static void arm_spe__synth_data_source_neoverse(const= struct arm_spe_record *rec } =20 switch (record->source) { - case ARM_SPE_NV_L1D: + case ARM_SPE_COMMON_DS_L1D: data_src->mem_lvl =3D PERF_MEM_LVL_L1 | PERF_MEM_LVL_HIT; data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_L1; data_src->mem_snoop =3D PERF_MEM_SNOOP_NONE; break; - case ARM_SPE_NV_L2: + case ARM_SPE_COMMON_DS_L2: data_src->mem_lvl =3D PERF_MEM_LVL_L2 | PERF_MEM_LVL_HIT; data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_L2; data_src->mem_snoop =3D PERF_MEM_SNOOP_NONE; break; - case ARM_SPE_NV_PEER_CORE: + case ARM_SPE_COMMON_DS_PEER_CORE: data_src->mem_lvl =3D PERF_MEM_LVL_L2 | PERF_MEM_LVL_HIT; data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_L2; data_src->mem_snoopx =3D PERF_MEM_SNOOPX_PEER; @@ -462,8 +462,8 @@ static void arm_spe__synth_data_source_neoverse(const s= truct arm_spe_record *rec * We don't know if this is L1, L2 but we do know it was a cache-2-cache * transfer, so set SNOOPX_PEER */ - case ARM_SPE_NV_LOCAL_CLUSTER: - case ARM_SPE_NV_PEER_CLUSTER: + case ARM_SPE_COMMON_DS_LOCAL_CLUSTER: + case ARM_SPE_COMMON_DS_PEER_CLUSTER: data_src->mem_lvl =3D PERF_MEM_LVL_L3 | PERF_MEM_LVL_HIT; data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_L3; data_src->mem_snoopx =3D PERF_MEM_SNOOPX_PEER; @@ -471,7 +471,7 @@ static void arm_spe__synth_data_source_neoverse(const s= truct arm_spe_record *rec /* * System cache is assumed to be L3 */ - case ARM_SPE_NV_SYS_CACHE: + case ARM_SPE_COMMON_DS_SYS_CACHE: data_src->mem_lvl =3D PERF_MEM_LVL_L3 | PERF_MEM_LVL_HIT; data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_L3; data_src->mem_snoop =3D PERF_MEM_SNOOP_HIT; @@ -480,13 +480,13 @@ static void arm_spe__synth_data_source_neoverse(const= struct arm_spe_record *rec * We don't know what level it hit in, except it came from the other * socket */ - case ARM_SPE_NV_REMOTE: + case ARM_SPE_COMMON_DS_REMOTE: data_src->mem_lvl =3D PERF_MEM_LVL_REM_CCE1; data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_ANY_CACHE; data_src->mem_remote =3D PERF_MEM_REMOTE_REMOTE; data_src->mem_snoopx =3D PERF_MEM_SNOOPX_PEER; break; - case ARM_SPE_NV_DRAM: + case ARM_SPE_COMMON_DS_DRAM: data_src->mem_lvl =3D PERF_MEM_LVL_LOC_RAM | PERF_MEM_LVL_HIT; data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_RAM; data_src->mem_snoop =3D PERF_MEM_SNOOP_NONE; @@ -522,7 +522,7 @@ static void arm_spe__synth_memory_level(const struct ar= m_spe_record *record, static u64 arm_spe__synth_data_source(const struct arm_spe_record *record,= u64 midr) { union perf_mem_data_src data_src =3D { .mem_op =3D PERF_MEM_OP_NA }; - bool is_neoverse =3D is_midr_in_range_list(midr, neoverse_spe); + bool is_common =3D is_midr_in_range_list(midr, common_ds_encoding_cpus); =20 if (record->op & ARM_SPE_OP_LD) data_src.mem_op =3D PERF_MEM_OP_LOAD; @@ -531,8 +531,8 @@ static u64 arm_spe__synth_data_source(const struct arm_= spe_record *record, u64 m else return 0; =20 - if (is_neoverse) - arm_spe__synth_data_source_neoverse(record, &data_src); + if (is_common) + arm_spe__synth_data_source_common(record, &data_src); else arm_spe__synth_memory_level(record, &data_src); =20 --=20 2.34.1 From nobody Fri Nov 29 20:57:25 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C3E84148823; Sat, 14 Sep 2024 22:09:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351769; cv=none; b=aR8TvtyUf3WeKPutOHJuYCBpaDsWkxQOxhErJRyBuC0xgXZBe75jrRLoBDWyuHvcLJxUYeVchT+Jkkk6YviBovg/WQdjoIPXZDz6EF+B/mmnRS6sLABs8bFWVy1YiytNkgPao71juO5xrfZLzXy5t+OYKhkTU1XGq80hLvt+FtM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351769; c=relaxed/simple; bh=tCs131liyX3NjisbwqG8GgR4OUdt7zf5z+B/vqGgsl8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ibfWTX3YlhzHOENnpJfOJLUxMORmg90CiFzknxUYWIc9sXAU8wDFzQjt7UFapAW0Soecn4PdOzGXs2/+rlmM58/bxbNgAIWFos0Gx24f14WuFKNnK91dxELpd30Hpqozh/xA2nmL6kf8njUA/AuO8I8wdJWjQBm8vExkJ0pM1Bo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AE1801691; Sat, 14 Sep 2024 15:09:56 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7B2393F66E; Sat, 14 Sep 2024 15:09:25 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , James Clark , Mark Rutland , Namhyung Kim , Ian Rogers , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Will Deacon , Mike Leach , Besar Wicaksono , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v2 3/7] perf arm-spe: Introduce arm_spe__is_homogeneous() Date: Sat, 14 Sep 2024 23:08:57 +0100 Message-Id: <20240914220901.756177-4-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240914220901.756177-1-leo.yan@arm.com> References: <20240914220901.756177-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce the arm_spe__is_homogeneous() function, it uses to check if Arm SPE is homogeneous cross all CPUs. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 7cde6584b02d..7e00cf1c287c 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -82,6 +82,7 @@ struct arm_spe { u64 **metadata; u64 metadata_ver; u64 metadata_nr_cpu; + bool is_homogeneous; }; =20 struct arm_spe_queue { @@ -1374,6 +1375,30 @@ arm_spe_synth_events(struct arm_spe *spe, struct per= f_session *session) return 0; } =20 +static bool arm_spe__is_homogeneous(u64 **metadata, int nr_cpu) +{ + u64 midr; + int i; + + if (!nr_cpu) + return false; + + for (i =3D 0; i < nr_cpu; i++) { + if (!metadata[i]) + return false; + + if (i =3D=3D 0) { + midr =3D metadata[i][ARM_SPE_CPU_MIDR]; + continue; + } + + if (midr !=3D metadata[i][ARM_SPE_CPU_MIDR]) + return false; + } + + return true; +} + int arm_spe_process_auxtrace_info(union perf_event *event, struct perf_session *session) { @@ -1417,6 +1442,7 @@ int arm_spe_process_auxtrace_info(union perf_event *e= vent, spe->metadata =3D metadata; spe->metadata_ver =3D metadata_ver; spe->metadata_nr_cpu =3D nr_cpu; + spe->is_homogeneous =3D arm_spe__is_homogeneous(metadata, nr_cpu); =20 spe->timeless_decoding =3D arm_spe__is_timeless_decoding(spe); =20 --=20 2.34.1 From nobody Fri Nov 29 20:57:25 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ABAD514A635; Sat, 14 Sep 2024 22:09:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351771; cv=none; b=szCqKLJXegue0PUrv2OValzDs+tnO7QxokTagNfy0gPjelJI4zM+TlVEtJ7+v/YAbTgO+pHlRDAVC+W2HvT2tBrK+7gYFZafxWN7arDcJhJFmWkketcynvKnAcH/qS2B0aKng/xaxNs1pqSj2i7lPflQ0CsbsgcBG6XlVJyY5fE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351771; c=relaxed/simple; bh=NwwNJvy+fcK/CH3YXIVH4JS1QYTSlfC+fphTw2X/Y3g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fWg6XB8sI2eisulZNUEG5gsl3vMVqfp1MnvHHNJe1tw7zySoKQz5daSAvEW1CxWQ03aItZWtGMhMfM+XJdKp9TR1/mVw6OTSxe1V+iE4q4csRSLZn9CXrvOyAPVj/KLhMUNRnCWNGdEa0iipvZA6pRZxj18eQsP0t3LOMx1MCvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B79C8169C; Sat, 14 Sep 2024 15:09:58 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8326D3F66E; Sat, 14 Sep 2024 15:09:27 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , James Clark , Mark Rutland , Namhyung Kim , Ian Rogers , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Will Deacon , Mike Leach , Besar Wicaksono , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v2 4/7] perf arm-spe: Use metadata to decide the data source feature Date: Sat, 14 Sep 2024 23:08:58 +0100 Message-Id: <20240914220901.756177-5-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240914220901.756177-1-leo.yan@arm.com> References: <20240914220901.756177-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the info in the metadata to decide if the data source feature is supported. The CPU MIDR must be in the CPU list for the common data source encoding. For the metadata version 1, it doesn't include info for MIDR. In this case, due to absent info for making decision, print out warning to remind users to upgrade tool and returns false. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 67 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 7e00cf1c287c..e263df079c14 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -278,6 +278,20 @@ static int arm_spe_set_tid(struct arm_spe_queue *speq,= pid_t tid) return 0; } =20 +static u64 *arm_spe__get_metadata_by_cpu(struct arm_spe *spe, u64 cpu) +{ + u64 i; + + if (!spe->metadata) + return NULL; + + for (i =3D 0; i < spe->metadata_nr_cpu; i++) + if (spe->metadata[i][ARM_SPE_CPU] =3D=3D cpu) + return spe->metadata[i]; + + return NULL; +} + static struct simd_flags arm_spe__synth_simd_flags(const struct arm_spe_re= cord *record) { struct simd_flags simd_flags =3D {}; @@ -520,10 +534,57 @@ static void arm_spe__synth_memory_level(const struct = arm_spe_record *record, data_src->mem_lvl |=3D PERF_MEM_LVL_REM_CCE1; } =20 -static u64 arm_spe__synth_data_source(const struct arm_spe_record *record,= u64 midr) +static bool arm_spe__is_common_ds_encoding(struct arm_spe_queue *speq) +{ + struct arm_spe *spe =3D speq->spe; + bool is_in_cpu_list; + u64 *metadata =3D NULL; + u64 midr =3D 0; + + /* + * Metadata version 1 doesn't contain any info for MIDR. + * Simply return false in this case. + */ + if (spe->metadata_ver =3D=3D 1) { + pr_warning_once("The data file contains metadata version 1, " + "which is absent the info for data source. " + "Please upgrade the tool to record data.\n"); + return false; + } + + /* CPU ID is -1 for per-thread mode */ + if (speq->cpu < 0) { + /* + * On the heterogeneous system, due to CPU ID is -1, + * cannot confirm the data source packet is supported. + */ + if (!spe->is_homogeneous) + return false; + + /* In homogeneous system, simply use CPU0's metadata */ + if (spe->metadata) + metadata =3D spe->metadata[0]; + } else { + metadata =3D arm_spe__get_metadata_by_cpu(spe, speq->cpu); + } + + if (!metadata) + return false; + + midr =3D metadata[ARM_SPE_CPU_MIDR]; + + is_in_cpu_list =3D is_midr_in_range_list(midr, common_ds_encoding_cpus); + if (is_in_cpu_list) + return true; + else + return false; +} + +static u64 arm_spe__synth_data_source(struct arm_spe_queue *speq, + const struct arm_spe_record *record) { union perf_mem_data_src data_src =3D { .mem_op =3D PERF_MEM_OP_NA }; - bool is_common =3D is_midr_in_range_list(midr, common_ds_encoding_cpus); + bool is_common =3D arm_spe__is_common_ds_encoding(speq); =20 if (record->op & ARM_SPE_OP_LD) data_src.mem_op =3D PERF_MEM_OP_LOAD; @@ -556,7 +617,7 @@ static int arm_spe_sample(struct arm_spe_queue *speq) u64 data_src; int err; =20 - data_src =3D arm_spe__synth_data_source(record, spe->midr); + data_src =3D arm_spe__synth_data_source(speq, record); =20 if (spe->sample_flc) { if (record->type & ARM_SPE_L1D_MISS) { --=20 2.34.1 From nobody Fri Nov 29 20:57:25 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE90F13E41D; Sat, 14 Sep 2024 22:09:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351774; cv=none; b=e/6xhxPwZoMVV+gXdmD+henBZXFWCnF4tMMbuG5h6NLjRhigBCbt6jkkIPKvJm6pqDPyoW3mSuyK+IlvXC5eG/v2EPqoXp2C9E83ArZYYAn3tfVhRcjd0mO3FOPhzE3ybGXouIcXoF/45p9CSpy18ts7KBiXh/OfaNahRN5kn9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351774; c=relaxed/simple; bh=d8rR32wbqytuhQb1NJe3j1aYlGXVPbIpeqJxFOZ75mo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P2uQOAwmCsARY86NlPzPJvfoe7CdlLaDBnGqyvnnysFd6Y1/GIYq/O/+JmT9M2Q0S7McxHMZJnuaHAfaM/FUf8u7WegG7/Cctal8ZvSgtlhRYixfErk5/kZ+PrrTas40pRt7rAMEAJrB4mUZhbSkLWk9rkdKuQVhqi9yx69HWiU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BD5B111FB; Sat, 14 Sep 2024 15:10:00 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8A7BC3F66E; Sat, 14 Sep 2024 15:09:29 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , James Clark , Mark Rutland , Namhyung Kim , Ian Rogers , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Will Deacon , Mike Leach , Besar Wicaksono , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v2 5/7] perf arm-spe: Remove the unused 'midr' field Date: Sat, 14 Sep 2024 23:08:59 +0100 Message-Id: <20240914220901.756177-6-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240914220901.756177-1-leo.yan@arm.com> References: <20240914220901.756177-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The 'midr' field is replaced by the MIDR values stored in metadata (per CPU wise). Remove the 'midr' field as it is no longer used. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index e263df079c14..cb0d40b7e3fa 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -46,7 +46,6 @@ struct arm_spe { struct perf_session *session; struct machine *machine; u32 pmu_type; - u64 midr; =20 struct perf_tsc_conversion tc; =20 @@ -1466,8 +1465,6 @@ int arm_spe_process_auxtrace_info(union perf_event *e= vent, struct perf_record_auxtrace_info *auxtrace_info =3D &event->auxtrace_info; size_t min_sz =3D ARM_SPE_AUXTRACE_V1_PRIV_SIZE; struct perf_record_time_conv *tc =3D &session->time_conv; - const char *cpuid =3D perf_env__cpuid(session->evlist->env); - u64 midr =3D strtol(cpuid, NULL, 16); struct arm_spe *spe; u64 **metadata =3D NULL; u64 metadata_ver; @@ -1499,7 +1496,6 @@ int arm_spe_process_auxtrace_info(union perf_event *e= vent, spe->pmu_type =3D auxtrace_info->priv[ARM_SPE_PMU_TYPE]; else spe->pmu_type =3D auxtrace_info->priv[ARM_SPE_SHARED_PMU_TYPE]; - spe->midr =3D midr; spe->metadata =3D metadata; spe->metadata_ver =3D metadata_ver; spe->metadata_nr_cpu =3D nr_cpu; --=20 2.34.1 From nobody Fri Nov 29 20:57:25 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE7E814A635; Sat, 14 Sep 2024 22:09:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351775; cv=none; b=hlTeRofmN2Kesu+krEZh3WIj1wQ/nvJwLPHNrQD6StE0n8QANGDxqY3my6u0FCYFHm4KmiIyq7MN8fJMqh69XGndFQ4wRwP1ofY8CO3aC29cHfIxhQl91edfKIQPuMBGwZ6Y8ODrb4QIZwgBP8TVwili9jXwlXHySSeRGkkrEk4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351775; c=relaxed/simple; bh=VkOUDlVxYwrPSOrg/medc2fCns6IwYe1oVW8xKV6Gfg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CXnA/aln6CGargmqzTMCPwryPZTCECdgMFH8wePzNtawLhBckiH6UUsAOiLrJ8B0LQjRCSylvBPW8ZXmOEwt9qKW3SEnFQV0t33z04sESmAiRDuDB0by6VLlAavLQxRAVZN+ndt+/hkS45xJ7//QcCMJFZkO8Dxe7Ca8V3qq1Xk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CDEFC1691; Sat, 14 Sep 2024 15:10:02 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 92A803F66E; Sat, 14 Sep 2024 15:09:31 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , James Clark , Mark Rutland , Namhyung Kim , Ian Rogers , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Will Deacon , Mike Leach , Besar Wicaksono , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v2 6/7] perf arm-spe: Add Neoverse-V2 to common data source encoding list Date: Sat, 14 Sep 2024 23:09:00 +0100 Message-Id: <20240914220901.756177-7-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240914220901.756177-1-leo.yan@arm.com> References: <20240914220901.756177-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Besar Wicaksono Add Neoverse-V2 MIDR to the common data source encoding range list. Signed-off-by: Besar Wicaksono Reviewed-by: Leo Yan --- tools/perf/util/arm-spe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index cb0d40b7e3fa..07bec88a3c7d 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -431,6 +431,7 @@ static const struct midr_range common_ds_encoding_cpus[= ] =3D { MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1), MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2), MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1), + MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V2), {}, }; =20 --=20 2.34.1 From nobody Fri Nov 29 20:57:25 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 10AC615575F; Sat, 14 Sep 2024 22:09:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351777; cv=none; b=L2eRJBonNJEzmXZX0jWAlk4Uh6h43WXhKCLcdG+xEepRTmfvm6mP5x+RxZ/kaPPe+OhMSkHNQqyU3ZiFYOB0wViulHotlbJY867MhTKo6Xk1Ew9X/nKv5XFZMejSvEhDChljLyIys28JCXGN05KUkZAzqFxR/r3ThezLHnorOWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726351777; c=relaxed/simple; bh=/X1eIoXTgs28/tCarZ6WVyEGCBHdsLYnDDJJxdZeuAE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KS6ClxoLWjKWqTOAMxvG8+nEcINWKcjUekhDDtFr/mnuB+Oa9WhMcYl123/q+H/Pnw3QPgyzBVUTC1b+SqPEF11H1AThLCLwtOJaJdF7jrrRJRjMk80hIpPbbe9bULX9UhFm/AzC9T9+zUraKtVT5wcJ5pKSwuS6mJ8AXasFFYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DEA4C11FB; Sat, 14 Sep 2024 15:10:04 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A38B33F66E; Sat, 14 Sep 2024 15:09:33 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , James Clark , Mark Rutland , Namhyung Kim , Ian Rogers , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Will Deacon , Mike Leach , Besar Wicaksono , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v2 7/7] perf arm-spe: Add Cortex CPUs to common data source encoding list Date: Sat, 14 Sep 2024 23:09:01 +0100 Message-Id: <20240914220901.756177-8-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240914220901.756177-1-leo.yan@arm.com> References: <20240914220901.756177-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add Cortex-A720, Cortex-A725, Cortex-X1C, Cortex-X3 and Cortex-X925 into the common data source encoding list. For everyone of these CPUs, it technical reference manual defines the data source packet as the common encoding format. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 07bec88a3c7d..b64a5f3949f5 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -428,6 +428,11 @@ static int arm_spe__synth_instruction_sample(struct ar= m_spe_queue *speq, } =20 static const struct midr_range common_ds_encoding_cpus[] =3D { + MIDR_ALL_VERSIONS(MIDR_CORTEX_A720), + MIDR_ALL_VERSIONS(MIDR_CORTEX_A725), + MIDR_ALL_VERSIONS(MIDR_CORTEX_X1C), + MIDR_ALL_VERSIONS(MIDR_CORTEX_X3), + MIDR_ALL_VERSIONS(MIDR_CORTEX_X925), MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1), MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2), MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1), --=20 2.34.1