2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* include/linux/cpu.h - generic cpu definition
|
|
|
|
*
|
|
|
|
* This is mainly for topological representation. We define the
|
|
|
|
* basic 'struct cpu' here, which can be embedded in per-arch
|
|
|
|
* definitions of processors.
|
|
|
|
*
|
|
|
|
* Basic handling of the devices is done in drivers/base/cpu.c
|
|
|
|
*
|
2013-05-03 18:45:48 +08:00
|
|
|
* CPUs are exported via sysfs in the devices/system/cpu
|
2005-04-17 06:20:36 +08:00
|
|
|
* directory.
|
|
|
|
*/
|
|
|
|
#ifndef _LINUX_CPU_H_
|
|
|
|
#define _LINUX_CPU_H_
|
|
|
|
|
|
|
|
#include <linux/node.h>
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <linux/cpumask.h>
|
|
|
|
|
2012-01-31 00:46:54 +08:00
|
|
|
struct device;
|
2013-10-04 05:24:51 +08:00
|
|
|
struct device_node;
|
2012-01-31 00:46:54 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct cpu {
|
|
|
|
int node_id; /* The node which contains the CPU */
|
2006-12-07 09:14:10 +08:00
|
|
|
int hotpluggable; /* creates sysfs control file if hotpluggable */
|
2011-12-22 06:29:42 +08:00
|
|
|
struct device dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
[PATCH] node hotplug: register cpu: remove node struct
With Goto-san's patch, we can add new pgdat/node at runtime. I'm now
considering node-hot-add with cpu + memory on ACPI.
I found acpi container, which describes node, could evaluate cpu before
memory. This means cpu-hot-add occurs before memory hot add.
In most part, cpu-hot-add doesn't depend on node hot add. But register_cpu(),
which creates symbolic link from node to cpu, requires that node should be
onlined before register_cpu(). When a node is onlined, its pgdat should be
there.
This patch-set holds off creating symbolic link from node to cpu
until node is onlined.
This removes node arguments from register_cpu().
Now, register_cpu() requires 'struct node' as its argument. But the array of
struct node is now unified in driver/base/node.c now (By Goto's node hotplug
patch). We can get struct node in generic way. So, this argument is not
necessary now.
This patch also guarantees add cpu under node only when node is onlined. It
is necessary for node-hot-add vs. cpu-hot-add patch following this.
Moreover, register_cpu calculates cpu->node_id by cpu_to_node() without regard
to its 'struct node *root' argument. This patch removes it.
Also modify callers of register_cpu()/unregister_cpu, whose args are changed
by register-cpu-remove-node-struct patch.
[Brice.Goglin@ens-lyon.org: fix it]
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Brice Goglin <Brice.Goglin@ens-lyon.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-27 17:53:41 +08:00
|
|
|
extern int register_cpu(struct cpu *cpu, int num);
|
2011-12-22 06:29:42 +08:00
|
|
|
extern struct device *get_cpu_device(unsigned cpu);
|
2011-12-04 05:06:50 +08:00
|
|
|
extern bool cpu_is_hotpluggable(unsigned cpu);
|
2013-08-15 21:01:40 +08:00
|
|
|
extern bool arch_match_cpu_phys_id(int cpu, u64 phys_id);
|
2013-10-04 05:24:51 +08:00
|
|
|
extern bool arch_find_n_match_cpu_physical_id(struct device_node *cpun,
|
|
|
|
int cpu, unsigned int *thread);
|
2006-10-25 00:31:24 +08:00
|
|
|
|
2011-12-22 06:29:42 +08:00
|
|
|
extern int cpu_add_dev_attr(struct device_attribute *attr);
|
|
|
|
extern void cpu_remove_dev_attr(struct device_attribute *attr);
|
2006-10-25 00:31:24 +08:00
|
|
|
|
2011-12-22 06:29:42 +08:00
|
|
|
extern int cpu_add_dev_attr_group(struct attribute_group *attrs);
|
|
|
|
extern void cpu_remove_dev_attr_group(struct attribute_group *attrs);
|
2006-10-25 00:31:24 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
[PATCH] node hotplug: register cpu: remove node struct
With Goto-san's patch, we can add new pgdat/node at runtime. I'm now
considering node-hot-add with cpu + memory on ACPI.
I found acpi container, which describes node, could evaluate cpu before
memory. This means cpu-hot-add occurs before memory hot add.
In most part, cpu-hot-add doesn't depend on node hot add. But register_cpu(),
which creates symbolic link from node to cpu, requires that node should be
onlined before register_cpu(). When a node is onlined, its pgdat should be
there.
This patch-set holds off creating symbolic link from node to cpu
until node is onlined.
This removes node arguments from register_cpu().
Now, register_cpu() requires 'struct node' as its argument. But the array of
struct node is now unified in driver/base/node.c now (By Goto's node hotplug
patch). We can get struct node in generic way. So, this argument is not
necessary now.
This patch also guarantees add cpu under node only when node is onlined. It
is necessary for node-hot-add vs. cpu-hot-add patch following this.
Moreover, register_cpu calculates cpu->node_id by cpu_to_node() without regard
to its 'struct node *root' argument. This patch removes it.
Also modify callers of register_cpu()/unregister_cpu, whose args are changed
by register-cpu-remove-node-struct patch.
[Brice.Goglin@ens-lyon.org: fix it]
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Brice Goglin <Brice.Goglin@ens-lyon.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-27 17:53:41 +08:00
|
|
|
extern void unregister_cpu(struct cpu *cpu);
|
2009-11-26 01:23:25 +08:00
|
|
|
extern ssize_t arch_cpu_probe(const char *, size_t);
|
|
|
|
extern ssize_t arch_cpu_release(const char *, size_t);
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
struct notifier_block;
|
|
|
|
|
2012-01-26 07:09:14 +08:00
|
|
|
#ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE
|
|
|
|
extern int arch_cpu_uevent(struct device *dev, struct kobj_uevent_env *env);
|
|
|
|
extern ssize_t arch_print_cpu_modalias(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *bufptr);
|
|
|
|
#endif
|
|
|
|
|
2010-06-09 03:40:36 +08:00
|
|
|
/*
|
|
|
|
* CPU notifier priorities.
|
|
|
|
*/
|
|
|
|
enum {
|
2010-06-09 03:40:36 +08:00
|
|
|
/*
|
|
|
|
* SCHED_ACTIVE marks a cpu which is coming up active during
|
|
|
|
* CPU_ONLINE and CPU_DOWN_FAILED and must be the first
|
|
|
|
* notifier. CPUSET_ACTIVE adjusts cpuset according to
|
|
|
|
* cpu_active mask right after SCHED_ACTIVE. During
|
|
|
|
* CPU_DOWN_PREPARE, SCHED_INACTIVE and CPUSET_INACTIVE are
|
|
|
|
* ordered in the similar way.
|
|
|
|
*
|
|
|
|
* This ordering guarantees consistent cpu_active mask and
|
|
|
|
* migration behavior to all cpu notifiers.
|
|
|
|
*/
|
|
|
|
CPU_PRI_SCHED_ACTIVE = INT_MAX,
|
|
|
|
CPU_PRI_CPUSET_ACTIVE = INT_MAX - 1,
|
|
|
|
CPU_PRI_SCHED_INACTIVE = INT_MIN + 1,
|
|
|
|
CPU_PRI_CPUSET_INACTIVE = INT_MIN,
|
|
|
|
|
2010-06-09 03:40:36 +08:00
|
|
|
/* migration should happen before other stuff but after perf */
|
|
|
|
CPU_PRI_PERF = 20,
|
|
|
|
CPU_PRI_MIGRATION = 10,
|
2012-07-18 03:39:26 +08:00
|
|
|
/* bring up workqueues before normal notifiers and down after */
|
|
|
|
CPU_PRI_WORKQUEUE_UP = 5,
|
|
|
|
CPU_PRI_WORKQUEUE_DOWN = -5,
|
2010-06-09 03:40:36 +08:00
|
|
|
};
|
|
|
|
|
2011-07-26 08:13:08 +08:00
|
|
|
#define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */
|
|
|
|
#define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */
|
|
|
|
#define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */
|
|
|
|
#define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */
|
|
|
|
#define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */
|
|
|
|
#define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */
|
|
|
|
#define CPU_DYING 0x0008 /* CPU (unsigned)v not running any task,
|
|
|
|
* not handling interrupts, soon dead.
|
|
|
|
* Called on the dying cpu, interrupts
|
|
|
|
* are already disabled. Must not
|
|
|
|
* sleep, must not fail */
|
|
|
|
#define CPU_POST_DEAD 0x0009 /* CPU (unsigned)v dead, cpu_hotplug
|
|
|
|
* lock is dropped */
|
|
|
|
#define CPU_STARTING 0x000A /* CPU (unsigned)v soon running.
|
|
|
|
* Called on the new cpu, just before
|
|
|
|
* enabling interrupts. Must not sleep,
|
|
|
|
* must not fail */
|
|
|
|
|
|
|
|
/* Used for CPU hotplug events occurring while tasks are frozen due to a suspend
|
|
|
|
* operation in progress
|
|
|
|
*/
|
|
|
|
#define CPU_TASKS_FROZEN 0x0010
|
|
|
|
|
|
|
|
#define CPU_ONLINE_FROZEN (CPU_ONLINE | CPU_TASKS_FROZEN)
|
|
|
|
#define CPU_UP_PREPARE_FROZEN (CPU_UP_PREPARE | CPU_TASKS_FROZEN)
|
|
|
|
#define CPU_UP_CANCELED_FROZEN (CPU_UP_CANCELED | CPU_TASKS_FROZEN)
|
|
|
|
#define CPU_DOWN_PREPARE_FROZEN (CPU_DOWN_PREPARE | CPU_TASKS_FROZEN)
|
|
|
|
#define CPU_DOWN_FAILED_FROZEN (CPU_DOWN_FAILED | CPU_TASKS_FROZEN)
|
|
|
|
#define CPU_DEAD_FROZEN (CPU_DEAD | CPU_TASKS_FROZEN)
|
|
|
|
#define CPU_DYING_FROZEN (CPU_DYING | CPU_TASKS_FROZEN)
|
|
|
|
#define CPU_STARTING_FROZEN (CPU_STARTING | CPU_TASKS_FROZEN)
|
|
|
|
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/* Need to know about CPUs going up/down? */
|
2009-08-16 00:53:47 +08:00
|
|
|
#if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
|
|
|
|
#define cpu_notifier(fn, pri) { \
|
2013-06-20 02:53:51 +08:00
|
|
|
static struct notifier_block fn##_nb = \
|
2009-08-16 00:53:47 +08:00
|
|
|
{ .notifier_call = fn, .priority = pri }; \
|
|
|
|
register_cpu_notifier(&fn##_nb); \
|
|
|
|
}
|
|
|
|
#else /* #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) */
|
|
|
|
#define cpu_notifier(fn, pri) do { (void)(fn); } while (0)
|
|
|
|
#endif /* #else #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) */
|
2006-06-27 17:54:08 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
[PATCH] hotplug: Allow modules to use the cpu hotplug notifiers even if !CONFIG_HOTPLUG_CPU
The following patchset allows a host with running virtual machines to be
suspended and, on at least a subset of the machines tested, resumed. Note
that this is orthogonal to suspending and resuming an individual guest to a
file.
A side effect of implementing suspend/resume is that cpu hotplug is now
supported. This should please the owners of big iron.
This patch:
KVM wants the cpu hotplug notifications, both for cpu hotplug itself, but more
commonly for host suspend/resume.
In order to avoid extensive #ifdefs, provide stubs when CONFIG_CPU_HOTPLUG is
not defined.
In all, we have four cases:
- UP: register and unregister stubbed out
- SMP+hotplug: full register and unregister
- SMP, no hotplug, core: register as __init, unregister stubbed
(cpus are brought up during core initialization)
- SMP, no hotplug, module: register and unregister stubbed out
(cpus cannot be brought up during module lifetime)
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-02-12 16:54:43 +08:00
|
|
|
extern int register_cpu_notifier(struct notifier_block *nb);
|
2005-04-17 06:20:36 +08:00
|
|
|
extern void unregister_cpu_notifier(struct notifier_block *nb);
|
2006-06-27 17:54:08 +08:00
|
|
|
#else
|
[PATCH] hotplug: Allow modules to use the cpu hotplug notifiers even if !CONFIG_HOTPLUG_CPU
The following patchset allows a host with running virtual machines to be
suspended and, on at least a subset of the machines tested, resumed. Note
that this is orthogonal to suspending and resuming an individual guest to a
file.
A side effect of implementing suspend/resume is that cpu hotplug is now
supported. This should please the owners of big iron.
This patch:
KVM wants the cpu hotplug notifications, both for cpu hotplug itself, but more
commonly for host suspend/resume.
In order to avoid extensive #ifdefs, provide stubs when CONFIG_CPU_HOTPLUG is
not defined.
In all, we have four cases:
- UP: register and unregister stubbed out
- SMP+hotplug: full register and unregister
- SMP, no hotplug, core: register as __init, unregister stubbed
(cpus are brought up during core initialization)
- SMP, no hotplug, module: register and unregister stubbed out
(cpus cannot be brought up during module lifetime)
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-02-12 16:54:43 +08:00
|
|
|
|
|
|
|
#ifndef MODULE
|
|
|
|
extern int register_cpu_notifier(struct notifier_block *nb);
|
|
|
|
#else
|
|
|
|
static inline int register_cpu_notifier(struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-06-27 17:54:08 +08:00
|
|
|
static inline void unregister_cpu_notifier(struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
int cpu_up(unsigned int cpu);
|
2008-09-07 22:57:22 +08:00
|
|
|
void notify_cpu_starting(unsigned int cpu);
|
2008-07-25 16:47:50 +08:00
|
|
|
extern void cpu_maps_update_begin(void);
|
|
|
|
extern void cpu_maps_update_done(void);
|
2008-01-26 04:08:02 +08:00
|
|
|
|
2008-07-25 16:47:50 +08:00
|
|
|
#else /* CONFIG_SMP */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-08-16 00:53:47 +08:00
|
|
|
#define cpu_notifier(fn, pri) do { (void)(fn); } while (0)
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static inline int register_cpu_notifier(struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2008-01-26 04:08:02 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static inline void unregister_cpu_notifier(struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-07-25 16:47:50 +08:00
|
|
|
static inline void cpu_maps_update_begin(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void cpu_maps_update_done(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* CONFIG_SMP */
|
2011-12-22 06:29:42 +08:00
|
|
|
extern struct bus_type cpu_subsys;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
|
|
/* Stop CPUs going up and down. */
|
2006-12-07 12:38:58 +08:00
|
|
|
|
ACPI / processor: Acquire writer lock to update CPU maps
CPU system maps are protected with reader/writer locks. The reader
lock, get_online_cpus(), assures that the maps are not updated while
holding the lock. The writer lock, cpu_hotplug_begin(), is used to
udpate the cpu maps along with cpu_maps_update_begin().
However, the ACPI processor handler updates the cpu maps without
holding the the writer lock.
acpi_map_lsapic() is called from acpi_processor_hotadd_init() to
update cpu_possible_mask and cpu_present_mask. acpi_unmap_lsapic()
is called from acpi_processor_remove() to update cpu_possible_mask.
Currently, they are either unprotected or protected with the reader
lock, which is not correct.
For example, the get_online_cpus() below is supposed to assure that
cpu_possible_mask is not changed while the code is iterating with
for_each_possible_cpu().
get_online_cpus();
for_each_possible_cpu(cpu) {
:
}
put_online_cpus();
However, this lock has no protection with CPU hotplug since the ACPI
processor handler does not use the writer lock when it updates
cpu_possible_mask. The reader lock does not serialize within the
readers.
This patch protects them with the writer lock with cpu_hotplug_begin()
along with cpu_maps_update_begin(), which must be held before calling
cpu_hotplug_begin(). It also protects arch_register_cpu() /
arch_unregister_cpu(), which creates / deletes a sysfs cpu device
interface. For this purpose it changes cpu_hotplug_begin() and
cpu_hotplug_done() to global and exports them in cpu.h.
Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-08-12 23:45:53 +08:00
|
|
|
extern void cpu_hotplug_begin(void);
|
|
|
|
extern void cpu_hotplug_done(void);
|
2008-01-26 04:08:02 +08:00
|
|
|
extern void get_online_cpus(void);
|
|
|
|
extern void put_online_cpus(void);
|
2013-06-13 05:04:36 +08:00
|
|
|
extern void cpu_hotplug_disable(void);
|
|
|
|
extern void cpu_hotplug_enable(void);
|
2009-08-16 00:53:47 +08:00
|
|
|
#define hotcpu_notifier(fn, pri) cpu_notifier(fn, pri)
|
2006-06-27 17:54:10 +08:00
|
|
|
#define register_hotcpu_notifier(nb) register_cpu_notifier(nb)
|
|
|
|
#define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb)
|
cpu: introduce clear_tasks_mm_cpumask() helper
Many architectures clear tasks' mm_cpumask like this:
read_lock(&tasklist_lock);
for_each_process(p) {
if (p->mm)
cpumask_clear_cpu(cpu, mm_cpumask(p->mm));
}
read_unlock(&tasklist_lock);
Depending on the context, the code above may have several problems,
such as:
1. Working with task->mm w/o getting mm or grabing the task lock is
dangerous as ->mm might disappear (exit_mm() assigns NULL under
task_lock(), so tasklist lock is not enough).
2. Checking for process->mm is not enough because process' main
thread may exit or detach its mm via use_mm(), but other threads
may still have a valid mm.
This patch implements a small helper function that does things
correctly, i.e.:
1. We take the task's lock while whe handle its mm (we can't use
get_task_mm()/mmput() pair as mmput() might sleep);
2. To catch exited main thread case, we use find_lock_task_mm(),
which walks up all threads and returns an appropriate task
(with task lock held).
Also, Per Peter Zijlstra's idea, now we don't grab tasklist_lock in
the new helper, instead we take the rcu read lock. We can do this
because the function is called after the cpu is taken down and marked
offline, so no new tasks will get this cpu set in their mm mask.
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-06-01 07:26:22 +08:00
|
|
|
void clear_tasks_mm_cpumask(int cpu);
|
2005-04-17 06:20:36 +08:00
|
|
|
int cpu_down(unsigned int cpu);
|
2006-12-07 12:38:58 +08:00
|
|
|
|
|
|
|
#else /* CONFIG_HOTPLUG_CPU */
|
|
|
|
|
ACPI / processor: Acquire writer lock to update CPU maps
CPU system maps are protected with reader/writer locks. The reader
lock, get_online_cpus(), assures that the maps are not updated while
holding the lock. The writer lock, cpu_hotplug_begin(), is used to
udpate the cpu maps along with cpu_maps_update_begin().
However, the ACPI processor handler updates the cpu maps without
holding the the writer lock.
acpi_map_lsapic() is called from acpi_processor_hotadd_init() to
update cpu_possible_mask and cpu_present_mask. acpi_unmap_lsapic()
is called from acpi_processor_remove() to update cpu_possible_mask.
Currently, they are either unprotected or protected with the reader
lock, which is not correct.
For example, the get_online_cpus() below is supposed to assure that
cpu_possible_mask is not changed while the code is iterating with
for_each_possible_cpu().
get_online_cpus();
for_each_possible_cpu(cpu) {
:
}
put_online_cpus();
However, this lock has no protection with CPU hotplug since the ACPI
processor handler does not use the writer lock when it updates
cpu_possible_mask. The reader lock does not serialize within the
readers.
This patch protects them with the writer lock with cpu_hotplug_begin()
along with cpu_maps_update_begin(), which must be held before calling
cpu_hotplug_begin(). It also protects arch_register_cpu() /
arch_unregister_cpu(), which creates / deletes a sysfs cpu device
interface. For this purpose it changes cpu_hotplug_begin() and
cpu_hotplug_done() to global and exports them in cpu.h.
Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-08-12 23:45:53 +08:00
|
|
|
static inline void cpu_hotplug_begin(void) {}
|
|
|
|
static inline void cpu_hotplug_done(void) {}
|
2008-01-26 04:08:02 +08:00
|
|
|
#define get_online_cpus() do { } while (0)
|
|
|
|
#define put_online_cpus() do { } while (0)
|
2013-06-13 05:04:36 +08:00
|
|
|
#define cpu_hotplug_disable() do { } while (0)
|
|
|
|
#define cpu_hotplug_enable() do { } while (0)
|
2006-12-07 12:38:17 +08:00
|
|
|
#define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0)
|
2007-10-18 18:06:38 +08:00
|
|
|
/* These aren't inline functions due to a GCC bug. */
|
|
|
|
#define register_hotcpu_notifier(nb) ({ (void)(nb); 0; })
|
|
|
|
#define unregister_hotcpu_notifier(nb) ({ (void)(nb); })
|
2006-12-07 12:38:58 +08:00
|
|
|
#endif /* CONFIG_HOTPLUG_CPU */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-08-31 14:56:29 +08:00
|
|
|
#ifdef CONFIG_PM_SLEEP_SMP
|
2006-09-26 14:32:48 +08:00
|
|
|
extern int disable_nonboot_cpus(void);
|
|
|
|
extern void enable_nonboot_cpus(void);
|
2007-08-31 14:56:29 +08:00
|
|
|
#else /* !CONFIG_PM_SLEEP_SMP */
|
2006-09-26 14:32:48 +08:00
|
|
|
static inline int disable_nonboot_cpus(void) { return 0; }
|
|
|
|
static inline void enable_nonboot_cpus(void) {}
|
2007-08-31 14:56:29 +08:00
|
|
|
#endif /* !CONFIG_PM_SLEEP_SMP */
|
2006-09-26 14:32:48 +08:00
|
|
|
|
2013-03-22 05:49:34 +08:00
|
|
|
enum cpuhp_state {
|
|
|
|
CPUHP_OFFLINE,
|
|
|
|
CPUHP_ONLINE,
|
|
|
|
};
|
|
|
|
|
|
|
|
void cpu_startup_entry(enum cpuhp_state state);
|
|
|
|
void cpu_idle(void);
|
|
|
|
|
2013-03-22 05:49:35 +08:00
|
|
|
void cpu_idle_poll_ctrl(bool enable);
|
|
|
|
|
|
|
|
void arch_cpu_idle(void);
|
|
|
|
void arch_cpu_idle_prepare(void);
|
|
|
|
void arch_cpu_idle_enter(void);
|
|
|
|
void arch_cpu_idle_exit(void);
|
|
|
|
void arch_cpu_idle_dead(void);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* _LINUX_CPU_H_ */
|