LCOV - code coverage report
Current view: top level - plugins/perfmon/intel/bundle - mem_bw.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 1 25 4.0 %
Date: 2023-07-05 22:20:52 Functions: 1 2 50.0 %

          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 <vppinfra/linux/sysfs.h>
      18             : #include <perfmon/perfmon.h>
      19             : #include <perfmon/intel/uncore.h>
      20             : 
      21             : static u8 *
      22           0 : format_intel_uncore_imc_bw (u8 *s, va_list *args)
      23             : {
      24           0 :   perfmon_reading_t *r = va_arg (*args, perfmon_reading_t *);
      25           0 :   int col = va_arg (*args, int);
      26           0 :   f64 tr = r->time_running * 1e-9;
      27             : 
      28           0 :   switch (col)
      29             :     {
      30           0 :     case 0:
      31           0 :       s = format (s, "%9.2f", tr);
      32           0 :       break;
      33           0 :     case 1:
      34           0 :       if (r->time_running)
      35           0 :         s = format (s, "%9.2f", (f64) r->value[0] * 64 * 1e-6 / tr);
      36           0 :       break;
      37           0 :     case 2:
      38           0 :       if (r->time_running)
      39           0 :         s = format (s, "%9.2f", (f64) r->value[1] * 64 * 1e-6 / tr);
      40           0 :       break;
      41           0 :     case 3:
      42           0 :       if (r->time_running)
      43           0 :         s = format (s, "%9.2f",
      44           0 :                     (f64) (r->value[0] + r->value[1]) * 64 * 1e-6 / tr);
      45           0 :       break;
      46           0 :     default:
      47           0 :       break;
      48             :     }
      49             : 
      50           0 :   return s;
      51             : }
      52             : 
      53         559 : PERFMON_REGISTER_BUNDLE (intel_uncore_imc_bw) = {
      54             :   .name = "memory-bandwidth",
      55             :   .description = "memory reads and writes per memory controller channel",
      56             :   .source = "intel-uncore",
      57             :   .type = PERFMON_BUNDLE_TYPE_SYSTEM,
      58             :   .events[0] = INTEL_UNCORE_E_IMC_UNC_M_CAS_COUNT_RD,
      59             :   .events[1] = INTEL_UNCORE_E_IMC_UNC_M_CAS_COUNT_WR,
      60             :   .n_events = 2,
      61             :   .format_fn = format_intel_uncore_imc_bw,
      62             :   .column_headers = PERFMON_STRINGS ("RunTime", "Reads (MB/s)",
      63             :                                      "Writes (MB/s)", "Total (MB/s)"),
      64             : };

Generated by: LCOV version 1.14