Add notifiers for idle entry and exit, called with IDLE_START when a
CPU goes idle and IDLE_END when it goes out of idle, based on the
existing idle notifiers for the x86_64 arch.
Convert x86_64 to use these notifiers, and call the notifiers on ARM.
Convert the ARM LEDs events for idle start/end to these notifiers.
arch/arm/kernel/leds.c | 27 ++++++++++++++++++++++++++-
arch/arm/kernel/process.c | 5 ++---
arch/x86/include/asm/idle.h | 7 -------
arch/x86/kernel/process_64.c | 18 ++----------------
include/linux/cpu.h | 7 +++++++
kernel/cpu.c | 20 ++++++++++++++++++++
6 files changed, 57 insertions(+), 27 deletions(-)
--
1.7.3.1
@@ -56,31 +56,17 @@ asmlinkage extern void ret_from_fork(void);DEFINE_PER_CPU(unsignedlong,old_rsp);staticDEFINE_PER_CPU(unsignedchar,is_idle);-staticATOMIC_NOTIFIER_HEAD(idle_notifier);--voididle_notifier_register(structnotifier_block*n)-{-atomic_notifier_chain_register(&idle_notifier,n);-}-EXPORT_SYMBOL_GPL(idle_notifier_register);--voididle_notifier_unregister(structnotifier_block*n)-{-atomic_notifier_chain_unregister(&idle_notifier,n);-}-EXPORT_SYMBOL_GPL(idle_notifier_unregister);-voidenter_idle(void){percpu_write(is_idle,1);-atomic_notifier_call_chain(&idle_notifier,IDLE_START,NULL);+idle_notifier_call_chain(IDLE_START);}staticvoid__exit_idle(void){if(x86_test_and_clear_bit_percpu(0,is_idle)==0)return;-atomic_notifier_call_chain(&idle_notifier,IDLE_END,NULL);+idle_notifier_call_chain(IDLE_END);}/* Called from interrupts to signify idle end */
@@ -183,7 +182,6 @@ void cpu_idle(void)/* endless idle loop with no priority at all */while(1){tick_nohz_stop_sched_tick(1);-leds_event(led_idle_start);idle_notifier_call_chain(IDLE_START);while(!need_resched()){#ifdef CONFIG_HOTPLUG_CPU
On Tue, Jun 28, 2011 at 10:46 AM, Todd Poynor [off-list ref] wrote:
Add notifiers for idle entry and exit, called with IDLE_START when a
CPU goes idle and IDLE_END when it goes out of idle, based on the
existing idle notifiers for the x86_64 arch.
Convert x86_64 to use these notifiers, and call the notifiers on ARM.
Convert the ARM LEDs events for idle start/end to these notifiers.
LinusW and I is working on consolidation LED events interface in ARM.
Please take a look at https://patchwork.kernel.org/patch/918792/
I do like to add notifiers into ledtrig-cpu driver, which can be also
shared by x86
Thanks,
-Bryan
From: Nicolas Pitre <nico@fluxnic.net> Date: 2011-06-28 18:29:33
On Mon, 27 Jun 2011, Todd Poynor wrote:
Add notifiers for idle entry and exit, called with IDLE_START when a
CPU goes idle and IDLE_END when it goes out of idle, based on the
existing idle notifiers for the x86_64 arch.
Convert x86_64 to use these notifiers, and call the notifiers on ARM.
Convert the ARM LEDs events for idle start/end to these notifiers.
This is nice.
Acked-by: Nicolas Pitre <redacted>
for all 3 patches.
Nicolas
From: Nicolas Pitre <nico@fluxnic.net> Date: 2011-06-28 18:30:27
On Tue, 28 Jun 2011, Bryan Wu wrote:
On Tue, Jun 28, 2011 at 10:46 AM, Todd Poynor [off-list ref] wrote:
quoted
Add notifiers for idle entry and exit, called with IDLE_START when a
CPU goes idle and IDLE_END when it goes out of idle, based on the
existing idle notifiers for the x86_64 arch.
Convert x86_64 to use these notifiers, and call the notifiers on ARM.
Convert the ARM LEDs events for idle start/end to these notifiers.
There is no conflict between those two series as one deals with the way
the LED events are generated and the other with the way those events are
acted upon. The LED event mechanism in the middle is still untouched
(could be deprecated eventually when all its users have migrated to the
common LED API but not yet).
Nicolas
You seem to use this notifier with different semantics than x86.
x86 notifies idle state when it knows it goes to sleep and exit it any
time it gets interrupted. And it does that every time in the need_resched()
loop.
But here in ARM you enter idle only once before the loop (and you don't even
know if you will enter the loop). And you don't notify idle exit state on interrupts.
So if in the end this idle notifier is something that is really wanted, it needs
to have a consistant behaviour across archs.
You seem to use this notifier with different semantics than x86.
x86 notifies idle state when it knows it goes to sleep and exit it any
time it gets interrupted. And it does that every time in the need_resched()
loop.
But here in ARM you enter idle only once before the loop (and you don't even
know if you will enter the loop). And you don't notify idle exit state on interrupts.
So if in the end this idle notifier is something that is really wanted, it needs
to have a consistant behaviour across archs.
Yes, I didn't want to change the behavior of the existing notifiers
being converted in these patches, but eventually one would want
cross-arch idle callbacks with consistent behavior, and the
existing arch-specific notifications have different semantics.
My goal is to notify when the OS scheduler enters and exits its idle
loop, so the existing ARM semantics are what I'm aiming for; the x86_64
behavior is probably further evidence that it is really a
cpuidle-style operation being performed. If the idle notifiers do
find any traction then it sounds like moving the notification to the
common schedule code would be the right thing to do.
Thanks -- Todd