FD.io VPP  v21.06
Vector Packet Processing
mem_bw.c
Go to the documentation of this file.
1 /*
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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 
16 #include <vnet/vnet.h>
17 #include <vppinfra/linux/sysfs.h>
18 #include <perfmon/perfmon.h>
19 #include <perfmon/intel/uncore.h>
20 
21 static u8 *
22 format_intel_uncore_imc_bw (u8 *s, va_list *args)
23 {
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;
27 
28  switch (col)
29  {
30  case 0:
31  s = format (s, "%9.2f", tr);
32  break;
33  case 1:
34  if (r->time_running)
35  s = format (s, "%9.2f", (f64) r->value[0] * 64 * 1e-6 / tr);
36  break;
37  case 2:
38  if (r->time_running)
39  s = format (s, "%9.2f", (f64) r->value[1] * 64 * 1e-6 / tr);
40  break;
41  case 3:
42  if (r->time_running)
43  s = format (s, "%9.2f",
44  (f64) (r->value[0] + r->value[1]) * 64 * 1e-6 / tr);
45  break;
46  default:
47  break;
48  }
49 
50  return s;
51 }
52 
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",
58  .events[0] = INTEL_UNCORE_E_IMC_UNC_M_CAS_COUNT_RD,
59  .events[1] = INTEL_UNCORE_E_IMC_UNC_M_CAS_COUNT_WR,
60  .n_events = 2,
61  .format_fn = format_intel_uncore_imc_bw,
62  .column_headers = PERFMON_STRINGS ("RunTime", "Reads (MB/s)",
63  "Writes (MB/s)", "Total (MB/s)"),
64 };
vnet_hw_if_output_node_runtime_t * r
unsigned char u8
Definition: types.h:56
double f64
Definition: types.h:142
description fragment has unexpected format
Definition: map.api:433
#define PERFMON_STRINGS(...)
Definition: perfmon.h:195
PERFMON_REGISTER_BUNDLE(intel_uncore_imc_bw)
u64 value[PERF_MAX_EVENTS]
Definition: perfmon.h:126
static u8 * format_intel_uncore_imc_bw(u8 *s, va_list *args)
Definition: mem_bw.c:22