FD.io VPP  v21.06
Vector Packet Processing
topdown_metrics.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 Intel 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 <perfmon/perfmon.h>
18 #include <perfmon/intel/core.h>
19 
20 #define GET_METRIC(m, i) (((m) >> (i * 8)) & 0xff)
21 #define GET_RATIO(m, i) (((m) >> (i * 32)) & 0xffffffff)
22 #define RDPMC_FIXED_SLOTS (1 << 30) /* fixed slots */
23 #define RDPMC_L1_METRICS (1 << 29) /* l1 metric counters */
24 
25 #define FIXED_COUNTER_SLOTS 3
26 #define METRIC_COUNTER_TOPDOWN_L1 0
27 
28 typedef enum
29 {
35 
36 enum
37 {
41 
44 {
45  f64 slots_t0 =
46  ns->t[0].value[TOPDOWN_SLOTS] *
47  ((f64) GET_METRIC (ns->t[0].value[TOPDOWN_METRICS], e) / 0xff);
48  f64 slots_t1 =
49  ns->t[1].value[TOPDOWN_SLOTS] *
50  ((f64) GET_METRIC (ns->t[1].value[TOPDOWN_METRICS], e) / 0xff);
51  u64 slots_delta =
52  ns->t[1].value[TOPDOWN_SLOTS] - ns->t[0].value[TOPDOWN_SLOTS];
53 
54  slots_t1 = slots_t1 - slots_t0;
55 
56  return (slots_t1 / slots_delta) * 100;
57 }
58 
59 static u8 *
60 format_topdown_lvl1 (u8 *s, va_list *args)
61 {
62  perfmon_node_stats_t *st = va_arg (*args, perfmon_node_stats_t *);
63  u64 row = va_arg (*args, int);
64 
65  switch (row)
66  {
67  case 0:
68  s = format (s, "%f",
71  break;
72  case 1:
73  s = format (s, "%f",
76  break;
77  case 2:
78  s = format (s, "%f",
80  break;
81  case 3:
82  s = format (s, "%f",
84  break;
85  case 4:
86  s = format (s, "%f",
88  break;
89  case 5:
90  s = format (s, "%f",
92  break;
93  }
94  return s;
95 }
96 
97 PERFMON_REGISTER_BUNDLE (topdown_lvl1) = {
98  .name = "topdown-level1",
99  .description = "Top-down Microarchitecture Analysis Level 1",
100  .source = "intel-core",
101  .type = PERFMON_BUNDLE_TYPE_NODE,
102  .offset_type = PERFMON_OFFSET_TYPE_METRICS,
103  .events[0] = INTEL_CORE_E_TOPDOWN_SLOTS,
104  .events[1] = INTEL_CORE_E_TOPDOWN_L1_METRICS,
105  .metrics[0] = RDPMC_FIXED_SLOTS | FIXED_COUNTER_SLOTS,
107  .n_events = 2,
108  .cpu_supports = clib_cpu_supports_avx512_bitalg,
109  .format_fn = format_topdown_lvl1,
110  .column_headers = PERFMON_STRINGS ("% NS", "% ST", "% NS.RT", "% NS.BS",
111  "% ST.FE", "% ST.BE"),
112  .footer = "Not Stalled (NS),STalled (ST),\n"
113  " Retiring (RT), Bad Speculation (BS),\n"
114  " FrontEnd bound (FE), BackEnd bound (BE)",
115 };
#define RDPMC_FIXED_SLOTS
unsigned long u64
Definition: types.h:89
static_always_inline f32 topdown_lvl1_parse_row(perfmon_node_stats_t *ns, topdown_lvl1_counters_t e)
unsigned char u8
Definition: types.h:56
#define FIXED_COUNTER_SLOTS
double f64
Definition: types.h:142
#define static_always_inline
Definition: clib.h:112
description fragment has unexpected format
Definition: map.api:433
#define GET_METRIC(m, i)
#define PERFMON_STRINGS(...)
Definition: perfmon.h:195
PERFMON_REGISTER_BUNDLE(topdown_lvl1)
#define RDPMC_L1_METRICS
static u8 * format_topdown_lvl1(u8 *s, va_list *args)
float f32
Definition: types.h:143
enum @756 topdown_lvl1_metrics_t
topdown_lvl1_counters_t
#define METRIC_COUNTER_TOPDOWN_L1
struct perfmon_node_stats_t::@759::@761 t[2]