From: Nathan Lynch <nathanl@austin.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: greg@kroah.com, rusty@rustcorp.com.au,
Nathan Lynch <nathanl@austin.ibm.com>,
mochel@digitalimplant.org, anton@samba.org
Subject: [RFC/PATCH 3/4] introduce cpu_add and cpu_remove
Date: Sun, 24 Oct 2004 05:42:31 -0400 [thread overview]
Message-ID: <20041024094613.28808.17748.71291@biclops> (raw)
In-Reply-To: <20041024094551.28808.28284.87316@biclops>
These functions safely update cpu_present_map (i.e. with the
cpucontrol semaphore held) and register or unregister the cpu device
as needed. These are needed by systems which can add or remove cpus
from the system after boot (e.g. ppc64 and ia64), and are intended to
be called from the platform-specific code such as the ACPI or Open
Firmware layers.
Signed-off-by: Nathan Lynch <nathanl@austin.ibm.com>
---
diff -puN include/linux/cpu.h~introduce-cpu_add-and-cpu_remove include/linux/cpu.h
--- 2.6.10-rc1/include/linux/cpu.h~introduce-cpu_add-and-cpu_remove 2004-10-24 03:52:59.000000000 -0500
+++ 2.6.10-rc1-nathanl/include/linux/cpu.h 2004-10-24 03:52:59.000000000 -0500
@@ -67,6 +67,8 @@ extern struct semaphore cpucontrol;
register_cpu_notifier(&fn##_nb); \
}
int cpu_down(unsigned int cpu);
+unsigned int cpu_add(void);
+void cpu_remove(unsigned int);
#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
#else
#define lock_cpu_hotplug() do { } while (0)
diff -puN kernel/cpu.c~introduce-cpu_add-and-cpu_remove kernel/cpu.c
--- 2.6.10-rc1/kernel/cpu.c~introduce-cpu_add-and-cpu_remove 2004-10-24 03:52:59.000000000 -0500
+++ 2.6.10-rc1-nathanl/kernel/cpu.c 2004-10-24 03:52:59.000000000 -0500
@@ -180,6 +180,49 @@ out:
unlock_cpu_hotplug();
return err;
}
+
+/*
+ * Add a cpu to the system. Return the number of the cpu added,
+ * or NR_CPUS if no more slots available.
+ */
+unsigned int cpu_add(void)
+{
+ unsigned int cpu = NR_CPUS;
+
+ lock_cpu_hotplug();
+
+ if (num_present_cpus() == num_possible_cpus())
+ goto out;
+
+ for_each_cpu(cpu)
+ if (!cpu_present(cpu))
+ break;
+
+ if (register_cpu(cpu)) {
+ cpu = NR_CPUS;
+ goto out;
+ }
+ cpu_set(cpu, cpu_present_map);
+out:
+ unlock_cpu_hotplug();
+ return cpu;
+}
+
+/*
+ * Remove a cpu from the system.
+ */
+void cpu_remove(unsigned int cpu)
+{
+ lock_cpu_hotplug();
+
+ BUG_ON(cpu_present(cpu));
+
+ unregister_cpu(cpu);
+
+ cpu_clear(cpu, cpu_present_map);
+
+ unlock_cpu_hotplug();
+}
#else
static inline int cpu_run_sbin_hotplug(unsigned int cpu, const char *action)
{
_
next prev parent reply other threads:[~2004-10-24 9:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-24 9:42 [RFC/PATCH 0/4] cpus, nodes, and the device model: dynamic cpu registration Nathan Lynch
2004-10-24 9:42 ` [RFC/PATCH 1/4] dynamic cpu registration - core changes Nathan Lynch
2004-11-05 1:51 ` Ashok Raj
2004-11-09 3:45 ` Nathan Lynch
2004-10-24 9:42 ` [RFC/PATCH 2/4] drivers/base/node.c changes for dynamic cpu registration Nathan Lynch
2004-10-24 9:42 ` Nathan Lynch [this message]
2004-11-05 1:57 ` [RFC/PATCH 3/4] introduce cpu_add and cpu_remove Ashok Raj
2004-11-05 23:14 ` Matthew Dobson
2004-10-24 9:42 ` [RFC/PATCH 4/4] ppc64: convert to sysdev_driver Nathan Lynch
2004-10-25 6:12 ` [RFC/PATCH 0/4] cpus, nodes, and the device model: dynamic cpu registration Rusty Russell
2004-10-25 11:20 ` Nathan Lynch
2004-11-05 1:09 ` Ashok Raj
2004-11-09 3:45 ` Nathan Lynch
2004-11-05 1:54 ` Keshavamurthy Anil S
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=20041024094613.28808.17748.71291@biclops \
--to=nathanl@austin.ibm.com \
--cc=anton@samba.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mochel@digitalimplant.org \
--cc=rusty@rustcorp.com.au \
/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