diff options
author | Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | 2011-03-16 19:05:29 -0400 |
---|---|---|
committer | Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> | 2011-03-16 19:05:29 -0400 |
commit | 9cf695f37cd70bbcb26cf14693267955b74ae97e (patch) | |
tree | eace13a9da80722698a4536c17941915921dbe8b | |
parent | e6ee1522ebee41af3ea24f20432210aa7b732b81 (diff) |
idle-notifier-standardize
-rw-r--r-- | arch/x86/include/asm/idle.h | 7 | ||||
-rw-r--r-- | arch/x86/kernel/process_64.c | 19 | ||||
-rw-r--r-- | include/linux/idle.h | 19 | ||||
-rw-r--r-- | kernel/notifier.c | 25 |
4 files changed, 47 insertions, 23 deletions
diff --git a/arch/x86/include/asm/idle.h b/arch/x86/include/asm/idle.h index 38d87379e27..192e5a02a8c 100644 --- a/arch/x86/include/asm/idle.h +++ b/arch/x86/include/asm/idle.h @@ -1,13 +1,6 @@ #ifndef _ASM_X86_IDLE_H #define _ASM_X86_IDLE_H -#define IDLE_START 1 -#define IDLE_END 2 - -struct notifier_block; -void idle_notifier_register(struct notifier_block *n); -void idle_notifier_unregister(struct notifier_block *n); - #ifdef CONFIG_X86_64 void enter_idle(void); void exit_idle(void); diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 034100e5ade..fbd564ecfdc 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -35,6 +35,7 @@ #include <linux/tick.h> #include <linux/prctl.h> #include <linux/uaccess.h> +#include <linux/idle.h> #include <linux/io.h> #include <linux/ftrace.h> #include <trace/pm.h> @@ -60,20 +61,6 @@ asmlinkage extern void ret_from_fork(void); DEFINE_PER_CPU(unsigned long, old_rsp); static DEFINE_PER_CPU(unsigned char, is_idle); -static ATOMIC_NOTIFIER_HEAD(idle_notifier); - -void idle_notifier_register(struct notifier_block *n) -{ - atomic_notifier_chain_register(&idle_notifier, n); -} -EXPORT_SYMBOL_GPL(idle_notifier_register); - -void idle_notifier_unregister(struct notifier_block *n) -{ - atomic_notifier_chain_unregister(&idle_notifier, n); -} -EXPORT_SYMBOL_GPL(idle_notifier_unregister); - void enter_idle(void) { percpu_write(is_idle, 1); @@ -82,14 +69,14 @@ void enter_idle(void) * data from buffers before going to idle. */ trace_pm_idle_entry(); - atomic_notifier_call_chain(&idle_notifier, IDLE_START, NULL); + notify_idle(IDLE_START); } static void __exit_idle(void) { if (x86_test_and_clear_bit_percpu(0, is_idle) == 0) return; - atomic_notifier_call_chain(&idle_notifier, IDLE_END, NULL); + notify_idle(IDLE_END); trace_pm_idle_exit(); } diff --git a/include/linux/idle.h b/include/linux/idle.h new file mode 100644 index 00000000000..75bd2a422c8 --- /dev/null +++ b/include/linux/idle.h @@ -0,0 +1,19 @@ +/* + * include/linux/idle.h - generic idle definition + * + */ +#ifndef _LINUX_IDLE_H_ +#define _LINUX_IDLE_H_ + +#include <linux/notifier.h> + +enum idle_val { + IDLE_START = 1, + IDLE_END = 2, +}; + +int notify_idle(enum idle_val val); +void register_idle_notifier(struct notifier_block *n); +void unregister_idle_notifier(struct notifier_block *n); + +#endif /* _LINUX_IDLE_H_ */ diff --git a/kernel/notifier.c b/kernel/notifier.c index 88453a7e56b..e8481427153 100644 --- a/kernel/notifier.c +++ b/kernel/notifier.c @@ -5,6 +5,7 @@ #include <linux/rcupdate.h> #include <linux/vmalloc.h> #include <linux/reboot.h> +#include <linux/idle.h> /* * Notifier list for kernel code which wants to be called @@ -584,3 +585,27 @@ int unregister_die_notifier(struct notifier_block *nb) return atomic_notifier_chain_unregister(&die_chain, nb); } EXPORT_SYMBOL_GPL(unregister_die_notifier); + +static ATOMIC_NOTIFIER_HEAD(idle_notifier); + +/* + * Trace last event before calling notifiers. Notifiers flush data from buffers + * before going to idle. + */ +int notrace notify_idle(enum idle_val val) +{ + return atomic_notifier_call_chain(&idle_notifier, val, NULL); +} +EXPORT_SYMBOL_GPL(notify_idle); + +void register_idle_notifier(struct notifier_block *n) +{ + atomic_notifier_chain_register(&idle_notifier, n); +} +EXPORT_SYMBOL_GPL(register_idle_notifier); + +void unregister_idle_notifier(struct notifier_block *n) +{ + atomic_notifier_chain_unregister(&idle_notifier, n); +} +EXPORT_SYMBOL_GPL(unregister_idle_notifier); |