2005-04-17 00:20:36 +02: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
|
|
|
|
* and system devices are handled in drivers/base/sys.c.
|
|
|
|
*
|
2005-09-02 08:59:25 +02:00
|
|
|
* CPUs are exported via sysfs in the class/cpu/devices/
|
2005-04-17 00:20:36 +02:00
|
|
|
* directory.
|
|
|
|
*
|
|
|
|
* Per-cpu interfaces can be implemented using a struct device_interface.
|
|
|
|
* See the following for how to do this:
|
|
|
|
* - drivers/base/intf.c
|
|
|
|
* - Documentation/driver-model/interface.txt
|
|
|
|
*/
|
|
|
|
#ifndef _LINUX_CPU_H_
|
|
|
|
#define _LINUX_CPU_H_
|
|
|
|
|
|
|
|
#include <linux/sysdev.h>
|
|
|
|
#include <linux/node.h>
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <linux/cpumask.h>
|
|
|
|
#include <asm/semaphore.h>
|
2006-12-07 05:38:58 +01:00
|
|
|
#include <linux/mutex.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
struct cpu {
|
|
|
|
int node_id; /* The node which contains the CPU */
|
2006-12-07 02:14:10 +01:00
|
|
|
int hotpluggable; /* creates sysfs control file if hotpluggable */
|
2005-04-17 00:20:36 +02:00
|
|
|
struct sys_device sysdev;
|
|
|
|
};
|
|
|
|
|
[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 11:53:41 +02:00
|
|
|
extern int register_cpu(struct cpu *cpu, int num);
|
2006-03-08 08:53:25 +01:00
|
|
|
extern struct sys_device *get_cpu_sysdev(unsigned cpu);
|
2006-10-24 18:31:24 +02:00
|
|
|
|
|
|
|
extern int cpu_add_sysdev_attr(struct sysdev_attribute *attr);
|
|
|
|
extern void cpu_remove_sysdev_attr(struct sysdev_attribute *attr);
|
|
|
|
|
|
|
|
extern int cpu_add_sysdev_attr_group(struct attribute_group *attrs);
|
|
|
|
extern void cpu_remove_sysdev_attr_group(struct attribute_group *attrs);
|
|
|
|
|
2007-05-08 09:27:52 +02:00
|
|
|
extern struct sysdev_attribute attr_sched_mc_power_savings;
|
|
|
|
extern struct sysdev_attribute attr_sched_smt_power_savings;
|
|
|
|
extern int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls);
|
2006-10-24 18:31:24 +02:00
|
|
|
|
2005-04-17 00:20:36 +02: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 11:53:41 +02:00
|
|
|
extern void unregister_cpu(struct cpu *cpu);
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif
|
|
|
|
struct notifier_block;
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/* Need to know about CPUs going up/down? */
|
2006-06-27 11:54:08 +02: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 09:54:43 +01:00
|
|
|
extern int register_cpu_notifier(struct notifier_block *nb);
|
2005-04-17 00:20:36 +02:00
|
|
|
extern void unregister_cpu_notifier(struct notifier_block *nb);
|
2006-06-27 11:54:08 +02: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 09:54:43 +01: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 11:54:08 +02:00
|
|
|
static inline void unregister_cpu_notifier(struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
int cpu_up(unsigned int cpu);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static inline int register_cpu_notifier(struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void unregister_cpu_notifier(struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
extern struct sysdev_class cpu_sysdev_class;
|
|
|
|
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
|
|
/* Stop CPUs going up and down. */
|
2006-12-07 05:38:58 +01:00
|
|
|
|
|
|
|
static inline void cpuhotplug_mutex_lock(struct mutex *cpu_hp_mutex)
|
|
|
|
{
|
|
|
|
mutex_lock(cpu_hp_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex)
|
|
|
|
{
|
|
|
|
mutex_unlock(cpu_hp_mutex);
|
|
|
|
}
|
|
|
|
|
2005-11-28 22:43:46 +01:00
|
|
|
extern void lock_cpu_hotplug(void);
|
|
|
|
extern void unlock_cpu_hotplug(void);
|
2005-04-17 00:20:36 +02:00
|
|
|
#define hotcpu_notifier(fn, pri) { \
|
|
|
|
static struct notifier_block fn##_nb = \
|
|
|
|
{ .notifier_call = fn, .priority = pri }; \
|
|
|
|
register_cpu_notifier(&fn##_nb); \
|
|
|
|
}
|
2006-06-27 11:54:10 +02:00
|
|
|
#define register_hotcpu_notifier(nb) register_cpu_notifier(nb)
|
|
|
|
#define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb)
|
2005-04-17 00:20:36 +02:00
|
|
|
int cpu_down(unsigned int cpu);
|
|
|
|
#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
|
2006-12-07 05:38:58 +01:00
|
|
|
|
|
|
|
#else /* CONFIG_HOTPLUG_CPU */
|
|
|
|
|
|
|
|
static inline void cpuhotplug_mutex_lock(struct mutex *cpu_hp_mutex)
|
|
|
|
{ }
|
|
|
|
static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex)
|
|
|
|
{ }
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
#define lock_cpu_hotplug() do { } while (0)
|
|
|
|
#define unlock_cpu_hotplug() do { } while (0)
|
|
|
|
#define lock_cpu_hotplug_interruptible() 0
|
2006-12-07 05:38:17 +01:00
|
|
|
#define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0)
|
|
|
|
#define register_hotcpu_notifier(nb) do { (void)(nb); } while (0)
|
|
|
|
#define unregister_hotcpu_notifier(nb) do { (void)(nb); } while (0)
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* CPUs don't go offline once they're online w/o CONFIG_HOTPLUG_CPU */
|
|
|
|
static inline int cpu_is_offline(int cpu) { return 0; }
|
2006-12-07 05:38:58 +01:00
|
|
|
#endif /* CONFIG_HOTPLUG_CPU */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-09-26 08:32:48 +02:00
|
|
|
#ifdef CONFIG_SUSPEND_SMP
|
2007-04-02 08:49:49 +02:00
|
|
|
extern int suspend_cpu_hotplug;
|
|
|
|
|
2006-09-26 08:32:48 +02:00
|
|
|
extern int disable_nonboot_cpus(void);
|
|
|
|
extern void enable_nonboot_cpus(void);
|
|
|
|
#else
|
2007-04-02 08:49:49 +02:00
|
|
|
#define suspend_cpu_hotplug 0
|
|
|
|
|
2006-09-26 08:32:48 +02:00
|
|
|
static inline int disable_nonboot_cpus(void) { return 0; }
|
|
|
|
static inline void enable_nonboot_cpus(void) {}
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif /* _LINUX_CPU_H_ */
|