Line data Source code
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 0 : format_inst_and_clock (u8 *s, va_list *args)
22 : {
23 0 : perfmon_node_stats_t *ns = va_arg (*args, perfmon_node_stats_t *);
24 0 : int row = va_arg (*args, int);
25 :
26 0 : switch (row)
27 : {
28 0 : case 0:
29 0 : s = format (s, "%lu", ns->n_calls);
30 0 : break;
31 0 : case 1:
32 0 : s = format (s, "%lu", ns->n_packets);
33 0 : break;
34 0 : case 2:
35 0 : s = format (s, "%.2f", (f64) ns->n_packets / ns->n_calls);
36 0 : break;
37 0 : case 3:
38 0 : s = format (s, "%.2f", (f64) ns->value[1] / ns->n_packets);
39 0 : break;
40 0 : case 4:
41 0 : s = format (s, "%.2f", (f64) ns->value[0] / ns->n_packets);
42 0 : break;
43 0 : case 5:
44 0 : s = format (s, "%.2f", (f64) ns->value[0] / ns->value[1]);
45 0 : break;
46 : }
47 0 : return s;
48 : }
49 :
50 559 : PERFMON_REGISTER_BUNDLE (inst_and_clock) = {
51 : .name = "inst-and-clock",
52 : .description = "instructions/packet, cycles/packet and IPC",
53 : .source = "intel-core",
54 : .type = PERFMON_BUNDLE_TYPE_NODE,
55 : .events[0] = INTEL_CORE_E_INST_RETIRED_ANY_P,
56 : .events[1] = INTEL_CORE_E_CPU_CLK_UNHALTED_THREAD_P,
57 : .events[2] = INTEL_CORE_E_CPU_CLK_UNHALTED_REF_TSC,
58 : .n_events = 3,
59 : .format_fn = format_inst_and_clock,
60 : .column_headers = PERFMON_STRINGS ("Calls", "Packets", "Packets/Call",
61 : "Clocks/Packet", "Instructions/Packet",
62 : "IPC"),
63 : };
|