From cbec1294e6e550a274178934b725973466e25968 Mon Sep 17 00:00:00 2001 From: Tyler Nijmeh Date: Fri, 14 Jun 2019 15:04:57 -0700 Subject: [PATCH] block: Disable preemption during IPI consideration The function `__blk_complete_request` attempts to acquire the current CPU. It determines where the demanding request should be processed. In doing so, it checks if the current CPU and the previously requested CPU share the same cache, and if so, to place the request on the local CPU. The issue with acquiring the current CPU with using `smp_processor_id` is that the current task might be preempted mid-request completion. This will either delay block requests from being executed, or fail to execute entirely. Use `get_cpu` and `put_cpu` to prevent this oops from occurring. See `blk-mq.c` for more details. Change-Id: I4b97c1eb91f4194920baaafbb6e488dfc38e07ab Signed-off-by: Tyler Nijmeh Signed-off-by: Richard Raya --- block/blk-softirq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/blk-softirq.c b/block/blk-softirq.c index c77a77c5e1db..f52b210d6c7a 100644 --- a/block/blk-softirq.c +++ b/block/blk-softirq.c @@ -105,7 +105,7 @@ void __blk_complete_request(struct request *req) BUG_ON(!q->softirq_done_fn); local_irq_save(flags); - cpu = smp_processor_id(); + cpu = get_cpu(); /* * Select completion CPU @@ -147,6 +147,7 @@ do_local: } else if (raise_blk_irq(ccpu, req)) goto do_local; + put_cpu(); local_irq_restore(flags); }