LCOV - code coverage report
Current view: top level - spdk/module/event/subsystems/scheduler - scheduler.c (source / functions) Hit Total Coverage
Test: Combined Lines: 27 29 93.1 %
Date: 2024-07-11 04:21:50 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 8 75.0 %

           Branch data     Line data    Source code
       1                 :            : /*   SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  *   Copyright (C) 2021 Intel Corporation.
       3                 :            :  *   All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #include "spdk/stdinc.h"
       7                 :            : #include "spdk/env.h"
       8                 :            : #include "spdk/scheduler.h"
       9                 :            : 
      10                 :            : #include "spdk_internal/event.h"
      11                 :            : #include "spdk_internal/init.h"
      12                 :            : 
      13                 :            : static void
      14                 :        935 : scheduler_subsystem_init(void)
      15                 :            : {
      16                 :        935 :         int rc = 0;
      17                 :            : 
      18                 :            :         /* Set the defaults */
      19         [ +  + ]:        935 :         if (spdk_scheduler_get() == NULL) {
      20                 :        868 :                 rc = spdk_scheduler_set("static");
      21                 :            :         }
      22                 :            : 
      23                 :        935 :         spdk_subsystem_init_next(rc);
      24                 :        935 : }
      25                 :            : 
      26                 :            : static void
      27                 :        935 : scheduler_subsystem_fini(void)
      28                 :            : {
      29                 :        935 :         spdk_scheduler_set_period(0);
      30                 :        935 :         spdk_scheduler_set(NULL);
      31                 :            : 
      32                 :        935 :         spdk_subsystem_fini_next();
      33                 :        935 : }
      34                 :            : 
      35                 :            : static void
      36                 :        115 : scheduler_write_config_json(struct spdk_json_write_ctx *w)
      37                 :            : {
      38                 :            :         struct spdk_scheduler *scheduler;
      39                 :            :         uint64_t scheduler_period;
      40                 :            : 
      41         [ -  + ]:        115 :         assert(w != NULL);
      42                 :            : 
      43                 :        115 :         scheduler = spdk_scheduler_get();
      44         [ -  + ]:        115 :         if (scheduler == NULL) {
      45                 :          0 :                 SPDK_ERRLOG("Unable to get scheduler info\n");
      46                 :          0 :                 return;
      47                 :            :         }
      48                 :            : 
      49                 :        115 :         scheduler_period = spdk_scheduler_get_period();
      50                 :            : 
      51                 :        115 :         spdk_json_write_array_begin(w);
      52                 :            : 
      53                 :        115 :         spdk_json_write_object_begin(w);
      54                 :        115 :         spdk_json_write_named_string(w, "method", "framework_set_scheduler");
      55                 :        115 :         spdk_json_write_named_object_begin(w, "params");
      56                 :        115 :         spdk_json_write_named_string(w, "name", scheduler->name);
      57         [ +  + ]:        115 :         if (scheduler_period != 0) {
      58                 :          2 :                 spdk_json_write_named_uint32(w, "period", scheduler_period);
      59                 :            :         }
      60                 :        115 :         spdk_json_write_object_end(w);
      61                 :        115 :         spdk_json_write_object_end(w);
      62                 :            : 
      63                 :        115 :         spdk_json_write_array_end(w);
      64                 :            : }
      65                 :            : 
      66                 :            : static struct spdk_subsystem g_spdk_subsystem_scheduler = {
      67                 :            :         .name = "scheduler",
      68                 :            :         .init = scheduler_subsystem_init,
      69                 :            :         .fini = scheduler_subsystem_fini,
      70                 :            :         .write_config_json = scheduler_write_config_json,
      71                 :            : };
      72                 :            : 
      73                 :       1021 : SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_scheduler);

Generated by: LCOV version 1.14