LCOV - code coverage report
Current view: top level - spdk/test/unit/lib/blob - bs_scheduler.c (source / functions) Hit Total Coverage
Test: Combined Lines: 4 23 17.4 %
Date: 2024-07-15 14:20:07 Functions: 1 3 33.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 16 12.5 %

           Branch data     Line data    Source code
       1                 :            : /*   SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  *   Copyright (C) 2018 Intel Corporation.
       3                 :            :  *   All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #include "spdk/thread.h"
       7                 :            : 
       8                 :            : bool g_scheduler_delay = false;
       9                 :            : 
      10                 :            : struct scheduled_ops {
      11                 :            :         spdk_msg_fn     fn;
      12                 :            :         void            *ctx;
      13                 :            : 
      14                 :            :         TAILQ_ENTRY(scheduled_ops)      ops_queue;
      15                 :            : };
      16                 :            : 
      17                 :            : static TAILQ_HEAD(, scheduled_ops) g_scheduled_ops = TAILQ_HEAD_INITIALIZER(g_scheduled_ops);
      18                 :            : 
      19                 :            : void _bs_flush_scheduler(uint32_t);
      20                 :            : 
      21                 :            : static void
      22                 :     253280 : _bs_send_msg(spdk_msg_fn fn, void *ctx, void *thread_ctx)
      23                 :            : {
      24   [ -  +  -  + ]:     253280 :         if (g_scheduler_delay) {
      25                 :          0 :                 struct scheduled_ops *ops = calloc(1, sizeof(*ops));
      26                 :            : 
      27         [ #  # ]:          0 :                 SPDK_CU_ASSERT_FATAL(ops != NULL);
      28                 :          0 :                 ops->fn = fn;
      29                 :          0 :                 ops->ctx = ctx;
      30                 :          0 :                 TAILQ_INSERT_TAIL(&g_scheduled_ops, ops, ops_queue);
      31                 :            : 
      32                 :            :         } else {
      33                 :     253280 :                 fn(ctx);
      34                 :            :         }
      35                 :     253280 : }
      36                 :            : 
      37                 :            : static void
      38                 :          0 : _bs_flush_scheduler_single(void)
      39                 :            : {
      40                 :            :         struct scheduled_ops *op;
      41                 :          0 :         TAILQ_HEAD(, scheduled_ops) ops;
      42                 :          0 :         TAILQ_INIT(&ops);
      43                 :            : 
      44   [ #  #  #  # ]:          0 :         TAILQ_SWAP(&g_scheduled_ops, &ops, scheduled_ops, ops_queue);
      45                 :            : 
      46         [ #  # ]:          0 :         while (!TAILQ_EMPTY(&ops)) {
      47                 :          0 :                 op = TAILQ_FIRST(&ops);
      48         [ #  # ]:          0 :                 TAILQ_REMOVE(&ops, op, ops_queue);
      49                 :            : 
      50                 :          0 :                 op->fn(op->ctx);
      51                 :          0 :                 free(op);
      52                 :            :         }
      53                 :          0 : }
      54                 :            : 
      55                 :            : void
      56                 :          0 : _bs_flush_scheduler(uint32_t n)
      57                 :            : {
      58         [ #  # ]:          0 :         while (n--) {
      59                 :          0 :                 _bs_flush_scheduler_single();
      60                 :            :         }
      61                 :          0 : }

Generated by: LCOV version 1.14