LCOV - code coverage report
Current view: top level - plugins/perfmon/intel/bundle - topdown_tremont.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 3 23 13.0 %
Date: 2023-07-05 22:20:52 Functions: 2 3 66.7 %

          Line data    Source code
       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             : typedef enum
      21             : {
      22             :   TOPDOWN_E_RETIRING = 0,
      23             :   TOPDOWN_E_BAD_SPEC,
      24             :   TOPDOWN_E_FE_BOUND,
      25             :   TOPDOWN_E_BE_BOUND,
      26             :   TOPDOWN_E_MAX,
      27             : } topdown_lvl1_t;
      28             : 
      29             : static u8 *
      30           0 : format_topdown_lvl1 (u8 *s, va_list *args)
      31             : {
      32           0 :   perfmon_reading_t *ss = va_arg (*args, perfmon_reading_t *);
      33           0 :   u64 idx = va_arg (*args, int);
      34           0 :   f64 sv = 0;
      35           0 :   u64 total = 0;
      36             : 
      37           0 :   for (int i = 0; i < TOPDOWN_E_MAX; i++)
      38           0 :     total += ss->value[i];
      39             : 
      40           0 :   switch (idx)
      41             :     {
      42           0 :     case 0:
      43           0 :       sv = (f64) ss->value[TOPDOWN_E_RETIRING] + ss->value[TOPDOWN_E_BAD_SPEC];
      44           0 :       break;
      45           0 :     case 1:
      46           0 :       sv = (f64) ss->value[TOPDOWN_E_FE_BOUND] + ss->value[TOPDOWN_E_BE_BOUND];
      47           0 :       break;
      48           0 :     default:
      49           0 :       sv = (f64) ss->value[idx - 2];
      50           0 :       break;
      51             :     }
      52             : 
      53           0 :   sv = (sv / total) * 100;
      54           0 :   s = format (s, "%f", sv);
      55           0 :   return s;
      56             : }
      57             : 
      58             : static int
      59        1118 : is_tremont ()
      60             : {
      61        1118 :   return clib_cpu_supports_movdir64b () && !clib_cpu_supports_avx2 ();
      62             : }
      63             : 
      64             : static perfmon_cpu_supports_t topdown_lvl1_cpu_supports[] = {
      65             :   { is_tremont, PERFMON_BUNDLE_TYPE_THREAD }
      66             : };
      67             : 
      68         559 : PERFMON_REGISTER_BUNDLE (topdown_lvl1_tremont) = {
      69             :   .name = "topdown-level1",
      70             :   .description = "Top-down Microarchitecture Analysis Level 1",
      71             :   .source = "intel-core",
      72             :   .events[0] = INTEL_CORE_E_TOPDOWN_L1_RETIRING_TREMONT,
      73             :   .events[1] = INTEL_CORE_E_TOPDOWN_L1_BAD_SPEC_TREMONT,
      74             :   .events[2] = INTEL_CORE_E_TOPDOWN_L1_FE_BOUND_TREMONT,
      75             :   .events[3] = INTEL_CORE_E_TOPDOWN_L1_BE_BOUND_TREMONT,
      76             :   .n_events = 4,
      77             :   .cpu_supports = topdown_lvl1_cpu_supports,
      78             :   .n_cpu_supports = ARRAY_LEN (topdown_lvl1_cpu_supports),
      79             :   .format_fn = format_topdown_lvl1,
      80             :   .column_headers = PERFMON_STRINGS ("% NS", "% ST", "% NS.RT", "% NS.BS",
      81             :                                      "% ST.FE", "% ST.BE"),
      82             :   .footer = "Not Stalled (NS),STalled (ST),\n"
      83             :             " Retiring (RT), Bad Speculation (BS),\n"
      84             :             " FrontEnd bound (FE), BackEnd bound (BE)",
      85             : };

Generated by: LCOV version 1.14