FD.io VPP  v21.06
Vector Packet Processing
cache_hit_miss.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/core.h>
20 
21 static u8 *
23 {
24  perfmon_node_stats_t *ns = va_arg (*args, perfmon_node_stats_t *);
25  int row = va_arg (*args, int);
26 
27  switch (row)
28  {
29  case 0:
30  s = format (s, "%0.2f", (f64) ns->value[0] / ns->n_packets);
31  break;
32  case 1:
33  s = format (s, "%0.2f", (f64) ns->value[1] / ns->n_packets);
34  break;
35  case 2:
36  s =
37  format (s, "%0.2f",
38  (f64) (ns->value[1] - clib_min (ns->value[1], ns->value[2])) /
39  ns->n_packets);
40  break;
41  case 3:
42  s = format (s, "%0.2f", (f64) ns->value[2] / ns->n_packets);
43  break;
44  case 4:
45  s =
46  format (s, "%0.2f",
47  (f64) (ns->value[2] - clib_min (ns->value[2], ns->value[3])) /
48  ns->n_packets);
49  break;
50  case 5:
51  s = format (s, "%0.2f", (f64) ns->value[3] / ns->n_packets);
52  break;
53  }
54 
55  return s;
56 }
57 
58 PERFMON_REGISTER_BUNDLE (intel_core_cache_miss_hit) = {
59  .name = "cache-hierarchy",
60  .description = "cache hits and misses",
61  .source = "intel-core",
63 
64  .events[0] = INTEL_CORE_E_MEM_LOAD_RETIRED_L1_HIT,
65  .events[1] = INTEL_CORE_E_MEM_LOAD_RETIRED_L1_MISS,
66  .events[2] = INTEL_CORE_E_MEM_LOAD_RETIRED_L2_MISS,
67  .events[3] = INTEL_CORE_E_MEM_LOAD_RETIRED_L3_MISS,
68  .n_events = 4,
70  .column_headers = PERFMON_STRINGS ("L1 hit/pkt", "L1 miss/pkt", "L2 hit/pkt",
71  "L2 miss/pkt", "L3 hit/pkt",
72  "L3 miss/pkt"),
73 };
#define clib_min(x, y)
Definition: clib.h:342
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_core_cache_miss_hit)
u64 value[PERF_MAX_EVENTS]
Definition: perfmon.h:138
static u8 * format_intel_core_cache_hit_miss(u8 *s, va_list *args)