2 * Copyright (c) 2020 Cisco 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/intel/uncore.h>
22 format_intel_uncore_imc_bw (u8 *s, va_list *args)
24 perfmon_reading_t *r = va_arg (*args, perfmon_reading_t *);
25 int col = va_arg (*args, int);
26 f64 tr = r->time_running * 1e-9;
31 s = format (s, "%9.2f", tr);
35 s = format (s, "%9.2f", (f64) r->value[0] * 64 * 1e-6 / tr);
39 s = format (s, "%9.2f", (f64) r->value[1] * 64 * 1e-6 / tr);
43 s = format (s, "%9.2f",
44 (f64) (r->value[0] + r->value[1]) * 64 * 1e-6 / tr);
53 PERFMON_REGISTER_BUNDLE (intel_uncore_imc_bw) = {
54 .name = "memory-bandwidth",
55 .description = "memory reads and writes per memory controller channel",
56 .source = "intel-uncore",
57 .type = PERFMON_BUNDLE_TYPE_SYSTEM,
58 .events[0] = INTEL_UNCORE_E_IMC_UNC_M_CAS_COUNT_RD,
59 .events[1] = INTEL_UNCORE_E_IMC_UNC_M_CAS_COUNT_WR,
61 .format_fn = format_intel_uncore_imc_bw,
62 .column_headers = PERFMON_STRINGS ("RunTime", "Reads (MB/s)",
63 "Writes (MB/s)", "Total (MB/s)"),