]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/blob - rt-patches/0164-blk-mq-revert-raw-locks-post-pone-notifier-to-POST_D.patch
rt_patches: required rebase due to printk change
[hercules2020/nv-tegra/linux-4.4.git] / rt-patches / 0164-blk-mq-revert-raw-locks-post-pone-notifier-to-POST_D.patch
1 From b4a2c96654d8ba0599c138e5340cf6647f85d8bd Mon Sep 17 00:00:00 2001
2 From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
3 Date: Sat, 3 May 2014 11:00:29 +0200
4 Subject: [PATCH 164/366] blk-mq: revert raw locks, post pone notifier to
5  POST_DEAD
6
7 The blk_mq_cpu_notify_lock should be raw because some CPU down levels
8 are called with interrupts off. The notifier itself calls currently one
9 function that is blk_mq_hctx_notify().
10 That function acquires the ctx->lock lock which is sleeping and I would
11 prefer to keep it that way. That function only moves IO-requests from
12 the CPU that is going offline to another CPU and it is currently the
13 only one. Therefore I revert the list lock back to sleeping spinlocks
14 and let the notifier run at POST_DEAD time.
15
16 Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
17 ---
18  block/blk-mq-cpu.c | 17 ++++++++++-------
19  block/blk-mq.c     |  2 +-
20  2 files changed, 11 insertions(+), 8 deletions(-)
21
22 diff --git a/block/blk-mq-cpu.c b/block/blk-mq-cpu.c
23 index bb3ed48..628c6c1 100644
24 --- a/block/blk-mq-cpu.c
25 +++ b/block/blk-mq-cpu.c
26 @@ -16,7 +16,7 @@
27  #include "blk-mq.h"
28  
29  static LIST_HEAD(blk_mq_cpu_notify_list);
30 -static DEFINE_RAW_SPINLOCK(blk_mq_cpu_notify_lock);
31 +static DEFINE_SPINLOCK(blk_mq_cpu_notify_lock);
32  
33  static int blk_mq_main_cpu_notify(struct notifier_block *self,
34                                   unsigned long action, void *hcpu)
35 @@ -25,7 +25,10 @@ static int blk_mq_main_cpu_notify(struct notifier_block *self,
36         struct blk_mq_cpu_notifier *notify;
37         int ret = NOTIFY_OK;
38  
39 -       raw_spin_lock(&blk_mq_cpu_notify_lock);
40 +       if (action != CPU_POST_DEAD)
41 +               return NOTIFY_OK;
42 +
43 +       spin_lock(&blk_mq_cpu_notify_lock);
44  
45         list_for_each_entry(notify, &blk_mq_cpu_notify_list, list) {
46                 ret = notify->notify(notify->data, action, cpu);
47 @@ -33,7 +36,7 @@ static int blk_mq_main_cpu_notify(struct notifier_block *self,
48                         break;
49         }
50  
51 -       raw_spin_unlock(&blk_mq_cpu_notify_lock);
52 +       spin_unlock(&blk_mq_cpu_notify_lock);
53         return ret;
54  }
55  
56 @@ -41,16 +44,16 @@ void blk_mq_register_cpu_notifier(struct blk_mq_cpu_notifier *notifier)
57  {
58         BUG_ON(!notifier->notify);
59  
60 -       raw_spin_lock(&blk_mq_cpu_notify_lock);
61 +       spin_lock(&blk_mq_cpu_notify_lock);
62         list_add_tail(&notifier->list, &blk_mq_cpu_notify_list);
63 -       raw_spin_unlock(&blk_mq_cpu_notify_lock);
64 +       spin_unlock(&blk_mq_cpu_notify_lock);
65  }
66  
67  void blk_mq_unregister_cpu_notifier(struct blk_mq_cpu_notifier *notifier)
68  {
69 -       raw_spin_lock(&blk_mq_cpu_notify_lock);
70 +       spin_lock(&blk_mq_cpu_notify_lock);
71         list_del(&notifier->list);
72 -       raw_spin_unlock(&blk_mq_cpu_notify_lock);
73 +       spin_unlock(&blk_mq_cpu_notify_lock);
74  }
75  
76  void blk_mq_init_cpu_notifier(struct blk_mq_cpu_notifier *notifier,
77 diff --git a/block/blk-mq.c b/block/blk-mq.c
78 index 0345b44..fe026b6 100644
79 --- a/block/blk-mq.c
80 +++ b/block/blk-mq.c
81 @@ -1642,7 +1642,7 @@ static int blk_mq_hctx_notify(void *data, unsigned long action,
82  {
83         struct blk_mq_hw_ctx *hctx = data;
84  
85 -       if (action == CPU_DEAD || action == CPU_DEAD_FROZEN)
86 +       if (action == CPU_POST_DEAD)
87                 return blk_mq_hctx_cpu_offline(hctx, cpu);
88  
89         /*
90 -- 
91 1.9.1
92