linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers: base: update cpu offline info when do hotplug
@ 2014-10-20  3:29 Neil Zhang
  2014-10-20  4:43 ` Greg KH
  2014-10-21 13:02 ` Dan Streetman
  0 siblings, 2 replies; 22+ messages in thread
From: Neil Zhang @ 2014-10-20  3:29 UTC (permalink / raw)
  To: linux-kernel, gregkh; +Cc: Neil Zhang

The current per-cpu offline info won't be updated if it is
hotplugged in/out by a kernel governer.
Let's update it via cpu notifier.

Signed-off-by: Neil Zhang <zhangwm@marvell.com>
---
 drivers/base/cpu.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 006b1bc..9d61824 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -418,10 +418,35 @@ static void __init cpu_dev_register_generic(void)
 #endif
 }
 
+static int device_hotplug_notifier(struct notifier_block *nfb,
+				      unsigned long action, void *hcpu)
+{
+	unsigned int cpu = (unsigned long)hcpu;
+	struct device *dev = get_cpu_device(cpu);
+	int ret;
+
+	switch (action & ~CPU_TASKS_FROZEN) {
+	case CPU_ONLINE:
+		dev->offline = false;
+		ret = NOTIFY_OK;
+		break;
+	case CPU_DYING:
+		dev->offline = true;
+		ret = NOTIFY_OK;
+		break;
+	default:
+		ret = NOTIFY_DONE;
+		break;
+	}
+
+	return ret;
+}
+
 void __init cpu_dev_init(void)
 {
 	if (subsys_system_register(&cpu_subsys, cpu_root_attr_groups))
 		panic("Failed to register CPU subsystem");
 
 	cpu_dev_register_generic();
+	cpu_notifier(device_hotplug_notifier, 0);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2014-10-27 16:29 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-20  3:29 [PATCH] drivers: base: update cpu offline info when do hotplug Neil Zhang
2014-10-20  4:43 ` Greg KH
2014-10-20  6:39   ` Neil Zhang
2014-10-20  6:48     ` Greg KH
2014-10-20  7:40       ` Neil Zhang
2014-10-20 17:02         ` Dan Streetman
2014-10-21  0:47           ` Neil Zhang
2014-10-21  2:57           ` Yasuaki Ishimatsu
2014-10-21  3:18             ` Neil Zhang
2014-10-21  3:26               ` Yasuaki Ishimatsu
2014-10-21  3:36                 ` Neil Zhang
2014-10-21  4:47                   ` Yasuaki Ishimatsu
2014-10-21 12:58             ` Dan Streetman
2014-10-27  1:43           ` Neil Zhang
2014-10-27  1:58             ` Greg KH
2014-10-27  2:17               ` Neil Zhang
2014-10-27  2:26                 ` Greg KH
2014-10-27  2:30                   ` Neil Zhang
2014-10-27 16:28                   ` Dan Streetman
2014-10-21 13:02 ` Dan Streetman
2014-10-22  1:32   ` Neil Zhang
2014-10-23 14:05   ` Dan Streetman

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).