linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neil Zhang <zhangwm@marvell.com>
To: <linux-kernel@vger.kernel.org>, <gregkh@linuxfoundation.org>
Cc: Neil Zhang <zhangwm@marvell.com>
Subject: [PATCH] drivers: base: update cpu offline info when do hotplug
Date: Mon, 20 Oct 2014 11:29:08 +0800	[thread overview]
Message-ID: <1413775748-22478-1-git-send-email-zhangwm@marvell.com> (raw)

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


             reply	other threads:[~2014-10-20  3:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-20  3:29 Neil Zhang [this message]
2014-10-20  4:43 ` [PATCH] drivers: base: update cpu offline info when do hotplug 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

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=1413775748-22478-1-git-send-email-zhangwm@marvell.com \
    --to=zhangwm@marvell.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).