2 * Copyright (c) 2022 Arm and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #include <vnet/vnet.h>
17 #include <vppinfra/linux/sysfs.h>
18 #include <perfmon/perfmon.h>
19 #include <perfmon/arm/events.h>
21 /* as per .events[n] in PERFMON_REGISTER_BUNDLE */
30 format_arm_memory_access (u8 *s, va_list *args)
32 perfmon_node_stats_t *ns = va_arg (*args, perfmon_node_stats_t *);
33 int row = va_arg (*args, int);
38 s = format (s, "%.2f", (f64) ns->value[MEM_ACCESS] / ns->n_packets);
42 s = format (s, "%.3f", (f64) ns->value[BUS_ACCESS] / ns->n_packets);
46 s = format (s, "%llu", ns->value[MEMORY_ERROR]);
50 s = format (s, "%llu", ns->n_packets);
56 PERFMON_REGISTER_BUNDLE (arm_memory_access) = {
57 .name = "memory-access",
58 .description = "Memory/bus accesses per pkt + total memory errors",
60 .type = PERFMON_BUNDLE_TYPE_NODE,
61 .events[0] = ARMV8_PMUV3_MEM_ACCESS,
62 .events[1] = ARMV8_PMUV3_BUS_ACCESS,
63 .events[2] = ARMV8_PMUV3_MEMORY_ERROR,
66 .format_fn = format_arm_memory_access,
67 .column_headers = PERFMON_STRINGS ("Mem-access/pkt", "Bus-access/pkt",
68 "Total-mem-errors", "pkts"),
70 * set a bit for every event used in each column
71 * this allows us to disable columns at bundle registration if an
72 * event is not supported
74 .column_events = PERFMON_COLUMN_EVENTS (SET_BIT (MEM_ACCESS),
76 SET_BIT (MEMORY_ERROR), 0),
78 "Mem-access: The counter counts Memory-read operations and Memory-write"
79 " operations that the PE made\n"
80 "Bus-access: The counter counts Memory-read operations and Memory-write"
81 " operations that access outside of the boundary of the PE and its "
82 "closely-coupled caches\n"
83 "Mem-error: Memory error refers to a physical error in memory closely "
84 "coupled to this PE, and detected by the hardware, such as a parity or"
86 "- See Armv8-A Architecture Reference Manual, D7.10 PMU events and"
87 " event numbers for full description.\n"