linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Richard Weinberger <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	mingo@kernel.org, tglx@linutronix.de, bigeasy@linutronix.de,
	hpa@zytor.com, richard@nod.at, peterz@infradead.org
Subject: [tip:smp/hotplug] relayfs: Convert to hotplug state machine
Date: Tue, 6 Sep 2016 08:20:46 -0700	[thread overview]
Message-ID: <tip-0a02f95b4e94fd2908518763a367d64fe78dd4db@git.kernel.org> (raw)
In-Reply-To: <20160818125731.27256-3-bigeasy@linutronix.de>

Commit-ID:  0a02f95b4e94fd2908518763a367d64fe78dd4db
Gitweb:     http://git.kernel.org/tip/0a02f95b4e94fd2908518763a367d64fe78dd4db
Author:     Richard Weinberger <richard@nod.at>
AuthorDate: Thu, 18 Aug 2016 14:57:17 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 6 Sep 2016 16:20:28 +0200

relayfs: Convert to hotplug state machine

Install the callbacks via the state machine. They are installed at run time but
relay_prepare_cpu() does not need to be invoked by the boot CPU because
relay_open() was not yet invoked and there are no pools that need to be created.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: rt@linutronix.de
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20160818125731.27256-3-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 include/linux/cpuhotplug.h |  1 +
 include/linux/relay.h      |  6 +++++
 kernel/cpu.c               |  6 +++++
 kernel/relay.c             | 58 +++++++++++-----------------------------------
 4 files changed, 26 insertions(+), 45 deletions(-)

diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 9e6d107..4c79f40 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -21,6 +21,7 @@ enum cpuhp_state {
 	CPUHP_PROFILE_PREPARE,
 	CPUHP_X2APIC_PREPARE,
 	CPUHP_SMPCFD_PREPARE,
+	CPUHP_RELAY_PREPARE,
 	CPUHP_RCUTREE_PREP,
 	CPUHP_NOTIFY_PREPARE,
 	CPUHP_TIMERS_DEAD,
diff --git a/include/linux/relay.h b/include/linux/relay.h
index eb295e3..ecbb34a 100644
--- a/include/linux/relay.h
+++ b/include/linux/relay.h
@@ -288,5 +288,11 @@ static inline void subbuf_start_reserve(struct rchan_buf *buf,
  */
 extern const struct file_operations relay_file_operations;
 
+#ifdef CONFIG_RELAY
+int relay_prepare_cpu(unsigned int cpu);
+#else
+#define relay_prepare_cpu     NULL
+#endif
+
 #endif /* _LINUX_RELAY_H */
 
diff --git a/kernel/cpu.c b/kernel/cpu.c
index d14ae44..09f66cc 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -23,6 +23,7 @@
 #include <linux/tick.h>
 #include <linux/irq.h>
 #include <linux/smpboot.h>
+#include <linux/relay.h>
 
 #include <trace/events/power.h>
 #define CREATE_TRACE_POINTS
@@ -1272,6 +1273,11 @@ static struct cpuhp_step cpuhp_bp_states[] = {
 		.startup.single		= smpcfd_prepare_cpu,
 		.teardown.single	= smpcfd_dead_cpu,
 	},
+	[CPUHP_RELAY_PREPARE] = {
+		.name			= "relay:prepare",
+		.startup		= relay_prepare_cpu,
+		.teardown		= NULL,
+	},
 	[CPUHP_RCUTREE_PREP] = {
 		.name			= "RCU/tree:prepare",
 		.startup.single		= rcutree_prepare_cpu,
diff --git a/kernel/relay.c b/kernel/relay.c
index ed15737..fc9b4a4 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -513,48 +513,25 @@ static void setup_callbacks(struct rchan *chan,
 	chan->cb = cb;
 }
 
-/**
- * 	relay_hotcpu_callback - CPU hotplug callback
- * 	@nb: notifier block
- * 	@action: hotplug action to take
- * 	@hcpu: CPU number
- *
- * 	Returns the success/failure of the operation. (%NOTIFY_OK, %NOTIFY_BAD)
- */
-static int relay_hotcpu_callback(struct notifier_block *nb,
-				unsigned long action,
-				void *hcpu)
+int relay_prepare_cpu(unsigned int cpu)
 {
-	unsigned int hotcpu = (unsigned long)hcpu;
 	struct rchan *chan;
 	struct rchan_buf *buf;
 
-	switch(action) {
-	case CPU_UP_PREPARE:
-	case CPU_UP_PREPARE_FROZEN:
-		mutex_lock(&relay_channels_mutex);
-		list_for_each_entry(chan, &relay_channels, list) {
-			if ((buf = *per_cpu_ptr(chan->buf, hotcpu)))
-				continue;
-			buf = relay_open_buf(chan, hotcpu);
-			if (!buf) {
-				printk(KERN_ERR
-					"relay_hotcpu_callback: cpu %d buffer "
-					"creation failed\n", hotcpu);
-				mutex_unlock(&relay_channels_mutex);
-				return notifier_from_errno(-ENOMEM);
-			}
-			*per_cpu_ptr(chan->buf, hotcpu) = buf;
+	mutex_lock(&relay_channels_mutex);
+	list_for_each_entry(chan, &relay_channels, list) {
+		if ((buf = *per_cpu_ptr(chan->buf, cpu)))
+			continue;
+		buf = relay_open_buf(chan, cpu);
+		if (!buf) {
+			pr_err("relay: cpu %d buffer creation failed\n", cpu);
+			mutex_unlock(&relay_channels_mutex);
+			return -ENOMEM;
 		}
-		mutex_unlock(&relay_channels_mutex);
-		break;
-	case CPU_DEAD:
-	case CPU_DEAD_FROZEN:
-		/* No need to flush the cpu : will be flushed upon
-		 * final relay_flush() call. */
-		break;
+		*per_cpu_ptr(chan->buf, cpu) = buf;
 	}
-	return NOTIFY_OK;
+	mutex_unlock(&relay_channels_mutex);
+	return 0;
 }
 
 /**
@@ -1387,12 +1364,3 @@ const struct file_operations relay_file_operations = {
 	.splice_read	= relay_file_splice_read,
 };
 EXPORT_SYMBOL_GPL(relay_file_operations);
-
-static __init int relay_init(void)
-{
-
-	hotcpu_notifier(relay_hotcpu_callback, 0);
-	return 0;
-}
-
-early_initcall(relay_init);

  reply	other threads:[~2016-09-06 15:22 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-18 12:57 cpu hotplug: convert more drivers Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 01/16] cpuhotplug: Remove CPU_STARTING and CPU_DYING notifier Sebastian Andrzej Siewior
2016-09-06 15:19   ` [tip:smp/hotplug] cpu/hotplug: " tip-bot for Thomas Gleixner
2016-09-06 16:37   ` tip-bot for Thomas Gleixner
2016-08-18 12:57 ` [PATCH 02/16] relayfs: Convert to hotplug state machine Sebastian Andrzej Siewior
2016-09-06 15:20   ` tip-bot for Richard Weinberger [this message]
2016-09-06 16:38   ` [tip:smp/hotplug] " tip-bot for Richard Weinberger
2016-08-18 12:57 ` [PATCH 03/16] slab: " Sebastian Andrzej Siewior
2016-08-18 17:08   ` Sebastian Andrzej Siewior
2016-08-23 12:53     ` [PATCH 03/16 v2] " Sebastian Andrzej Siewior
2016-09-06 15:21       ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:38       ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 04/16] slub: " Sebastian Andrzej Siewior
2016-09-06 15:21   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:38   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 05/16] mm: writeback: " Sebastian Andrzej Siewior
2016-09-06 15:22   ` [tip:smp/hotplug] mm/writeback: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:39   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 06/16] kernel: softirq: " Sebastian Andrzej Siewior
2016-09-06 15:22   ` [tip:smp/hotplug] kernel/softirq: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:39   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 07/16] rcu: rcutorture: " Sebastian Andrzej Siewior
2016-08-18 16:20   ` Paul E. McKenney
2016-08-18 12:57 ` [PATCH 08/16] net: mvneta: " Sebastian Andrzej Siewior
2016-09-06 15:23   ` [tip:smp/hotplug] net/mvneta: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:40   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 09/16] md: raid5: " Sebastian Andrzej Siewior
2016-09-06 15:23   ` [tip:smp/hotplug] md/raid5: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:40   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 10/16] cpuidle: pseries: " Sebastian Andrzej Siewior
2016-08-22 16:09   ` Daniel Lezcano
2016-08-22 19:04     ` Sebastian Andrzej Siewior
2016-08-23 14:16       ` Daniel Lezcano
2016-08-23 16:32         ` Sebastian Andrzej Siewior
2016-08-24  9:09           ` [PATCH 10/16 v2] " Sebastian Andrzej Siewior
2016-09-06 15:24   ` [tip:smp/hotplug] cpuidle/pseries: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:41   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 11/16] cpuidle: powernv: " Sebastian Andrzej Siewior
2016-08-24  9:12   ` Sebastian Andrzej Siewior
2016-09-06 15:24     ` [tip:smp/hotplug] cpuidle/powernv: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:41     ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 12/16] cpuidle: coupled: " Sebastian Andrzej Siewior
2016-08-23 14:24   ` Daniel Lezcano
2016-08-24  9:14     ` [PATCH 12/16 v2] " Sebastian Andrzej Siewior
2016-09-06 15:25       ` [tip:smp/hotplug] cpuidle/coupled: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:42       ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 13/16] MIPS: BUS: CDMM: " Sebastian Andrzej Siewior
2016-09-06 15:25   ` [tip:smp/hotplug] MIPS/BUS/CDMM: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:42   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 14/16] x86: kvm: " Sebastian Andrzej Siewior
2016-08-18 17:06   ` Paolo Bonzini
2016-09-06 15:25   ` [tip:smp/hotplug] x86/kvm: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:43   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 15/16] powerpc: powermac: " Sebastian Andrzej Siewior
2016-09-06 15:26   ` [tip:smp/hotplug] powerpc/powermac: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:43   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 16/16] powerpc: mmu nohash: " Sebastian Andrzej Siewior
2016-09-06 15:26   ` [tip:smp/hotplug] powerpc/mmu " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:44   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 13:40 ` cpu hotplug: convert more drivers Ingo Molnar

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=tip-0a02f95b4e94fd2908518763a367d64fe78dd4db@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=richard@nod.at \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).