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 */
31 format_arm_cache_inst (u8 *s, va_list *args)
33 perfmon_node_stats_t *ns = va_arg (*args, perfmon_node_stats_t *);
34 int row = va_arg (*args, int);
39 s = format (s, "%.2f", (f64) ns->value[L1I_CACHE] / ns->n_packets);
44 format (s, "%.2f", (f64) ns->value[L1I_CACHE_REFILL] / ns->n_packets);
48 s = format (s, "%.2f%%",
49 (ns->value[L1I_CACHE] ? (f64) ns->value[L1I_CACHE_REFILL] /
50 ns->value[L1I_CACHE] * 100 :
55 s = format (s, "%.2f", (f64) ns->value[L2I_CACHE] / ns->n_packets);
60 format (s, "%.2f", (f64) ns->value[L2I_CACHE_REFILL] / ns->n_packets);
64 s = format (s, "%.2f%%",
65 (ns->value[L2I_CACHE] ? (f64) ns->value[L2I_CACHE_REFILL] /
66 ns->value[L2I_CACHE] * 100 :
71 s = format (s, "%llu", ns->n_packets);
77 PERFMON_REGISTER_BUNDLE (arm_cache_inst) = {
79 .description = "L1I/L2I instruction cache accesses and refills per packet",
81 .type = PERFMON_BUNDLE_TYPE_NODE,
82 .events[0] = ARMV8_PMUV3_L1I_CACHE,
83 .events[1] = ARMV8_PMUV3_L1I_CACHE_REFILL,
84 .events[2] = ARMV8_PMUV3_L2I_CACHE,
85 .events[3] = ARMV8_PMUV3_L2I_CACHE_REFILL,
88 .format_fn = format_arm_cache_inst,
89 .column_headers = PERFMON_STRINGS ("L1I: access", "refill", "\%*",
90 "L2I: access", "refill", "\%*", "pkts"),
92 * set a bit for every event used in each column
93 * this allows us to disable columns at bundle registration if an
94 * event is not supported
96 .column_events = PERFMON_COLUMN_EVENTS (
97 SET_BIT (L1I_CACHE), SET_BIT (L1I_CACHE_REFILL),
98 SET_BIT (L1I_CACHE) | SET_BIT (L1I_CACHE_REFILL), SET_BIT (L2I_CACHE),
99 SET_BIT (L2I_CACHE_REFILL),
100 SET_BIT (L2I_CACHE) | SET_BIT (L2I_CACHE_REFILL), 0),
101 .footer = "all stats are per packet except refill rate (\%)\n"
102 "*\% percentage shown is total refills/accesses\n"