1*82e53e7aSIan Rogers# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) 2*82e53e7aSIan Rogersfrom metric import (d_ratio, Event, Metric, MetricGroup) 3*82e53e7aSIan Rogers 4*82e53e7aSIan Rogers 5*82e53e7aSIan Rogersdef Cycles() -> MetricGroup: 6*82e53e7aSIan Rogers cyc_k = Event("cpu\\-cycles:kHh") # exclude user and guest 7*82e53e7aSIan Rogers cyc_g = Event("cpu\\-cycles:G") # exclude host 8*82e53e7aSIan Rogers cyc_u = Event("cpu\\-cycles:uH") # exclude kernel, hypervisor and guest 9*82e53e7aSIan Rogers cyc = cyc_k + cyc_g + cyc_u 10*82e53e7aSIan Rogers 11*82e53e7aSIan Rogers return MetricGroup("lpm_cycles", [ 12*82e53e7aSIan Rogers Metric("lpm_cycles_total", "Total number of cycles", cyc, "cycles"), 13*82e53e7aSIan Rogers Metric("lpm_cycles_user", "User cycles as a percentage of all cycles", 14*82e53e7aSIan Rogers d_ratio(cyc_u, cyc), "100%"), 15*82e53e7aSIan Rogers Metric("lpm_cycles_kernel", "Kernel cycles as a percentage of all cycles", 16*82e53e7aSIan Rogers d_ratio(cyc_k, cyc), "100%"), 17*82e53e7aSIan Rogers Metric("lpm_cycles_guest", "Hypervisor guest cycles as a percentage of all cycles", 18*82e53e7aSIan Rogers d_ratio(cyc_g, cyc), "100%"), 19*82e53e7aSIan Rogers ], description="cycles breakdown per privilege level (users, kernel, guest)") 20