LCOV - code coverage report
Current view: top level - spdk/lib/env_dpdk - threads.c (source / functions) Hit Total Coverage
Test: Combined Lines: 28 34 82.4 %
Date: 2024-07-15 16:55:29 Functions: 8 10 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 10 70.0 %

           Branch data     Line data    Source code
       1                 :            : /*   SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  *   Copyright (C) 2017 Intel Corporation.
       3                 :            :  *   All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #include "env_internal.h"
       7                 :            : 
       8                 :            : #include <rte_config.h>
       9                 :            : #include <rte_lcore.h>
      10                 :            : 
      11                 :            : #include "spdk/cpuset.h"
      12                 :            : 
      13                 :            : uint32_t
      14                 :      54615 : spdk_env_get_core_count(void)
      15                 :            : {
      16                 :      54615 :         return rte_lcore_count();
      17                 :            : }
      18                 :            : 
      19                 :            : uint32_t
      20                 :  469851368 : spdk_env_get_current_core(void)
      21                 :            : {
      22                 :  469851368 :         return rte_lcore_id();
      23                 :            : }
      24                 :            : 
      25                 :            : uint32_t
      26                 :          0 : spdk_env_get_main_core(void)
      27                 :            : {
      28                 :          0 :         return rte_get_main_lcore();
      29                 :            : }
      30                 :            : 
      31                 :            : uint32_t
      32                 :      70631 : spdk_env_get_first_core(void)
      33                 :            : {
      34                 :      70631 :         return rte_get_next_lcore(-1, 0, 0);
      35                 :            : }
      36                 :            : 
      37                 :            : uint32_t
      38                 :       2795 : spdk_env_get_last_core(void)
      39                 :            : {
      40                 :            :         uint32_t i;
      41                 :       2795 :         uint32_t last_core = UINT32_MAX;
      42                 :            : 
      43         [ +  + ]:       6957 :         SPDK_ENV_FOREACH_CORE(i) {
      44                 :       4162 :                 last_core = i;
      45                 :            :         }
      46                 :            : 
      47         [ -  + ]:       2795 :         assert(last_core != UINT32_MAX);
      48                 :            : 
      49                 :       2795 :         return last_core;
      50                 :            : }
      51                 :            : 
      52                 :            : uint32_t
      53                 :     179328 : spdk_env_get_next_core(uint32_t prev_core)
      54                 :            : {
      55                 :            :         unsigned lcore;
      56                 :            : 
      57                 :     179328 :         lcore = rte_get_next_lcore(prev_core, 0, 0);
      58         [ +  + ]:     179328 :         if (lcore == RTE_MAX_LCORE) {
      59                 :      69831 :                 return UINT32_MAX;
      60                 :            :         }
      61                 :     109497 :         return lcore;
      62                 :            : }
      63                 :            : 
      64                 :            : uint32_t
      65                 :          0 : spdk_env_get_socket_id(uint32_t core)
      66                 :            : {
      67         [ #  # ]:          0 :         if (core >= RTE_MAX_LCORE) {
      68                 :          0 :                 return SPDK_ENV_SOCKET_ID_ANY;
      69                 :            :         }
      70                 :            : 
      71                 :          0 :         return rte_lcore_to_socket_id(core);
      72                 :            : }
      73                 :            : 
      74                 :            : void
      75                 :          5 : spdk_env_get_cpuset(struct spdk_cpuset *cpuset)
      76                 :            : {
      77                 :            :         uint32_t i;
      78                 :            : 
      79                 :          5 :         spdk_cpuset_zero(cpuset);
      80         [ +  + ]:         13 :         SPDK_ENV_FOREACH_CORE(i) {
      81                 :          8 :                 spdk_cpuset_set_cpu(cpuset, i, true);
      82                 :            :         }
      83                 :          5 : }
      84                 :            : 
      85                 :            : int
      86                 :       1226 : spdk_env_thread_launch_pinned(uint32_t core, thread_start_fn fn, void *arg)
      87                 :            : {
      88                 :            :         int rc;
      89                 :            : 
      90                 :       1226 :         rc = rte_eal_remote_launch(fn, arg, core);
      91                 :            : 
      92                 :       1226 :         return rc;
      93                 :            : }
      94                 :            : 
      95                 :            : void
      96                 :       5948 : spdk_env_thread_wait_all(void)
      97                 :            : {
      98                 :       5948 :         rte_eal_mp_wait_lcore();
      99                 :       5948 : }

Generated by: LCOV version 1.14