perfmon: new perfmon plugin
[vpp.git] / src / plugins / perfmon / intel / bundle / load_blocks.c
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 <perfmon/perfmon.h>
18 #include <perfmon/intel/core.h>
19
20 static u8 *
21 format_load_blocks (u8 *s, va_list *args)
22 {
23   perfmon_node_stats_t *ns = va_arg (*args, perfmon_node_stats_t *);
24   int row = va_arg (*args, int);
25
26   switch (row)
27     {
28     case 0:
29       s = format (s, "%12lu", ns->n_calls);
30       break;
31     case 1:
32       s = format (s, "%12lu", ns->n_packets);
33       break;
34     case 2:
35       s = format (s, "%9.2f", (f64) ns->value[0] / ns->n_calls);
36       break;
37     case 3:
38       s = format (s, "%9.2f", (f64) ns->value[1] / ns->n_calls);
39       break;
40     case 4:
41       s = format (s, "%9.2f", (f64) ns->value[2] / ns->n_calls);
42       break;
43     }
44   return s;
45 }
46
47 PERFMON_REGISTER_BUNDLE (load_blocks) = {
48   .name = "load-blocks",
49   .description = "load operations blocked due to various uarch reasons",
50   .source = "intel-core",
51   .type = PERFMON_BUNDLE_TYPE_NODE,
52   .events[0] = INTEL_CORE_E_LD_BLOCKS_STORE_FORWARD,
53   .events[1] = INTEL_CORE_E_LD_BLOCKS_NO_SR,
54   .events[2] = INTEL_CORE_E_LD_BLOCKS_PARTIAL_ADDRESS_ALIAS,
55   .n_events = 3,
56   .format_fn = format_load_blocks,
57   .column_headers = PERFMON_STRINGS ("Calls", "Packets", "[1]", "[2]", "[3]"),
58   .footer = "Per node call statistics:\n"
59             "[1] Loads blocked due to overlapping with a preceding store that "
60             "cannot be forwarded.\n"
61             "[2] The number of times that split load operations are "
62             "temporarily blocked because\n"
63             "    all resources for handling the split accesses are in use\n"
64             "[3] False dependencies in Memory Order Buffer (MOB) due to "
65             "partial compare on address.\n",
66 };