LCOV - code coverage report
Current view: top level - lib/graph - graph_debug.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 16 68 23.5 %
Date: 2026-11-01 19:11:22 Functions: 1 3 33.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 5 28 17.9 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2020 Marvell International Ltd.
       3                 :            :  */
       4                 :            : 
       5                 :            : 
       6                 :            : #include "graph_private.h"
       7                 :            : 
       8                 :            : #include <eal_export.h>
       9                 :            : 
      10                 :            : void
      11                 :          0 : graph_dump(FILE *f, struct graph *g)
      12                 :            : {
      13                 :            :         struct graph_node *graph_node;
      14                 :            :         rte_edge_t i = 0;
      15                 :            : 
      16                 :          0 :         fprintf(f, "graph <%s>\n", g->name);
      17                 :          0 :         fprintf(f, "  id=%" PRIu32 "\n", g->id);
      18                 :          0 :         fprintf(f, "  sched_table_off=%" PRIu32 "\n", g->sched_table_off);
      19                 :          0 :         fprintf(f, "  nb_sched_words=%" PRIu16 "\n", g->nb_sched_words);
      20                 :            :         fprintf(f, "  addr=%p\n", g);
      21                 :          0 :         fprintf(f, "  graph=%p\n", g->graph);
      22                 :          0 :         fprintf(f, "  mem_sz=%zu\n", g->mem_sz);
      23                 :          0 :         fprintf(f, "  node_count=%" PRIu32 "\n", g->node_count);
      24                 :          0 :         fprintf(f, "  src_node_count=%" PRIu32 "\n", g->src_node_count);
      25                 :            : 
      26         [ #  # ]:          0 :         STAILQ_FOREACH(graph_node, &g->node_list, next)
      27                 :          0 :                 fprintf(f, "     node[%d] <%s>\n", i++, graph_node->node->name);
      28                 :          0 : }
      29                 :            : 
      30                 :            : void
      31                 :         34 : node_dump(FILE *f, struct node *n)
      32                 :            : {
      33                 :            :         rte_edge_t i;
      34                 :            : 
      35                 :         34 :         fprintf(f, "node <%s>\n", n->name);
      36                 :         34 :         fprintf(f, "  id=%" PRIu32 "\n", n->id);
      37                 :         34 :         fprintf(f, "  flags=0x%" PRIx64 "\n", n->flags);
      38                 :            :         fprintf(f, "  addr=%p\n", n);
      39                 :         34 :         fprintf(f, "  process=%p\n", n->process);
      40         [ +  - ]:         34 :         if (n->parent_id == RTE_NODE_ID_INVALID)
      41                 :            :                 fprintf(f, "  parent_id=RTE_NODE_ID_INVALID\n");
      42                 :            :         else
      43                 :            :                 fprintf(f, "  parent_id=%" PRIu32 "\n", n->parent_id);
      44                 :         34 :         fprintf(f, "  init=%p\n", n->init);
      45                 :         34 :         fprintf(f, "  fini=%p\n", n->fini);
      46                 :         34 :         fprintf(f, "  xstats=%p\n", n->xstats);
      47                 :         34 :         fprintf(f, "  next node addr=%p\n", STAILQ_NEXT(n, next));
      48         [ +  + ]:         34 :         if (STAILQ_NEXT(n, next))
      49                 :         33 :                 fprintf(f, "  next node name=%s\n", STAILQ_NEXT(n, next)->name);
      50                 :         34 :         fprintf(f, "  nb_edges=%d\n", n->nb_edges);
      51         [ +  + ]:         78 :         for (i = 0; i < n->nb_edges; i++)
      52                 :         44 :                 fprintf(f, "     edge[%d] <%s>\n", i, n->next_nodes[i]);
      53                 :         34 : }
      54                 :            : 
      55                 :            : RTE_EXPORT_SYMBOL(rte_graph_obj_dump)
      56                 :            : void
      57                 :          0 : rte_graph_obj_dump(FILE *f, struct rte_graph *g, bool all)
      58                 :            : {
      59                 :            :         rte_node_t count;
      60                 :            :         rte_graph_off_t off;
      61                 :            :         struct rte_node *n;
      62                 :            :         rte_edge_t i;
      63                 :            :         uint64_t all_total_cycles = 0;
      64                 :            : 
      65                 :          0 :         fprintf(f, "graph <%s> @ %p\n", g->name, g);
      66                 :          0 :         fprintf(f, "  id=%" PRIu32 "\n", g->id);
      67                 :          0 :         fprintf(f, "  nb_nodes=%" PRId32 "\n", g->nb_nodes);
      68                 :          0 :         fprintf(f, "  nb_sched_words=%" PRIu16 "\n", g->nb_sched_words);
      69                 :          0 :         fprintf(f, "  socket=%d\n", g->socket);
      70                 :          0 :         fprintf(f, "  fence=0x%" PRIx64 "\n", g->fence);
      71                 :          0 :         fprintf(f, "  nodes_start=0x%" PRIx32 "\n", g->nodes_start);
      72                 :          0 :         fprintf(f, "  sched_table=%p\n", g->sched_table);
      73                 :          0 :         fprintf(f, "  pending=%p\n", g->pending);
      74                 :          0 :         fprintf(f, "  src_pending=%p\n", g->src_pending);
      75                 :            : 
      76         [ #  # ]:          0 :         rte_graph_foreach_node(count, off, g, n) {
      77   [ #  #  #  # ]:          0 :                 if (!all && n->idx == 0)
      78                 :          0 :                         continue;
      79                 :          0 :                 all_total_cycles += n->total_cycles;
      80                 :            :         }
      81                 :            : 
      82         [ #  # ]:          0 :         rte_graph_foreach_node(count, off, g, n) {
      83   [ #  #  #  # ]:          0 :                 if (!all && n->idx == 0)
      84                 :          0 :                         continue;
      85                 :          0 :                 fprintf(f, "     node[%d] <%s>\n", count, n->name);
      86                 :          0 :                 fprintf(f, "       fence=0x%" PRIx64 "\n", n->fence);
      87                 :          0 :                 fprintf(f, "       objs=%p\n", n->objs);
      88                 :          0 :                 fprintf(f, "       process=%p\n", n->process);
      89                 :          0 :                 fprintf(f, "       id=0x%" PRIx32 "\n", n->id);
      90                 :          0 :                 fprintf(f, "       offset=0x%" PRIx32 "\n", n->off);
      91                 :          0 :                 fprintf(f, "       nb_edges=%" PRId32 "\n", n->nb_edges);
      92                 :          0 :                 fprintf(f, "       realloc_count=%d\n", n->realloc_count);
      93                 :          0 :                 fprintf(f, "       size=%d\n", n->size);
      94                 :          0 :                 fprintf(f, "       idx=%d\n", n->idx);
      95                 :          0 :                 fprintf(f, "       total_objs=%" PRId64 "\n", n->total_objs);
      96         [ #  # ]:          0 :                 if (rte_graph_worker_model_get(g) == RTE_GRAPH_MODEL_MCORE_DISPATCH) {
      97                 :          0 :                         fprintf(f, "       total_sched_objs=%" PRId64 "\n",
      98                 :            :                                 n->dispatch.total_sched_objs);
      99                 :          0 :                         fprintf(f, "       total_sched_fail=%" PRId64 "\n",
     100                 :            :                                 n->dispatch.total_sched_fail);
     101                 :            :                 }
     102                 :          0 :                 fprintf(f, "       total_calls=%" PRId64 "\n", n->total_calls);
     103                 :            :                 if (rte_graph_has_stats_feature())
     104         [ #  # ]:          0 :                         fprintf(f, "       total_cycles=%" PRIu64 " (%.1f%% of all nodes), avg cycles/call=%.1f\n",
     105                 :            :                                 n->total_cycles,
     106                 :            :                                 all_total_cycles == 0 ? 0.0 :
     107                 :          0 :                                 (double)n->total_cycles / (double)all_total_cycles * 100.0,
     108         [ #  # ]:          0 :                                 n->total_calls == 0 ? 0.0 :
     109                 :          0 :                                 (double)n->total_cycles / (double)n->total_calls);
     110                 :            : 
     111                 :            : #ifdef RTE_GRAPH_PROFILE
     112                 :            :                 static const uint16_t sample_sizes[] = {
     113                 :            :                                 0, 1, 2, RTE_GRAPH_PROFILE_BURST_SMALL,
     114                 :            :                                 RTE_GRAPH_PROFILE_BURST_MEDIUM, RTE_GRAPH_PROFILE_BURST_LARGE};
     115                 :            :                 static_assert(RTE_DIM(sample_sizes) == 2U + RTE_DIM(n->usage_stats),
     116                 :            :                                 "usage_stats array size mismatch");
     117                 :            :                 for (unsigned int idx = 0; idx < RTE_DIM(sample_sizes); idx++) {
     118                 :            :                         uint64_t calls;
     119                 :            :                         uint64_t cycles;
     120                 :            :                         double objs_per_call;
     121                 :            :                         if (idx < 2) {
     122                 :            :                                 calls = n->usage_stats_01[idx].calls;
     123                 :            :                                 cycles = n->usage_stats_01[idx].cycles;
     124                 :            :                                 objs_per_call = (double)idx;
     125                 :            :                                 fprintf(f, "       for %u objs/call\n",
     126                 :            :                                         idx);
     127                 :            :                         } else {
     128                 :            :                                 calls = n->usage_stats[idx - 2].calls;
     129                 :            :                                 cycles = n->usage_stats[idx - 2].cycles;
     130                 :            :                                 objs_per_call = calls == 0 ? 0.0 :
     131                 :            :                                                 (double)n->usage_stats[idx - 2].objs /
     132                 :            :                                                 (double)calls;
     133                 :            :                                 if (idx < RTE_DIM(sample_sizes) - 1)
     134                 :            :                                         fprintf(f, "       for [%u;%u[ objs/call",
     135                 :            :                                                 sample_sizes[idx], sample_sizes[idx + 1]);
     136                 :            :                                 else
     137                 :            :                                         fprintf(f, "       for %u+ objs/call",
     138                 :            :                                                 sample_sizes[idx]);
     139                 :            :                                 if (calls != 0)
     140                 :            :                                         fprintf(f, ", avg %.1f objs/call\n",
     141                 :            :                                                 objs_per_call);
     142                 :            :                                 fprintf(f, "\n");
     143                 :            :                         }
     144                 :            :                         fprintf(f, "         calls=%" PRIu64,
     145                 :            :                                 calls);
     146                 :            :                         if (calls != 0) {
     147                 :            :                                 fprintf(f, " (%.1f%% of this node)\n",
     148                 :            :                                         n->total_calls == 0 ? 0.0 :
     149                 :            :                                         (double)calls / (double)n->total_calls * 100.0);
     150                 :            :                                 fprintf(f, "         cycles=%" PRIu64 " (%.1f%% of this node), avg cycles/call=%.1f",
     151                 :            :                                         cycles,
     152                 :            :                                         n->total_cycles == 0 ? 0.0 :
     153                 :            :                                         (double)cycles / (double)n->total_cycles * 100.0,
     154                 :            :                                         (double)cycles / (double)calls);
     155                 :            :                                 if (objs_per_call != 0.0)
     156                 :            :                                         fprintf(f, ", avg cycles/obj=%.1f",
     157                 :            :                                                 (double)cycles / (double)calls / objs_per_call);
     158                 :            :                         }
     159                 :            :                         fprintf(f, "\n");
     160                 :            :                 }
     161                 :            : #endif /* RTE_GRAPH_PROFILE */
     162                 :            : 
     163         [ #  # ]:          0 :                 for (i = 0; i < n->nb_edges; i++)
     164                 :            :                         fprintf(f, "          edge[%d] <%s>\n", i,
     165                 :          0 :                                 n->nodes[i]->name);
     166                 :            :         }
     167                 :          0 : }

Generated by: LCOV version 1.14