Skip to contentSkip to conversation

blk-mq: use __smp_call_function_single directly

PATCH In review Christoph Hellwig 2 participants 4 messages Jan 8, 2014 – Jan 10, 2014 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blk-mq: use __smp_call_function_single directly

__smp_call_function_single already avoids multiple IPIs by internally queing up the items, and now also is available for non-SMP builds as a trivially correct stub, so there is no need to wrap it. If the additional lock roundtrip cause problems my patch to convert the generic IPI code to llists is waiting to get merged will fix it.

---
 block/blk-mq-cpu.c |   31 ------------------------
 block/blk-mq.c     |   68 +++++++++-------------------------------------------
 block/blk-mq.h     |    1 -
 3 files changed, 11 insertions(+), 89 deletions(-)
block/blk-mq-cpu.c +0 -31
index 0045ace..20576e3 100644
@@ -28,32 +28,6 @@ static int blk_mq_main_cpu_notify(struct notifier_block *self,
 	return NOTIFY_OK;
 }
 
-static void blk_mq_cpu_notify(void *data, unsigned long action,
-			      unsigned int cpu)
-{
-	if (action == CPU_DEAD || action == CPU_DEAD_FROZEN) {
-		/*
-		 * If the CPU goes away, ensure that we run any pending
-		 * completions.
-		 */
-		struct llist_node *node;
-		struct request *rq;
-
-		local_irq_disable();
-
-		node = llist_del_all(&per_cpu(ipi_lists, cpu));
-		while (node) {
-			struct llist_node *next = node->next;
-
-			rq = llist_entry(node, struct request, ll_list);
-			__blk_mq_end_io(rq, rq->errors);
-			node = next;
-		}
-
-		local_irq_enable();
-	}
-}
-
 static struct notifier_block __cpuinitdata blk_mq_main_cpu_notifier = {
 	.notifier_call	= blk_mq_main_cpu_notify,
 };
@@ -82,12 +56,7 @@ void blk_mq_init_cpu_notifier(struct blk_mq_cpu_notifier *notifier,
 	notifier->data = data;
 }
 
-static struct blk_mq_cpu_notifier __cpuinitdata cpu_notifier = {
-	.notify = blk_mq_cpu_notify,
-};
-
 void __init blk_mq_cpu_init(void)
 {
 	register_hotcpu_notifier(&blk_mq_main_cpu_notifier);
-	blk_mq_register_cpu_notifier(&cpu_notifier);
 }
block/blk-mq.c +11 -57

96 lines not on this page · raw message

block/blk-mq.h +0 -1
index 52bf1f9..5761eed 100644
@@ -38,7 +38,6 @@ void blk_mq_init_cpu_notifier(struct blk_mq_cpu_notifier *notifier,
 void blk_mq_register_cpu_notifier(struct blk_mq_cpu_notifier *notifier);
 void blk_mq_unregister_cpu_notifier(struct blk_mq_cpu_notifier *notifier);
 void blk_mq_cpu_init(void);
-DECLARE_PER_CPU(struct llist_head, ipi_lists);
 
 /*
  * CPU -> queue mappings
Signature · 1 line
1.7.10.4
maintainer
#1 lore raw
Quoted 5 lines · Christoph Hellwig

__smp_call_function_single already avoids multiple IPIs by internally queing up the items, and now also is available for non-SMP builds as a trivially correct stub, so there is no need to wrap it. If the additional lock roundtrip cause problems my patch to convert the generic IPI code to llists is waiting to get merged will fix it.

Thanks Christoph, applied it.

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 8 lines · Jens Axboe
Quoted 5 lines · Christoph Hellwig

__smp_call_function_single already avoids multiple IPIs by internally queing up the items, and now also is available for non-SMP builds as a trivially correct stub, so there is no need to wrap it. If the additional lock roundtrip cause problems my patch to convert the generic IPI code to llists is waiting to get merged will fix it.

Thanks Christoph, applied it.

Btw, the same should be done to the null_blk ipi completion path in theory. But given that it always tries to IPI the local CPU __smp_call_function_single turns into a simple indirect function call, so I don't really understand the point of that code path at all.

maintainer
#3 lore raw
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · Jens Axboe
Quoted 5 lines · Christoph Hellwig

__smp_call_function_single already avoids multiple IPIs by internally queing up the items, and now also is available for non-SMP builds as a trivially correct stub, so there is no need to wrap it. If the additional lock roundtrip cause problems my patch to convert the generic IPI code to llists is waiting to get merged will fix it.

Quoted 6 lines
Quoted 1 line

Thanks Christoph, applied it.

Btw, the same should be done to the null_blk ipi completion path in theory. But given that it always tries to IPI the local CPU __smp_call_function_single turns into a simple indirect function call, so I don't really understand the point of that code path at all.

The idea would be to have it forced be remote, on the given CPU, not always just go local. So it just needs to be fixed up, it doesn't make a lot of sense as it stands as a separate completion method.

Signature · 1 line
Jens Axboe