All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	rt@linutronix.de, tglx@linutronix.de,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 20/21] blk: mq: cpu-notif: Convert to hotplug state machine
Date: Tue,  6 Sep 2016 19:04:56 +0200	[thread overview]
Message-ID: <20160906170457.32393-21-bigeasy@linutronix.de> (raw)
In-Reply-To: <20160906170457.32393-1-bigeasy@linutronix.de>

Install the callbacks via the state machine. The only currently handled
callback is CPU_DEAD and this one is converted.

Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
This patch against linux-next to take the block changes into account. It
depends on "blk: mq: reserve hotplug ID states for block"

 block/blk-mq-cpu.c     |   15 +++++++--------
 block/blk-mq.c         |   17 ++++-------------
 block/blk-mq.h         |    2 +-
 include/linux/blk-mq.h |    2 +-
 4 files changed, 13 insertions(+), 23 deletions(-)

--- a/block/blk-mq-cpu.c
+++ b/block/blk-mq-cpu.c
@@ -18,18 +18,16 @@
 static LIST_HEAD(blk_mq_cpu_notify_list);
 static DEFINE_RAW_SPINLOCK(blk_mq_cpu_notify_lock);
 
-static int blk_mq_main_cpu_notify(struct notifier_block *self,
-				  unsigned long action, void *hcpu)
+static int blk_mq_main_cpu_dead(unsigned int cpu)
 {
-	unsigned int cpu = (unsigned long) hcpu;
 	struct blk_mq_cpu_notifier *notify;
-	int ret = NOTIFY_OK;
+	int ret;
 
 	raw_spin_lock(&blk_mq_cpu_notify_lock);
 
 	list_for_each_entry(notify, &blk_mq_cpu_notify_list, list) {
-		ret = notify->notify(notify->data, action, cpu);
-		if (ret != NOTIFY_OK)
+		ret = notify->notify(notify->data, cpu);
+		if (ret)
 			break;
 	}
 
@@ -54,7 +52,7 @@ void blk_mq_unregister_cpu_notifier(stru
 }
 
 void blk_mq_init_cpu_notifier(struct blk_mq_cpu_notifier *notifier,
-			      int (*fn)(void *, unsigned long, unsigned int),
+			      int (*fn)(void *, unsigned int),
 			      void *data)
 {
 	notifier->notify = fn;
@@ -63,5 +61,6 @@ void blk_mq_init_cpu_notifier(struct blk
 
 void __init blk_mq_cpu_init(void)
 {
-	hotcpu_notifier(blk_mq_main_cpu_notify, 0);
+	cpuhp_setup_state_nocalls(CPUHP_BLKMQ_DEAD, "block/mq:dead", NULL,
+				  blk_mq_main_cpu_dead);
 }
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1649,7 +1649,7 @@ static int blk_mq_hctx_cpu_offline(struc
 	spin_unlock(&ctx->lock);
 
 	if (list_empty(&tmp))
-		return NOTIFY_OK;
+		return 0;
 
 	ctx = blk_mq_get_ctx(q);
 	spin_lock(&ctx->lock);
@@ -1669,23 +1669,14 @@ static int blk_mq_hctx_cpu_offline(struc
 
 	blk_mq_run_hw_queue(hctx, true);
 	blk_mq_put_ctx(ctx);
-	return NOTIFY_OK;
+	return 0;
 }
 
-static int blk_mq_hctx_notify(void *data, unsigned long action,
-			      unsigned int cpu)
+static int blk_mq_hctx_notify(void *data, unsigned int cpu)
 {
 	struct blk_mq_hw_ctx *hctx = data;
 
-	if (action == CPU_DEAD || action == CPU_DEAD_FROZEN)
-		return blk_mq_hctx_cpu_offline(hctx, cpu);
-
-	/*
-	 * In case of CPU online, tags may be reallocated
-	 * in blk_mq_map_swqueue() after mapping is updated.
-	 */
-
-	return NOTIFY_OK;
+	return blk_mq_hctx_cpu_offline(hctx, cpu);
 }
 
 /* hctx->ctxs will be freed in queue's release handler */
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -36,7 +36,7 @@ void blk_mq_wake_waiters(struct request_
  */
 struct blk_mq_cpu_notifier;
 void blk_mq_init_cpu_notifier(struct blk_mq_cpu_notifier *notifier,
-			      int (*fn)(void *, unsigned long, unsigned int),
+			      int (*fn)(void *, unsigned int),
 			      void *data);
 void blk_mq_register_cpu_notifier(struct blk_mq_cpu_notifier *notifier);
 void blk_mq_unregister_cpu_notifier(struct blk_mq_cpu_notifier *notifier);
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -9,7 +9,7 @@ struct blk_flush_queue;
 struct blk_mq_cpu_notifier {
 	struct list_head list;
 	void *data;
-	int (*notify)(void *data, unsigned long action, unsigned int cpu);
+	int (*notify)(void *data, unsigned int cpu);
 };
 
 struct blk_mq_ctxmap {

  parent reply	other threads:[~2016-09-06 17:06 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 01/21] arm64: FP/SIMD: Convert to hotplug state machine Sebastian Andrzej Siewior
2016-09-06 17:04   ` Sebastian Andrzej Siewior
2016-09-06 18:14   ` Will Deacon
2016-09-06 18:14     ` Will Deacon
2016-09-19 19:51   ` [tip:smp/hotplug] arm64/FP/SIMD: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 02/21] ARM: shmobile: " Sebastian Andrzej Siewior
2016-09-06 17:04   ` Sebastian Andrzej Siewior
2016-09-06 17:04   ` Sebastian Andrzej Siewior
2016-09-06 18:05   ` Geert Uytterhoeven
2016-09-06 18:05     ` Geert Uytterhoeven
2016-09-06 18:05     ` Geert Uytterhoeven
2016-09-06 18:05     ` Geert Uytterhoeven
2016-09-07 13:58     ` Sebastian Andrzej Siewior
2016-09-07 13:58       ` Sebastian Andrzej Siewior
2016-09-07 13:58       ` Sebastian Andrzej Siewior
2016-09-07 13:58       ` Sebastian Andrzej Siewior
2016-09-19 19:52   ` [tip:smp/hotplug] ARM/shmobile: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 03/21] ARM: OMAP: wakeupgen: " Sebastian Andrzej Siewior
2016-09-06 17:04   ` Sebastian Andrzej Siewior
2016-09-13 22:24   ` Tony Lindgren
2016-09-13 22:24     ` Tony Lindgren
2016-09-19 19:52   ` [tip:smp/hotplug] ARM/OMAP/wakeupgen: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 04/21] ia64: mca: " Sebastian Andrzej Siewior
2016-09-06 17:04   ` Sebastian Andrzej Siewior
2016-09-19 19:53   ` [tip:smp/hotplug] ia64/mca: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 05/21] sh: SH-X3 SMP: " Sebastian Andrzej Siewior
2016-09-06 17:04   ` Sebastian Andrzej Siewior
2016-09-19 19:53   ` [tip:smp/hotplug] sh/SH-X3 " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 06/21] x86: microcode: " Sebastian Andrzej Siewior
2016-09-07 11:36   ` Borislav Petkov
2016-09-07 14:51     ` Sebastian Andrzej Siewior
2016-09-07 16:02       ` Borislav Petkov
2016-09-07 16:45     ` [PATCH 06/21 v2] " Sebastian Andrzej Siewior
2016-09-19 19:54       ` [tip:smp/hotplug] x86/microcode: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 07/21] lib: irq_poll: " Sebastian Andrzej Siewior
2016-09-19 19:54   ` [tip:smp/hotplug] lib/irq_poll: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 08/21] block: softirq: " Sebastian Andrzej Siewior
2016-09-19 19:55   ` [tip:smp/hotplug] block/softirq: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 09/21] oprofile: timer: " Sebastian Andrzej Siewior
2016-09-19 19:55   ` [tip:smp/hotplug] oprofile/timer: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 10/21] virtio scsi: " Sebastian Andrzej Siewior
2016-09-06 17:04 ` Sebastian Andrzej Siewior
2016-09-19 19:56   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 11/21] ACPI: processor: " Sebastian Andrzej Siewior
2016-09-06 21:08   ` Rafael J. Wysocki
2016-09-07 14:01     ` Sebastian Andrzej Siewior
2016-09-07 15:59       ` Rafael J. Wysocki
2016-09-19 19:56   ` [tip:smp/hotplug] ACPI/processor: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 12/21] cpufreq: " Sebastian Andrzej Siewior
2016-09-06 21:27   ` Rafael J. Wysocki
2016-09-07 14:18     ` Sebastian Andrzej Siewior
2016-09-07 15:58       ` Rafael J. Wysocki
2016-09-19 19:56   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-20 14:56     ` [PATCH] cpufreq: fix up conversion " Sebastian Andrzej Siewior
2016-09-20 15:07       ` [tip:smp/hotplug] cpufreq: Fix " tip-bot for Sebastian Andrzej Siewior
2016-09-20 16:08         ` Borislav Petkov
2016-09-20 16:17       ` [PATCH] cpufreq: fix " Rafael J. Wysocki
2016-09-06 17:04 ` [PATCH 13/21] padata: Convert " Sebastian Andrzej Siewior
2016-09-19 19:57   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 14/21] fault-injection: cpu: " Sebastian Andrzej Siewior
2016-09-19 19:57   ` [tip:smp/hotplug] fault-injection/cpu: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 15/21] mips: octeon: smp: " Sebastian Andrzej Siewior
2016-09-07  8:24   ` Matt Redfearn
2016-09-07  8:24     ` Matt Redfearn
2016-09-07 14:27     ` Sebastian Andrzej Siewior
2016-09-08  8:34       ` Matt Redfearn
2016-09-08  8:34         ` Matt Redfearn
2016-09-19 15:10   ` Ralf Baechle
2016-09-19 19:58   ` [tip:smp/hotplug] mips/octeon/smp: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 16/21] mips: loongson: smp: " Sebastian Andrzej Siewior
2016-09-19 15:10   ` Ralf Baechle
2016-09-19 19:58   ` [tip:smp/hotplug] mips/loongson/smp: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 17/21] s390: mm: pfault: " Sebastian Andrzej Siewior
2016-09-19 19:59   ` [tip:smp/hotplug] s390/mm/pfault: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 18/21] x86: apic: uv: " Sebastian Andrzej Siewior
2016-09-19 19:59   ` [tip:smp/hotplug] x86/apic/uv: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 19/21] blk: mq: reserve hotplug ID states for block Sebastian Andrzej Siewior
2016-09-19 20:03   ` [tip:smp/hotplug] blk/mq: Reserve hotplug ID states for block multiqueue tip-bot for Sebastian Andrzej Siewior
2016-09-19 21:24   ` [tip:smp/hotplug] blk/mq: Reserve hotplug " tip-bot for Sebastian Andrzej Siewior
2016-09-21  7:45   ` tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` Sebastian Andrzej Siewior [this message]
2016-09-06 17:04 ` [PATCH 21/21] blk: mq: Convert to hotplug state machine Sebastian Andrzej Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160906170457.32393-21-bigeasy@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rt@linutronix.de \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.