LCOV - code coverage report
Current view: top level - block - blk-mq-cpu.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 4 21 19.0 %
Date: 2014-04-16 Functions: 1 5 20.0 %
Branches: 1 4 25.0 %

           Branch data     Line data    Source code
       1                 :            : #include <linux/kernel.h>
       2                 :            : #include <linux/module.h>
       3                 :            : #include <linux/init.h>
       4                 :            : #include <linux/blkdev.h>
       5                 :            : #include <linux/list.h>
       6                 :            : #include <linux/llist.h>
       7                 :            : #include <linux/smp.h>
       8                 :            : #include <linux/cpu.h>
       9                 :            : 
      10                 :            : #include <linux/blk-mq.h>
      11                 :            : #include "blk-mq.h"
      12                 :            : 
      13                 :            : static LIST_HEAD(blk_mq_cpu_notify_list);
      14                 :            : static DEFINE_RAW_SPINLOCK(blk_mq_cpu_notify_lock);
      15                 :            : 
      16                 :          0 : static int blk_mq_main_cpu_notify(struct notifier_block *self,
      17                 :            :                                   unsigned long action, void *hcpu)
      18                 :            : {
      19                 :        555 :         unsigned int cpu = (unsigned long) hcpu;
      20                 :            :         struct blk_mq_cpu_notifier *notify;
      21                 :            : 
      22                 :        555 :         raw_spin_lock(&blk_mq_cpu_notify_lock);
      23                 :            : 
      24         [ -  + ]:       1110 :         list_for_each_entry(notify, &blk_mq_cpu_notify_list, list)
      25                 :          0 :                 notify->notify(notify->data, action, cpu);
      26                 :            : 
      27                 :            :         raw_spin_unlock(&blk_mq_cpu_notify_lock);
      28                 :        555 :         return NOTIFY_OK;
      29                 :            : }
      30                 :            : 
      31                 :          0 : void blk_mq_register_cpu_notifier(struct blk_mq_cpu_notifier *notifier)
      32                 :            : {
      33         [ #  # ]:          0 :         BUG_ON(!notifier->notify);
      34                 :            : 
      35                 :          0 :         raw_spin_lock(&blk_mq_cpu_notify_lock);
      36                 :          0 :         list_add_tail(&notifier->list, &blk_mq_cpu_notify_list);
      37                 :            :         raw_spin_unlock(&blk_mq_cpu_notify_lock);
      38                 :          0 : }
      39                 :            : 
      40                 :          0 : void blk_mq_unregister_cpu_notifier(struct blk_mq_cpu_notifier *notifier)
      41                 :            : {
      42                 :          0 :         raw_spin_lock(&blk_mq_cpu_notify_lock);
      43                 :            :         list_del(&notifier->list);
      44                 :            :         raw_spin_unlock(&blk_mq_cpu_notify_lock);
      45                 :          0 : }
      46                 :            : 
      47                 :          0 : void blk_mq_init_cpu_notifier(struct blk_mq_cpu_notifier *notifier,
      48                 :            :                               void (*fn)(void *, unsigned long, unsigned int),
      49                 :            :                               void *data)
      50                 :            : {
      51                 :          0 :         notifier->notify = fn;
      52                 :          0 :         notifier->data = data;
      53                 :          0 : }
      54                 :            : 
      55                 :          0 : void __init blk_mq_cpu_init(void)
      56                 :            : {
      57                 :          0 :         hotcpu_notifier(blk_mq_main_cpu_notify, 0);
      58                 :          0 : }

Generated by: LCOV version 1.9