All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 01/34] arch: Cleanup enable/disable_hlt
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
@ 2013-03-21 21:52 ` Thomas Gleixner
  2013-04-08 20:08   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:52 ` [patch 02/34] arch: Consolidate tsk_is_polling() Thomas Gleixner
                   ` (36 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:52 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

[-- Attachment #1: arch-cleanup-disable-hlt.patch --]
[-- Type: text/plain, Size: 4841 bytes --]

enable/disable_hlt() does not need to be exported and can be killed on
architectures which do not use it at all.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/arm/kernel/process.c               |    4 ----
 arch/cris/arch-v32/kernel/process.c     |    8 +++-----
 arch/cris/include/asm/processor.h       |    7 -------
 arch/cris/kernel/process.c              |   25 -------------------------
 arch/microblaze/include/asm/processor.h |    2 --
 arch/microblaze/kernel/process.c        |   12 ------------
 arch/mn10300/kernel/smp.c               |    5 -----
 7 files changed, 3 insertions(+), 60 deletions(-)

Index: linux-2.6/arch/arm/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/arm/kernel/process.c
+++ linux-2.6/arch/arm/kernel/process.c
@@ -64,16 +64,12 @@ void disable_hlt(void)
 	hlt_counter++;
 }
 
-EXPORT_SYMBOL(disable_hlt);
-
 void enable_hlt(void)
 {
 	hlt_counter--;
 	BUG_ON(hlt_counter < 0);
 }
 
-EXPORT_SYMBOL(enable_hlt);
-
 static int __init nohlt_setup(char *__unused)
 {
 	hlt_counter = 1;
Index: linux-2.6/arch/cris/arch-v32/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/cris/arch-v32/kernel/process.c
+++ linux-2.6/arch/cris/arch-v32/kernel/process.c
@@ -20,16 +20,14 @@
 
 extern void stop_watchdog(void);
 
-extern int cris_hlt_counter;
-
 /* We use this if we don't have any better idle routine. */
 void default_idle(void)
 {
 	local_irq_disable();
-	if (!need_resched() && !cris_hlt_counter) {
-	        /* Halt until exception. */
+	if (!need_resched()) {
+		/* Halt until exception. */
 		__asm__ volatile("ei    \n\t"
-                                 "halt      ");
+				 "halt      ");
 	}
 	local_irq_enable();
 }
Index: linux-2.6/arch/cris/include/asm/processor.h
===================================================================
--- linux-2.6.orig/arch/cris/include/asm/processor.h
+++ linux-2.6/arch/cris/include/asm/processor.h
@@ -65,13 +65,6 @@ static inline void release_thread(struct
 
 #define cpu_relax()     barrier()
 
-/*
- * disable hlt during certain critical i/o operations
- */
-#define HAVE_DISABLE_HLT
-void disable_hlt(void);
-void enable_hlt(void);
-
 void default_idle(void);
 
 #endif /* __ASM_CRIS_PROCESSOR_H */
Index: linux-2.6/arch/cris/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/cris/kernel/process.c
+++ linux-2.6/arch/cris/kernel/process.c
@@ -29,31 +29,6 @@
 
 //#define DEBUG
 
-/*
- * The hlt_counter, disable_hlt and enable_hlt is just here as a hook if
- * there would ever be a halt sequence (for power save when idle) with
- * some largish delay when halting or resuming *and* a driver that can't
- * afford that delay.  The hlt_counter would then be checked before
- * executing the halt sequence, and the driver marks the unhaltable
- * region by enable_hlt/disable_hlt.
- */
-
-int cris_hlt_counter=0;
-
-void disable_hlt(void)
-{
-	cris_hlt_counter++;
-}
-
-EXPORT_SYMBOL(disable_hlt);
-
-void enable_hlt(void)
-{
-	cris_hlt_counter--;
-}
-
-EXPORT_SYMBOL(enable_hlt);
- 
 extern void default_idle(void);
 
 void (*pm_power_off)(void);
Index: linux-2.6/arch/microblaze/include/asm/processor.h
===================================================================
--- linux-2.6.orig/arch/microblaze/include/asm/processor.h
+++ linux-2.6/arch/microblaze/include/asm/processor.h
@@ -160,8 +160,6 @@ unsigned long get_wchan(struct task_stru
 #  define STACK_TOP	TASK_SIZE
 #  define STACK_TOP_MAX	STACK_TOP
 
-void disable_hlt(void);
-void enable_hlt(void);
 void default_idle(void);
 
 #ifdef CONFIG_DEBUG_FS
Index: linux-2.6/arch/microblaze/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/microblaze/kernel/process.c
+++ linux-2.6/arch/microblaze/kernel/process.c
@@ -46,18 +46,6 @@ EXPORT_SYMBOL(pm_power_off);
 
 static int hlt_counter = 1;
 
-void disable_hlt(void)
-{
-	hlt_counter++;
-}
-EXPORT_SYMBOL(disable_hlt);
-
-void enable_hlt(void)
-{
-	hlt_counter--;
-}
-EXPORT_SYMBOL(enable_hlt);
-
 static int __init nohlt_setup(char *__unused)
 {
 	hlt_counter = 1;
Index: linux-2.6/arch/mn10300/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/mn10300/kernel/smp.c
+++ linux-2.6/arch/mn10300/kernel/smp.c
@@ -935,8 +935,6 @@ int __cpu_up(unsigned int cpu, struct ta
 	int timeout;
 
 #ifdef CONFIG_HOTPLUG_CPU
-	if (num_online_cpus() == 1)
-		disable_hlt();
 	if (sleep_mode[cpu])
 		run_wakeup_cpu(cpu);
 #endif /* CONFIG_HOTPLUG_CPU */
@@ -1003,9 +1001,6 @@ int __cpu_disable(void)
 void __cpu_die(unsigned int cpu)
 {
 	run_sleep_cpu(cpu);
-
-	if (num_online_cpus() == 1)
-		enable_hlt();
 }
 
 #ifdef CONFIG_MN10300_CACHE_ENABLED



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 00/34] idle: Consolidate idle implementations
@ 2013-03-21 21:52 Thomas Gleixner
  2013-03-21 21:52 ` [patch 01/34] arch: Cleanup enable/disable_hlt Thomas Gleixner
                   ` (37 more replies)
  0 siblings, 38 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:52 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

Each architecture implements its own cpu_idle() code, which is more or
less the same on all architectures (plus/minus a few bugs and a few
missing extra functionalities, instrumentation ...). That also forces
everyone who is interested in idle related features to add new
functionality to every architecture. What a waste.

Aside of that pointless code duplicaiton the ongoing quest to
consolidate the cpu hotplug code needs a common entry point for the
non boot cpus.

The following series implements a generic idle function and converts
most architectures over. I left out SPARC (it involves sparc asm) and
UM (it made me barf). If we can move those architectures as well, we
can get rid of the extra config switch and have everything
consolidated.

I spent a lot of time to make sure that the conversion preserved the
non obvious differences of the architecture implementations, but I
really need help from the affected maintainers to prove the
correctness.

Thanks,

	tglx
---
 arch/openrisc/kernel/idle.c                         |   73 ------------
 linux-2.6/arch/Kconfig                              |    3 
 linux-2.6/arch/alpha/Kconfig                        |    1 
 linux-2.6/arch/alpha/include/asm/thread_info.h      |    2 
 linux-2.6/arch/alpha/kernel/process.c               |   19 ---
 linux-2.6/arch/alpha/kernel/smp.c                   |    3 
 linux-2.6/arch/arc/Kconfig                          |    1 
 linux-2.6/arch/arc/kernel/process.c                 |   27 ----
 linux-2.6/arch/arc/kernel/smp.c                     |    2 
 linux-2.6/arch/arm/Kconfig                          |    2 
 linux-2.6/arch/arm/include/asm/system_misc.h        |    3 
 linux-2.6/arch/arm/kernel/process.c                 |  100 ++++-------------
 linux-2.6/arch/arm/kernel/smp.c                     |    2 
 linux-2.6/arch/arm/mach-gemini/idle.c               |    4 
 linux-2.6/arch/arm/mach-gemini/irq.c                |    2 
 linux-2.6/arch/arm/mach-ixp4xx/common.c             |    2 
 linux-2.6/arch/arm/mach-omap1/pm.c                  |    5 
 linux-2.6/arch/arm/mach-omap2/omap_hwmod.c          |    6 -
 linux-2.6/arch/arm/mach-omap2/pm.c                  |    5 
 linux-2.6/arch/arm/mach-orion5x/board-dt.c          |    2 
 linux-2.6/arch/arm/mach-orion5x/common.c            |    2 
 linux-2.6/arch/arm/mach-shark/core.c                |    2 
 linux-2.6/arch/arm/mach-shmobile/suspend.c          |    4 
 linux-2.6/arch/arm/mach-w90x900/dev.c               |    2 
 linux-2.6/arch/arm64/Kconfig                        |    1 
 linux-2.6/arch/arm64/kernel/process.c               |   43 -------
 linux-2.6/arch/arm64/kernel/smp.c                   |    2 
 linux-2.6/arch/avr32/Kconfig                        |    1 
 linux-2.6/arch/avr32/kernel/process.c               |   13 --
 linux-2.6/arch/avr32/kernel/time.c                  |    8 +
 linux-2.6/arch/avr32/mach-at32ap/include/mach/pm.h  |   24 ----
 linux-2.6/arch/avr32/mach-at32ap/pm-at32ap700x.S    |    7 -
 linux-2.6/arch/blackfin/Kconfig                     |    1 
 linux-2.6/arch/blackfin/kernel/process.c            |   30 -----
 linux-2.6/arch/blackfin/mach-common/smp.c           |    2 
 linux-2.6/arch/c6x/Kconfig                          |    1 
 linux-2.6/arch/c6x/kernel/process.c                 |   28 ----
 linux-2.6/arch/cris/Kconfig                         |    1 
 linux-2.6/arch/cris/arch-v10/kernel/process.c       |    3 
 linux-2.6/arch/cris/arch-v32/kernel/process.c       |   12 --
 linux-2.6/arch/cris/arch-v32/kernel/smp.c           |    4 
 linux-2.6/arch/cris/include/asm/processor.h         |    7 -
 linux-2.6/arch/cris/kernel/process.c                |   49 --------
 linux-2.6/arch/frv/Kconfig                          |    1 
 linux-2.6/arch/frv/kernel/process.c                 |   27 ----
 linux-2.6/arch/h8300/Kconfig                        |    1 
 linux-2.6/arch/h8300/kernel/process.c               |   35 ------
 linux-2.6/arch/hexagon/Kconfig                      |    1 
 linux-2.6/arch/hexagon/kernel/process.c             |   23 ----
 linux-2.6/arch/hexagon/kernel/smp.c                 |    2 
 linux-2.6/arch/ia64/Kconfig                         |    1 
 linux-2.6/arch/ia64/include/asm/thread_info.h       |    2 
 linux-2.6/arch/ia64/kernel/perfmon.c                |   13 --
 linux-2.6/arch/ia64/kernel/process.c                |   83 ++------------
 linux-2.6/arch/ia64/kernel/smpboot.c                |    2 
 linux-2.6/arch/m32r/Kconfig                         |    1 
 linux-2.6/arch/m32r/kernel/process.c                |   18 ---
 linux-2.6/arch/m32r/kernel/smpboot.c                |    2 
 linux-2.6/arch/m68k/Kconfig                         |    1 
 linux-2.6/arch/m68k/kernel/process.c                |   32 -----
 linux-2.6/arch/metag/Kconfig                        |    1 
 linux-2.6/arch/metag/include/asm/thread_info.h      |    2 
 linux-2.6/arch/metag/kernel/process.c               |   32 -----
 linux-2.6/arch/metag/kernel/smp.c                   |    2 
 linux-2.6/arch/microblaze/Kconfig                   |    2 
 linux-2.6/arch/microblaze/include/asm/processor.h   |    5 
 linux-2.6/arch/microblaze/include/asm/thread_info.h |    1 
 linux-2.6/arch/microblaze/kernel/process.c          |   65 -----------
 linux-2.6/arch/mips/Kconfig                         |    1 
 linux-2.6/arch/mips/kernel/process.c                |   46 ++------
 linux-2.6/arch/mips/kernel/smp.c                    |    2 
 linux-2.6/arch/mn10300/Kconfig                      |    1 
 linux-2.6/arch/mn10300/include/asm/thread_info.h    |    2 
 linux-2.6/arch/mn10300/kernel/process.c             |   70 +-----------
 linux-2.6/arch/mn10300/kernel/smp.c                 |    7 -
 linux-2.6/arch/openrisc/Kconfig                     |    1 
 linux-2.6/arch/openrisc/include/asm/thread_info.h   |    2 
 linux-2.6/arch/parisc/Kconfig                       |    1 
 linux-2.6/arch/parisc/include/asm/thread_info.h     |    2 
 linux-2.6/arch/parisc/kernel/process.c              |   22 ---
 linux-2.6/arch/parisc/kernel/smp.c                  |    2 
 linux-2.6/arch/powerpc/Kconfig                      |    1 
 linux-2.6/arch/powerpc/include/asm/thread_info.h    |    4 
 linux-2.6/arch/powerpc/kernel/idle.c                |   78 +++----------
 linux-2.6/arch/powerpc/kernel/smp.c                 |    2 
 linux-2.6/arch/s390/kernel/process.c                |   25 +---
 linux-2.6/arch/s390/kernel/smp.c                    |    3 
 linux-2.6/arch/score/Kconfig                        |    1 
 linux-2.6/arch/score/kernel/process.c               |   18 ---
 linux-2.6/arch/sh/Kconfig                           |    2 
 linux-2.6/arch/sh/include/asm/thread_info.h         |    4 
 linux-2.6/arch/sh/kernel/idle.c                     |  102 +----------------
 linux-2.6/arch/sh/kernel/smp.c                      |    2 
 linux-2.6/arch/sparc/include/asm/thread_info_32.h   |    2 
 linux-2.6/arch/sparc/include/asm/thread_info_64.h   |    2 
 linux-2.6/arch/tile/include/asm/thread_info.h       |    2 
 linux-2.6/arch/tile/kernel/process.c                |   61 +---------
 linux-2.6/arch/tile/kernel/smpboot.c                |    4 
 linux-2.6/arch/unicore32/Kconfig                    |    1 
 linux-2.6/arch/unicore32/kernel/process.c           |   21 ---
 linux-2.6/arch/x86/Kconfig                          |    1 
 linux-2.6/arch/x86/include/asm/thread_info.h        |    2 
 linux-2.6/arch/x86/kernel/process.c                 |  106 +++++-------------
 linux-2.6/arch/x86/kernel/smpboot.c                 |    2 
 linux-2.6/arch/x86/xen/smp.c                        |    2 
 linux-2.6/arch/xtensa/Kconfig                       |    1 
 linux-2.6/arch/xtensa/kernel/process.c              |   14 --
 linux-2.6/include/linux/cpu.h                       |   16 ++
 linux-2.6/include/linux/sched.h                     |   41 +++++++
 linux-2.6/init/main.c                               |    2 
 linux-2.6/kernel/Makefile                           |    1 
 linux-2.6/kernel/cpu/Makefile                       |    1 
 linux-2.6/kernel/cpu/idle.c                         |  115 ++++++++++++++++++++
 linux-2.6/kernel/sched/core.c                       |    5 
 114 files changed, 432 insertions(+), 1237 deletions(-)


^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 02/34] arch: Consolidate tsk_is_polling()
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
  2013-03-21 21:52 ` [patch 01/34] arch: Cleanup enable/disable_hlt Thomas Gleixner
@ 2013-03-21 21:52 ` Thomas Gleixner
  2013-03-22  5:01   ` Tony Breeds
                     ` (2 more replies)
  2013-03-21 21:52 ` [patch 03/34] idle: Implement set/clr functions for need_resched poll Thomas Gleixner
                   ` (35 subsequent siblings)
  37 siblings, 3 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:52 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

[-- Attachment #1: arch-consolidate-tsk-is-polling.patch --]
[-- Type: text/plain, Size: 9432 bytes --]

Move it to a common place. Preparatory patch for implementing
set/clear for the idle need_resched poll implementation.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/alpha/include/asm/thread_info.h      |    2 --
 arch/ia64/include/asm/thread_info.h       |    2 --
 arch/metag/include/asm/thread_info.h      |    2 --
 arch/microblaze/include/asm/thread_info.h |    1 -
 arch/mn10300/include/asm/thread_info.h    |    2 --
 arch/openrisc/include/asm/thread_info.h   |    2 --
 arch/parisc/include/asm/thread_info.h     |    2 --
 arch/powerpc/include/asm/thread_info.h    |    4 ----
 arch/sh/include/asm/thread_info.h         |    4 ----
 arch/sparc/include/asm/thread_info_32.h   |    2 --
 arch/sparc/include/asm/thread_info_64.h   |    2 --
 arch/tile/include/asm/thread_info.h       |    2 --
 arch/x86/include/asm/thread_info.h        |    2 --
 include/linux/sched.h                     |   20 ++++++++++++++++++++
 kernel/sched/core.c                       |    5 -----
 15 files changed, 20 insertions(+), 34 deletions(-)

Index: linux-2.6/arch/alpha/include/asm/thread_info.h
===================================================================
--- linux-2.6.orig/arch/alpha/include/asm/thread_info.h
+++ linux-2.6/arch/alpha/include/asm/thread_info.h
@@ -95,8 +95,6 @@ register struct thread_info *__current_t
 #define TS_POLLING		0x0010	/* idle task polling need_resched,
 					   skip sending interrupt */
 
-#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
-
 #ifndef __ASSEMBLY__
 #define HAVE_SET_RESTORE_SIGMASK	1
 static inline void set_restore_sigmask(void)
Index: linux-2.6/arch/ia64/include/asm/thread_info.h
===================================================================
--- linux-2.6.orig/arch/ia64/include/asm/thread_info.h
+++ linux-2.6/arch/ia64/include/asm/thread_info.h
@@ -131,8 +131,6 @@ struct thread_info {
 #define TS_POLLING		1 	/* true if in idle loop and not sleeping */
 #define TS_RESTORE_SIGMASK	2	/* restore signal mask in do_signal() */
 
-#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
-
 #ifndef __ASSEMBLY__
 #define HAVE_SET_RESTORE_SIGMASK	1
 static inline void set_restore_sigmask(void)
Index: linux-2.6/arch/metag/include/asm/thread_info.h
===================================================================
--- linux-2.6.orig/arch/metag/include/asm/thread_info.h
+++ linux-2.6/arch/metag/include/asm/thread_info.h
@@ -150,6 +150,4 @@ static inline int kstack_end(void *addr)
 #define _TIF_WORK_MASK		(_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
 				 _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP))
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #endif /* _ASM_THREAD_INFO_H */
Index: linux-2.6/arch/microblaze/include/asm/thread_info.h
===================================================================
--- linux-2.6.orig/arch/microblaze/include/asm/thread_info.h
+++ linux-2.6/arch/microblaze/include/asm/thread_info.h
@@ -182,7 +182,6 @@ static inline bool test_and_clear_restor
 	ti->status &= ~TS_RESTORE_SIGMASK;
 	return true;
 }
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
 #endif
 
 #endif /* __KERNEL__ */
Index: linux-2.6/arch/mn10300/include/asm/thread_info.h
===================================================================
--- linux-2.6.orig/arch/mn10300/include/asm/thread_info.h
+++ linux-2.6/arch/mn10300/include/asm/thread_info.h
@@ -165,8 +165,6 @@ void arch_release_thread_info(struct thr
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */
Index: linux-2.6/arch/openrisc/include/asm/thread_info.h
===================================================================
--- linux-2.6.orig/arch/openrisc/include/asm/thread_info.h
+++ linux-2.6/arch/openrisc/include/asm/thread_info.h
@@ -128,8 +128,6 @@ register struct thread_info *current_thr
 /* For OpenRISC, this is anything in the LSW other than syscall trace */
 #define _TIF_WORK_MASK (0xff & ~(_TIF_SYSCALL_TRACE|_TIF_SINGLESTEP))
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */
Index: linux-2.6/arch/parisc/include/asm/thread_info.h
===================================================================
--- linux-2.6.orig/arch/parisc/include/asm/thread_info.h
+++ linux-2.6/arch/parisc/include/asm/thread_info.h
@@ -77,8 +77,6 @@ struct thread_info {
 #define _TIF_SYSCALL_TRACE_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP |	\
 				 _TIF_BLOCKSTEP)
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_PARISC_THREAD_INFO_H */
Index: linux-2.6/arch/powerpc/include/asm/thread_info.h
===================================================================
--- linux-2.6.orig/arch/powerpc/include/asm/thread_info.h
+++ linux-2.6/arch/powerpc/include/asm/thread_info.h
@@ -182,10 +182,6 @@ static inline bool test_thread_local_fla
 #define is_32bit_task()	(1)
 #endif
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
-#endif	/* !__ASSEMBLY__ */
-
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_POWERPC_THREAD_INFO_H */
Index: linux-2.6/arch/sh/include/asm/thread_info.h
===================================================================
--- linux-2.6.orig/arch/sh/include/asm/thread_info.h
+++ linux-2.6/arch/sh/include/asm/thread_info.h
@@ -207,10 +207,6 @@ static inline bool test_and_clear_restor
 	return true;
 }
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
-#endif	/* !__ASSEMBLY__ */
-
 #endif /* __KERNEL__ */
 
 #endif /* __ASM_SH_THREAD_INFO_H */
Index: linux-2.6/arch/sparc/include/asm/thread_info_32.h
===================================================================
--- linux-2.6.orig/arch/sparc/include/asm/thread_info_32.h
+++ linux-2.6/arch/sparc/include/asm/thread_info_32.h
@@ -132,8 +132,6 @@ register struct thread_info *current_thr
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING)
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */
Index: linux-2.6/arch/sparc/include/asm/thread_info_64.h
===================================================================
--- linux-2.6.orig/arch/sparc/include/asm/thread_info_64.h
+++ linux-2.6/arch/sparc/include/asm/thread_info_64.h
@@ -256,8 +256,6 @@ static inline bool test_and_clear_restor
 	return true;
 }
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #define thread32_stack_is_64bit(__SP) (((__SP) & 0x1) != 0)
 #define test_thread_64bit_stack(__SP) \
 	((test_thread_flag(TIF_32BIT) && !thread32_stack_is_64bit(__SP)) ? \
Index: linux-2.6/arch/tile/include/asm/thread_info.h
===================================================================
--- linux-2.6.orig/arch/tile/include/asm/thread_info.h
+++ linux-2.6/arch/tile/include/asm/thread_info.h
@@ -153,8 +153,6 @@ extern void _cpu_idle(void);
 #define TS_POLLING		0x0004	/* in idle loop but not sleeping */
 #define TS_RESTORE_SIGMASK	0x0008	/* restore signal mask in do_signal */
 
-#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
-
 #ifndef __ASSEMBLY__
 #define HAVE_SET_RESTORE_SIGMASK	1
 static inline void set_restore_sigmask(void)
Index: linux-2.6/arch/x86/include/asm/thread_info.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/thread_info.h
+++ linux-2.6/arch/x86/include/asm/thread_info.h
@@ -241,8 +241,6 @@ static inline struct thread_info *curren
 					   skip sending interrupt */
 #define TS_RESTORE_SIGMASK	0x0008	/* restore signal mask in do_signal() */
 
-#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
-
 #ifndef __ASSEMBLY__
 #define HAVE_SET_RESTORE_SIGMASK	1
 static inline void set_restore_sigmask(void)
Index: linux-2.6/include/linux/sched.h
===================================================================
--- linux-2.6.orig/include/linux/sched.h
+++ linux-2.6/include/linux/sched.h
@@ -2472,6 +2472,26 @@ static inline unsigned long *end_of_stac
 
 #endif
 
+/*
+ * Idle thread specific functions to determine the need_resched
+ * polling state. We have two versions, one based on TS_POLLING in
+ * thread_info.status and one based on TIF_POLLING_NRFLAG in
+ * thread_info.flags
+ */
+#ifdef TS_POLLING
+static inline int tsk_is_polling(struct task_struct *p)
+{
+	return task_thread_info(p)->status & TS_POLLING;
+}
+#elif defined(TIF_POLLING_NRFLAG)
+static inline int tsk_is_polling(struct task_struct *p)
+{
+	test_tsk_thread_flag(p, TIF_POLLING_NRFLAG);
+}
+#else
+static inline int tsk_is_polling(struct task_struct *p) { return 0; }
+#endif
+
 static inline int object_is_on_stack(void *obj)
 {
 	void *stack = task_stack_page(current);
Index: linux-2.6/kernel/sched/core.c
===================================================================
--- linux-2.6.orig/kernel/sched/core.c
+++ linux-2.6/kernel/sched/core.c
@@ -512,11 +512,6 @@ static inline void init_hrtick(void)
  * the target CPU.
  */
 #ifdef CONFIG_SMP
-
-#ifndef tsk_is_polling
-#define tsk_is_polling(t) 0
-#endif
-
 void resched_task(struct task_struct *p)
 {
 	int cpu;



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 03/34] idle: Implement set/clr functions for need_resched poll
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
  2013-03-21 21:52 ` [patch 01/34] arch: Cleanup enable/disable_hlt Thomas Gleixner
  2013-03-21 21:52 ` [patch 02/34] arch: Consolidate tsk_is_polling() Thomas Gleixner
@ 2013-03-21 21:52 ` Thomas Gleixner
  2013-03-22  9:38     ` James Hogan
  2013-04-08 20:10   ` [tip:smp/hotplug] idle: Implement set/ clr " tip-bot for Thomas Gleixner
  2013-03-21 21:52 ` [patch 04/34] idle: Provide a generic entry point for the idle code Thomas Gleixner
                   ` (34 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:52 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

[-- Attachment #1: smpboot-implement-need-resched-polling-helpers.patch --]
[-- Type: text/plain, Size: 1698 bytes --]

Implement set/clear functions for the idle need_resched poll
implementation.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/sched.h |   23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

Index: linux-2.6/include/linux/sched.h
===================================================================
--- linux-2.6.orig/include/linux/sched.h
+++ linux-2.6/include/linux/sched.h
@@ -2473,7 +2473,7 @@ static inline unsigned long *end_of_stac
 #endif
 
 /*
- * Idle thread specific functions to determine the need_resched
+ * Idle thread specific functions for the the need_resched
  * polling state. We have two versions, one based on TS_POLLING in
  * thread_info.status and one based on TIF_POLLING_NRFLAG in
  * thread_info.flags
@@ -2483,13 +2483,34 @@ static inline int tsk_is_polling(struct 
 {
 	return task_thread_info(p)->status & TS_POLLING;
 }
+static inline void current_set_polling(void)
+{
+	current_thread_info()->status |= TS_POLLING;
+}
+
+static inline void current_clr_polling(void)
+{
+	current_thread_info()->status &= ~TS_POLLING;
+	smp_mb__after_clear_bit();
+}
 #elif defined(TIF_POLLING_NRFLAG)
 static inline int tsk_is_polling(struct task_struct *p)
 {
 	test_tsk_thread_flag(p, TIF_POLLING_NRFLAG);
 }
+static inline void current_set_polling(void)
+{
+	set_thread_flag(TIF_POLLING_NRFLAG);
+}
+
+static inline void current_clr_polling(void)
+{
+	clear_thread_flag(TIF_POLLING_NRFLAG);
+}
 #else
 static inline int tsk_is_polling(struct task_struct *p) { return 0; }
+static inline void current_set_polling(void) { }
+static inline void current_clr_polling(void) { }
 #endif
 
 static inline int object_is_on_stack(void *obj)



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 04/34] idle: Provide a generic entry point for the idle code
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (2 preceding siblings ...)
  2013-03-21 21:52 ` [patch 03/34] idle: Implement set/clr functions for need_resched poll Thomas Gleixner
@ 2013-03-21 21:52 ` Thomas Gleixner
  2013-04-08 20:12   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 06/34] arc: Use generic idle loop Thomas Gleixner
                   ` (33 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:52 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

[-- Attachment #1: smpboot-implement-core-idle-function.patch --]
[-- Type: text/plain, Size: 2161 bytes --]

For now this calls cpu_idle(), but in the long run we want to move the
cpu bringup code to the core and therefor we add a state argument.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/cpu.h |    8 ++++++++
 init/main.c         |    2 +-
 kernel/Makefile     |    1 +
 kernel/cpu/Makefile |    1 +
 kernel/cpu/idle.c   |   10 ++++++++++
 5 files changed, 21 insertions(+), 1 deletion(-)

Index: linux-2.6/include/linux/cpu.h
===================================================================
--- linux-2.6.orig/include/linux/cpu.h
+++ linux-2.6/include/linux/cpu.h
@@ -212,4 +212,12 @@ static inline int disable_nonboot_cpus(v
 static inline void enable_nonboot_cpus(void) {}
 #endif /* !CONFIG_PM_SLEEP_SMP */
 
+enum cpuhp_state {
+	CPUHP_OFFLINE,
+	CPUHP_ONLINE,
+};
+
+void cpu_startup_entry(enum cpuhp_state state);
+void cpu_idle(void);
+
 #endif /* _LINUX_CPU_H_ */
Index: linux-2.6/init/main.c
===================================================================
--- linux-2.6.orig/init/main.c
+++ linux-2.6/init/main.c
@@ -384,7 +384,7 @@ static noinline void __init_refok rest_i
 	init_idle_bootup_task(current);
 	schedule_preempt_disabled();
 	/* Call into cpu_idle with preempt disabled */
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 /* Check for early params. */
Index: linux-2.6/kernel/Makefile
===================================================================
--- linux-2.6.orig/kernel/Makefile
+++ linux-2.6/kernel/Makefile
@@ -24,6 +24,7 @@ endif
 
 obj-y += sched/
 obj-y += power/
+obj-y += cpu/
 
 obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o
 obj-$(CONFIG_FREEZER) += freezer.o
Index: linux-2.6/kernel/cpu/Makefile
===================================================================
--- /dev/null
+++ linux-2.6/kernel/cpu/Makefile
@@ -0,0 +1 @@
+obj-y	= idle.o
Index: linux-2.6/kernel/cpu/idle.c
===================================================================
--- /dev/null
+++ linux-2.6/kernel/cpu/idle.c
@@ -0,0 +1,10 @@
+/*
+ * Generic entry point for the idle threads
+ */
+#include <linux/sched.h>
+#include <linux/cpu.h>
+
+void cpu_startup_entry(enum cpuhp_state state)
+{
+	cpu_idle();
+}



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 06/34] arc: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (3 preceding siblings ...)
  2013-03-21 21:52 ` [patch 04/34] idle: Provide a generic entry point for the idle code Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-22  9:02     ` Vineet Gupta
  2013-04-08 20:15   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 05/34] idle: Implement generic idle function Thomas Gleixner
                   ` (32 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Vineet Gupta

[-- Attachment #1: arc-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 2346 bytes --]

The generic idle loop implements all functionality. Aside of that it
allows arc to implement the tsk_is_polling() functionality correctly,
despite the patently (now gone) comment in the original arc cpu_idle()
function:
/* Since we SLEEP in idle loop, TIF_POLLING_NRFLAG can't be set */
See kernel/cpu/idle.c

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Vineet Gupta <vgupta@synopsys.com>
---
 arch/arc/Kconfig          |    1 +
 arch/arc/kernel/process.c |   27 +--------------------------
 arch/arc/kernel/smp.c     |    2 +-
 3 files changed, 3 insertions(+), 27 deletions(-)

Index: linux-2.6/arch/arc/Kconfig
===================================================================
--- linux-2.6.orig/arch/arc/Kconfig
+++ linux-2.6/arch/arc/Kconfig
@@ -20,6 +20,7 @@ config ARC
 	select GENERIC_KERNEL_THREAD
 	select GENERIC_PENDING_IRQ if SMP
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_GENERIC_HARDIRQS
Index: linux-2.6/arch/arc/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/arc/kernel/process.c
+++ linux-2.6/arch/arc/kernel/process.c
@@ -41,37 +41,12 @@ SYSCALL_DEFINE0(arc_gettls)
 	return task_thread_info(current)->thr_ptr;
 }
 
-static inline void arch_idle(void)
+void arch_cpu_idle(void)
 {
 	/* sleep, but enable all interrupts before committing */
 	__asm__("sleep 0x3");
 }
 
-void cpu_idle(void)
-{
-	/* Since we SLEEP in idle loop, TIF_POLLING_NRFLAG can't be set */
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-doze:
-		local_irq_disable();
-		if (!need_resched()) {
-			arch_idle();
-			goto doze;
-		} else {
-			local_irq_enable();
-		}
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
-		schedule_preempt_disabled();
-	}
-}
-
 asmlinkage void ret_from_fork(void);
 
 /* Layout of Child kernel mode stack as setup at the end of this function is
Index: linux-2.6/arch/arc/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/arc/kernel/smp.c
+++ linux-2.6/arch/arc/kernel/smp.c
@@ -141,7 +141,7 @@ void __cpuinit start_kernel_secondary(vo
 
 	local_irq_enable();
 	preempt_disable();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 /*



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 05/34] idle: Implement generic idle function
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (4 preceding siblings ...)
  2013-03-21 21:53 ` [patch 06/34] arc: Use generic idle loop Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-23  8:56   ` Heiko Carstens
                     ` (3 more replies)
  2013-03-21 21:53 ` [patch 07/34] alpha: Use generic idle loop Thomas Gleixner
                   ` (31 subsequent siblings)
  37 siblings, 4 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

[-- Attachment #1: smpboot-implement-common-idle-functionality.patch --]
[-- Type: text/plain, Size: 3968 bytes --]

All idle functions in arch/* are more or less the same, plus minus a
few bugs and extra instrumentation, tickless support and other
optional items.

Implement a generic idle function which resembles the functionality
found in arch/. Provide weak arch_cpu_idle_* functions which can be
overridden by the architecture code if needed.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/Kconfig        |    3 +
 include/linux/cpu.h |    8 +++
 kernel/cpu/idle.c   |  105 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+)

Index: linux-2.6/arch/Kconfig
===================================================================
--- linux-2.6.orig/arch/Kconfig
+++ linux-2.6/arch/Kconfig
@@ -216,6 +216,9 @@ config USE_GENERIC_SMP_HELPERS
 config GENERIC_SMP_IDLE_THREAD
        bool
 
+config GENERIC_IDLE_LOOP
+       bool
+
 # Select if arch init_task initializer is different to init/init_task.c
 config ARCH_INIT_TASK
        bool
Index: linux-2.6/include/linux/cpu.h
===================================================================
--- linux-2.6.orig/include/linux/cpu.h
+++ linux-2.6/include/linux/cpu.h
@@ -220,4 +220,12 @@ enum cpuhp_state {
 void cpu_startup_entry(enum cpuhp_state state);
 void cpu_idle(void);
 
+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);
+
 #endif /* _LINUX_CPU_H_ */
Index: linux-2.6/kernel/cpu/idle.c
===================================================================
--- linux-2.6.orig/kernel/cpu/idle.c
+++ linux-2.6/kernel/cpu/idle.c
@@ -3,8 +3,113 @@
  */
 #include <linux/sched.h>
 #include <linux/cpu.h>
+#include <linux/tick.h>
+#include <linux/mm.h>
 
+#include <asm/tlb.h>
+
+#include <trace/events/power.h>
+
+#ifndef CONFIG_GENERIC_IDLE_LOOP
 void cpu_startup_entry(enum cpuhp_state state)
 {
 	cpu_idle();
 }
+#else
+
+static int __read_mostly cpu_idle_force_poll;
+
+void cpu_idle_poll_ctrl(bool enable)
+{
+	if (enable) {
+		cpu_idle_force_poll++;
+	} else {
+		cpu_idle_force_poll--;
+		WARN_ON_ONCE(cpu_idle_force_poll < 0);
+	}
+}
+
+#ifdef CONFIG_GENERIC_IDLE_POLL_SETUP
+static int __init cpu_idle_poll_setup(char *__unused)
+{
+	cpu_idle_force_poll = 1;
+	return 1;
+}
+__setup("nohlt", cpu_idle_poll_setup);
+
+static int __init cpu_idle_nopoll_setup(char *__unused)
+{
+	cpu_idle_force_poll = 0;
+	return 1;
+}
+__setup("hlt", cpu_idle_nopoll_setup);
+#endif
+
+static inline int cpu_idle_poll(void)
+{
+	trace_cpu_idle_rcuidle(0, smp_processor_id());
+	local_irq_enable();
+	while (!need_resched())
+		cpu_relax();
+	trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
+	return 1;
+}
+
+/* Weak implementations for optional arch specific functions */
+void __weak arch_cpu_idle_prepare(void) { }
+void __weak arch_cpu_idle_enter(void) { }
+void __weak arch_cpu_idle_exit(void) { }
+void __weak arch_cpu_idle_dead(void) { }
+void __weak arch_cpu_idle(void)
+{
+	cpu_idle_poll();
+}
+
+/*
+ * Generic idle loop implementation
+ */
+static void cpu_idle_loop(void)
+{
+	while (1) {
+		tick_nohz_idle_enter();
+
+		while (!need_resched()) {
+			check_pgt_cache();
+			rmb();
+
+			if (cpu_is_offline(smp_processor_id()))
+				arch_cpu_idle_dead();
+
+			local_irq_disable();
+			arch_cpu_idle_enter();
+
+			if (cpu_idle_force_poll) {
+				cpu_idle_poll();
+			} else {
+				current_clr_polling();
+				if (!need_resched()) {
+					stop_critical_timings();
+					rcu_idle_enter();
+					arch_cpu_idle();
+					WARN_ON_ONCE(!irqs_disabled());
+					rcu_idle_exit();
+					start_critical_timings();
+				} else {
+					local_irq_enable();
+				}
+				current_set_polling();
+			}
+			arch_cpu_idle_exit();
+		}
+		tick_nohz_idle_exit();
+		schedule_preempt_disabled();
+	}
+}
+
+void cpu_startup_entry(enum cpuhp_state state)
+{
+	current_set_polling();
+	arch_cpu_idle_prepare();
+	cpu_idle_loop();
+}
+#endif



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 07/34] alpha: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (5 preceding siblings ...)
  2013-03-21 21:53 ` [patch 05/34] idle: Implement generic idle function Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-28 15:37   ` Srivatsa S. Bhat
  2013-04-08 20:16   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 08/34] arm: " Thomas Gleixner
                   ` (30 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Richard Henderson, Ivan Kokshaysky, Matt Turner

[-- Attachment #1: alpha-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 1936 bytes --]

The core provides a generic idle poll loop.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
---
 arch/alpha/Kconfig          |    1 +
 arch/alpha/kernel/process.c |   19 -------------------
 arch/alpha/kernel/smp.c     |    3 +--
 3 files changed, 2 insertions(+), 21 deletions(-)

Index: linux-2.6/arch/alpha/Kconfig
===================================================================
--- linux-2.6.orig/arch/alpha/Kconfig
+++ linux-2.6/arch/alpha/Kconfig
@@ -17,6 +17,7 @@ config ALPHA
 	select ARCH_WANT_IPC_PARSE_VERSION
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
Index: linux-2.6/arch/alpha/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/alpha/kernel/process.c
+++ linux-2.6/arch/alpha/kernel/process.c
@@ -46,25 +46,6 @@
 void (*pm_power_off)(void) = machine_power_off;
 EXPORT_SYMBOL(pm_power_off);
 
-void
-cpu_idle(void)
-{
-	current_thread_info()->status |= TS_POLLING;
-
-	while (1) {
-		/* FIXME -- EV6 and LCA45 know how to power down
-		   the CPU.  */
-
-		rcu_idle_enter();
-		while (!need_resched())
-			cpu_relax();
-
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
-}
-
-
 struct halt_info {
 	int mode;
 	char *restart_cmd;
Index: linux-2.6/arch/alpha/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/alpha/kernel/smp.c
+++ linux-2.6/arch/alpha/kernel/smp.c
@@ -167,8 +167,7 @@ smp_callin(void)
 	      cpuid, current, current->active_mm));
 
 	preempt_disable();
-	/* Do nothing.  */
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 /* Wait until hwrpb->txrdy is clear for cpu.  Return -1 on timeout.  */



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 08/34] arm: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (6 preceding siblings ...)
  2013-03-21 21:53 ` [patch 07/34] alpha: Use generic idle loop Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-22 21:24   ` Kevin Hilman
  2013-04-08 20:17   ` [tip:smp/hotplug] arm: Use generic idle loop tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 09/34] arm64: " Thomas Gleixner
                   ` (29 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Russell King

[-- Attachment #1: arm-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 11024 bytes --]

Use the generic idle loop and replace enable/disable_hlt with the
respective core functions.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
---
 arch/arm/Kconfig                   |    2 
 arch/arm/include/asm/system_misc.h |    3 -
 arch/arm/kernel/process.c          |   96 ++++++++++---------------------------
 arch/arm/kernel/smp.c              |    2 
 arch/arm/mach-gemini/idle.c        |    4 +
 arch/arm/mach-gemini/irq.c         |    2 
 arch/arm/mach-ixp4xx/common.c      |    2 
 arch/arm/mach-omap1/pm.c           |    5 -
 arch/arm/mach-omap2/omap_hwmod.c   |    6 +-
 arch/arm/mach-omap2/pm.c           |    5 -
 arch/arm/mach-orion5x/board-dt.c   |    2 
 arch/arm/mach-orion5x/common.c     |    2 
 arch/arm/mach-shark/core.c         |    2 
 arch/arm/mach-shmobile/suspend.c   |    4 -
 arch/arm/mach-w90x900/dev.c        |    2 
 15 files changed, 47 insertions(+), 92 deletions(-)

Index: linux-2.6/arch/arm/Kconfig
===================================================================
--- linux-2.6.orig/arch/arm/Kconfig
+++ linux-2.6/arch/arm/Kconfig
@@ -15,6 +15,8 @@ config ARM
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
+	select GENERIC_IDLE_POLL_SETUP
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
 	select HARDIRQS_SW_RESEND
Index: linux-2.6/arch/arm/include/asm/system_misc.h
===================================================================
--- linux-2.6.orig/arch/arm/include/asm/system_misc.h
+++ linux-2.6/arch/arm/include/asm/system_misc.h
@@ -21,9 +21,6 @@ extern void (*arm_pm_idle)(void);
 
 extern unsigned int user_debug;
 
-extern void disable_hlt(void);
-extern void enable_hlt(void);
-
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __ASM_ARM_SYSTEM_MISC_H */
Index: linux-2.6/arch/arm/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/arm/kernel/process.c
+++ linux-2.6/arch/arm/kernel/process.c
@@ -57,34 +57,6 @@ static const char *isa_modes[] = {
   "ARM" , "Thumb" , "Jazelle", "ThumbEE"
 };
 
-static volatile int hlt_counter;
-
-void disable_hlt(void)
-{
-	hlt_counter++;
-}
-
-void enable_hlt(void)
-{
-	hlt_counter--;
-	BUG_ON(hlt_counter < 0);
-}
-
-static int __init nohlt_setup(char *__unused)
-{
-	hlt_counter = 1;
-	return 1;
-}
-
-static int __init hlt_setup(char *__unused)
-{
-	hlt_counter = 0;
-	return 1;
-}
-
-__setup("nohlt", nohlt_setup);
-__setup("hlt", hlt_setup);
-
 extern void call_with_stack(void (*fn)(void *), void *arg, void *sp);
 typedef void (*phys_reset_t)(unsigned long);
 
@@ -168,54 +140,38 @@ static void default_idle(void)
 	local_irq_enable();
 }
 
-/*
- * The idle thread.
- * We always respect 'hlt_counter' to prevent low power idle.
- */
-void cpu_idle(void)
+void arch_cpu_idle_prepare(void)
 {
 	local_fiq_enable();
+}
 
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		ledtrig_cpu(CPU_LED_IDLE_START);
-		while (!need_resched()) {
-#ifdef CONFIG_HOTPLUG_CPU
-			if (cpu_is_offline(smp_processor_id()))
-				cpu_die();
+void arch_cpu_idle_enter(void)
+{
+	ledtrig_cpu(CPU_LED_IDLE_START);
+#ifdef CONFIG_PL310_ERRATA_769419
+	wmb();
 #endif
+}
 
-			/*
-			 * We need to disable interrupts here
-			 * to ensure we don't miss a wakeup call.
-			 */
-			local_irq_disable();
-#ifdef CONFIG_PL310_ERRATA_769419
-			wmb();
+void arch_cpu_idle_exit(void)
+{
+	ledtrig_cpu(CPU_LED_IDLE_END);
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
+void arch_cpu_idle_dead(void)
+{
+	cpu_die();
+}
 #endif
-			if (hlt_counter) {
-				local_irq_enable();
-				cpu_relax();
-			} else if (!need_resched()) {
-				stop_critical_timings();
-				if (cpuidle_idle_call())
-					default_idle();
-				start_critical_timings();
-				/*
-				 * default_idle functions must always
-				 * return with IRQs enabled.
-				 */
-				WARN_ON(irqs_disabled());
-			} else
-				local_irq_enable();
-		}
-		ledtrig_cpu(CPU_LED_IDLE_END);
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	}
+
+/*
+ * Called from the core idle loop.
+ */
+void arch_cpu_idle(void)
+{
+	if (cpuidle_idle_call())
+		default_idle();
 }
 
 static char reboot_mode = 'h';
Index: linux-2.6/arch/arm/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/arm/kernel/smp.c
+++ linux-2.6/arch/arm/kernel/smp.c
@@ -336,7 +336,7 @@ asmlinkage void __cpuinit secondary_star
 	/*
 	 * OK, it's off to the idle thread for us
 	 */
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void __init smp_cpus_done(unsigned int max_cpus)
Index: linux-2.6/arch/arm/mach-gemini/idle.c
===================================================================
--- linux-2.6.orig/arch/arm/mach-gemini/idle.c
+++ linux-2.6/arch/arm/mach-gemini/idle.c
@@ -13,9 +13,11 @@ static void gemini_idle(void)
 	 * will never wakeup... Acctualy it is not very good to enable
 	 * interrupts first since scheduler can miss a tick, but there is
 	 * no other way around this. Platforms that needs it for power saving
-	 * should call enable_hlt() in init code, since by default it is
+	 * should enable it in init code, since by default it is
 	 * disabled.
 	 */
+
+	/* FIXME: Enabling interrupts here is racy! */
 	local_irq_enable();
 	cpu_do_idle();
 }
Index: linux-2.6/arch/arm/mach-gemini/irq.c
===================================================================
--- linux-2.6.orig/arch/arm/mach-gemini/irq.c
+++ linux-2.6/arch/arm/mach-gemini/irq.c
@@ -77,7 +77,7 @@ void __init gemini_init_irq(void)
 	 * Disable the idle handler by default since it is buggy
 	 * For more info see arch/arm/mach-gemini/idle.c
 	 */
-	disable_hlt();
+	cpu_idle_poll_ctrl(true);
 
 	request_resource(&iomem_resource, &irq_resource);
 
Index: linux-2.6/arch/arm/mach-ixp4xx/common.c
===================================================================
--- linux-2.6.orig/arch/arm/mach-ixp4xx/common.c
+++ linux-2.6/arch/arm/mach-ixp4xx/common.c
@@ -239,7 +239,7 @@ void __init ixp4xx_init_irq(void)
 	 * ixp4xx does not implement the XScale PWRMODE register
 	 * so it must not call cpu_do_idle().
 	 */
-	disable_hlt();
+	cpu_idle_poll_ctrl(true);
 
 	/* Route all sources to IRQ instead of FIQ */
 	*IXP4XX_ICLR = 0x0;
Index: linux-2.6/arch/arm/mach-omap1/pm.c
===================================================================
--- linux-2.6.orig/arch/arm/mach-omap1/pm.c
+++ linux-2.6/arch/arm/mach-omap1/pm.c
@@ -584,8 +584,7 @@ static void omap_pm_init_proc(void)
 static int omap_pm_prepare(void)
 {
 	/* We cannot sleep in idle until we have resumed */
-	disable_hlt();
-
+	cpu_idle_poll_ctrl(true);
 	return 0;
 }
 
@@ -621,7 +620,7 @@ static int omap_pm_enter(suspend_state_t
 
 static void omap_pm_finish(void)
 {
-	enable_hlt();
+	cpu_idle_poll_ctrl(false);
 }
 
 
Index: linux-2.6/arch/arm/mach-omap2/omap_hwmod.c
===================================================================
--- linux-2.6.orig/arch/arm/mach-omap2/omap_hwmod.c
+++ linux-2.6/arch/arm/mach-omap2/omap_hwmod.c
@@ -2154,7 +2154,7 @@ static int _enable(struct omap_hwmod *oh
 	if (soc_ops.enable_module)
 		soc_ops.enable_module(oh);
 	if (oh->flags & HWMOD_BLOCK_WFI)
-		disable_hlt();
+		cpu_idle_poll_ctrl(true);
 
 	if (soc_ops.update_context_lost)
 		soc_ops.update_context_lost(oh);
@@ -2218,7 +2218,7 @@ static int _idle(struct omap_hwmod *oh)
 	_del_initiator_dep(oh, mpu_oh);
 
 	if (oh->flags & HWMOD_BLOCK_WFI)
-		enable_hlt();
+		cpu_idle_poll_ctrl(false);
 	if (soc_ops.disable_module)
 		soc_ops.disable_module(oh);
 
@@ -2328,7 +2328,7 @@ static int _shutdown(struct omap_hwmod *
 		_del_initiator_dep(oh, mpu_oh);
 		/* XXX what about the other system initiators here? dma, dsp */
 		if (oh->flags & HWMOD_BLOCK_WFI)
-			enable_hlt();
+			cpu_idle_poll_ctrl(false);
 		if (soc_ops.disable_module)
 			soc_ops.disable_module(oh);
 		_disable_clocks(oh);
Index: linux-2.6/arch/arm/mach-omap2/pm.c
===================================================================
--- linux-2.6.orig/arch/arm/mach-omap2/pm.c
+++ linux-2.6/arch/arm/mach-omap2/pm.c
@@ -218,7 +218,7 @@ static int omap_pm_enter(suspend_state_t
 
 static int omap_pm_begin(suspend_state_t state)
 {
-	disable_hlt();
+	cpu_idle_poll_ctrl(true);
 	if (cpu_is_omap34xx())
 		omap_prcm_irq_prepare();
 	return 0;
@@ -226,8 +226,7 @@ static int omap_pm_begin(suspend_state_t
 
 static void omap_pm_end(void)
 {
-	enable_hlt();
-	return;
+	cpu_idle_poll_ctrl(false);
 }
 
 static void omap_pm_finish(void)
Index: linux-2.6/arch/arm/mach-orion5x/board-dt.c
===================================================================
--- linux-2.6.orig/arch/arm/mach-orion5x/board-dt.c
+++ linux-2.6/arch/arm/mach-orion5x/board-dt.c
@@ -52,7 +52,7 @@ static void __init orion5x_dt_init(void)
 	 */
 	if (dev == MV88F5281_DEV_ID && rev == MV88F5281_REV_D0) {
 		printk(KERN_INFO "Orion: Applying 5281 D0 WFI workaround.\n");
-		disable_hlt();
+		cpu_idle_poll_ctrl(true);
 	}
 
 	if (of_machine_is_compatible("lacie,ethernet-disk-mini-v2"))
Index: linux-2.6/arch/arm/mach-orion5x/common.c
===================================================================
--- linux-2.6.orig/arch/arm/mach-orion5x/common.c
+++ linux-2.6/arch/arm/mach-orion5x/common.c
@@ -293,7 +293,7 @@ void __init orion5x_init(void)
 	 */
 	if (dev == MV88F5281_DEV_ID && rev == MV88F5281_REV_D0) {
 		printk(KERN_INFO "Orion: Applying 5281 D0 WFI workaround.\n");
-		disable_hlt();
+		cpu_idle_poll_ctrl(true);
 	}
 
 	/*
Index: linux-2.6/arch/arm/mach-shark/core.c
===================================================================
--- linux-2.6.orig/arch/arm/mach-shark/core.c
+++ linux-2.6/arch/arm/mach-shark/core.c
@@ -130,7 +130,7 @@ static void __init shark_timer_init(void
 
 static void shark_init_early(void)
 {
-	disable_hlt();
+	cpu_idle_poll_ctrl(true);
 }
 
 MACHINE_START(SHARK, "Shark")
Index: linux-2.6/arch/arm/mach-shmobile/suspend.c
===================================================================
--- linux-2.6.orig/arch/arm/mach-shmobile/suspend.c
+++ linux-2.6/arch/arm/mach-shmobile/suspend.c
@@ -23,13 +23,13 @@ static int shmobile_suspend_default_ente
 
 static int shmobile_suspend_begin(suspend_state_t state)
 {
-	disable_hlt();
+	cpu_idle_poll_ctrl(true);
 	return 0;
 }
 
 static void shmobile_suspend_end(void)
 {
-	enable_hlt();
+	cpu_idle_poll_ctrl(false);
 }
 
 struct platform_suspend_ops shmobile_suspend_ops = {
Index: linux-2.6/arch/arm/mach-w90x900/dev.c
===================================================================
--- linux-2.6.orig/arch/arm/mach-w90x900/dev.c
+++ linux-2.6/arch/arm/mach-w90x900/dev.c
@@ -531,7 +531,7 @@ static struct platform_device *nuc900_pu
 
 void __init nuc900_board_init(struct platform_device **device, int size)
 {
-	disable_hlt();
+	cpu_idle_poll_ctrl(true);
 	platform_add_devices(device, size);
 	platform_add_devices(nuc900_public_dev, ARRAY_SIZE(nuc900_public_dev));
 	spi_register_board_info(nuc900_spi_board_info,



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 09/34] arm64: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (7 preceding siblings ...)
  2013-03-21 21:53 ` [patch 08/34] arm: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-25 18:06   ` Catalin Marinas
  2013-04-08 20:18   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 10/34] avr32: " Thomas Gleixner
                   ` (28 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Catalin Marinas

[-- Attachment #1: arm64-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 2612 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
---
 arch/arm64/Kconfig          |    1 +
 arch/arm64/kernel/process.c |   43 +++++--------------------------------------
 arch/arm64/kernel/smp.c     |    2 +-
 3 files changed, 7 insertions(+), 39 deletions(-)

Index: linux-2.6/arch/arm64/Kconfig
===================================================================
--- linux-2.6.orig/arch/arm64/Kconfig
+++ linux-2.6/arch/arm64/Kconfig
@@ -14,6 +14,7 @@ config ARM64
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select GENERIC_TIME_VSYSCALL
 	select HARDIRQS_SW_RESEND
 	select HAVE_ARCH_TRACEHOOK
Index: linux-2.6/arch/arm64/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/arm64/kernel/process.c
+++ linux-2.6/arch/arm64/kernel/process.c
@@ -84,11 +84,15 @@ EXPORT_SYMBOL_GPL(pm_power_off);
 void (*pm_restart)(const char *cmd);
 EXPORT_SYMBOL_GPL(pm_restart);
 
+void arch_cpu_idle_prepare(void)
+{
+	local_fiq_enable();
+}
 
 /*
  * This is our default idle handler.
  */
-static void default_idle(void)
+void arch_cpu_idle(void)
 {
 	/*
 	 * This should do all the clock switching and wait for interrupt
@@ -98,43 +102,6 @@ static void default_idle(void)
 	local_irq_enable();
 }
 
-/*
- * The idle thread.
- * We always respect 'hlt_counter' to prevent low power idle.
- */
-void cpu_idle(void)
-{
-	local_fiq_enable();
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched()) {
-			/*
-			 * We need to disable interrupts here to ensure
-			 * we don't miss a wakeup call.
-			 */
-			local_irq_disable();
-			if (!need_resched()) {
-				stop_critical_timings();
-				default_idle();
-				start_critical_timings();
-				/*
-				 * default_idle functions should always return
-				 * with IRQs enabled.
-				 */
-				WARN_ON(irqs_disabled());
-			} else {
-				local_irq_enable();
-			}
-		}
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	}
-}
-
 void machine_shutdown(void)
 {
 #ifdef CONFIG_SMP
Index: linux-2.6/arch/arm64/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/arm64/kernel/smp.c
+++ linux-2.6/arch/arm64/kernel/smp.c
@@ -216,7 +216,7 @@ asmlinkage void __cpuinit secondary_star
 	/*
 	 * OK, it's off to the idle thread for us
 	 */
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void __init smp_cpus_done(unsigned int max_cpus)



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 10/34] avr32: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (8 preceding siblings ...)
  2013-03-21 21:53 ` [patch 09/34] arm64: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:20   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 12/34] c6x: " Thomas Gleixner
                   ` (27 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Hans-Christian Egtvedt

[-- Attachment #1: avr32-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 3808 bytes --]

Also replace the idle poll enforcement by the generic functionality.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
---
 arch/avr32/Kconfig                       |    1 +
 arch/avr32/kernel/process.c              |   13 ++-----------
 arch/avr32/kernel/time.c                 |    8 ++++++--
 arch/avr32/mach-at32ap/include/mach/pm.h |   24 ------------------------
 arch/avr32/mach-at32ap/pm-at32ap700x.S   |    7 -------
 5 files changed, 9 insertions(+), 44 deletions(-)

Index: linux-2.6/arch/avr32/Kconfig
===================================================================
--- linux-2.6.orig/arch/avr32/Kconfig
+++ linux-2.6/arch/avr32/Kconfig
@@ -10,6 +10,7 @@ config AVR32
 	select VIRT_TO_BUS
 	select GENERIC_IRQ_PROBE
 	select GENERIC_ATOMIC64
+	seletc GENERIC_IDLE_LOOP
 	select HARDIRQS_SW_RESEND
 	select GENERIC_IRQ_SHOW
 	select ARCH_HAVE_CUSTOM_GPIO_H
Index: linux-2.6/arch/avr32/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/avr32/kernel/process.c
+++ linux-2.6/arch/avr32/kernel/process.c
@@ -30,18 +30,9 @@ EXPORT_SYMBOL(pm_power_off);
  * This file handles the architecture-dependent parts of process handling..
  */
 
-void cpu_idle(void)
+void arch_cpu_idle(void)
 {
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched())
-			cpu_idle_sleep();
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	}
+	cpu_enter_idle();
 }
 
 void machine_halt(void)
Index: linux-2.6/arch/avr32/kernel/time.c
===================================================================
--- linux-2.6.orig/arch/avr32/kernel/time.c
+++ linux-2.6/arch/avr32/kernel/time.c
@@ -87,13 +87,17 @@ static void comparator_mode(enum clock_e
 		pr_debug("%s: start\n", evdev->name);
 		/* FALLTHROUGH */
 	case CLOCK_EVT_MODE_RESUME:
-		cpu_disable_idle_sleep();
+		/*
+		 * If we're using the COUNT and COMPARE registers we
+		 * need to force idle poll.
+		 */
+		cpu_idle_poll_ctrl(true);
 		break;
 	case CLOCK_EVT_MODE_UNUSED:
 	case CLOCK_EVT_MODE_SHUTDOWN:
 		sysreg_write(COMPARE, 0);
 		pr_debug("%s: stop\n", evdev->name);
-		cpu_enable_idle_sleep();
+		cpu_idle_poll_ctrl(false);
 		break;
 	default:
 		BUG();
Index: linux-2.6/arch/avr32/mach-at32ap/include/mach/pm.h
===================================================================
--- linux-2.6.orig/arch/avr32/mach-at32ap/include/mach/pm.h
+++ linux-2.6/arch/avr32/mach-at32ap/include/mach/pm.h
@@ -21,30 +21,6 @@
 extern void cpu_enter_idle(void);
 extern void cpu_enter_standby(unsigned long sdramc_base);
 
-extern bool disable_idle_sleep;
-
-static inline void cpu_disable_idle_sleep(void)
-{
-	disable_idle_sleep = true;
-}
-
-static inline void cpu_enable_idle_sleep(void)
-{
-	disable_idle_sleep = false;
-}
-
-static inline void cpu_idle_sleep(void)
-{
-	/*
-	 * If we're using the COUNT and COMPARE registers for
-	 * timekeeping, we can't use the IDLE state.
-	 */
-	if (disable_idle_sleep)
-		cpu_relax();
-	else
-		cpu_enter_idle();
-}
-
 void intc_set_suspend_handler(unsigned long offset);
 #endif
 
Index: linux-2.6/arch/avr32/mach-at32ap/pm-at32ap700x.S
===================================================================
--- linux-2.6.orig/arch/avr32/mach-at32ap/pm-at32ap700x.S
+++ linux-2.6/arch/avr32/mach-at32ap/pm-at32ap700x.S
@@ -18,13 +18,6 @@
 /* Same as 0xfff00000 but fits in a 21 bit signed immediate */
 #define PM_BASE	-0x100000
 
-	.section .bss, "wa", @nobits
-	.global	disable_idle_sleep
-	.type	disable_idle_sleep, @object
-disable_idle_sleep:
-	.int	4
-	.size	disable_idle_sleep, . - disable_idle_sleep
-
 	/* Keep this close to the irq handlers */
 	.section .irq.text, "ax", @progbits
 



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 11/34] bfin: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (10 preceding siblings ...)
  2013-03-21 21:53 ` [patch 12/34] c6x: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:21   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 13/34] cris: " Thomas Gleixner
                   ` (25 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Mike Frysinger

[-- Attachment #1: bfin-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 2661 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/Kconfig           |    1 +
 arch/blackfin/kernel/process.c  |   30 ++----------------------------
 arch/blackfin/mach-common/smp.c |    2 +-
 3 files changed, 4 insertions(+), 29 deletions(-)

Index: linux-2.6/arch/blackfin/Kconfig
===================================================================
--- linux-2.6.orig/arch/blackfin/Kconfig
+++ linux-2.6/arch/blackfin/Kconfig
@@ -41,6 +41,7 @@ config BLACKFIN
 	select USE_GENERIC_SMP_HELPERS if SMP
 	select HAVE_NMI_WATCHDOG if NMI_WATCHDOG
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select ARCH_USES_GETTIMEOFFSET if !GENERIC_CLOCKEVENTS
 	select HAVE_MOD_ARCH_SPECIFIC
 	select MODULES_USE_ELF_RELA
Index: linux-2.6/arch/blackfin/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/blackfin/kernel/process.c
+++ linux-2.6/arch/blackfin/kernel/process.c
@@ -47,14 +47,14 @@ EXPORT_SYMBOL(pm_power_off);
  */
 #ifdef CONFIG_IDLE_L1
 static void default_idle(void)__attribute__((l1_text));
-void cpu_idle(void)__attribute__((l1_text));
+void arch_cpu_idle(void)__attribute__((l1_text));
 #endif
 
 /*
  * This is our default idle handler.  We need to disable
  * interrupts here to ensure we don't miss a wakeup call.
  */
-static void default_idle(void)
+void arch_cpu_idle(void)
 {
 #ifdef CONFIG_IPIPE
 	ipipe_suspend_domain();
@@ -67,32 +67,6 @@ static void default_idle(void)
 }
 
 /*
- * The idle thread.  We try to conserve power, while trying to keep
- * overall latency low.  The architecture specific idle is passed
- * a value to indicate the level of "idleness" of the system.
- */
-void cpu_idle(void)
-{
-	/* endless idle loop with no priority at all */
-	while (1) {
-
-#ifdef CONFIG_HOTPLUG_CPU
-		if (cpu_is_offline(smp_processor_id()))
-			cpu_die();
-#endif
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched())
-			default_idle();
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		preempt_enable_no_resched();
-		schedule();
-		preempt_disable();
-	}
-}
-
-/*
  * Do necessary setup to start up a newly executed thread.
  *
  * pass the data segment into user programs if it exists,
Index: linux-2.6/arch/blackfin/mach-common/smp.c
===================================================================
--- linux-2.6.orig/arch/blackfin/mach-common/smp.c
+++ linux-2.6/arch/blackfin/mach-common/smp.c
@@ -335,7 +335,7 @@ void __cpuinit secondary_start_kernel(vo
 	 */
 	calibrate_delay();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void __init smp_prepare_boot_cpu(void)



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 12/34] c6x: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (9 preceding siblings ...)
  2013-03-21 21:53 ` [patch 10/34] avr32: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:22   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 11/34] bfin: " Thomas Gleixner
                   ` (26 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Mark Salter

[-- Attachment #1: c6x-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 1601 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Mark Salter <msalter@redhat.com>
---
 arch/c6x/Kconfig          |    1 +
 arch/c6x/kernel/process.c |   28 +---------------------------
 2 files changed, 2 insertions(+), 27 deletions(-)

Index: linux-2.6/arch/c6x/Kconfig
===================================================================
--- linux-2.6.orig/arch/c6x/Kconfig
+++ linux-2.6/arch/c6x/Kconfig
@@ -18,6 +18,7 @@ config C6X
 	select OF_EARLY_FLATTREE
 	select GENERIC_CLOCKEVENTS
 	select MODULES_USE_ELF_RELA
+	select GENERIC_IDLE_LOOP
 
 config MMU
 	def_bool n
Index: linux-2.6/arch/c6x/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/c6x/kernel/process.c
+++ linux-2.6/arch/c6x/kernel/process.c
@@ -33,7 +33,7 @@ extern asmlinkage void ret_from_kernel_t
 void (*pm_power_off)(void);
 EXPORT_SYMBOL(pm_power_off);
 
-static void c6x_idle(void)
+void arch_cpu_idle(void)
 {
 	unsigned long tmp;
 
@@ -49,32 +49,6 @@ static void c6x_idle(void)
 		      : "=b"(tmp));
 }
 
-/*
- * The idle loop for C64x
- */
-void cpu_idle(void)
-{
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (1) {
-			local_irq_disable();
-			if (need_resched()) {
-				local_irq_enable();
-				break;
-			}
-			c6x_idle(); /* enables local irqs */
-		}
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
-		preempt_enable_no_resched();
-		schedule();
-		preempt_disable();
-	}
-}
-
 static void halt_loop(void)
 {
 	printk(KERN_EMERG "System Halted, OK to turn off power\n");



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 13/34] cris: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (11 preceding siblings ...)
  2013-03-21 21:53 ` [patch 11/34] bfin: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-27 15:04   ` Jesper Nilsson
  2013-04-08 20:23   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 14/34] frv: " Thomas Gleixner
                   ` (24 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Jesper Nilsson

[-- Attachment #1: cris-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 3564 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
---
 arch/cris/Kconfig                   |    1 +
 arch/cris/arch-v10/kernel/process.c |    3 ++-
 arch/cris/arch-v32/kernel/process.c |   10 ++++------
 arch/cris/arch-v32/kernel/smp.c     |    4 +---
 arch/cris/kernel/process.c          |   24 ++----------------------
 5 files changed, 10 insertions(+), 32 deletions(-)

Index: linux-2.6/arch/cris/Kconfig
===================================================================
--- linux-2.6.orig/arch/cris/Kconfig
+++ linux-2.6/arch/cris/Kconfig
@@ -48,6 +48,7 @@ config CRIS
 	select GENERIC_IRQ_SHOW
 	select GENERIC_IOMAP
 	select GENERIC_SMP_IDLE_THREAD if ETRAX_ARCH_V32
+	select GENERIC_IDLE_LOOP
 	select GENERIC_CMOS_UPDATE
 	select MODULES_USE_ELF_RELA
 	select CLONE_BACKWARDS2
Index: linux-2.6/arch/cris/arch-v10/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/cris/arch-v10/kernel/process.c
+++ linux-2.6/arch/cris/arch-v10/kernel/process.c
@@ -30,8 +30,9 @@ void etrax_gpio_wake_up_check(void); /* 
 void default_idle(void)
 {
 #ifdef CONFIG_ETRAX_GPIO
-  etrax_gpio_wake_up_check();
+	etrax_gpio_wake_up_check();
 #endif
+	local_irq_enable();
 }
 
 /*
Index: linux-2.6/arch/cris/arch-v32/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/cris/arch-v32/kernel/process.c
+++ linux-2.6/arch/cris/arch-v32/kernel/process.c
@@ -23,12 +23,10 @@ extern void stop_watchdog(void);
 /* We use this if we don't have any better idle routine. */
 void default_idle(void)
 {
-	local_irq_disable();
-	if (!need_resched()) {
-		/* Halt until exception. */
-		__asm__ volatile("ei    \n\t"
-				 "halt      ");
-	}
+	/* Halt until exception. */
+	__asm__ volatile("ei    \n\t"
+			 "halt      ");
+	/* CHECKME: Is this really needed ?? */
 	local_irq_enable();
 }
 
Index: linux-2.6/arch/cris/arch-v32/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/cris/arch-v32/kernel/smp.c
+++ linux-2.6/arch/cris/arch-v32/kernel/smp.c
@@ -145,8 +145,6 @@ smp_boot_one_cpu(int cpuid, struct task_
  * specific stuff such as the local timer and the MMU. */
 void __init smp_callin(void)
 {
-	extern void cpu_idle(void);
-
 	int cpu = cpu_now_booting;
 	reg_intr_vect_rw_mask vect_mask = {0};
 
@@ -170,7 +168,7 @@ void __init smp_callin(void)
 	local_irq_enable();
 
 	set_cpu_online(cpu, true);
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 /* Stop execution on this CPU.*/
Index: linux-2.6/arch/cris/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/cris/kernel/process.c
+++ linux-2.6/arch/cris/kernel/process.c
@@ -34,29 +34,9 @@ extern void default_idle(void);
 void (*pm_power_off)(void);
 EXPORT_SYMBOL(pm_power_off);
 
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-
-void cpu_idle (void)
+void arch_cpu_idle(void)
 {
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched()) {
-			/*
-			 * Mark this as an RCU critical section so that
-			 * synchronize_kernel() in the unload path waits
-			 * for our completion.
-			 */
-			default_idle();
-		}
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
+	default_idle();
 }
 
 void hard_reset_now (void);



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 14/34] frv: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (12 preceding siblings ...)
  2013-03-21 21:53 ` [patch 13/34] cris: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:24   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 15/34] h8300: " Thomas Gleixner
                   ` (23 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, David Howells

[-- Attachment #1: frv-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 1587 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: David Howells <dhowells@redhat.com>
---
 arch/frv/Kconfig          |    1 +
 arch/frv/kernel/process.c |   27 +++++----------------------
 2 files changed, 6 insertions(+), 22 deletions(-)

Index: linux-2.6/arch/frv/Kconfig
===================================================================
--- linux-2.6.orig/arch/frv/Kconfig
+++ linux-2.6/arch/frv/Kconfig
@@ -8,6 +8,7 @@ config FRV
 	select HAVE_GENERIC_HARDIRQS
 	select VIRT_TO_BUS
 	select GENERIC_IRQ_SHOW
+	select GENERIC_IDLE_LOOP
 	select HAVE_DEBUG_BUGVERBOSE
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_CPU_DEVICES
Index: linux-2.6/arch/frv/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/frv/kernel/process.c
+++ linux-2.6/arch/frv/kernel/process.c
@@ -59,29 +59,12 @@ static void core_sleep_idle(void)
 	mb();
 }
 
-void (*idle)(void) = core_sleep_idle;
-
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle(void)
+void arch_cpu_idle(void)
 {
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched()) {
-			check_pgt_cache();
-
-			if (!frv_dma_inprogress && idle)
-				idle();
-		}
-		rcu_idle_exit();
-
-		schedule_preempt_disabled();
-	}
+	if (!frv_dma_inprogress)
+		core_sleep_idle();
+	else
+		local_irq_enable();
 }
 
 void machine_restart(char * __unused)



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 15/34] h8300: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (13 preceding siblings ...)
  2013-03-21 21:53 ` [patch 14/34] frv: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:26   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 16/34] hexagon: " Thomas Gleixner
                   ` (22 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Yoshinori Sato

[-- Attachment #1: h8300-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 1962 bytes --]

Use the core idle poll function instead of the private one

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 arch/h8300/Kconfig          |    1 +
 arch/h8300/kernel/process.c |   35 ++++-------------------------------
 2 files changed, 5 insertions(+), 31 deletions(-)

Index: linux-2.6/arch/h8300/Kconfig
===================================================================
--- linux-2.6.orig/arch/h8300/Kconfig
+++ linux-2.6/arch/h8300/Kconfig
@@ -8,6 +8,7 @@ config H8300
 	select VIRT_TO_BUS
 	select ARCH_WANT_IPC_PARSE_VERSION
 	select GENERIC_IRQ_SHOW
+	select GENERIC_IDLE_LOOP
 	select GENERIC_CPU_DEVICES
 	select MODULES_USE_ELF_RELA
 	select OLD_SIGSUSPEND3
Index: linux-2.6/arch/h8300/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/h8300/kernel/process.c
+++ linux-2.6/arch/h8300/kernel/process.c
@@ -53,40 +53,13 @@ asmlinkage void ret_from_kernel_thread(v
  * The idle loop on an H8/300..
  */
 #if !defined(CONFIG_H8300H_SIM) && !defined(CONFIG_H8S_SIM)
-static void default_idle(void)
+void arch_cpu_idle(void)
 {
-	local_irq_disable();
-	if (!need_resched()) {
-		local_irq_enable();
-		/* XXX: race here! What if need_resched() gets set now? */
-		__asm__("sleep");
-	} else
-		local_irq_enable();
-}
-#else
-static void default_idle(void)
-{
-	cpu_relax();
+	local_irq_enable();
+	/* XXX: race here! What if need_resched() gets set now? */
+	__asm__("sleep");
 }
 #endif
-void (*idle)(void) = default_idle;
-
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle(void)
-{
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched())
-			idle();
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
-}
 
 void machine_restart(char * __unused)
 {



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 16/34] hexagon: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (14 preceding siblings ...)
  2013-03-21 21:53 ` [patch 15/34] h8300: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:27   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 18/34] m32r: " Thomas Gleixner
                   ` (21 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Richard Kuo

[-- Attachment #1: hexagon-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 1937 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Richard Kuo <rkuo@codeaurora.org>
---
 arch/hexagon/Kconfig          |    1 +
 arch/hexagon/kernel/process.c |   23 +++--------------------
 arch/hexagon/kernel/smp.c     |    2 +-
 3 files changed, 5 insertions(+), 21 deletions(-)

Index: linux-2.6/arch/hexagon/Kconfig
===================================================================
--- linux-2.6.orig/arch/hexagon/Kconfig
+++ linux-2.6/arch/hexagon/Kconfig
@@ -24,6 +24,7 @@ config HEXAGON
 	select NO_IOPORT
 	select GENERIC_IOMAP
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select STACKTRACE_SUPPORT
 	select KTIME_SCALAR
 	select GENERIC_CLOCKEVENTS
Index: linux-2.6/arch/hexagon/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/hexagon/kernel/process.c
+++ linux-2.6/arch/hexagon/kernel/process.c
@@ -51,28 +51,11 @@ void start_thread(struct pt_regs *regs, 
  *  If hardware or VM offer wait termination even though interrupts
  *  are disabled.
  */
-static void default_idle(void)
+void arch_cpu_idle(void)
 {
 	__vmwait();
-}
-
-void (*idle_sleep)(void) = default_idle;
-
-void cpu_idle(void)
-{
-	while (1) {
-		tick_nohz_idle_enter();
-		local_irq_disable();
-		while (!need_resched()) {
-			idle_sleep();
-			/*  interrupts wake us up, but aren't serviced  */
-			local_irq_enable();	/* service interrupt   */
-			local_irq_disable();
-		}
-		local_irq_enable();
-		tick_nohz_idle_exit();
-		schedule();
-	}
+	/*  interrupts wake us up, but irqs are still disabled */
+	local_irq_enable();
 }
 
 /*
Index: linux-2.6/arch/hexagon/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/hexagon/kernel/smp.c
+++ linux-2.6/arch/hexagon/kernel/smp.c
@@ -184,7 +184,7 @@ void __cpuinit start_secondary(void)
 
 	local_irq_enable();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 18/34] m32r: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (15 preceding siblings ...)
  2013-03-21 21:53 ` [patch 16/34] hexagon: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:29   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 17/34] ia64: " Thomas Gleixner
                   ` (20 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Hirokazu Takata

[-- Attachment #1: m32r-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 1892 bytes --]

Replace the private poller.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Hirokazu Takata <takata@linux-m32r.org>
---
 arch/m32r/Kconfig          |    1 +
 arch/m32r/kernel/process.c |   18 ------------------
 arch/m32r/kernel/smpboot.c |    2 +-
 3 files changed, 2 insertions(+), 19 deletions(-)

Index: linux-2.6/arch/m32r/Kconfig
===================================================================
--- linux-2.6.orig/arch/m32r/Kconfig
+++ linux-2.6/arch/m32r/Kconfig
@@ -13,6 +13,7 @@ config M32R
 	select VIRT_TO_BUS
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
+	select GENERIC_IDLE_LOOP
 	select GENERIC_ATOMIC64
 	select ARCH_USES_GETTIMEOFFSET
 	select MODULES_USE_ELF_RELA
Index: linux-2.6/arch/m32r/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/m32r/kernel/process.c
+++ linux-2.6/arch/m32r/kernel/process.c
@@ -47,24 +47,6 @@ unsigned long thread_saved_pc(struct tas
 void (*pm_power_off)(void) = NULL;
 EXPORT_SYMBOL(pm_power_off);
 
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle (void)
-{
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched())
-			cpu_relax();
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
-}
-
 void machine_restart(char *__unused)
 {
 #if defined(CONFIG_PLAT_MAPPI3)
Index: linux-2.6/arch/m32r/kernel/smpboot.c
===================================================================
--- linux-2.6.orig/arch/m32r/kernel/smpboot.c
+++ linux-2.6/arch/m32r/kernel/smpboot.c
@@ -432,7 +432,7 @@ int __init start_secondary(void *unused)
 	 */
 	local_flush_tlb_all();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 	return 0;
 }
 



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 17/34] ia64: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (16 preceding siblings ...)
  2013-03-21 21:53 ` [patch 18/34] m32r: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-28 15:40   ` Srivatsa S. Bhat
  2013-04-08 20:28   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 19/34] m68k: " Thomas Gleixner
                   ` (19 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Tony Luck

[-- Attachment #1: ia64-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 4493 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
---
 arch/ia64/Kconfig          |    1 
 arch/ia64/kernel/perfmon.c |   13 ++-----
 arch/ia64/kernel/process.c |   83 +++++++++------------------------------------
 arch/ia64/kernel/smpboot.c |    2 -
 4 files changed, 23 insertions(+), 76 deletions(-)

Index: linux-2.6/arch/ia64/Kconfig
===================================================================
--- linux-2.6.orig/arch/ia64/Kconfig
+++ linux-2.6/arch/ia64/Kconfig
@@ -35,6 +35,7 @@ config IA64
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_IOMAP
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select ARCH_INIT_TASK
 	select ARCH_TASK_STRUCT_ALLOCATOR
 	select ARCH_THREAD_INFO_ALLOCATOR
Index: linux-2.6/arch/ia64/kernel/perfmon.c
===================================================================
--- linux-2.6.orig/arch/ia64/kernel/perfmon.c
+++ linux-2.6/arch/ia64/kernel/perfmon.c
@@ -1322,8 +1322,6 @@ out:
 }
 EXPORT_SYMBOL(pfm_unregister_buffer_fmt);
 
-extern void update_pal_halt_status(int);
-
 static int
 pfm_reserve_session(struct task_struct *task, int is_syswide, unsigned int cpu)
 {
@@ -1371,9 +1369,9 @@ pfm_reserve_session(struct task_struct *
 		cpu));
 
 	/*
-	 * disable default_idle() to go to PAL_HALT
+	 * Force idle() into poll mode
 	 */
-	update_pal_halt_status(0);
+	cpu_idle_poll_ctrl(true);
 
 	UNLOCK_PFS(flags);
 
@@ -1430,11 +1428,8 @@ pfm_unreserve_session(pfm_context_t *ctx
 		is_syswide,
 		cpu));
 
-	/*
-	 * if possible, enable default_idle() to go into PAL_HALT
-	 */
-	if (pfm_sessions.pfs_task_sessions == 0 && pfm_sessions.pfs_sys_sessions == 0)
-		update_pal_halt_status(1);
+	/* Undo forced polling. Last session reenables pal_halt */
+	cpu_idle_poll_ctrl(false);
 
 	UNLOCK_PFS(flags);
 
Index: linux-2.6/arch/ia64/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/ia64/kernel/process.c
+++ linux-2.6/arch/ia64/kernel/process.c
@@ -209,41 +209,13 @@ do_notify_resume_user(sigset_t *unused, 
 	local_irq_disable();	/* force interrupt disable */
 }
 
-static int pal_halt        = 1;
-static int can_do_pal_halt = 1;
-
 static int __init nohalt_setup(char * str)
 {
-	pal_halt = can_do_pal_halt = 0;
+	cpu_idle_poll_ctrl(true);
 	return 1;
 }
 __setup("nohalt", nohalt_setup);
 
-void
-update_pal_halt_status(int status)
-{
-	can_do_pal_halt = pal_halt && status;
-}
-
-/*
- * We use this if we don't have any better idle routine..
- */
-void
-default_idle (void)
-{
-	local_irq_enable();
-	while (!need_resched()) {
-		if (can_do_pal_halt) {
-			local_irq_disable();
-			if (!need_resched()) {
-				safe_halt();
-			}
-			local_irq_enable();
-		} else
-			cpu_relax();
-	}
-}
-
 #ifdef CONFIG_HOTPLUG_CPU
 /* We don't actually take CPU down, just spin without interrupts. */
 static inline void play_dead(void)
@@ -270,50 +242,29 @@ static inline void play_dead(void)
 }
 #endif /* CONFIG_HOTPLUG_CPU */
 
-void __attribute__((noreturn))
-cpu_idle (void)
+void arch_cpu_idle_dead(void)
 {
-	void (*mark_idle)(int) = ia64_mark_idle;
-  	int cpu = smp_processor_id();
+	play_dead();
+}
 
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		if (can_do_pal_halt) {
-			current_thread_info()->status &= ~TS_POLLING;
-			/*
-			 * TS_POLLING-cleared state must be visible before we
-			 * test NEED_RESCHED:
-			 */
-			smp_mb();
-		} else {
-			current_thread_info()->status |= TS_POLLING;
-		}
+void arch_cpu_idle(void)
+{
+	void (*mark_idle)(int) = ia64_mark_idle;
 
-		if (!need_resched()) {
-			void (*idle)(void);
 #ifdef CONFIG_SMP
-			min_xtp();
+	min_xtp();
 #endif
-			rmb();
-			if (mark_idle)
-				(*mark_idle)(1);
-
-			if (!idle)
-				idle = default_idle;
-			(*idle)();
-			if (mark_idle)
-				(*mark_idle)(0);
+	rmb();
+	if (mark_idle)
+		(*mark_idle)(1);
+
+	safe_halt();
+
+	if (mark_idle)
+		(*mark_idle)(0);
 #ifdef CONFIG_SMP
-			normal_xtp();
+	normal_xtp();
 #endif
-		}
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-		check_pgt_cache();
-		if (cpu_is_offline(cpu))
-			play_dead();
-	}
 }
 
 void
Index: linux-2.6/arch/ia64/kernel/smpboot.c
===================================================================
--- linux-2.6.orig/arch/ia64/kernel/smpboot.c
+++ linux-2.6/arch/ia64/kernel/smpboot.c
@@ -455,7 +455,7 @@ start_secondary (void *unused)
 	preempt_disable();
 	smp_callin();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 	return 0;
 }
 



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 19/34] m68k: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (17 preceding siblings ...)
  2013-03-21 21:53 ` [patch 17/34] ia64: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:30   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 20/34] metag: " Thomas Gleixner
                   ` (18 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Geert Uytterhoeven

[-- Attachment #1: m68k-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 1870 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
 arch/m68k/Kconfig          |    1 +
 arch/m68k/kernel/process.c |   32 ++++----------------------------
 2 files changed, 5 insertions(+), 28 deletions(-)

Index: linux-2.6/arch/m68k/Kconfig
===================================================================
--- linux-2.6.orig/arch/m68k/Kconfig
+++ linux-2.6/arch/m68k/Kconfig
@@ -6,6 +6,7 @@ config M68K
 	select HAVE_DEBUG_BUGVERBOSE
 	select HAVE_GENERIC_HARDIRQS
 	select GENERIC_IRQ_SHOW
+	select GENERIC_IDLE_LOOP
 	select GENERIC_ATOMIC64
 	select HAVE_UID16
 	select VIRT_TO_BUS
Index: linux-2.6/arch/m68k/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/m68k/kernel/process.c
+++ linux-2.6/arch/m68k/kernel/process.c
@@ -51,40 +51,16 @@ unsigned long thread_saved_pc(struct tas
 		return sw->retpc;
 }
 
-/*
- * The idle loop on an m68k..
- */
-static void default_idle(void)
+void arch_cpu_idle(void)
 {
-	if (!need_resched())
 #if defined(MACH_ATARI_ONLY)
-		/* block out HSYNC on the atari (falcon) */
-		__asm__("stop #0x2200" : : : "cc");
+	/* block out HSYNC on the atari (falcon) */
+	__asm__("stop #0x2200" : : : "cc");
 #else
-		__asm__("stop #0x2000" : : : "cc");
+	__asm__("stop #0x2000" : : : "cc");
 #endif
 }
 
-void (*idle)(void) = default_idle;
-
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle(void)
-{
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched())
-			idle();
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
-}
-
 void machine_restart(char * __unused)
 {
 	if (mach_reset)



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 20/34] metag: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (18 preceding siblings ...)
  2013-03-21 21:53 ` [patch 19/34] m68k: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-22 10:16     ` James Hogan
  2013-04-08 20:32   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 21/34] microblaze: " Thomas Gleixner
                   ` (17 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, James Hogan

[-- Attachment #1: metag-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 2223 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: James Hogan <james.hogan@imgtec.com>
---
 arch/metag/Kconfig          |    1 +
 arch/metag/kernel/process.c |   32 +++-----------------------------
 arch/metag/kernel/smp.c     |    2 +-
 3 files changed, 5 insertions(+), 30 deletions(-)

Index: linux-2.6/arch/metag/Kconfig
===================================================================
--- linux-2.6.orig/arch/metag/Kconfig
+++ linux-2.6/arch/metag/Kconfig
@@ -9,6 +9,7 @@ config METAG
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_IRQ_SHOW
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select HAVE_64BIT_ALIGNED_ACCESS
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_C_RECORDMCOUNT
Index: linux-2.6/arch/metag/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/metag/kernel/process.c
+++ linux-2.6/arch/metag/kernel/process.c
@@ -31,7 +31,7 @@
 /*
  * Wait for the next interrupt and enable local interrupts
  */
-static inline void arch_idle(void)
+void arch_cpu_idle(void)
 {
 	int tmp;
 
@@ -59,35 +59,9 @@ static inline void arch_idle(void)
 		      : "r" (get_trigger_mask()));
 }
 
-void cpu_idle(void)
+void arch_cpu_idle_dead(void)
 {
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched()) {
-			/*
-			 * We need to disable interrupts here to ensure we don't
-			 * miss a wakeup call.
-			 */
-			local_irq_disable();
-			if (!need_resched()) {
-#ifdef CONFIG_HOTPLUG_CPU
-				if (cpu_is_offline(smp_processor_id()))
-					cpu_die();
-#endif
-				arch_idle();
-			} else {
-				local_irq_enable();
-			}
-		}
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	 }
+	cpu_die();
 }
 
 void (*pm_power_off)(void);
Index: linux-2.6/arch/metag/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/metag/kernel/smp.c
+++ linux-2.6/arch/metag/kernel/smp.c
@@ -297,7 +297,7 @@ asmlinkage void secondary_start_kernel(v
 	/*
 	 * OK, it's off to the idle thread for us
 	 */
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void __init smp_cpus_done(unsigned int max_cpus)



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 21/34] microblaze: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (19 preceding siblings ...)
  2013-03-21 21:53 ` [patch 20/34] metag: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:33   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 22/34] mips: " Thomas Gleixner
                   ` (16 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Michal Simek

[-- Attachment #1: microblaze-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 3020 bytes --]

The microblaze idle loop provides a polling and a non polling version,
which are suprisingly both polling, just with slightly different
instrumentation. Remove them and use the generic poller.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Michal Simek <monstr@monstr.eu>
---
 arch/microblaze/Kconfig                 |    2 +
 arch/microblaze/include/asm/processor.h |    3 -
 arch/microblaze/kernel/process.c        |   53 --------------------------------
 3 files changed, 2 insertions(+), 56 deletions(-)

Index: linux-2.6/arch/microblaze/Kconfig
===================================================================
--- linux-2.6.orig/arch/microblaze/Kconfig
+++ linux-2.6/arch/microblaze/Kconfig
@@ -26,6 +26,8 @@ config MICROBLAZE
 	select GENERIC_CPU_DEVICES
 	select GENERIC_ATOMIC64
 	select GENERIC_CLOCKEVENTS
+	select GENERIC_IDLE_LOOP
+	select GENERIC_IDLE_POLL_SETUP
 	select MODULES_USE_ELF_RELA
 	select CLONE_BACKWARDS
 
Index: linux-2.6/arch/microblaze/include/asm/processor.h
===================================================================
--- linux-2.6.orig/arch/microblaze/include/asm/processor.h
+++ linux-2.6/arch/microblaze/include/asm/processor.h
@@ -22,7 +22,6 @@
 extern const struct seq_operations cpuinfo_op;
 
 # define cpu_relax()		barrier()
-# define cpu_sleep()		do {} while (0)
 
 #define task_pt_regs(tsk) \
 		(((struct pt_regs *)(THREAD_SIZE + task_stack_page(tsk))) - 1)
@@ -160,8 +159,6 @@ unsigned long get_wchan(struct task_stru
 #  define STACK_TOP	TASK_SIZE
 #  define STACK_TOP_MAX	STACK_TOP
 
-void default_idle(void);
-
 #ifdef CONFIG_DEBUG_FS
 extern struct dentry *of_debugfs_root;
 #endif
Index: linux-2.6/arch/microblaze/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/microblaze/kernel/process.c
+++ linux-2.6/arch/microblaze/kernel/process.c
@@ -44,59 +44,6 @@ void show_regs(struct pt_regs *regs)
 void (*pm_power_off)(void) = NULL;
 EXPORT_SYMBOL(pm_power_off);
 
-static int hlt_counter = 1;
-
-static int __init nohlt_setup(char *__unused)
-{
-	hlt_counter = 1;
-	return 1;
-}
-__setup("nohlt", nohlt_setup);
-
-static int __init hlt_setup(char *__unused)
-{
-	hlt_counter = 0;
-	return 1;
-}
-__setup("hlt", hlt_setup);
-
-void default_idle(void)
-{
-	if (likely(hlt_counter)) {
-		local_irq_disable();
-		stop_critical_timings();
-		cpu_relax();
-		start_critical_timings();
-		local_irq_enable();
-	} else {
-		clear_thread_flag(TIF_POLLING_NRFLAG);
-		smp_mb__after_clear_bit();
-		local_irq_disable();
-		while (!need_resched())
-			cpu_sleep();
-		local_irq_enable();
-		set_thread_flag(TIF_POLLING_NRFLAG);
-	}
-}
-
-void cpu_idle(void)
-{
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched())
-			default_idle();
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
-		schedule_preempt_disabled();
-		check_pgt_cache();
-	}
-}
-
 void flush_thread(void)
 {
 }



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 22/34] mips: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (20 preceding siblings ...)
  2013-03-21 21:53 ` [patch 21/34] microblaze: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-28 15:42   ` Srivatsa S. Bhat
  2013-04-08 20:34   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 24/34] openrisc: " Thomas Gleixner
                   ` (15 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Ralf Baechle

[-- Attachment #1: mips-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 2626 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
---
 arch/mips/Kconfig          |    1 
 arch/mips/kernel/process.c |   46 ++++++++++++---------------------------------
 arch/mips/kernel/smp.c     |    2 -
 3 files changed, 15 insertions(+), 34 deletions(-)

Index: linux-2.6/arch/mips/Kconfig
===================================================================
--- linux-2.6.orig/arch/mips/Kconfig
+++ linux-2.6/arch/mips/Kconfig
@@ -34,6 +34,7 @@ config MIPS
 	select HAVE_MEMBLOCK_NODE_MAP
 	select ARCH_DISCARD_MEMBLOCK
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select BUILDTIME_EXTABLE_SORT
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_CMOS_UPDATE
Index: linux-2.6/arch/mips/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/mips/kernel/process.c
+++ linux-2.6/arch/mips/kernel/process.c
@@ -41,44 +41,24 @@
 #include <asm/inst.h>
 #include <asm/stacktrace.h>
 
-/*
- * The idle thread. There's no useful work to be done, so just try to conserve
- * power and have a low exit latency (ie sit in a loop waiting for somebody to
- * say that they'd like to reschedule)
- */
-void __noreturn cpu_idle(void)
+void arch_cpu_idle_dead(void)
 {
-	int cpu;
-
-	/* CPU is going idle. */
-	cpu = smp_processor_id();
+	/* What the heck is this check doing ? */
+	if (!cpu_isset(cpu, cpu_callin_map))
+		play_dead();}
+}
 
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched() && cpu_online(cpu)) {
+void arch__cpu_idle(void)
+{
 #ifdef CONFIG_MIPS_MT_SMTC
-			extern void smtc_idle_loop_hook(void);
+	extern void smtc_idle_loop_hook(void);
 
-			smtc_idle_loop_hook();
+	smtc_idle_loop_hook();
 #endif
-
-			if (cpu_wait) {
-				/* Don't trace irqs off for idle */
-				stop_critical_timings();
-				(*cpu_wait)();
-				start_critical_timings();
-			}
-		}
-#ifdef CONFIG_HOTPLUG_CPU
-		if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map))
-			play_dead();
-#endif
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	}
+	if (cpu_wait)
+		(*cpu_wait)();
+	else
+		local_irq_enable();
 }
 
 asmlinkage void ret_from_fork(void);
Index: linux-2.6/arch/mips/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/mips/kernel/smp.c
+++ linux-2.6/arch/mips/kernel/smp.c
@@ -139,7 +139,7 @@ asmlinkage __cpuinit void start_secondar
 	WARN_ON_ONCE(!irqs_disabled());
 	mp_ops->smp_finish();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 /*



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 24/34] openrisc: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (21 preceding siblings ...)
  2013-03-21 21:53 ` [patch 22/34] mips: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:36   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 23/34] mn10300: " Thomas Gleixner
                   ` (14 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

[-- Attachment #1: openrisc-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 2786 bytes --]

Idle poller with an extra check_pgt_cache() invocation. Use the core
code.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/openrisc/Kconfig       |    1 
 arch/openrisc/kernel/idle.c |   73 --------------------------------------------
 2 files changed, 1 insertion(+), 73 deletions(-)

Index: linux-2.6/arch/openrisc/Kconfig
===================================================================
--- linux-2.6.orig/arch/openrisc/Kconfig
+++ linux-2.6/arch/openrisc/Kconfig
@@ -21,6 +21,7 @@ config OPENRISC
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
+	select GENERIC_IDLE_LOOP
 	select MODULES_USE_ELF_RELA
 
 config MMU
Index: linux-2.6/arch/openrisc/kernel/idle.c
===================================================================
--- linux-2.6.orig/arch/openrisc/kernel/idle.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * OpenRISC idle.c
- *
- * Linux architectural port borrowing liberally from similar works of
- * others.  All original copyrights apply as per the original source
- * declaration.
- *
- * Modifications for the OpenRISC architecture:
- * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
- * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
- *
- *      This program is free software; you can redistribute it and/or
- *      modify it under the terms of the GNU General Public License
- *      as published by the Free Software Foundation; either version
- *      2 of the License, or (at your option) any later version.
- *
- * Idle daemon for or32.  Idle daemon will handle any action
- * that needs to be taken when the system becomes idle.
- */
-
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/smp.h>
-#include <linux/stddef.h>
-#include <linux/unistd.h>
-#include <linux/ptrace.h>
-#include <linux/slab.h>
-#include <linux/tick.h>
-
-#include <asm/pgtable.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
-#include <asm/processor.h>
-#include <asm/mmu.h>
-#include <asm/cache.h>
-#include <asm/pgalloc.h>
-
-void (*powersave) (void) = NULL;
-
-void cpu_idle(void)
-{
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched()) {
-			check_pgt_cache();
-			rmb();
-
-			clear_thread_flag(TIF_POLLING_NRFLAG);
-
-			local_irq_disable();
-			/* Don't trace irqs off for idle */
-			stop_critical_timings();
-			if (!need_resched() && powersave != NULL)
-				powersave();
-			start_critical_timings();
-			local_irq_enable();
-			set_thread_flag(TIF_POLLING_NRFLAG);
-		}
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		preempt_enable_no_resched();
-		schedule();
-		preempt_disable();
-	}
-}



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 23/34] mn10300: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (22 preceding siblings ...)
  2013-03-21 21:53 ` [patch 24/34] openrisc: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:35   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 25/34] parisc: " Thomas Gleixner
                   ` (13 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, David Howells

[-- Attachment #1: mn10300-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 3358 bytes --]

default_idle() boils down to safe_halt() and the other option is idle
polling. Use the core functionality.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: David Howells <dhowells@redhat.com>
---
 arch/mn10300/Kconfig          |    1 
 arch/mn10300/kernel/process.c |   70 +++---------------------------------------
 arch/mn10300/kernel/smp.c     |    2 -
 3 files changed, 8 insertions(+), 65 deletions(-)

Index: linux-2.6/arch/mn10300/Kconfig
===================================================================
--- linux-2.6.orig/arch/mn10300/Kconfig
+++ linux-2.6/arch/mn10300/Kconfig
@@ -13,6 +13,7 @@ config MN10300
 	select MODULES_USE_ELF_RELA
 	select OLD_SIGSUSPEND3
 	select OLD_SIGACTION
+	select GENERIC_IDLE_LOOP
 
 config AM33_2
 	def_bool n
Index: linux-2.6/arch/mn10300/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/mn10300/kernel/process.c
+++ linux-2.6/arch/mn10300/kernel/process.c
@@ -50,77 +50,19 @@ unsigned long thread_saved_pc(struct tas
 void (*pm_power_off)(void);
 EXPORT_SYMBOL(pm_power_off);
 
-#if !defined(CONFIG_SMP) || defined(CONFIG_HOTPLUG_CPU)
-/*
- * we use this if we don't have any better idle routine
- */
-static void default_idle(void)
-{
-	local_irq_disable();
-	if (!need_resched())
-		safe_halt();
-	else
-		local_irq_enable();
-}
-
-#else /* !CONFIG_SMP || CONFIG_HOTPLUG_CPU  */
 /*
  * On SMP it's slightly faster (but much more power-consuming!)
  * to poll the ->work.need_resched flag instead of waiting for the
  * cross-CPU IPI to arrive. Use this option with caution.
+ *
+ * tglx: No idea why this depends on HOTPLUG_CPU !?!
  */
-static inline void poll_idle(void)
-{
-	int oldval;
-
-	local_irq_enable();
-
-	/*
-	 * Deal with another CPU just having chosen a thread to
-	 * run here:
-	 */
-	oldval = test_and_clear_thread_flag(TIF_NEED_RESCHED);
-
-	if (!oldval) {
-		set_thread_flag(TIF_POLLING_NRFLAG);
-		while (!need_resched())
-			cpu_relax();
-		clear_thread_flag(TIF_POLLING_NRFLAG);
-	} else {
-		set_need_resched();
-	}
-}
-#endif /* !CONFIG_SMP || CONFIG_HOTPLUG_CPU */
-
-/*
- * the idle thread
- * - there's no useful work to be done, so just try to conserve power and have
- *   a low exit latency (ie sit in a loop waiting for somebody to say that
- *   they'd like to reschedule)
- */
-void cpu_idle(void)
+#if !defined(CONFIG_SMP) || defined(CONFIG_HOTPLUG_CPU)
+void arch_cpu_idle(void)
 {
-	/* endless idle loop with no priority at all */
-	for (;;) {
-		rcu_idle_enter();
-		while (!need_resched()) {
-			void (*idle)(void);
-
-			smp_rmb();
-			if (!idle) {
-#if defined(CONFIG_SMP) && !defined(CONFIG_HOTPLUG_CPU)
-				idle = poll_idle;
-#else  /* CONFIG_SMP && !CONFIG_HOTPLUG_CPU */
-				idle = default_idle;
-#endif /* CONFIG_SMP && !CONFIG_HOTPLUG_CPU */
-			}
-			idle();
-		}
-		rcu_idle_exit();
-
-		schedule_preempt_disabled();
-	}
+	safe_halt();
 }
+#endif
 
 void release_segments(struct mm_struct *mm)
 {
Index: linux-2.6/arch/mn10300/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/mn10300/kernel/smp.c
+++ linux-2.6/arch/mn10300/kernel/smp.c
@@ -675,7 +675,7 @@ int __init start_secondary(void *unused)
 #ifdef CONFIG_GENERIC_CLOCKEVENTS
 	init_clockevents();
 #endif
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 	return 0;
 }
 



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 25/34] parisc: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (23 preceding siblings ...)
  2013-03-21 21:53 ` [patch 23/34] mn10300: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:38   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 26/34] powerpc: " Thomas Gleixner
                   ` (12 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, James E.J. Bottomley, Helge Deller

[-- Attachment #1: parisc-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 2113 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>
---
 arch/parisc/Kconfig          |    1 +
 arch/parisc/kernel/process.c |   22 ----------------------
 arch/parisc/kernel/smp.c     |    2 +-
 3 files changed, 2 insertions(+), 23 deletions(-)

Index: linux-2.6/arch/parisc/Kconfig
===================================================================
--- linux-2.6.orig/arch/parisc/Kconfig
+++ linux-2.6/arch/parisc/Kconfig
@@ -18,6 +18,7 @@ config PARISC
 	select GENERIC_PCI_IOMAP
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select GENERIC_STRNCPY_FROM_USER
 	select SYSCTL_ARCH_UNALIGN_ALLOW
 	select HAVE_MOD_ARCH_SPECIFIC
Index: linux-2.6/arch/parisc/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/parisc/kernel/process.c
+++ linux-2.6/arch/parisc/kernel/process.c
@@ -59,28 +59,6 @@
 #include <asm/unwind.h>
 #include <asm/sections.h>
 
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle(void)
-{
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched())
-			barrier();
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-		check_pgt_cache();
-	}
-}
-
-
 #define COMMAND_GLOBAL  F_EXTEND(0xfffe0030)
 #define CMD_RESET       5       /* reset any module */
 
Index: linux-2.6/arch/parisc/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/parisc/kernel/smp.c
+++ linux-2.6/arch/parisc/kernel/smp.c
@@ -329,7 +329,7 @@ void __init smp_callin(void)
 
 	local_irq_enable();  /* Interrupts have been off until now */
 
-	cpu_idle();      /* Wait for timer to schedule some work */
+	cpu_startup_entry(CPUHP_ONLINE);
 
 	/* NOTREACHED */
 	panic("smp_callin() AAAAaaaaahhhh....\n");



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 26/34] powerpc: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (24 preceding siblings ...)
  2013-03-21 21:53 ` [patch 25/34] parisc: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-28 15:40   ` Srivatsa S. Bhat
  2013-04-08 20:39   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 27/34] s390: " Thomas Gleixner
                   ` (11 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Benjamin Herrenschmidt

[-- Attachment #1: powerpc-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 3120 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/Kconfig       |    1 
 arch/powerpc/kernel/idle.c |   78 ++++++++++++---------------------------------
 arch/powerpc/kernel/smp.c  |    2 -
 3 files changed, 24 insertions(+), 57 deletions(-)

Index: linux-2.6/arch/powerpc/Kconfig
===================================================================
--- linux-2.6.orig/arch/powerpc/Kconfig
+++ linux-2.6/arch/powerpc/Kconfig
@@ -133,6 +133,7 @@ config PPC
 	select HAVE_ARCH_JUMP_LABEL
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_TIME_VSYSCALL_OLD
 	select GENERIC_CLOCKEVENTS
Index: linux-2.6/arch/powerpc/kernel/idle.c
===================================================================
--- linux-2.6.orig/arch/powerpc/kernel/idle.c
+++ linux-2.6/arch/powerpc/kernel/idle.c
@@ -50,64 +50,30 @@ static int __init powersave_off(char *ar
 }
 __setup("powersave=off", powersave_off);
 
-/*
- * The body of the idle task.
- */
-void cpu_idle(void)
+void arch_cpu_idle(void)
 {
-	set_thread_flag(TIF_POLLING_NRFLAG);
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched() && !cpu_should_die()) {
-			ppc64_runlatch_off();
-
-			if (ppc_md.power_save) {
-				clear_thread_flag(TIF_POLLING_NRFLAG);
-				/*
-				 * smp_mb is so clearing of TIF_POLLING_NRFLAG
-				 * is ordered w.r.t. need_resched() test.
-				 */
-				smp_mb();
-				local_irq_disable();
-
-				/* Don't trace irqs off for idle */
-				stop_critical_timings();
-
-				/* check again after disabling irqs */
-				if (!need_resched() && !cpu_should_die())
-					ppc_md.power_save();
-
-				start_critical_timings();
-
-				/* Some power_save functions return with
-				 * interrupts enabled, some don't.
-				 */
-				if (irqs_disabled())
-					local_irq_enable();
-				set_thread_flag(TIF_POLLING_NRFLAG);
-
-			} else {
-				/*
-				 * Go into low thread priority and possibly
-				 * low power mode.
-				 */
-				HMT_low();
-				HMT_very_low();
-			}
-		}
-
-		HMT_medium();
-		ppc64_runlatch_on();
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		if (cpu_should_die()) {
-			sched_preempt_enable_no_resched();
-			cpu_die();
-		}
-		schedule_preempt_disabled();
+	ppc64_runlatch_off();
+
+	if (ppc_md.power_save) {
+		ppc_md.power_save();
+		/*
+		 * Some power_save functions return with
+		 * interrupts enabled, some don't.
+		 */
+		if (irqs_disabled())
+			local_irq_enable();
+	} else {
+		local_irq_enable();
+		/*
+		 * Go into low thread priority and possibly
+		 * low power mode.
+		 */
+		HMT_low();
+		HMT_very_low();
 	}
+
+	HMT_medium();
+	ppc64_runlatch_on();
 }
 
 int powersave_nap;
Index: linux-2.6/arch/powerpc/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/powerpc/kernel/smp.c
+++ linux-2.6/arch/powerpc/kernel/smp.c
@@ -669,7 +669,7 @@ __cpuinit void start_secondary(void *unu
 
 	local_irq_enable();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 
 	BUG();
 }



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 27/34] s390: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (25 preceding siblings ...)
  2013-03-21 21:53 ` [patch 26/34] powerpc: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-23  9:38   ` Heiko Carstens
                     ` (2 more replies)
  2013-03-21 21:53 ` [patch 28/34] score: " Thomas Gleixner
                   ` (10 subsequent siblings)
  37 siblings, 3 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Heiko Carstens

[-- Attachment #1: s390-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 1956 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 arch/s390/kernel/process.c |   25 +++++++------------------
 arch/s390/kernel/smp.c     |    3 +--
 2 files changed, 8 insertions(+), 20 deletions(-)

Index: linux-2.6/arch/s390/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/s390/kernel/process.c
+++ linux-2.6/arch/s390/kernel/process.c
@@ -62,17 +62,15 @@ unsigned long thread_saved_pc(struct tas
 }
 
 /*
- * The idle loop on a S390...
+ * The idle function on a S390...
  */
-static void default_idle(void)
+void arch_cpu_idle(void)
 {
-	if (cpu_is_offline(smp_processor_id()))
-		cpu_die();
-	local_irq_disable();
-	if (need_resched()) {
+	if (test_thread_flag(TIF_MCCK_PENDING)) {
 		local_irq_enable();
 		return;
 	}
+
 	local_mcck_disable();
 	if (test_thread_flag(TIF_MCCK_PENDING)) {
 		local_mcck_enable();
@@ -83,19 +81,10 @@ static void default_idle(void)
 	vtime_stop_cpu();
 }
 
-void cpu_idle(void)
+void arch_cpu_idle_exit(void)
 {
-	for (;;) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched() && !test_thread_flag(TIF_MCCK_PENDING))
-			default_idle();
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		if (test_thread_flag(TIF_MCCK_PENDING))
-			s390_handle_mcck();
-		schedule_preempt_disabled();
-	}
+	if (test_thread_flag(TIF_MCCK_PENDING))
+		s390_handle_mcck();
 }
 
 extern void __kprobes kernel_thread_starter(void);
Index: linux-2.6/arch/s390/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/s390/kernel/smp.c
+++ linux-2.6/arch/s390/kernel/smp.c
@@ -711,8 +711,7 @@ static void __cpuinit smp_start_secondar
 	set_cpu_online(smp_processor_id(), true);
 	inc_irq_stat(CPU_RST);
 	local_irq_enable();
-	/* cpu_idle will call schedule for us */
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 /* Upping and downing of CPUs */



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 28/34] score: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (26 preceding siblings ...)
  2013-03-21 21:53 ` [patch 27/34] s390: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:41   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 29/34] sh: " Thomas Gleixner
                   ` (9 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Lennox Wu

[-- Attachment #1: score-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 1532 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Lennox Wu <lennox.wu@gmail.com>
---
 arch/score/Kconfig          |    1 +
 arch/score/kernel/process.c |   18 ------------------
 2 files changed, 1 insertion(+), 18 deletions(-)

Index: linux-2.6/arch/score/Kconfig
===================================================================
--- linux-2.6.orig/arch/score/Kconfig
+++ linux-2.6/arch/score/Kconfig
@@ -11,6 +11,7 @@ config SCORE
        select ARCH_DISCARD_MEMBLOCK
        select GENERIC_CPU_DEVICES
        select GENERIC_CLOCKEVENTS
+       select GENERIC_IDLE_LOOP
        select HAVE_MOD_ARCH_SPECIFIC
 	select VIRT_TO_BUS
 	select MODULES_USE_ELF_REL
Index: linux-2.6/arch/score/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/score/kernel/process.c
+++ linux-2.6/arch/score/kernel/process.c
@@ -41,24 +41,6 @@ void machine_halt(void) {}
 /* If or when software machine-power-off is implemented, add code here. */
 void machine_power_off(void) {}
 
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void __noreturn cpu_idle(void)
-{
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched())
-			barrier();
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
-}
-
 void ret_from_fork(void);
 void ret_from_kernel_thread(void);
 



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 29/34] sh: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (27 preceding siblings ...)
  2013-03-21 21:53 ` [patch 28/34] score: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-28 15:40   ` Srivatsa S. Bhat
  2013-04-08 20:42   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 30/34] tile: Enter idle with preemption disabled Thomas Gleixner
                   ` (8 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Paul Mundt

[-- Attachment #1: sh-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 3762 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Paul Mundt <lethal@linux-sh.org>
---
 arch/sh/Kconfig       |    2 
 arch/sh/kernel/idle.c |  102 ++++----------------------------------------------
 arch/sh/kernel/smp.c  |    2 
 3 files changed, 12 insertions(+), 94 deletions(-)

Index: linux-2.6/arch/sh/Kconfig
===================================================================
--- linux-2.6.orig/arch/sh/Kconfig
+++ linux-2.6/arch/sh/Kconfig
@@ -33,6 +33,8 @@ config SUPERH
 	select GENERIC_ATOMIC64
 	select GENERIC_IRQ_SHOW
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
+	select GENERIC_IDLE_POLL_SETUP
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_CMOS_UPDATE if SH_SH03 || SH_DREAMCAST
 	select GENERIC_STRNCPY_FROM_USER
Index: linux-2.6/arch/sh/kernel/idle.c
===================================================================
--- linux-2.6.orig/arch/sh/kernel/idle.c
+++ linux-2.6/arch/sh/kernel/idle.c
@@ -24,98 +24,19 @@
 
 static void (*sh_idle)(void);
 
-static int hlt_counter;
-
-static int __init nohlt_setup(char *__unused)
-{
-	hlt_counter = 1;
-	return 1;
-}
-__setup("nohlt", nohlt_setup);
-
-static int __init hlt_setup(char *__unused)
-{
-	hlt_counter = 0;
-	return 1;
-}
-__setup("hlt", hlt_setup);
-
-static inline int hlt_works(void)
-{
-	return !hlt_counter;
-}
-
-/*
- * On SMP it's slightly faster (but much more power-consuming!)
- * to poll the ->work.need_resched flag instead of waiting for the
- * cross-CPU IPI to arrive. Use this option with caution.
- */
-static void poll_idle(void)
-{
-	local_irq_enable();
-	while (!need_resched())
-		cpu_relax();
-}
-
 void default_idle(void)
 {
-	if (hlt_works()) {
-		clear_thread_flag(TIF_POLLING_NRFLAG);
-		smp_mb__after_clear_bit();
-
-		set_bl_bit();
-		if (!need_resched()) {
-			local_irq_enable();
-			cpu_sleep();
-		} else
-			local_irq_enable();
-
-		set_thread_flag(TIF_POLLING_NRFLAG);
-		clear_bl_bit();
-	} else
-		poll_idle();
+	set_bl_bit();
+	local_irq_enable();
+	/* Isn't this racy ? */
+	cpu_sleep();
+	clear_bl_bit();
 }
 
-/*
- * The idle thread. There's no useful work to be done, so just try to conserve
- * power and have a low exit latency (ie sit in a loop waiting for somebody to
- * say that they'd like to reschedule)
- */
-void cpu_idle(void)
+void arch_cpu_idle(void)
 {
-	unsigned int cpu = smp_processor_id();
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched()) {
-			check_pgt_cache();
-			rmb();
-
-			if (cpu_is_offline(cpu))
-				play_dead();
-
-			local_irq_disable();
-			/* Don't trace irqs off for idle */
-			stop_critical_timings();
-			if (cpuidle_idle_call())
-				sh_idle();
-			/*
-			 * Sanity check to ensure that sh_idle() returns
-			 * with IRQs enabled
-			 */
-			WARN_ON(irqs_disabled());
-			start_critical_timings();
-		}
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	}
+	if (cpuidle_idle_call())
+		sh_idle();
 }
 
 void __init select_idle_routine(void)
@@ -123,13 +44,8 @@ void __init select_idle_routine(void)
 	/*
 	 * If a platform has set its own idle routine, leave it alone.
 	 */
-	if (sh_idle)
-		return;
-
-	if (hlt_works())
+	if (!sh_idle)
 		sh_idle = default_idle;
-	else
-		sh_idle = poll_idle;
 }
 
 void stop_this_cpu(void *unused)
Index: linux-2.6/arch/sh/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/sh/kernel/smp.c
+++ linux-2.6/arch/sh/kernel/smp.c
@@ -203,7 +203,7 @@ asmlinkage void __cpuinit start_secondar
 	set_cpu_online(cpu, true);
 	per_cpu(cpu_state, cpu) = CPU_ONLINE;
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 extern struct {



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 30/34] tile: Enter idle with preemption disabled
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (28 preceding siblings ...)
  2013-03-21 21:53 ` [patch 29/34] sh: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-22 20:34     ` Chris Metcalf
                     ` (3 more replies)
  2013-03-21 21:53 ` [patch 31/34] tile: Use generic idle loop Thomas Gleixner
                   ` (7 subsequent siblings)
  37 siblings, 4 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Chris Metcalf

[-- Attachment #1: tile-enter-secondary-idle-with-preempt-disabled.patch --]
[-- Type: text/plain, Size: 605 bytes --]

cpu_idle() needs to be called with preemption disabled.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Metcalf <cmetcalf@tilera.com>
---
 arch/tile/kernel/smpboot.c |    2 --
 1 file changed, 2 deletions(-)

Index: linux-2.6/arch/tile/kernel/smpboot.c
===================================================================
--- linux-2.6.orig/arch/tile/kernel/smpboot.c
+++ linux-2.6/arch/tile/kernel/smpboot.c
@@ -207,8 +207,6 @@ void __cpuinit online_secondary(void)
 	/* Set up tile-timer clock-event device on this cpu */
 	setup_tile_timer();
 
-	preempt_enable();
-
 	cpu_idle();
 }
 



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 31/34] tile: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (29 preceding siblings ...)
  2013-03-21 21:53 ` [patch 30/34] tile: Enter idle with preemption disabled Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-28 15:41   ` Srivatsa S. Bhat
  2013-04-08 20:45   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 32/34] unicore: " Thomas Gleixner
                   ` (6 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Chris Metcalf

[-- Attachment #1: tile-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 2850 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Metcalf <cmetcalf@tilera.com>
---
 arch/tile/kernel/process.c |   61 ++++-----------------------------------------
 arch/tile/kernel/smpboot.c |    2 -
 2 files changed, 7 insertions(+), 56 deletions(-)

Index: linux-2.6/arch/tile/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/tile/kernel/process.c
+++ linux-2.6/arch/tile/kernel/process.c
@@ -40,13 +40,11 @@
 #include <arch/abi.h>
 #include <arch/sim_def.h>
 
-
 /*
  * Use the (x86) "idle=poll" option to prefer low latency when leaving the
  * idle loop over low power while in the idle loop, e.g. if we have
  * one thread per core and we want to get threads out of futex waits fast.
  */
-static int no_idle_nap;
 static int __init idle_setup(char *str)
 {
 	if (!str)
@@ -54,64 +52,17 @@ static int __init idle_setup(char *str)
 
 	if (!strcmp(str, "poll")) {
 		pr_info("using polling idle threads.\n");
-		no_idle_nap = 1;
+		cpu_idle_poll_ctrl(true);
 	} else if (!strcmp(str, "halt"))
-		no_idle_nap = 0;
-	else
-		return -1;
-
-	return 0;
+		return 0;
+	return -1;
 }
 early_param("idle", idle_setup);
 
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle(void)
+void arch_cpu_idle(void)
 {
-	int cpu = smp_processor_id();
-
-
-	current_thread_info()->status |= TS_POLLING;
-
-	if (no_idle_nap) {
-		while (1) {
-			while (!need_resched())
-				cpu_relax();
-			schedule();
-		}
-	}
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched()) {
-			if (cpu_is_offline(cpu))
-				BUG();  /* no HOTPLUG_CPU */
-
-			local_irq_disable();
-			__get_cpu_var(irq_stat).idle_timestamp = jiffies;
-			current_thread_info()->status &= ~TS_POLLING;
-			/*
-			 * TS_POLLING-cleared state must be visible before we
-			 * test NEED_RESCHED:
-			 */
-			smp_mb();
-
-			if (!need_resched())
-				_cpu_idle();
-			else
-				local_irq_enable();
-			current_thread_info()->status |= TS_POLLING;
-		}
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	}
+	__get_cpu_var(irq_stat).idle_timestamp = jiffies;
+	_cpu_idle();
 }
 
 /*
Index: linux-2.6/arch/tile/kernel/smpboot.c
===================================================================
--- linux-2.6.orig/arch/tile/kernel/smpboot.c
+++ linux-2.6/arch/tile/kernel/smpboot.c
@@ -207,7 +207,7 @@ void __cpuinit online_secondary(void)
 	/* Set up tile-timer clock-event device on this cpu */
 	setup_tile_timer();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 32/34] unicore: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (30 preceding siblings ...)
  2013-03-21 21:53 ` [patch 31/34] tile: Use generic idle loop Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-04-08 20:46   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 33/34] x86: " Thomas Gleixner
                   ` (5 subsequent siblings)
  37 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Guan Xuetao

[-- Attachment #1: unicore-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 1571 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
---
 arch/unicore32/Kconfig          |    1 +
 arch/unicore32/kernel/process.c |   21 +++------------------
 2 files changed, 4 insertions(+), 18 deletions(-)

Index: linux-2.6/arch/unicore32/Kconfig
===================================================================
--- linux-2.6.orig/arch/unicore32/Kconfig
+++ linux-2.6/arch/unicore32/Kconfig
@@ -17,6 +17,7 @@ config UNICORE32
 	select ARCH_WANT_FRAME_POINTERS
 	select GENERIC_IOMAP
 	select MODULES_USE_ELF_REL
+	select GENERIC_IDLE_LOOP
 	help
 	  UniCore-32 is 32-bit Instruction Set Architecture,
 	  including a series of low-power-consumption RISC chip
Index: linux-2.6/arch/unicore32/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/unicore32/kernel/process.c
+++ linux-2.6/arch/unicore32/kernel/process.c
@@ -45,25 +45,10 @@ static const char * const processor_mode
 	"UK18", "UK19", "UK1A", "EXTN", "UK1C", "UK1D", "UK1E", "SUSR"
 };
 
-void cpu_idle(void)
+void arch_cpu_idle(void)
 {
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched()) {
-			local_irq_disable();
-			stop_critical_timings();
-			cpu_do_idle();
-			local_irq_enable();
-			start_critical_timings();
-		}
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		preempt_enable_no_resched();
-		schedule();
-		preempt_disable();
-	}
+	cpu_do_idle();
+	local_irq_enable();
 }
 
 static char reboot_mode = 'h';



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 33/34] x86: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (31 preceding siblings ...)
  2013-03-21 21:53 ` [patch 32/34] unicore: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-28 15:43   ` Srivatsa S. Bhat
  2013-04-08 20:47   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-21 21:53 ` [patch 34/34] xtensa: " Thomas Gleixner
                   ` (4 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, x86

[-- Attachment #1: x86-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 5645 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
---
 arch/x86/Kconfig          |    1 
 arch/x86/kernel/process.c |  106 ++++++++++++----------------------------------
 arch/x86/kernel/smpboot.c |    2 
 arch/x86/xen/smp.c        |    2 
 4 files changed, 32 insertions(+), 79 deletions(-)

Index: linux-2.6/arch/x86/Kconfig
===================================================================
--- linux-2.6.orig/arch/x86/Kconfig
+++ linux-2.6/arch/x86/Kconfig
@@ -97,6 +97,7 @@ config X86
 	select GENERIC_IOMAP
 	select DCACHE_WORD_ACCESS
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select ARCH_WANT_IPC_PARSE_VERSION if X86_32
 	select HAVE_ARCH_SECCOMP_FILTER
 	select BUILDTIME_EXTABLE_SORT
Index: linux-2.6/arch/x86/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/process.c
+++ linux-2.6/arch/x86/kernel/process.c
@@ -29,6 +29,8 @@
 #include <asm/debugreg.h>
 #include <asm/nmi.h>
 
+#define POLL_IDLE	(void*) 0x01
+
 /*
  * per-CPU TSS segments. Threads are completely 'soft' on Linux,
  * no more per-task TSS's. The TSS size is kept cacheline-aligned
@@ -301,13 +303,7 @@ void exit_idle(void)
 }
 #endif
 
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle(void)
+void arch_cpu_idle_prepare(void)
 {
 	/*
 	 * If we're the non-boot CPU, nothing set the stack canary up
@@ -317,71 +313,40 @@ void cpu_idle(void)
 	 * canaries already on the stack wont ever trigger).
 	 */
 	boot_init_stack_canary();
-	current_thread_info()->status |= TS_POLLING;
-
-	while (1) {
-		tick_nohz_idle_enter();
-
-		while (!need_resched()) {
-			rmb();
-
-			if (cpu_is_offline(smp_processor_id()))
-				play_dead();
-
-			/*
-			 * Idle routines should keep interrupts disabled
-			 * from here on, until they go to idle.
-			 * Otherwise, idle callbacks can misfire.
-			 */
-			local_touch_nmi();
-			local_irq_disable();
-
-			enter_idle();
-
-			/* Don't trace irqs off for idle */
-			stop_critical_timings();
-
-			/* enter_idle() needs rcu for notifiers */
-			rcu_idle_enter();
+}
 
-			if (cpuidle_idle_call())
-				x86_idle();
+void arch_cpu_idle_enter(void)
+{
+	local_touch_nmi();
+	enter_idle();
+}
 
-			rcu_idle_exit();
-			start_critical_timings();
+void arch_cpu_idle_exit(void)
+{
+	__exit_idle();
+}
 
-			/* In many cases the interrupt that ended idle
-			   has already called exit_idle. But some idle
-			   loops can be woken up without interrupt. */
-			__exit_idle();
-		}
+void arch_cpu_idle_dead(void)
+{
+	play_dead();
+}
 
-		tick_nohz_idle_exit();
-		preempt_enable_no_resched();
-		schedule();
-		preempt_disable();
-	}
+/*
+ * Called from the generic idle code.
+ */
+void arch_cpu_idle(void)
+{
+	if (cpuidle_idle_call())
+		x86_idle();
 }
 
 /*
- * We use this if we don't have any better
- * idle routine..
+ * We use this if we don't have any better idle routine..
  */
 void default_idle(void)
 {
 	trace_cpu_idle_rcuidle(1, smp_processor_id());
-	current_thread_info()->status &= ~TS_POLLING;
-	/*
-	 * TS_POLLING-cleared state must be visible before we
-	 * test NEED_RESCHED:
-	 */
-	smp_mb();
-
-	if (!need_resched())
-		safe_halt();	/* enables interrupts racelessly */
-	else
-		local_irq_enable();
-	current_thread_info()->status |= TS_POLLING;
+	safe_halt();
 	trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
 }
 #ifdef CONFIG_APM_MODULE
@@ -411,20 +376,6 @@ void stop_this_cpu(void *dummy)
 		halt();
 }
 
-/*
- * On SMP it's slightly faster (but much more power-consuming!)
- * to poll the ->work.need_resched flag instead of waiting for the
- * cross-CPU IPI to arrive. Use this option with caution.
- */
-static void poll_idle(void)
-{
-	trace_cpu_idle_rcuidle(0, smp_processor_id());
-	local_irq_enable();
-	while (!need_resched())
-		cpu_relax();
-	trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
-}
-
 bool amd_e400_c1e_detected;
 EXPORT_SYMBOL(amd_e400_c1e_detected);
 
@@ -489,7 +440,7 @@ static void amd_e400_idle(void)
 void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_SMP
-	if (x86_idle == poll_idle && smp_num_siblings > 1)
+	if (x86_idle == POLL_IDLE && smp_num_siblings > 1)
 		pr_warn_once("WARNING: polling idle and HT enabled, performance may degrade\n");
 #endif
 	if (x86_idle)
@@ -517,8 +468,9 @@ static int __init idle_setup(char *str)
 
 	if (!strcmp(str, "poll")) {
 		pr_info("using polling idle threads\n");
-		x86_idle = poll_idle;
+		x86_idle = POLL_IDLE;
 		boot_option_idle_override = IDLE_POLL;
+		cpu_idle_poll_ctrl(true);
 	} else if (!strcmp(str, "halt")) {
 		/*
 		 * When the boot option of idle=halt is added, halt is
Index: linux-2.6/arch/x86/kernel/smpboot.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/smpboot.c
+++ linux-2.6/arch/x86/kernel/smpboot.c
@@ -284,7 +284,7 @@ notrace static void __cpuinit start_seco
 	x86_cpuinit.setup_percpu_clockev();
 
 	wmb();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void __init smp_store_boot_cpu_info(void)
Index: linux-2.6/arch/x86/xen/smp.c
===================================================================
--- linux-2.6.orig/arch/x86/xen/smp.c
+++ linux-2.6/arch/x86/xen/smp.c
@@ -95,7 +95,7 @@ static void __cpuinit cpu_bringup(void)
 static void __cpuinit cpu_bringup_and_idle(void)
 {
 	cpu_bringup();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 static int xen_smp_intr_init(unsigned int cpu)



^ permalink raw reply	[flat|nested] 147+ messages in thread

* [patch 34/34] xtensa: Use generic idle loop
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (32 preceding siblings ...)
  2013-03-21 21:53 ` [patch 33/34] x86: " Thomas Gleixner
@ 2013-03-21 21:53 ` Thomas Gleixner
  2013-03-22 12:37   ` Max Filippov
  2013-04-08 20:48   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-03-22 20:09 ` [patch 00/34] idle: Consolidate idle implementations Sam Ravnborg
                   ` (3 subsequent siblings)
  37 siblings, 2 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-21 21:53 UTC (permalink / raw)
  To: LKML
  Cc: linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Chris Zankel

[-- Attachment #1: xtensa-use-generic-idle-loop.patch --]
[-- Type: text/plain, Size: 1373 bytes --]

Unfortunately this arch does not compile at all :(

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Zankel <chris@zankel.net>
---
 arch/xtensa/Kconfig          |    1 +
 arch/xtensa/kernel/process.c |   14 ++------------
 2 files changed, 3 insertions(+), 12 deletions(-)

Index: linux-2.6/arch/xtensa/Kconfig
===================================================================
--- linux-2.6.orig/arch/xtensa/Kconfig
+++ linux-2.6/arch/xtensa/Kconfig
@@ -19,6 +19,7 @@ config XTENSA
 	select CLONE_BACKWARDS
 	select IRQ_DOMAIN
 	select HAVE_OPROFILE
+	select GENERIC_IDLE_LOOP
 	help
 	  Xtensa processors are 32-bit RISC machines designed by Tensilica
 	  primarily for embedded systems.  These processors are both
Index: linux-2.6/arch/xtensa/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/xtensa/kernel/process.c
+++ linux-2.6/arch/xtensa/kernel/process.c
@@ -105,19 +105,9 @@ void coprocessor_flush_all(struct thread
 /*
  * Powermanagement idle function, if any is provided by the platform.
  */
-
-void cpu_idle(void)
+void arch_cpu_idle(void)
 {
-	local_irq_enable();
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched())
-			platform_idle();
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
+	platform_idle();
 }
 
 /*



^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 02/34] arch: Consolidate tsk_is_polling()
  2013-03-21 21:52 ` [patch 02/34] arch: Consolidate tsk_is_polling() Thomas Gleixner
@ 2013-03-22  5:01   ` Tony Breeds
  2013-03-22  5:20   ` Tony Breeds
  2013-04-08 20:09   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2 siblings, 0 replies; 147+ messages in thread
From: Tony Breeds @ 2013-03-22  5:01 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]

On Thu, Mar 21, 2013 at 09:52:57PM -0000, Thomas Gleixner wrote:

> Index: linux-2.6/arch/powerpc/include/asm/thread_info.h
> ===================================================================
> --- linux-2.6.orig/arch/powerpc/include/asm/thread_info.h
> +++ linux-2.6/arch/powerpc/include/asm/thread_info.h
> @@ -182,10 +182,6 @@ static inline bool test_thread_local_fla
>  #define is_32bit_task()	(1)
>  #endif
>  
> -#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
> -
> -#endif	/* !__ASSEMBLY__ */
> -

I think taking out this #endif is wrong.  probably wrong in the other
arches as well.
 

Yours Tony

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 02/34] arch: Consolidate tsk_is_polling()
  2013-03-21 21:52 ` [patch 02/34] arch: Consolidate tsk_is_polling() Thomas Gleixner
  2013-03-22  5:01   ` Tony Breeds
@ 2013-03-22  5:20   ` Tony Breeds
  2013-03-22  9:26     ` Thomas Gleixner
  2013-04-08 20:09   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2 siblings, 1 reply; 147+ messages in thread
From: Tony Breeds @ 2013-03-22  5:20 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

[-- Attachment #1: Type: text/plain, Size: 817 bytes --]

On Thu, Mar 21, 2013 at 09:52:57PM -0000, Thomas Gleixner wrote:
 
> +/*
> + * Idle thread specific functions to determine the need_resched
> + * polling state. We have two versions, one based on TS_POLLING in
> + * thread_info.status and one based on TIF_POLLING_NRFLAG in
> + * thread_info.flags
> + */
> +#ifdef TS_POLLING
> +static inline int tsk_is_polling(struct task_struct *p)
> +{
> +	return task_thread_info(p)->status & TS_POLLING;
> +}
> +#elif defined(TIF_POLLING_NRFLAG)
> +static inline int tsk_is_polling(struct task_struct *p)
> +{
> +	test_tsk_thread_flag(p, TIF_POLLING_NRFLAG);
> +}

On powerpc (at least) this is used before it's declared.  Also I think
you're missing a 'return' in that function.

*cough* https://www.kernel.org/pub/tools/crosstool/ *cough*

Yours Tony

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 06/34] arc: Use generic idle loop
  2013-03-21 21:53 ` [patch 06/34] arc: Use generic idle loop Thomas Gleixner
@ 2013-03-22  9:02     ` Vineet Gupta
  2013-04-08 20:15   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: Vineet Gupta @ 2013-03-22  9:02 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

Hi Thomas,

> On 03/22/2013 03:23 AM, Thomas Gleixner wrote:

While the ARC specific changes look simple enough, do you have the series put up
somewhere which I can merge to give a quick build/run test.

Are you planning to add this to linux-next at some point as that will make it
really trivial to test out.

Thx,
-Vineet

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 06/34] arc: Use generic idle loop
@ 2013-03-22  9:02     ` Vineet Gupta
  0 siblings, 0 replies; 147+ messages in thread
From: Vineet Gupta @ 2013-03-22  9:02 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

Hi Thomas,

> On 03/22/2013 03:23 AM, Thomas Gleixner wrote:

While the ARC specific changes look simple enough, do you have the series put up
somewhere which I can merge to give a quick build/run test.

Are you planning to add this to linux-next at some point as that will make it
really trivial to test out.

Thx,
-Vineet

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 02/34] arch: Consolidate tsk_is_polling()
  2013-03-22  5:20   ` Tony Breeds
@ 2013-03-22  9:26     ` Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-22  9:26 UTC (permalink / raw)
  To: Tony Breeds
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On Fri, 22 Mar 2013, Tony Breeds wrote:

> On Thu, Mar 21, 2013 at 09:52:57PM -0000, Thomas Gleixner wrote:
>  
> > +/*
> > + * Idle thread specific functions to determine the need_resched
> > + * polling state. We have two versions, one based on TS_POLLING in
> > + * thread_info.status and one based on TIF_POLLING_NRFLAG in
> > + * thread_info.flags
> > + */
> > +#ifdef TS_POLLING
> > +static inline int tsk_is_polling(struct task_struct *p)
> > +{
> > +	return task_thread_info(p)->status & TS_POLLING;
> > +}
> > +#elif defined(TIF_POLLING_NRFLAG)
> > +static inline int tsk_is_polling(struct task_struct *p)
> > +{
> > +	test_tsk_thread_flag(p, TIF_POLLING_NRFLAG);
> > +}
> 
> On powerpc (at least) this is used before it's declared.  Also I think
> you're missing a 'return' in that function.

Mooo
 
> *cough* https://www.kernel.org/pub/tools/crosstool/ *cough*

Yes, I know. /me feels bad

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 03/34] idle: Implement set/clr functions for need_resched poll
  2013-03-21 21:52 ` [patch 03/34] idle: Implement set/clr functions for need_resched poll Thomas Gleixner
@ 2013-03-22  9:38     ` James Hogan
  2013-04-08 20:10   ` [tip:smp/hotplug] idle: Implement set/ clr " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: James Hogan @ 2013-03-22  9:38 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On 21/03/13 21:52, Thomas Gleixner wrote:
> Implement set/clear functions for the idle need_resched poll
> implementation.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  include/linux/sched.h |   23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> Index: linux-2.6/include/linux/sched.h
> ===================================================================
> --- linux-2.6.orig/include/linux/sched.h
> +++ linux-2.6/include/linux/sched.h
> @@ -2473,7 +2473,7 @@ static inline unsigned long *end_of_stac
>  #endif
>  
>  /*
> - * Idle thread specific functions to determine the need_resched
> + * Idle thread specific functions for the the need_resched
>   * polling state. We have two versions, one based on TS_POLLING in

s/the the/the/?

Cheers
James


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 03/34] idle: Implement set/clr functions for need_resched poll
@ 2013-03-22  9:38     ` James Hogan
  0 siblings, 0 replies; 147+ messages in thread
From: James Hogan @ 2013-03-22  9:38 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On 21/03/13 21:52, Thomas Gleixner wrote:
> Implement set/clear functions for the idle need_resched poll
> implementation.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  include/linux/sched.h |   23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> Index: linux-2.6/include/linux/sched.h
> ===================================================================
> --- linux-2.6.orig/include/linux/sched.h
> +++ linux-2.6/include/linux/sched.h
> @@ -2473,7 +2473,7 @@ static inline unsigned long *end_of_stac
>  #endif
>  
>  /*
> - * Idle thread specific functions to determine the need_resched
> + * Idle thread specific functions for the the need_resched
>   * polling state. We have two versions, one based on TS_POLLING in

s/the the/the/?

Cheers
James

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 20/34] metag: Use generic idle loop
  2013-03-21 21:53 ` [patch 20/34] metag: " Thomas Gleixner
@ 2013-03-22 10:16     ` James Hogan
  2013-04-08 20:32   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: James Hogan @ 2013-03-22 10:16 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Arnd

On 21/03/13 21:53, Thomas Gleixner wrote:
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: James Hogan <james.hogan@imgtec.com>
> ---
>  arch/metag/Kconfig          |    1 +
>  arch/metag/kernel/process.c |   32 +++-----------------------------
>  arch/metag/kernel/smp.c     |    2 +-
>  3 files changed, 5 insertions(+), 30 deletions(-)
> 
> Index: linux-2.6/arch/metag/Kconfig
> ===================================================================
> --- linux-2.6.orig/arch/metag/Kconfig
> +++ linux-2.6/arch/metag/Kconfig
> @@ -9,6 +9,7 @@ config METAG
>  	select GENERIC_CLOCKEVENTS
>  	select GENERIC_IRQ_SHOW
>  	select GENERIC_SMP_IDLE_THREAD
> +	select GENERIC_IDLE_LOOP

Please preserve alphabetical ordering

>  	select HAVE_64BIT_ALIGNED_ACCESS
>  	select HAVE_ARCH_TRACEHOOK
>  	select HAVE_C_RECORDMCOUNT
> Index: linux-2.6/arch/metag/kernel/process.c
> ===================================================================
> --- linux-2.6.orig/arch/metag/kernel/process.c
> +++ linux-2.6/arch/metag/kernel/process.c
> @@ -31,7 +31,7 @@
>  /*
>   * Wait for the next interrupt and enable local interrupts
>   */
> -static inline void arch_idle(void)
> +void arch_cpu_idle(void)
>  {
>  	int tmp;
>  
> @@ -59,35 +59,9 @@ static inline void arch_idle(void)
>  		      : "r" (get_trigger_mask()));
>  }
>  
> -void cpu_idle(void)
> +void arch_cpu_idle_dead(void)
>  {
> -	set_thread_flag(TIF_POLLING_NRFLAG);
> -
> -	while (1) {
> -		tick_nohz_idle_enter();
> -		rcu_idle_enter();
> -
> -		while (!need_resched()) {
> -			/*
> -			 * We need to disable interrupts here to ensure we don't
> -			 * miss a wakeup call.
> -			 */
> -			local_irq_disable();
> -			if (!need_resched()) {
> -#ifdef CONFIG_HOTPLUG_CPU
> -				if (cpu_is_offline(smp_processor_id()))
> -					cpu_die();
> -#endif
> -				arch_idle();
> -			} else {
> -				local_irq_enable();
> -			}
> -		}
> -
> -		rcu_idle_exit();
> -		tick_nohz_idle_exit();
> -		schedule_preempt_disabled();
> -	 }
> +	cpu_die();

This requires #include <linux/smp.h> and even then the definition of
cpu_die() is guarded by #ifdef CONFIG_HOTPLUG_CPU, like blackfin & s390.

>  }
>  
>  void (*pm_power_off)(void);
> Index: linux-2.6/arch/metag/kernel/smp.c
> ===================================================================
> --- linux-2.6.orig/arch/metag/kernel/smp.c
> +++ linux-2.6/arch/metag/kernel/smp.c
> @@ -297,7 +297,7 @@ asmlinkage void secondary_start_kernel(v
>  	/*
>  	 * OK, it's off to the idle thread for us
>  	 */
> -	cpu_idle();
> +	cpu_startup_entry(CPUHP_ONLINE);
>  }
>  
>  void __init smp_cpus_done(unsigned int max_cpus)
> 
> 

I also hit the same problems Tony Breeds hit.

After hacking around them, and enabling SMP and HOTPLUG_CPU, I hit the
WARN_ON_ONCE(!irqs_disabled()) after arch_cpu_idle() in cpu_idle_loop():

> META213-Thread1 DSP [LogF] WARNING: at kernel/cpu/idle.c:94 _cpu_startup_entry+0x1cc/0x1e0()

arch_cpu_idle() enables interrupts. See Arnd's comment in
https://patchwork.kernel.org/patch/2002571/:

> To avoid that, you need to disable interrupts around
> the inner loop. The sleep instruction should return with
> interrupts implicitly enabled if ARC behaves like most
> other architectures doing this.

Cheers
James


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 20/34] metag: Use generic idle loop
@ 2013-03-22 10:16     ` James Hogan
  0 siblings, 0 replies; 147+ messages in thread
From: James Hogan @ 2013-03-22 10:16 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Arnd

On 21/03/13 21:53, Thomas Gleixner wrote:
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: James Hogan <james.hogan@imgtec.com>
> ---
>  arch/metag/Kconfig          |    1 +
>  arch/metag/kernel/process.c |   32 +++-----------------------------
>  arch/metag/kernel/smp.c     |    2 +-
>  3 files changed, 5 insertions(+), 30 deletions(-)
> 
> Index: linux-2.6/arch/metag/Kconfig
> ===================================================================
> --- linux-2.6.orig/arch/metag/Kconfig
> +++ linux-2.6/arch/metag/Kconfig
> @@ -9,6 +9,7 @@ config METAG
>  	select GENERIC_CLOCKEVENTS
>  	select GENERIC_IRQ_SHOW
>  	select GENERIC_SMP_IDLE_THREAD
> +	select GENERIC_IDLE_LOOP

Please preserve alphabetical ordering

>  	select HAVE_64BIT_ALIGNED_ACCESS
>  	select HAVE_ARCH_TRACEHOOK
>  	select HAVE_C_RECORDMCOUNT
> Index: linux-2.6/arch/metag/kernel/process.c
> ===================================================================
> --- linux-2.6.orig/arch/metag/kernel/process.c
> +++ linux-2.6/arch/metag/kernel/process.c
> @@ -31,7 +31,7 @@
>  /*
>   * Wait for the next interrupt and enable local interrupts
>   */
> -static inline void arch_idle(void)
> +void arch_cpu_idle(void)
>  {
>  	int tmp;
>  
> @@ -59,35 +59,9 @@ static inline void arch_idle(void)
>  		      : "r" (get_trigger_mask()));
>  }
>  
> -void cpu_idle(void)
> +void arch_cpu_idle_dead(void)
>  {
> -	set_thread_flag(TIF_POLLING_NRFLAG);
> -
> -	while (1) {
> -		tick_nohz_idle_enter();
> -		rcu_idle_enter();
> -
> -		while (!need_resched()) {
> -			/*
> -			 * We need to disable interrupts here to ensure we don't
> -			 * miss a wakeup call.
> -			 */
> -			local_irq_disable();
> -			if (!need_resched()) {
> -#ifdef CONFIG_HOTPLUG_CPU
> -				if (cpu_is_offline(smp_processor_id()))
> -					cpu_die();
> -#endif
> -				arch_idle();
> -			} else {
> -				local_irq_enable();
> -			}
> -		}
> -
> -		rcu_idle_exit();
> -		tick_nohz_idle_exit();
> -		schedule_preempt_disabled();
> -	 }
> +	cpu_die();

This requires #include <linux/smp.h> and even then the definition of
cpu_die() is guarded by #ifdef CONFIG_HOTPLUG_CPU, like blackfin & s390.

>  }
>  
>  void (*pm_power_off)(void);
> Index: linux-2.6/arch/metag/kernel/smp.c
> ===================================================================
> --- linux-2.6.orig/arch/metag/kernel/smp.c
> +++ linux-2.6/arch/metag/kernel/smp.c
> @@ -297,7 +297,7 @@ asmlinkage void secondary_start_kernel(v
>  	/*
>  	 * OK, it's off to the idle thread for us
>  	 */
> -	cpu_idle();
> +	cpu_startup_entry(CPUHP_ONLINE);
>  }
>  
>  void __init smp_cpus_done(unsigned int max_cpus)
> 
> 

I also hit the same problems Tony Breeds hit.

After hacking around them, and enabling SMP and HOTPLUG_CPU, I hit the
WARN_ON_ONCE(!irqs_disabled()) after arch_cpu_idle() in cpu_idle_loop():

> META213-Thread1 DSP [LogF] WARNING: at kernel/cpu/idle.c:94 _cpu_startup_entry+0x1cc/0x1e0()

arch_cpu_idle() enables interrupts. See Arnd's comment in
https://patchwork.kernel.org/patch/2002571/:

> To avoid that, you need to disable interrupts around
> the inner loop. The sleep instruction should return with
> interrupts implicitly enabled if ARC behaves like most
> other architectures doing this.

Cheers
James

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 34/34] xtensa: Use generic idle loop
  2013-03-21 21:53 ` [patch 34/34] xtensa: " Thomas Gleixner
@ 2013-03-22 12:37   ` Max Filippov
  2013-04-08 20:48   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: Max Filippov @ 2013-03-22 12:37 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Chris Zankel

On Fri, Mar 22, 2013 at 1:53 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> Unfortunately this arch does not compile at all :(

Hi Thomas,

according to KISSKB http://kisskb.ellerman.id.au/kisskb/compiler/19/
it does, you probably don't need to build allmodconfig.

With this patch I see WARN coming from the kernel/cpu/idle.c:94,
xtensa __platform_idle returns with interrupts enabled.
Interestingly, even the default arch_cpu_idle does so.

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 00/34] idle: Consolidate idle implementations
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (33 preceding siblings ...)
  2013-03-21 21:53 ` [patch 34/34] xtensa: " Thomas Gleixner
@ 2013-03-22 20:09 ` Sam Ravnborg
       [not found] ` <alpine.LFD.2.02.1303271940150.22263@ionos>
                   ` (2 subsequent siblings)
  37 siblings, 0 replies; 147+ messages in thread
From: Sam Ravnborg @ 2013-03-22 20:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, David S. Miller

Hi Thomas.
On Thu, Mar 21, 2013 at 09:52:56PM -0000, Thomas Gleixner wrote:
> Each architecture implements its own cpu_idle() code, which is more or
> less the same on all architectures (plus/minus a few bugs and a few
> missing extra functionalities, instrumentation ...). That also forces
> everyone who is interested in idle related features to add new
> functionality to every architecture. What a waste.
> 
> Aside of that pointless code duplicaiton the ongoing quest to
> consolidate the cpu hotplug code needs a common entry point for the
> non boot cpus.
> 
> The following series implements a generic idle function and converts
> most architectures over. I left out SPARC (it involves sparc asm) and
> UM (it made me barf). If we can move those architectures as well, we
> can get rid of the extra config switch and have everything
> consolidated.
I wanted to take a quick look at sparc - but build failed
after applying patch 1-5. Looks like the same issue Tony already
reaported.

At very first glnce it looks straightforward to convert
both sparc32 and sparc64.
The assembler stuff used by sparc64 fits into one of the arch functions
as far as I could see.

When I get back from vacation I may take a look.

	Sam

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 30/34] tile: Enter idle with preemption disabled
  2013-03-21 21:53 ` [patch 30/34] tile: Enter idle with preemption disabled Thomas Gleixner
@ 2013-03-22 20:34     ` Chris Metcalf
  2013-03-22 20:40     ` Chris Metcalf
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 147+ messages in thread
From: Chris Metcalf @ 2013-03-22 20:34 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On 3/21/2013 5:53 PM, Thomas Gleixner wrote:
> cpu_idle() needs to be called with preemption disabled.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Chris Metcalf <cmetcalf@tilera.com>
> ---
>  arch/tile/kernel/smpboot.c |    2 --
>  1 file changed, 2 deletions(-)

Thanks.  I had fixed this in our internal tree, but hadn't pushed it up yet.  I'll take your version into the public tile tree.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 30/34] tile: Enter idle with preemption disabled
@ 2013-03-22 20:34     ` Chris Metcalf
  0 siblings, 0 replies; 147+ messages in thread
From: Chris Metcalf @ 2013-03-22 20:34 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On 3/21/2013 5:53 PM, Thomas Gleixner wrote:
> cpu_idle() needs to be called with preemption disabled.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Chris Metcalf <cmetcalf@tilera.com>
> ---
>  arch/tile/kernel/smpboot.c |    2 --
>  1 file changed, 2 deletions(-)

Thanks.  I had fixed this in our internal tree, but hadn't pushed it up yet.  I'll take your version into the public tile tree.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 30/34] tile: Enter idle with preemption disabled
  2013-03-21 21:53 ` [patch 30/34] tile: Enter idle with preemption disabled Thomas Gleixner
@ 2013-03-22 20:40     ` Chris Metcalf
  2013-03-22 20:40     ` Chris Metcalf
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 147+ messages in thread
From: Chris Metcalf @ 2013-03-22 20:40 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On 3/21/2013 5:53 PM, Thomas Gleixner wrote:
> cpu_idle() needs to be called with preemption disabled.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Chris Metcalf <cmetcalf@tilera.com>
> ---
>  arch/tile/kernel/smpboot.c |    2 --
>  1 file changed, 2 deletions(-)

Or, given this is part of a series you're presumably intending to push yourself, it probably makes more sense just to add my

Acked-by: Chris Metcalf <cmetcalf@tilera.com>

to both this patch and patch 31/34.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 30/34] tile: Enter idle with preemption disabled
@ 2013-03-22 20:40     ` Chris Metcalf
  0 siblings, 0 replies; 147+ messages in thread
From: Chris Metcalf @ 2013-03-22 20:40 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On 3/21/2013 5:53 PM, Thomas Gleixner wrote:
> cpu_idle() needs to be called with preemption disabled.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Chris Metcalf <cmetcalf@tilera.com>
> ---
>  arch/tile/kernel/smpboot.c |    2 --
>  1 file changed, 2 deletions(-)

Or, given this is part of a series you're presumably intending to push yourself, it probably makes more sense just to add my

Acked-by: Chris Metcalf <cmetcalf@tilera.com>

to both this patch and patch 31/34.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 08/34] arm: Use generic idle loop
  2013-03-21 21:53 ` [patch 08/34] arm: " Thomas Gleixner
@ 2013-03-22 21:24   ` Kevin Hilman
  2013-03-25 11:31     ` Thomas Gleixner
  2013-04-08 20:17   ` [tip:smp/hotplug] arm: Use generic idle loop tip-bot for Thomas Gleixner
  1 sibling, 1 reply; 147+ messages in thread
From: Kevin Hilman @ 2013-03-22 21:24 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Russell King

Hi Thomas,

Thomas Gleixner <tglx@linutronix.de> writes:

> Use the generic idle loop and replace enable/disable_hlt with the
> respective core functions.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Russell King <linux@arm.linux.org.uk>

I gave patches 1-5 + this a quick spin on ARM (specifially some OMAP3 and
OMAP4 platforms, with and without CPUidle enabled.)

The OMAP stuff needed a couple minor compile fixes (below), but
otherwise it passes the quick "seems to work" test.

So at least for ARM/OMAP:

Tested-by: Kevin Hilman <khilman@linaro.org>

Kevin


diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
index 23c653a..db37f49 100644
--- a/arch/arm/mach-omap1/pm.c
+++ b/arch/arm/mach-omap1/pm.c
@@ -43,6 +43,7 @@
 #include <linux/module.h>
 #include <linux/io.h>
 #include <linux/atomic.h>
+#include <linux/cpu.h>
 
 #include <asm/fncpy.h>
 #include <asm/system_misc.h>
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 3a6c6b8..2f17f95 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -138,6 +138,7 @@
 #include <linux/spinlock.h>
 #include <linux/slab.h>
 #include <linux/bootmem.h>
+#include <linux/cpu.h>
 
 #include <asm/system_misc.h>

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [patch 05/34] idle: Implement generic idle function
  2013-03-21 21:53 ` [patch 05/34] idle: Implement generic idle function Thomas Gleixner
@ 2013-03-23  8:56   ` Heiko Carstens
  2013-03-25 10:39     ` Thomas Gleixner
  2013-03-28 15:39   ` Srivatsa S. Bhat
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 147+ messages in thread
From: Heiko Carstens @ 2013-03-23  8:56 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On Thu, Mar 21, 2013 at 09:53:00PM -0000, Thomas Gleixner wrote:
> All idle functions in arch/* are more or less the same, plus minus a
> few bugs and extra instrumentation, tickless support and other
> optional items.
> 
> Implement a generic idle function which resembles the functionality
> found in arch/. Provide weak arch_cpu_idle_* functions which can be
> overridden by the architecture code if needed.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

[...]

> +static void cpu_idle_loop(void)
> +{
> +	while (1) {
> +		tick_nohz_idle_enter();
> +
> +		while (!need_resched()) {
> +			check_pgt_cache();
> +			rmb();
> +
> +			if (cpu_is_offline(smp_processor_id()))
> +				arch_cpu_idle_dead();
> +
> +			local_irq_disable();
> +			arch_cpu_idle_enter();
> +
> +			if (cpu_idle_force_poll) {
> +				cpu_idle_poll();
> +			} else {
> +				current_clr_polling();
> +				if (!need_resched()) {
> +					stop_critical_timings();
> +					rcu_idle_enter();
> +					arch_cpu_idle();
> +					WARN_ON_ONCE(!irqs_disabled());

This should be WARN_ON_ONCE(irqs_disabled()), no?

> +					rcu_idle_exit();
> +					start_critical_timings();
> +				} else {
> +					local_irq_enable();
> +				}
> +				current_set_polling();
> +			}
> +			arch_cpu_idle_exit();
> +		}
> +		tick_nohz_idle_exit();

I was wondering why the scheduler doesn't complain when being called with
irqs disabled. In fact tick_nohz_idle_exit() enables irqs unconditionally
iff CONFIG_NO_HZ is set.

> +		schedule_preempt_disabled();
> +	}
> +}
> +
> +void cpu_startup_entry(enum cpuhp_state state)
> +{
> +	current_set_polling();
> +	arch_cpu_idle_prepare();
> +	cpu_idle_loop();
> +}
> +#endif


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 27/34] s390: Use generic idle loop
  2013-03-21 21:53 ` [patch 27/34] s390: " Thomas Gleixner
@ 2013-03-23  9:38   ` Heiko Carstens
  2013-03-23  9:39     ` Heiko Carstens
  2013-04-08 20:40   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2 siblings, 0 replies; 147+ messages in thread
From: Heiko Carstens @ 2013-03-23  9:38 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On Thu, Mar 21, 2013 at 09:53:18PM -0000, Thomas Gleixner wrote:
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> ---
>  arch/s390/kernel/process.c |   25 +++++++------------------
>  arch/s390/kernel/smp.c     |    3 +--
>  2 files changed, 8 insertions(+), 20 deletions(-)

Please merge the patch below into your patch to fix some issues.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 arch/s390/Kconfig          |  1 +
 arch/s390/kernel/process.c | 13 +++++--------
 arch/s390/kernel/vtime.c   |  5 -----
 3 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index eb8fb62..749513d 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -97,6 +97,7 @@ config S390
 	select CLONE_BACKWARDS2
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_CPU_DEVICES if !SMP
+	select GENERIC_IDLE_LOOP
 	select GENERIC_KERNEL_THREAD
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_TIME_VSYSCALL_OLD
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index 546afed..2bc3edd 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -61,16 +61,8 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
 	return sf->gprs[8];
 }
 
-/*
- * The idle function on a S390...
- */
 void arch_cpu_idle(void)
 {
-	if (test_thread_flag(TIF_MCCK_PENDING)) {
-		local_irq_enable();
-		return;
-	}
-
 	local_mcck_disable();
 	if (test_thread_flag(TIF_MCCK_PENDING)) {
 		local_mcck_enable();
@@ -87,6 +79,11 @@ void arch_cpu_idle_exit(void)
 		s390_handle_mcck();
 }
 
+void arch_cpu_idle_dead(void)
+{
+	cpu_die();
+}
+
 extern void __kprobes kernel_thread_starter(void);
 
 /*
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index a0042ac..3fb0935 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -158,8 +158,6 @@ void __kprobes vtime_stop_cpu(void)
 	unsigned long psw_mask;
 
 	trace_hardirqs_on();
-	/* Don't trace preempt off for idle. */
-	stop_critical_timings();
 
 	/* Wait for external, I/O or machine check interrupt. */
 	psw_mask = psw_kernel_bits | PSW_MASK_WAIT | PSW_MASK_DAT |
@@ -169,9 +167,6 @@ void __kprobes vtime_stop_cpu(void)
 	/* Call the assembler magic in entry.S */
 	psw_idle(idle, psw_mask);
 
-	/* Reenable preemption tracer. */
-	start_critical_timings();
-
 	/* Account time spent with enabled wait psw loaded as idle time. */
 	idle->sequence++;
 	smp_wmb();
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [patch 27/34] s390: Use generic idle loop
  2013-03-21 21:53 ` [patch 27/34] s390: " Thomas Gleixner
@ 2013-03-23  9:39     ` Heiko Carstens
  2013-03-23  9:39     ` Heiko Carstens
  2013-04-08 20:40   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2 siblings, 0 replies; 147+ messages in thread
From: Heiko Carstens @ 2013-03-23  9:39 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On Thu, Mar 21, 2013 at 09:53:18PM -0000, Thomas Gleixner wrote:
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> ---
>  arch/s390/kernel/process.c |   25 +++++++------------------
>  arch/s390/kernel/smp.c     |    3 +--
>  2 files changed, 8 insertions(+), 20 deletions(-)

FWIW, the patch below is also needed to fix a compile error.
I'll take care it gets upstream independently of your work.

>From 10c8cd5139f9a18cd6e955793ae7ad0877b5dd86 Mon Sep 17 00:00:00 2001
From: Heiko Carstens <heiko.carstens@de.ibm.com>
Date: Sat, 23 Mar 2013 10:29:01 +0100
Subject: [PATCH 2/2] s390/mm: provide emtpy check_pgt_cache() function

All architectures need to provide a check_pgt_cache() function. The s390 one
got lost somewhere.
So reintroduce it to prevent future compile errors e.g. if Thomas Gleixner's
idle loop rework patches get merged.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 arch/s390/include/asm/pgtable.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index 4a29308..a11c773 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -1533,6 +1533,8 @@ extern int s390_enable_sie(void);
  */
 #define pgtable_cache_init()	do { } while (0)
 
+static inline void check_pgt_cache(void) { }
+
 #include <asm-generic/pgtable.h>
 
 #endif /* _S390_PAGE_H */
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [patch 27/34] s390: Use generic idle loop
@ 2013-03-23  9:39     ` Heiko Carstens
  0 siblings, 0 replies; 147+ messages in thread
From: Heiko Carstens @ 2013-03-23  9:39 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On Thu, Mar 21, 2013 at 09:53:18PM -0000, Thomas Gleixner wrote:
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> ---
>  arch/s390/kernel/process.c |   25 +++++++------------------
>  arch/s390/kernel/smp.c     |    3 +--
>  2 files changed, 8 insertions(+), 20 deletions(-)

FWIW, the patch below is also needed to fix a compile error.
I'll take care it gets upstream independently of your work.

From 10c8cd5139f9a18cd6e955793ae7ad0877b5dd86 Mon Sep 17 00:00:00 2001
From: Heiko Carstens <heiko.carstens@de.ibm.com>
Date: Sat, 23 Mar 2013 10:29:01 +0100
Subject: [PATCH 2/2] s390/mm: provide emtpy check_pgt_cache() function

All architectures need to provide a check_pgt_cache() function. The s390 one
got lost somewhere.
So reintroduce it to prevent future compile errors e.g. if Thomas Gleixner's
idle loop rework patches get merged.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 arch/s390/include/asm/pgtable.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index 4a29308..a11c773 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -1533,6 +1533,8 @@ extern int s390_enable_sie(void);
  */
 #define pgtable_cache_init()	do { } while (0)
 
+static inline void check_pgt_cache(void) { }
+
 #include <asm-generic/pgtable.h>
 
 #endif /* _S390_PAGE_H */
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [patch 05/34] idle: Implement generic idle function
  2013-03-23  8:56   ` Heiko Carstens
@ 2013-03-25 10:39     ` Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-25 10:39 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On Sat, 23 Mar 2013, Heiko Carstens wrote:

> On Thu, Mar 21, 2013 at 09:53:00PM -0000, Thomas Gleixner wrote:
> > All idle functions in arch/* are more or less the same, plus minus a
> > few bugs and extra instrumentation, tickless support and other
> > optional items.
> > 
> > Implement a generic idle function which resembles the functionality
> > found in arch/. Provide weak arch_cpu_idle_* functions which can be
> > overridden by the architecture code if needed.
> > 
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> 
> [...]
> 
> > +static void cpu_idle_loop(void)
> > +{
> > +	while (1) {
> > +		tick_nohz_idle_enter();
> > +
> > +		while (!need_resched()) {
> > +			check_pgt_cache();
> > +			rmb();
> > +
> > +			if (cpu_is_offline(smp_processor_id()))
> > +				arch_cpu_idle_dead();
> > +
> > +			local_irq_disable();
> > +			arch_cpu_idle_enter();
> > +
> > +			if (cpu_idle_force_poll) {
> > +				cpu_idle_poll();
> > +			} else {
> > +				current_clr_polling();
> > +				if (!need_resched()) {
> > +					stop_critical_timings();
> > +					rcu_idle_enter();
> > +					arch_cpu_idle();
> > +					WARN_ON_ONCE(!irqs_disabled());
> 
> This should be WARN_ON_ONCE(irqs_disabled()), no?

Gah, yes.
 
> > +					rcu_idle_exit();
> > +					start_critical_timings();
> > +				} else {
> > +					local_irq_enable();
> > +				}
> > +				current_set_polling();
> > +			}
> > +			arch_cpu_idle_exit();
> > +		}
> > +		tick_nohz_idle_exit();
> 
> I was wondering why the scheduler doesn't complain when being called with
> irqs disabled. In fact tick_nohz_idle_exit() enables irqs unconditionally
> iff CONFIG_NO_HZ is set.

It should complain. I'll have a look again.
 
> > +		schedule_preempt_disabled();
> > +	}
> > +}
> > +
> > +void cpu_startup_entry(enum cpuhp_state state)
> > +{
> > +	current_set_polling();
> > +	arch_cpu_idle_prepare();
> > +	cpu_idle_loop();
> > +}
> > +#endif
> 
> 

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 20/34] metag: Use generic idle loop
  2013-03-22 10:16     ` James Hogan
  (?)
@ 2013-03-25 11:26     ` Thomas Gleixner
  -1 siblings, 0 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-25 11:26 UTC (permalink / raw)
  To: James Hogan
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Arnd

On Fri, 22 Mar 2013, James Hogan wrote:

> On 21/03/13 21:53, Thomas Gleixner wrote:
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > Cc: James Hogan <james.hogan@imgtec.com>
> > ---
> >  arch/metag/Kconfig          |    1 +
> >  arch/metag/kernel/process.c |   32 +++-----------------------------
> >  arch/metag/kernel/smp.c     |    2 +-
> >  3 files changed, 5 insertions(+), 30 deletions(-)
> > 
> > Index: linux-2.6/arch/metag/Kconfig
> > ===================================================================
> > --- linux-2.6.orig/arch/metag/Kconfig
> > +++ linux-2.6/arch/metag/Kconfig
> > @@ -9,6 +9,7 @@ config METAG
> >  	select GENERIC_CLOCKEVENTS
> >  	select GENERIC_IRQ_SHOW
> >  	select GENERIC_SMP_IDLE_THREAD
> > +	select GENERIC_IDLE_LOOP
> 
> Please preserve alphabetical ordering

Ok.
 
> >  	select HAVE_64BIT_ALIGNED_ACCESS
> >  	select HAVE_ARCH_TRACEHOOK
> >  	select HAVE_C_RECORDMCOUNT
> > Index: linux-2.6/arch/metag/kernel/process.c
> > ===================================================================
> > --- linux-2.6.orig/arch/metag/kernel/process.c
> > +++ linux-2.6/arch/metag/kernel/process.c
> > @@ -31,7 +31,7 @@
> >  /*
> >   * Wait for the next interrupt and enable local interrupts
> >   */
> > -static inline void arch_idle(void)
> > +void arch_cpu_idle(void)
> >  {
> >  	int tmp;
> >  
> > @@ -59,35 +59,9 @@ static inline void arch_idle(void)
> >  		      : "r" (get_trigger_mask()));
> >  }
> >  
> > -void cpu_idle(void)
> > +void arch_cpu_idle_dead(void)
> >  {
> > -	set_thread_flag(TIF_POLLING_NRFLAG);
> > -
> > -	while (1) {
> > -		tick_nohz_idle_enter();
> > -		rcu_idle_enter();
> > -
> > -		while (!need_resched()) {
> > -			/*
> > -			 * We need to disable interrupts here to ensure we don't
> > -			 * miss a wakeup call.
> > -			 */
> > -			local_irq_disable();
> > -			if (!need_resched()) {
> > -#ifdef CONFIG_HOTPLUG_CPU
> > -				if (cpu_is_offline(smp_processor_id()))
> > -					cpu_die();
> > -#endif
> > -				arch_idle();
> > -			} else {
> > -				local_irq_enable();
> > -			}
> > -		}
> > -
> > -		rcu_idle_exit();
> > -		tick_nohz_idle_exit();
> > -		schedule_preempt_disabled();
> > -	 }
> > +	cpu_die();
> 
> This requires #include <linux/smp.h> and even then the definition of
> cpu_die() is guarded by #ifdef CONFIG_HOTPLUG_CPU, like blackfin & s390.

Will fix.
 
> >  }
> >  
> >  void (*pm_power_off)(void);
> > Index: linux-2.6/arch/metag/kernel/smp.c
> > ===================================================================
> > --- linux-2.6.orig/arch/metag/kernel/smp.c
> > +++ linux-2.6/arch/metag/kernel/smp.c
> > @@ -297,7 +297,7 @@ asmlinkage void secondary_start_kernel(v
> >  	/*
> >  	 * OK, it's off to the idle thread for us
> >  	 */
> > -	cpu_idle();
> > +	cpu_startup_entry(CPUHP_ONLINE);
> >  }
> >  
> >  void __init smp_cpus_done(unsigned int max_cpus)
> > 
> > 
> 
> I also hit the same problems Tony Breeds hit.
> 
> After hacking around them, and enabling SMP and HOTPLUG_CPU, I hit the
> WARN_ON_ONCE(!irqs_disabled()) after arch_cpu_idle() in cpu_idle_loop():

My stupidity. I fatfingered it when last minute changing it to
WARN_ON_ONCE
 
> > META213-Thread1 DSP [LogF] WARNING: at kernel/cpu/idle.c:94 _cpu_startup_entry+0x1cc/0x1e0()
> 
> arch_cpu_idle() enables interrupts. See Arnd's comment in
> https://patchwork.kernel.org/patch/2002571/:
> 
> > To avoid that, you need to disable interrupts around
> > the inner loop. The sleep instruction should return with
> > interrupts implicitly enabled if ARC behaves like most
> > other architectures doing this.

Right. My fault. See above.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 08/34] arm: Use generic idle loop
  2013-03-22 21:24   ` Kevin Hilman
@ 2013-03-25 11:31     ` Thomas Gleixner
  2013-03-25 11:48       ` Russell King - ARM Linux
  0 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-25 11:31 UTC (permalink / raw)
  To: Kevin Hilman
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Russell King

On Fri, 22 Mar 2013, Kevin Hilman wrote:

> Hi Thomas,
> 
> Thomas Gleixner <tglx@linutronix.de> writes:
> 
> > Use the generic idle loop and replace enable/disable_hlt with the
> > respective core functions.
> >
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Russell King <linux@arm.linux.org.uk>
> 
> I gave patches 1-5 + this a quick spin on ARM (specifially some OMAP3 and
> OMAP4 platforms, with and without CPUidle enabled.)
> 
> The OMAP stuff needed a couple minor compile fixes (below), but
> otherwise it passes the quick "seems to work" test.

Yeah, that's needed for the other arch/arm conversions as well.

Thanks,

	tglx

 
> So at least for ARM/OMAP:
> 
> Tested-by: Kevin Hilman <khilman@linaro.org>
> 
> Kevin
> 
> 
> diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
> index 23c653a..db37f49 100644
> --- a/arch/arm/mach-omap1/pm.c
> +++ b/arch/arm/mach-omap1/pm.c
> @@ -43,6 +43,7 @@
>  #include <linux/module.h>
>  #include <linux/io.h>
>  #include <linux/atomic.h>
> +#include <linux/cpu.h>
>  
>  #include <asm/fncpy.h>
>  #include <asm/system_misc.h>
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index 3a6c6b8..2f17f95 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -138,6 +138,7 @@
>  #include <linux/spinlock.h>
>  #include <linux/slab.h>
>  #include <linux/bootmem.h>
> +#include <linux/cpu.h>
>  
>  #include <asm/system_misc.h>
> 

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 08/34] arm: Use generic idle loop
  2013-03-25 11:31     ` Thomas Gleixner
@ 2013-03-25 11:48       ` Russell King - ARM Linux
  2013-03-25 14:02         ` Thomas Gleixner
  0 siblings, 1 reply; 147+ messages in thread
From: Russell King - ARM Linux @ 2013-03-25 11:48 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Kevin Hilman, LKML, linux-arch, Linus Torvalds, Andrew Morton,
	Rusty Russell, Paul McKenney, Ingo Molnar, Peter Zijlstra,
	Srivatsa S. Bhat, Magnus Damm

On Mon, Mar 25, 2013 at 12:31:20PM +0100, Thomas Gleixner wrote:
> On Fri, 22 Mar 2013, Kevin Hilman wrote:
> 
> > Hi Thomas,
> > 
> > Thomas Gleixner <tglx@linutronix.de> writes:
> > 
> > > Use the generic idle loop and replace enable/disable_hlt with the
> > > respective core functions.
> > >
> > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > > Cc: Russell King <linux@arm.linux.org.uk>
> > 
> > I gave patches 1-5 + this a quick spin on ARM (specifially some OMAP3 and
> > OMAP4 platforms, with and without CPUidle enabled.)
> > 
> > The OMAP stuff needed a couple minor compile fixes (below), but
> > otherwise it passes the quick "seems to work" test.
> 
> Yeah, that's needed for the other arch/arm conversions as well.

So, the only patch I got was this one, which is useless to test on its
own...

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 08/34] arm: Use generic idle loop
  2013-03-25 11:48       ` Russell King - ARM Linux
@ 2013-03-25 14:02         ` Thomas Gleixner
  2013-04-08 21:47           ` Russell King - ARM Linux
  0 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-25 14:02 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Kevin Hilman, LKML, linux-arch, Linus Torvalds, Andrew Morton,
	Rusty Russell, Paul McKenney, Ingo Molnar, Peter Zijlstra,
	Srivatsa S. Bhat, Magnus Damm

On Mon, 25 Mar 2013, Russell King - ARM Linux wrote:

> On Mon, Mar 25, 2013 at 12:31:20PM +0100, Thomas Gleixner wrote:
> > On Fri, 22 Mar 2013, Kevin Hilman wrote:
> > 
> > > Hi Thomas,
> > > 
> > > Thomas Gleixner <tglx@linutronix.de> writes:
> > > 
> > > > Use the generic idle loop and replace enable/disable_hlt with the
> > > > respective core functions.
> > > >
> > > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > > > Cc: Russell King <linux@arm.linux.org.uk>
> > > 
> > > I gave patches 1-5 + this a quick spin on ARM (specifially some OMAP3 and
> > > OMAP4 platforms, with and without CPUidle enabled.)
> > > 
> > > The OMAP stuff needed a couple minor compile fixes (below), but
> > > otherwise it passes the quick "seems to work" test.
> > 
> > Yeah, that's needed for the other arch/arm conversions as well.
> 
> So, the only patch I got was this one, which is useless to test on its
> own...

I'm testing V2 now and will post an git URL with a testing branch
later tonight.

Thanks,

	tglx


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 09/34] arm64: Use generic idle loop
  2013-03-21 21:53 ` [patch 09/34] arm64: " Thomas Gleixner
@ 2013-03-25 18:06   ` Catalin Marinas
  2013-04-08 20:18   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: Catalin Marinas @ 2013-03-25 18:06 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On Thu, Mar 21, 2013 at 09:53:03PM +0000, Thomas Gleixner wrote:
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> ---
> Index: linux-2.6/arch/arm64/Kconfig
> ===================================================================
> --- linux-2.6.orig/arch/arm64/Kconfig
> +++ linux-2.6/arch/arm64/Kconfig
> @@ -14,6 +14,7 @@ config ARM64
>  	select GENERIC_IRQ_PROBE
>  	select GENERIC_IRQ_SHOW
>  	select GENERIC_SMP_IDLE_THREAD
> +	select GENERIC_IDLE_LOOP
>  	select GENERIC_TIME_VSYSCALL
>  	select HARDIRQS_SW_RESEND
>  	select HAVE_ARCH_TRACEHOOK

Minor thing, I try to keep these entries alphabetically sorted (it won't
last long, I'm sure). Otherwise,

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 13/34] cris: Use generic idle loop
  2013-03-21 21:53 ` [patch 13/34] cris: " Thomas Gleixner
@ 2013-03-27 15:04   ` Jesper Nilsson
  2013-03-27 17:10     ` Thomas Gleixner
  2013-04-08 20:23   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  1 sibling, 1 reply; 147+ messages in thread
From: Jesper Nilsson @ 2013-03-27 15:04 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm


On Thu, Mar 21, 2013 at 09:53:06PM -0000, Thomas Gleixner wrote:
[snip]
> Index: linux-2.6/arch/cris/arch-v32/kernel/process.c
> ===================================================================
> --- linux-2.6.orig/arch/cris/arch-v32/kernel/process.c
> +++ linux-2.6/arch/cris/arch-v32/kernel/process.c
> @@ -23,12 +23,10 @@ extern void stop_watchdog(void);
>  /* We use this if we don't have any better idle routine. */
>  void default_idle(void)
>  {
> -	local_irq_disable();
> -	if (!need_resched()) {
> -		/* Halt until exception. */
> -		__asm__ volatile("ei    \n\t"
> -				 "halt      ");
> -	}
> +	/* Halt until exception. */
> +	__asm__ volatile("ei    \n\t"
> +			 "halt      ");
> +	/* CHECKME: Is this really needed ?? */
>  	local_irq_enable();

No, that local_irq_enable() is redundant since we already enabled interrupts
in the assembler directive above.

>  }

Looks good,

Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>

/^JN - Jesper Nilsson
-- 
               Jesper Nilsson -- jesper.nilsson@axis.com

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 13/34] cris: Use generic idle loop
  2013-03-27 15:04   ` Jesper Nilsson
@ 2013-03-27 17:10     ` Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-27 17:10 UTC (permalink / raw)
  To: Jesper Nilsson
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On Wed, 27 Mar 2013, Jesper Nilsson wrote:
> 
> On Thu, Mar 21, 2013 at 09:53:06PM -0000, Thomas Gleixner wrote:
> [snip]
> > Index: linux-2.6/arch/cris/arch-v32/kernel/process.c
> > ===================================================================
> > --- linux-2.6.orig/arch/cris/arch-v32/kernel/process.c
> > +++ linux-2.6/arch/cris/arch-v32/kernel/process.c
> > @@ -23,12 +23,10 @@ extern void stop_watchdog(void);
> >  /* We use this if we don't have any better idle routine. */
> >  void default_idle(void)
> >  {
> > -	local_irq_disable();
> > -	if (!need_resched()) {
> > -		/* Halt until exception. */
> > -		__asm__ volatile("ei    \n\t"
> > -				 "halt      ");
> > -	}
> > +	/* Halt until exception. */
> > +	__asm__ volatile("ei    \n\t"
> > +			 "halt      ");
> > +	/* CHECKME: Is this really needed ?? */
> >  	local_irq_enable();
> 
> No, that local_irq_enable() is redundant since we already enabled interrupts
> in the assembler directive above.

That's what I thought:) Will remove it.
 
Thanks,

	tglx

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 00/34] idle: Consolidate idle implementations
       [not found]   ` <5153EC43.7070808@zankel.net>
@ 2013-03-28  9:24     ` Thomas Gleixner
  2013-03-28 22:16       ` Chris Zankel
  0 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-28  9:24 UTC (permalink / raw)
  To: Chris Zankel; +Cc: LKML, linux-arch

On Thu, 28 Mar 2013, Chris Zankel wrote:

> For Xtensa:
> Acked-by: Chris Zankel <chris@zankel.net>
> 
> Thanks for going the extra mile and test-compiling it.

Though, the build fails later with:

arch/xtensa/kernel/built-in.o:(.init.literal+0x90): undefined reference to `platform_pcibios_init'
arch/xtensa/kernel/built-in.o: In function `setup_arch':
(.init.text+0x1de): undefined reference to `platform_pcibios_init'
drivers/built-in.o: In function `pci_assign_unassigned_resources':
(.init.text+0x52b): dangerous relocation: call8: call target out of range: (.ref.text+0x3ac)
drivers/built-in.o: In function `pci_assign_unassigned_resources':
(.init.text+0x5b5): dangerous relocation: call8: call target out of range: (.ref.text+0x2c8)
drivers/built-in.o: In function `sysrq_init':
sysrq.c:(.init.text+0xb61): dangerous relocation: call8: call target out of range: panic
drivers/built-in.o: In function `console_map_init':
(.init.text+0xc97): dangerous relocation: call8: call target out of range: printk
drivers/built-in.o: In function `vtconsole_class_init':
vt.c:(.init.text+0xcdd): dangerous relocation: call8: call target out of range: printk
drivers/built-in.o: In function `con_init':
vt.c:(.init.text+0xe75): dangerous relocation: call8: call target out of range: printk
vt.c:(.init.text+0xece): dangerous relocation: call8: call target out of range: panic
drivers/built-in.o: In function `vty_init':
(.init.text+0xf32): dangerous relocation: call8: call target out of range: panic
drivers/built-in.o: In function `vty_init':
(.init.text+0xf8e): dangerous relocation: call8: call target out of range: panic
drivers/built-in.o: In function `serial8250_isa_init_ports':
8250.c:(.init.text+0x10ea): dangerous relocation: call8: call target out of range: printk
drivers/built-in.o: In function `setup_early_serial8250_console':
(.init.text+0x1450): dangerous relocation: call8: call target out of range: printk
drivers/built-in.o: In function `setup_early_serial8250_console':
(.init.text+0x1456): dangerous relocation: call8: call target out of range: panic
drivers/built-in.o: In function `setup_early_serial8250_console':
(.init.text+0x1461): dangerous relocation: call8: call target out of range: printk
drivers/built-in.o: In function `setup_early_serial8250_console':
(.init.text+0x155d): dangerous relocation: call8: call target out of range: printk
drivers/built-in.o: In function `setup_early_serial8250_console':
(.init.text+0x156e): dangerous relocation: call8: call target out of range: printk
drivers/built-in.o: In function `setup_early_serial8250_console':
(.init.text+0x1625): dangerous relocation: call8: call target out of range: printk
drivers/built-in.o: In function `chr_dev_init':
mem.c:(.init.text+0x16e6): dangerous relocation: call8: call target out of range: printk
drivers/built-in.o: In function `random_int_secret_init':
random.c:(.init.text+0x171a): dangerous relocation: call8: call target out of range: printk
drivers/built-in.o: In function `misc_init':
misc.c:(.init.text+0x1765): dangerous relocation: call8: call target out of range: printk
misc.c:(.init.text+0x1789): dangerous relocation: call8: call target out of range: printk
net/built-in.o: In function `synchronize_net':
(.text+0xc650): dangerous relocation: call8: misaligned call target: (.text.unlikely+0x43)
net/built-in.o: In function `alloc_netdev_mqs':
(.text+0xc7ed): dangerous relocation: call8: misaligned call target: (.text.unlikely+0x43)
net/built-in.o: In function `netlink_proto_init':
af_netlink.c:(.init.text+0x7a9): dangerous relocation: call8: call target out of range: (.text.unlikely+0xa4)
make[1]: *** [vmlinux] Error 1

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 07/34] alpha: Use generic idle loop
  2013-03-21 21:53 ` [patch 07/34] alpha: Use generic idle loop Thomas Gleixner
@ 2013-03-28 15:37   ` Srivatsa S. Bhat
  2013-03-29 11:22     ` Thomas Gleixner
  2013-04-08 20:16   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  1 sibling, 1 reply; 147+ messages in thread
From: Srivatsa S. Bhat @ 2013-03-28 15:37 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Magnus Damm,
	Richard Henderson, Ivan Kokshaysky, Matt Turner

On 03/22/2013 03:23 AM, Thomas Gleixner wrote:
> The core provides a generic idle poll loop.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Richard Henderson <rth@twiddle.net>
> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> Cc: Matt Turner <mattst88@gmail.com>
> ---
>  arch/alpha/Kconfig          |    1 +
>  arch/alpha/kernel/process.c |   19 -------------------
>  arch/alpha/kernel/smp.c     |    3 +--
>  3 files changed, 2 insertions(+), 21 deletions(-)
> 
> Index: linux-2.6/arch/alpha/Kconfig
> ===================================================================
> --- linux-2.6.orig/arch/alpha/Kconfig
> +++ linux-2.6/arch/alpha/Kconfig
> @@ -17,6 +17,7 @@ config ALPHA
>  	select ARCH_WANT_IPC_PARSE_VERSION
>  	select ARCH_HAVE_NMI_SAFE_CMPXCHG
>  	select GENERIC_SMP_IDLE_THREAD
> +	select GENERIC_IDLE_LOOP
>  	select GENERIC_CMOS_UPDATE
>  	select GENERIC_STRNCPY_FROM_USER
>  	select GENERIC_STRNLEN_USER
> Index: linux-2.6/arch/alpha/kernel/process.c
> ===================================================================
> --- linux-2.6.orig/arch/alpha/kernel/process.c
> +++ linux-2.6/arch/alpha/kernel/process.c
> @@ -46,25 +46,6 @@
>  void (*pm_power_off)(void) = machine_power_off;
>  EXPORT_SYMBOL(pm_power_off);
> 
> -void
> -cpu_idle(void)
> -{
> -	current_thread_info()->status |= TS_POLLING;
> -
> -	while (1) {
> -		/* FIXME -- EV6 and LCA45 know how to power down
> -		   the CPU.  */
> -
> -		rcu_idle_enter();
> -		while (!need_resched())
> -			cpu_relax();
> -
> -		rcu_idle_exit();
> -		schedule_preempt_disabled();
> -	}
> -}
> -
> -

(In all my replies, I'm referring to the code in your v2 on your git
tree, but replying to the corresponding patches in your v1).

So, in alpha, we poll in cpu idle. In the generic implementation in
kernel/cpu/idle.c, arch_cpu_idle() is defined as:

void __weak arch_cpu_idle(void)
{
        cpu_idle_poll();
}

Should it not have been:

void __weak arch_cpu_idle(void)
{
	current_set_polling();
        cpu_idle_poll();
	current_clr_polling();
}

instead?

Regards,
Srivatsa S. Bhat

>  struct halt_info {
>  	int mode;
>  	char *restart_cmd;
> Index: linux-2.6/arch/alpha/kernel/smp.c
> ===================================================================
> --- linux-2.6.orig/arch/alpha/kernel/smp.c
> +++ linux-2.6/arch/alpha/kernel/smp.c
> @@ -167,8 +167,7 @@ smp_callin(void)
>  	      cpuid, current, current->active_mm));
> 
>  	preempt_disable();
> -	/* Do nothing.  */
> -	cpu_idle();
> +	cpu_startup_entry(CPUHP_ONLINE);
>  }
> 
>  /* Wait until hwrpb->txrdy is clear for cpu.  Return -1 on timeout.  */
> 
> 



^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 05/34] idle: Implement generic idle function
  2013-03-21 21:53 ` [patch 05/34] idle: Implement generic idle function Thomas Gleixner
  2013-03-23  8:56   ` Heiko Carstens
@ 2013-03-28 15:39   ` Srivatsa S. Bhat
  2013-04-08 20:14   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  2013-11-18  6:05   ` [patch 05/34] idle: Implement generic idle function Viresh Kumar
  3 siblings, 0 replies; 147+ messages in thread
From: Srivatsa S. Bhat @ 2013-03-28 15:39 UTC (permalink / raw)
  To: Thomas Gleixner, Deepthi Dharwar, Rafael J. Wysocki
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Magnus Damm

On 03/22/2013 03:23 AM, Thomas Gleixner wrote:
> All idle functions in arch/* are more or less the same, plus minus a
> few bugs and extra instrumentation, tickless support and other
> optional items.
> 
> Implement a generic idle function which resembles the functionality
> found in arch/. Provide weak arch_cpu_idle_* functions which can be
> overridden by the architecture code if needed.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  arch/Kconfig        |    3 +
>  include/linux/cpu.h |    8 +++
>  kernel/cpu/idle.c   |  105 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 116 insertions(+)
[...]
> +
> +/*
> + * Generic idle loop implementation
> + */
> +static void cpu_idle_loop(void)
> +{
> +	while (1) {
> +		tick_nohz_idle_enter();
> +
> +		while (!need_resched()) {
> +			check_pgt_cache();
> +			rmb();
> +
> +			if (cpu_is_offline(smp_processor_id()))
> +				arch_cpu_idle_dead();
> +
> +			local_irq_disable();
> +			arch_cpu_idle_enter();
> +
> +			if (cpu_idle_force_poll) {
> +				cpu_idle_poll();
> +			} else {
> +				current_clr_polling();
> +				if (!need_resched()) {
> +					stop_critical_timings();
> +					rcu_idle_enter();
> +					arch_cpu_idle();
> +					WARN_ON_ONCE(!irqs_disabled());

I understand that you have changed it to WARN_ON_ONCE(irqs_disabled()) in
the v2 hosted in your git tree..

Sometime ago, Deepthi (in CC) had added such a check and Rafael had faced
some weird problems with that, and hence it was removed. Below are some
links to that discussion.

https://lkml.org/lkml/2012/6/22/48
https://lkml.org/lkml/2012/6/24/132
https://lkml.org/lkml/2012/6/25/402

Rafael, do you still see that problem after applying Thomas' patches?

> +					rcu_idle_exit();
> +					start_critical_timings();
> +				} else {
> +					local_irq_enable();
> +				}
> +				current_set_polling();
> +			}
> +			arch_cpu_idle_exit();
> +		}
> +		tick_nohz_idle_exit();
> +		schedule_preempt_disabled();
> +	}
> +}
> +
> +void cpu_startup_entry(enum cpuhp_state state)
> +{
> +	current_set_polling();
> +	arch_cpu_idle_prepare();
> +	cpu_idle_loop();
> +}
> +#endif
> 
> 

Regards,
Srivatsa S. Bhat


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 26/34] powerpc: Use generic idle loop
  2013-03-21 21:53 ` [patch 26/34] powerpc: " Thomas Gleixner
@ 2013-03-28 15:40   ` Srivatsa S. Bhat
  2013-04-01  9:13     ` Deepthi Dharwar
  2013-04-08 20:39   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  1 sibling, 1 reply; 147+ messages in thread
From: Srivatsa S. Bhat @ 2013-03-28 15:40 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Magnus Damm,
	Benjamin Herrenschmidt, Deepthi Dharwar, Preeti U Murthy,
	Vaidyanathan Srinivasan

On 03/22/2013 03:23 AM, Thomas Gleixner wrote:
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
[...]
> Index: linux-2.6/arch/powerpc/kernel/idle.c
> ===================================================================
> --- linux-2.6.orig/arch/powerpc/kernel/idle.c
> +++ linux-2.6/arch/powerpc/kernel/idle.c
> @@ -50,64 +50,30 @@ static int __init powersave_off(char *ar
>  }
>  __setup("powersave=off", powersave_off);
> 
> -/*
> - * The body of the idle task.
> - */
> -void cpu_idle(void)
> +void arch_cpu_idle(void)
>  {
> -	set_thread_flag(TIF_POLLING_NRFLAG);
> -	while (1) {
> -		tick_nohz_idle_enter();
> -		rcu_idle_enter();
> -
> -		while (!need_resched() && !cpu_should_die()) {
> -			ppc64_runlatch_off();
> -
> -			if (ppc_md.power_save) {
> -				clear_thread_flag(TIF_POLLING_NRFLAG);
> -				/*
> -				 * smp_mb is so clearing of TIF_POLLING_NRFLAG
> -				 * is ordered w.r.t. need_resched() test.
> -				 */
> -				smp_mb();
> -				local_irq_disable();
> -
> -				/* Don't trace irqs off for idle */
> -				stop_critical_timings();
> -
> -				/* check again after disabling irqs */
> -				if (!need_resched() && !cpu_should_die())
> -					ppc_md.power_save();
> -
> -				start_critical_timings();
> -
> -				/* Some power_save functions return with
> -				 * interrupts enabled, some don't.
> -				 */
> -				if (irqs_disabled())
> -					local_irq_enable();
> -				set_thread_flag(TIF_POLLING_NRFLAG);
> -
> -			} else {
> -				/*
> -				 * Go into low thread priority and possibly
> -				 * low power mode.
> -				 */
> -				HMT_low();
> -				HMT_very_low();
> -			}
> -		}
> -
> -		HMT_medium();
> -		ppc64_runlatch_on();
> -		rcu_idle_exit();
> -		tick_nohz_idle_exit();
> -		if (cpu_should_die()) {
> -			sched_preempt_enable_no_resched();
> -			cpu_die();
> -		}
> -		schedule_preempt_disabled();
> +	ppc64_runlatch_off();
> +
> +	if (ppc_md.power_save) {
> +		ppc_md.power_save();
> +		/*
> +		 * Some power_save functions return with
> +		 * interrupts enabled, some don't.
> +		 */
> +		if (irqs_disabled())
> +			local_irq_enable();
> +	} else {
> +		local_irq_enable();
> +		/*
> +		 * Go into low thread priority and possibly
> +		 * low power mode.
> +		 */
> +		HMT_low();
> +		HMT_very_low();
>  	}
> +
> +	HMT_medium();
> +	ppc64_runlatch_on();
>  }
> 


The call to cpu_die() seems to be missing. And considering this commit,

commit a7c2bb8279d20d853e43c34584eaf2b039de8026
Author: Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
Date:   Wed Aug 4 18:28:33 2010 +0000

    powerpc: Re-enable preemption before cpu_die()

we need to call it with preempt enabled. So how about folding the
following diff with this patch?


diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
index b751baa..e434fb9 100644
--- a/arch/powerpc/kernel/idle.c
+++ b/arch/powerpc/kernel/idle.c
@@ -33,11 +33,6 @@
 #include <asm/runlatch.h>
 #include <asm/smp.h>
 
-#ifdef CONFIG_HOTPLUG_CPU
-#define cpu_should_die()	cpu_is_offline(smp_processor_id())
-#else
-#define cpu_should_die()	0
-#endif
 
 unsigned long cpuidle_disable = IDLE_NO_OVERRIDE;
 EXPORT_SYMBOL(cpuidle_disable);
@@ -50,6 +45,12 @@ static int __init powersave_off(char *arg)
 }
 __setup("powersave=off", powersave_off);
 
+void arch_cpu_idle_dead(void)
+{
+	sched_preempt_enable_no_resched();
+	cpu_die();
+}
+
 void arch_cpu_idle(void)
 {
 	ppc64_runlatch_off();

 
Regards,
Srivatsa S. Bhat


^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [patch 29/34] sh: Use generic idle loop
  2013-03-21 21:53 ` [patch 29/34] sh: " Thomas Gleixner
@ 2013-03-28 15:40   ` Srivatsa S. Bhat
  2013-04-08 20:42   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: Srivatsa S. Bhat @ 2013-03-28 15:40 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Magnus Damm,
	Paul Mundt

On 03/22/2013 03:23 AM, Thomas Gleixner wrote:
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Paul Mundt <lethal@linux-sh.org>
> ---
[...]

> -/*
> - * The idle thread. There's no useful work to be done, so just try to conserve
> - * power and have a low exit latency (ie sit in a loop waiting for somebody to
> - * say that they'd like to reschedule)
> - */
> -void cpu_idle(void)
> +void arch_cpu_idle(void)
>  {
> -	unsigned int cpu = smp_processor_id();
> -
> -	set_thread_flag(TIF_POLLING_NRFLAG);
> -
> -	/* endless idle loop with no priority at all */
> -	while (1) {
> -		tick_nohz_idle_enter();
> -		rcu_idle_enter();
> -
> -		while (!need_resched()) {
> -			check_pgt_cache();
> -			rmb();
> -
> -			if (cpu_is_offline(cpu))
> -				play_dead();
> -
> -			local_irq_disable();
> -			/* Don't trace irqs off for idle */
> -			stop_critical_timings();
> -			if (cpuidle_idle_call())
> -				sh_idle();
> -			/*
> -			 * Sanity check to ensure that sh_idle() returns
> -			 * with IRQs enabled
> -			 */
> -			WARN_ON(irqs_disabled());
> -			start_critical_timings();
> -		}
> -
> -		rcu_idle_exit();
> -		tick_nohz_idle_exit();
> -		schedule_preempt_disabled();
> -	}
> +	if (cpuidle_idle_call())
> +		sh_idle();
>  }
> 

Missing call to play_dead(). Perhaps you can fold the following diff:


diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c
index 8b9d5d7..2ea4483 100644
--- a/arch/sh/kernel/idle.c
+++ b/arch/sh/kernel/idle.c
@@ -33,6 +33,11 @@ void default_idle(void)
 	clear_bl_bit();
 }
 
+void arch_cpu_idle_dead(void)
+{
+	play_dead();
+}
+
 void arch_cpu_idle(void)
 {
 	if (cpuidle_idle_call())


Regards,
Srivatsa S. Bhat


^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [patch 17/34] ia64: Use generic idle loop
  2013-03-21 21:53 ` [patch 17/34] ia64: " Thomas Gleixner
@ 2013-03-28 15:40   ` Srivatsa S. Bhat
  2013-04-08 20:28   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: Srivatsa S. Bhat @ 2013-03-28 15:40 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Magnus Damm,
	Tony Luck

On 03/22/2013 03:23 AM, Thomas Gleixner wrote:
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Tony Luck <tony.luck@intel.com>
> ---
>  arch/ia64/Kconfig          |    1 
>  arch/ia64/kernel/perfmon.c |   13 ++-----
>  arch/ia64/kernel/process.c |   83 +++++++++------------------------------------
>  arch/ia64/kernel/smpboot.c |    2 -
>  4 files changed, 23 insertions(+), 76 deletions(-)
> 
[...]
> -void
> -update_pal_halt_status(int status)
> -{
> -	can_do_pal_halt = pal_halt && status;
> -}
> -
> -/*
> - * We use this if we don't have any better idle routine..
> - */
> -void
> -default_idle (void)
> -{
> -	local_irq_enable();
> -	while (!need_resched()) {
> -		if (can_do_pal_halt) {
> -			local_irq_disable();
> -			if (!need_resched()) {
> -				safe_halt();
> -			}
> -			local_irq_enable();
> -		} else
> -			cpu_relax();
> -	}
> -}
> -
 
We can also get rid of the function prototype declaration of default_idle()
inside arch/ia64/include/asm/processor.h

Regards,
Srivatsa S. Bhat


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 31/34] tile: Use generic idle loop
  2013-03-21 21:53 ` [patch 31/34] tile: Use generic idle loop Thomas Gleixner
@ 2013-03-28 15:41   ` Srivatsa S. Bhat
  2013-03-29 11:24     ` Thomas Gleixner
  2013-04-08 20:45   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  1 sibling, 1 reply; 147+ messages in thread
From: Srivatsa S. Bhat @ 2013-03-28 15:41 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Magnus Damm,
	Chris Metcalf

On 03/22/2013 03:23 AM, Thomas Gleixner wrote:
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Chris Metcalf <cmetcalf@tilera.com>
> ---
>  arch/tile/kernel/process.c |   61 ++++-----------------------------------------
>  arch/tile/kernel/smpboot.c |    2 -
>  2 files changed, 7 insertions(+), 56 deletions(-)
> 
> Index: linux-2.6/arch/tile/kernel/process.c
> ===================================================================
> --- linux-2.6.orig/arch/tile/kernel/process.c
> +++ linux-2.6/arch/tile/kernel/process.c
> @@ -40,13 +40,11 @@
>  #include <arch/abi.h>
>  #include <arch/sim_def.h>
> 
> -
>  /*
>   * Use the (x86) "idle=poll" option to prefer low latency when leaving the
>   * idle loop over low power while in the idle loop, e.g. if we have
>   * one thread per core and we want to get threads out of futex waits fast.
>   */
> -static int no_idle_nap;
>  static int __init idle_setup(char *str)
>  {
>  	if (!str)
> @@ -54,64 +52,17 @@ static int __init idle_setup(char *str)
> 
>  	if (!strcmp(str, "poll")) {
>  		pr_info("using polling idle threads.\n");
> -		no_idle_nap = 1;
> +		cpu_idle_poll_ctrl(true);
>  	} else if (!strcmp(str, "halt"))
> -		no_idle_nap = 0;
> -	else
> -		return -1;
> -
> -	return 0;
> +		return 0;
> +	return -1;
>  }
>  early_param("idle", idle_setup);
>

That doesn't look quite right, since it returns -1 (instead of 0) when
str == poll.

Regards,
Srivatsa S. Bhat


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 22/34] mips: Use generic idle loop
  2013-03-21 21:53 ` [patch 22/34] mips: " Thomas Gleixner
@ 2013-03-28 15:42   ` Srivatsa S. Bhat
  2013-04-08 20:34   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: Srivatsa S. Bhat @ 2013-03-28 15:42 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Magnus Damm,
	Ralf Baechle

On 03/22/2013 03:23 AM, Thomas Gleixner wrote:
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> ---
>  arch/mips/Kconfig          |    1 
>  arch/mips/kernel/process.c |   46 ++++++++++++---------------------------------
>  arch/mips/kernel/smp.c     |    2 -
>  3 files changed, 15 insertions(+), 34 deletions(-)
>
[...]
 
> Index: linux-2.6/arch/mips/kernel/process.c
> ===================================================================
> --- linux-2.6.orig/arch/mips/kernel/process.c
> +++ linux-2.6/arch/mips/kernel/process.c
> @@ -41,44 +41,24 @@
>  #include <asm/inst.h>
>  #include <asm/stacktrace.h>
> 
> -/*
> - * The idle thread. There's no useful work to be done, so just try to conserve
> - * power and have a low exit latency (ie sit in a loop waiting for somebody to
> - * say that they'd like to reschedule)
> - */
> -void __noreturn cpu_idle(void)
> +void arch_cpu_idle_dead(void)
>  {
> -	int cpu;
> -
> -	/* CPU is going idle. */
> -	cpu = smp_processor_id();
> +	/* What the heck is this check doing ? */
> +	if (!cpu_isset(cpu, cpu_callin_map))
> +		play_dead();}

Extra closing brace?

> +}
> 
> -	/* endless idle loop with no priority at all */
> -	while (1) {
> -		tick_nohz_idle_enter();
> -		rcu_idle_enter();
> -		while (!need_resched() && cpu_online(cpu)) {
> +void arch__cpu_idle(void)

s/arch__cpu_idle/arch_cpu_idle (single underscore)


Regards,
Srivatsa S. Bhat

> +{
>  #ifdef CONFIG_MIPS_MT_SMTC
> -			extern void smtc_idle_loop_hook(void);
> +	extern void smtc_idle_loop_hook(void);
> 
> -			smtc_idle_loop_hook();
> +	smtc_idle_loop_hook();
>  #endif
> -
> -			if (cpu_wait) {
> -				/* Don't trace irqs off for idle */
> -				stop_critical_timings();
> -				(*cpu_wait)();
> -				start_critical_timings();
> -			}
> -		}
> -#ifdef CONFIG_HOTPLUG_CPU
> -		if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map))
> -			play_dead();
> -#endif
> -		rcu_idle_exit();
> -		tick_nohz_idle_exit();
> -		schedule_preempt_disabled();
> -	}
> +	if (cpu_wait)
> +		(*cpu_wait)();
> +	else
> +		local_irq_enable();
>  }
> 


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 30/34] tile: Enter idle with preemption disabled
  2013-03-21 21:53 ` [patch 30/34] tile: Enter idle with preemption disabled Thomas Gleixner
  2013-03-22 20:34     ` Chris Metcalf
  2013-03-22 20:40     ` Chris Metcalf
@ 2013-03-28 15:43   ` Srivatsa S. Bhat
  2013-04-08 20:44   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  3 siblings, 0 replies; 147+ messages in thread
From: Srivatsa S. Bhat @ 2013-03-28 15:43 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Magnus Damm,
	Chris Metcalf

On 03/22/2013 03:23 AM, Thomas Gleixner wrote:
> cpu_idle() needs to be called with preemption disabled.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Chris Metcalf <cmetcalf@tilera.com>
> ---
>  arch/tile/kernel/smpboot.c |    2 --
>  1 file changed, 2 deletions(-)
> 
> Index: linux-2.6/arch/tile/kernel/smpboot.c
> ===================================================================
> --- linux-2.6.orig/arch/tile/kernel/smpboot.c
> +++ linux-2.6/arch/tile/kernel/smpboot.c
> @@ -207,8 +207,6 @@ void __cpuinit online_secondary(void)
>  	/* Set up tile-timer clock-event device on this cpu */
>  	setup_tile_timer();
> 
> -	preempt_enable();
> -

Hmm, so shouldn't we call preempt_disabled() here?

I see that start_secondary() calls preempt_disabled(), but I didn't quite
understand as to which of the *_secondary() functions have to call
it... especially since its the online_secondary() function which calls
cpu_idle().

>  	cpu_idle();
>  }
> 
> 
> 
 
Regards,
Srivatsa S. Bhat


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 33/34] x86: Use generic idle loop
  2013-03-21 21:53 ` [patch 33/34] x86: " Thomas Gleixner
@ 2013-03-28 15:43   ` Srivatsa S. Bhat
  2013-04-08 20:47   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: Srivatsa S. Bhat @ 2013-03-28 15:43 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Magnus Damm, x86

On 03/22/2013 03:23 AM, Thomas Gleixner wrote:
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: x86@kernel.org
> ---
[...]
> +#define POLL_IDLE	(void*) 0x01
> +

[...]

>  #ifdef CONFIG_APM_MODULE
> @@ -411,20 +376,6 @@ void stop_this_cpu(void *dummy)
>  		halt();
>  }
> 
> -/*
> - * On SMP it's slightly faster (but much more power-consuming!)
> - * to poll the ->work.need_resched flag instead of waiting for the
> - * cross-CPU IPI to arrive. Use this option with caution.
> - */
> -static void poll_idle(void)
> -{
> -	trace_cpu_idle_rcuidle(0, smp_processor_id());
> -	local_irq_enable();
> -	while (!need_resched())
> -		cpu_relax();
> -	trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
> -}
> -
>  bool amd_e400_c1e_detected;
>  EXPORT_SYMBOL(amd_e400_c1e_detected);
> 
> @@ -489,7 +440,7 @@ static void amd_e400_idle(void)
>  void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
>  {
>  #ifdef CONFIG_SMP
> -	if (x86_idle == poll_idle && smp_num_siblings > 1)
> +	if (x86_idle == POLL_IDLE && smp_num_siblings > 1)
>  		pr_warn_once("WARNING: polling idle and HT enabled, performance may degrade\n");
>  #endif
>  	if (x86_idle)
> @@ -517,8 +468,9 @@ static int __init idle_setup(char *str)
> 
>  	if (!strcmp(str, "poll")) {
>  		pr_info("using polling idle threads\n");
> -		x86_idle = poll_idle;
> +		x86_idle = POLL_IDLE;
>  		boot_option_idle_override = IDLE_POLL;
> +		cpu_idle_poll_ctrl(true);

Why is that POLL_IDLE needed? Won't cpu_idle_poll_ctrl() suffice?

By the way, booting with idle=poll locks up the kernel during boot with
this patch applied (I verified it). So I think we should just skip the
whole POLL_IDLE thing and leave the job to cpu_idle_poll_ctrl().

 
Regards,
Srivatsa S. Bhat


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 00/34] idle: Consolidate idle implementations
  2013-03-28  9:24     ` Thomas Gleixner
@ 2013-03-28 22:16       ` Chris Zankel
  0 siblings, 0 replies; 147+ messages in thread
From: Chris Zankel @ 2013-03-28 22:16 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, linux-arch

Hi Thomas,

On 3/28/13 2:24 AM, Thomas Gleixner wrote:
> On Thu, 28 Mar 2013, Chris Zankel wrote:
>
>> For Xtensa:
>> Acked-by: Chris Zankel <chris@zankel.net>
>>
>> Thanks for going the extra mile and test-compiling it.
> Though, the build fails later with:
>
> arch/xtensa/kernel/built-in.o:(.init.literal+0x90): undefined reference to `platform_pcibios_init'
> arch/xtensa/kernel/built-in.o: In function `setup_arch':
> (.init.text+0x1de): undefined reference to `platform_pcibios_init'
> drivers/built-in.o: In function `pci_assign_unassigned_resources':
[...]

Thanks for the info. With KALLSYMS enabled, the .rodata section between 
the .text and the .init.text section is extended to a point where it 
exceeds the call range between those sections. I'm working on a fix 
(basically, move the .init.text section close to the .init section).

Thanks,
-Chris


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 07/34] alpha: Use generic idle loop
  2013-03-28 15:37   ` Srivatsa S. Bhat
@ 2013-03-29 11:22     ` Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-29 11:22 UTC (permalink / raw)
  To: Srivatsa S. Bhat
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Magnus Damm,
	Richard Henderson, Ivan Kokshaysky, Matt Turner

On Thu, 28 Mar 2013, Srivatsa S. Bhat wrote:
> (In all my replies, I'm referring to the code in your v2 on your git
> tree, but replying to the corresponding patches in your v1).
> 
> So, in alpha, we poll in cpu idle. In the generic implementation in
> kernel/cpu/idle.c, arch_cpu_idle() is defined as:
> 
> void __weak arch_cpu_idle(void)
> {
>         cpu_idle_poll();
> }
> 
> Should it not have been:
> 
> void __weak arch_cpu_idle(void)
> {
> 	current_set_polling();
>         cpu_idle_poll();
> 	current_clr_polling();
> }
> 
> instead?

Hmm, we should not clear it at all, because we are always polling and
never leave polling mode. So instead of calling cpu_idle_poll from the
weak arch_cpu_idle() we should set cpu_idle_force_poll so we drop into

	if (cpu_idle_force_poll) {
		cpu_idle_poll();
	} else ...

which keeps the polling flag set.

Thanks,

	tglx



^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 31/34] tile: Use generic idle loop
  2013-03-28 15:41   ` Srivatsa S. Bhat
@ 2013-03-29 11:24     ` Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-03-29 11:24 UTC (permalink / raw)
  To: Srivatsa S. Bhat
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Magnus Damm,
	Chris Metcalf

On Thu, 28 Mar 2013, Srivatsa S. Bhat wrote:
> 
> That doesn't look quite right, since it returns -1 (instead of 0) when
> str == poll.

Stupid me.

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 00/34] idle: Consolidate idle implementations
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
                   ` (35 preceding siblings ...)
       [not found] ` <alpine.LFD.2.02.1303271940150.22263@ionos>
@ 2013-03-29 16:19 ` Sam Ravnborg
  2013-03-29 20:29   ` [PATCH] sparc: Use generic idle loop Sam Ravnborg
  2013-05-03  9:47   ` Geert Uytterhoeven
  37 siblings, 1 reply; 147+ messages in thread
From: Sam Ravnborg @ 2013-03-29 16:19 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm

On Thu, Mar 21, 2013 at 09:52:56PM -0000, Thomas Gleixner wrote:
> Each architecture implements its own cpu_idle() code, which is more or
> less the same on all architectures (plus/minus a few bugs and a few
> missing extra functionalities, instrumentation ...). That also forces
> everyone who is interested in idle related features to add new
> functionality to every architecture. What a waste.
> 
> Aside of that pointless code duplicaiton the ongoing quest to
> consolidate the cpu hotplug code needs a common entry point for the
> non boot cpus.
> 
> The following series implements a generic idle function and converts
> most architectures over. I left out SPARC (it involves sparc asm) and
> UM (it made me barf). If we can move those architectures as well, we
> can get rid of the extra config switch and have everything
> consolidated.
> 
> I spent a lot of time to make sure that the conversion preserved the
> non obvious differences of the architecture implementations, but I
> really need help from the affected maintainers to prove the
> correctness.

Hi Thomas.

Where can I find the git tree with the latest patches?
Or do you plan to submit a v2 soon?

	Sam

^ permalink raw reply	[flat|nested] 147+ messages in thread

* [PATCH] sparc: Use generic idle loop
  2013-03-29 16:19 ` Sam Ravnborg
@ 2013-03-29 20:29   ` Sam Ravnborg
  2013-03-31 23:46     ` David Miller
  2013-04-01  6:53     ` Srivatsa S. Bhat
  0 siblings, 2 replies; 147+ messages in thread
From: Sam Ravnborg @ 2013-03-29 20:29 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, David S. Miller

Add generic cpu_idle support

sparc32:
- replace call to cpu_idle() with cpu_startup_entry()
- add arch_cpu_idle()

sparc64:
- smp_callin() includes cpu_startup_entry() call so we can
  skip calling cpu_idle from assembler
- add arch_cpu_idle_enter() and arch_cpu_idle_dead()

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: David S. Miller <davem@davemloft.net>

---
This patch is on top of smp/testing in the tip tree.
It is build tested on sparc32 + sparc64

	Sam


diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 3d361f2..5f22169 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -39,6 +39,7 @@ config SPARC
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
+	select GENERIC_IDLE_LOOP
 	select MODULES_USE_ELF_RELA
 	select ODD_RT_SIGACTION
 	select OLD_SIGSUSPEND
diff --git a/arch/sparc/kernel/hvtramp.S b/arch/sparc/kernel/hvtramp.S
index 9365432..605c960 100644
--- a/arch/sparc/kernel/hvtramp.S
+++ b/arch/sparc/kernel/hvtramp.S
@@ -128,8 +128,7 @@ hv_cpu_startup:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index 62eede1..ec92959 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -64,23 +64,13 @@ extern void fpsave(unsigned long *, unsigned long *, void *, unsigned long *);
 struct task_struct *last_task_used_math = NULL;
 struct thread_info *current_set[NR_CPUS];
 
-/*
- * the idle loop on a Sparc... ;)
- */
-void cpu_idle(void)
+/* the idle loop on a Sparc... ;) */
+void arch_cpu_idle(void)
 {
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	for (;;) {
-		while (!need_resched()) {
-			if (sparc_idle)
-				(*sparc_idle)();
-			else
-				cpu_relax();
-		}
-		schedule_preempt_disabled();
-	}
+	if (sparc_idle)
+		(*sparc_idle)();
+	else
+		cpu_relax();
 }
 
 /* XXX cli/sti -> local_irq_xxx here, check this works once SMP is fixed. */
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index cdb80b2..5ed6b02 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -52,8 +52,13 @@
 
 #include "kstack.h"
 
-static void sparc64_yield(int cpu)
+/* The idle loop on sparc64. */
+void arch_cpu_idle_enter()
 {
+	int cpu;
+
+	cpu = smp_processor_id();
+
 	if (tlb_type != hypervisor) {
 		touch_nmi_watchdog();
 		return;
@@ -88,31 +93,10 @@ static void sparc64_yield(int cpu)
 	set_thread_flag(TIF_POLLING_NRFLAG);
 }
 
-/* The idle loop on sparc64. */
-void cpu_idle(void)
+void arch_cpu_idle_dead()
 {
-	int cpu = smp_processor_id();
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	while(1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched() && !cpu_is_offline(cpu))
-			sparc64_yield(cpu);
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
-#ifdef CONFIG_HOTPLUG_CPU
-		if (cpu_is_offline(cpu)) {
-			sched_preempt_enable_no_resched();
-			cpu_play_dead();
-		}
-#endif
-		schedule_preempt_disabled();
-	}
+	sched_preempt_enable_no_resched();
+	cpu_play_dead();
 }
 
 #ifdef CONFIG_COMPAT
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index 9e7e6d7..e3f2b81 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -369,7 +369,7 @@ void __cpuinit sparc_start_secondary(void *arg)
 	local_irq_enable();
 
 	wmb();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 
 	/* We should never reach here! */
 	BUG();
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 537eb66..c025ffc 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -127,6 +127,8 @@ void __cpuinit smp_callin(void)
 
 	/* idle thread is expected to have preempt disabled */
 	preempt_disable();
+
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void cpu_panic(void)
diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
index da1b781..2e973a2 100644
--- a/arch/sparc/kernel/trampoline_64.S
+++ b/arch/sparc/kernel/trampoline_64.S
@@ -407,8 +407,7 @@ after_lock_tlb:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 1:	b,a,pt		%xcc, 1b

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [PATCH] sparc: Use generic idle loop
  2013-03-29 20:29   ` [PATCH] sparc: Use generic idle loop Sam Ravnborg
@ 2013-03-31 23:46     ` David Miller
  2013-04-01  6:53     ` Srivatsa S. Bhat
  1 sibling, 0 replies; 147+ messages in thread
From: David Miller @ 2013-03-31 23:46 UTC (permalink / raw)
  To: sam
  Cc: tglx, linux-kernel, linux-arch, torvalds, akpm, rusty, paulmck,
	mingo, peterz, srivatsa.bhat, magnus.damm

From: Sam Ravnborg <sam@ravnborg.org>
Date: Fri, 29 Mar 2013 21:29:26 +0100

> Add generic cpu_idle support
> 
> sparc32:
> - replace call to cpu_idle() with cpu_startup_entry()
> - add arch_cpu_idle()
> 
> sparc64:
> - smp_callin() includes cpu_startup_entry() call so we can
>   skip calling cpu_idle from assembler
> - add arch_cpu_idle_enter() and arch_cpu_idle_dead()
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [PATCH] sparc: Use generic idle loop
  2013-03-29 20:29   ` [PATCH] sparc: Use generic idle loop Sam Ravnborg
  2013-03-31 23:46     ` David Miller
@ 2013-04-01  6:53     ` Srivatsa S. Bhat
  2013-04-01  9:06         ` Sam Ravnborg
  1 sibling, 1 reply; 147+ messages in thread
From: Srivatsa S. Bhat @ 2013-04-01  6:53 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Thomas Gleixner, LKML, linux-arch, Linus Torvalds, Andrew Morton,
	Rusty Russell, Paul McKenney, Ingo Molnar, Peter Zijlstra,
	Magnus Damm, David S. Miller

On 03/30/2013 01:59 AM, Sam Ravnborg wrote:
> Add generic cpu_idle support
> 
> sparc32:
> - replace call to cpu_idle() with cpu_startup_entry()
> - add arch_cpu_idle()
> 
> sparc64:
> - smp_callin() includes cpu_startup_entry() call so we can
>   skip calling cpu_idle from assembler
> - add arch_cpu_idle_enter() and arch_cpu_idle_dead()
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: David S. Miller <davem@davemloft.net>
> 
> ---
> This patch is on top of smp/testing in the tip tree.
> It is build tested on sparc32 + sparc64
> 
> 	Sam
> 
[...]
> 
> diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
> index 62eede1..ec92959 100644
> --- a/arch/sparc/kernel/process_32.c
> +++ b/arch/sparc/kernel/process_32.c
> @@ -64,23 +64,13 @@ extern void fpsave(unsigned long *, unsigned long *, void *, unsigned long *);
>  struct task_struct *last_task_used_math = NULL;
>  struct thread_info *current_set[NR_CPUS];
> 
> -/*
> - * the idle loop on a Sparc... ;)
> - */
> -void cpu_idle(void)
> +/* the idle loop on a Sparc... ;) */
> +void arch_cpu_idle(void)
>  {
> -	set_thread_flag(TIF_POLLING_NRFLAG);
> -
> -	/* endless idle loop with no priority at all */
> -	for (;;) {
> -		while (!need_resched()) {
> -			if (sparc_idle)
> -				(*sparc_idle)();
> -			else
> -				cpu_relax();
> -		}
> -		schedule_preempt_disabled();
> -	}
> +	if (sparc_idle)
> +		(*sparc_idle)();
> +	else
> +		cpu_relax();
>  }

You need to enable interrupts when coming out in the 'else' case,
because we enter with interrupts disabled and expect to come out
of arch_cpu_idle() with interrupts enabled. (Otherwise you'll hit
that WARN_ON() in the generic code). Thomas has handled a similar
case in the mips patch.

> 
>  /* XXX cli/sti -> local_irq_xxx here, check this works once SMP is fixed. */
> diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
> index cdb80b2..5ed6b02 100644
> --- a/arch/sparc/kernel/process_64.c
> +++ b/arch/sparc/kernel/process_64.c
> @@ -52,8 +52,13 @@
> 
>  #include "kstack.h"
> 
> -static void sparc64_yield(int cpu)
> +/* The idle loop on sparc64. */
> +void arch_cpu_idle_enter()
>  {
> +	int cpu;
> +
> +	cpu = smp_processor_id();
> +
>  	if (tlb_type != hypervisor) {
>  		touch_nmi_watchdog();
>  		return;
> @@ -88,31 +93,10 @@ static void sparc64_yield(int cpu)
>  	set_thread_flag(TIF_POLLING_NRFLAG);
>  }
> 

Hmm, this looks weird. The contents of this function should have
been inside arch_cpu_idle() (not arch_cpu_idle_enter). And it is
unnecessary to set/clear POLLING flags here, since they are handled
in the generic code. (Same is the case with the need_resched and
the cpu_is_offline check).

I agree that the naming is a little subtle, but in the current
scheme of things in this patchset, arch_cpu_idle_enter() is what
you call to do initialization _before_ you perform cpu idle, whereas
arch_cpu_idle() is the function that is supposed to do the actual
arch-specific idling.

Regards,
Srivatsa S. Bhat

> -/* The idle loop on sparc64. */
> -void cpu_idle(void)
> +void arch_cpu_idle_dead()
>  {
> -	int cpu = smp_processor_id();
> -
> -	set_thread_flag(TIF_POLLING_NRFLAG);
> -
> -	while(1) {
> -		tick_nohz_idle_enter();
> -		rcu_idle_enter();
> -
> -		while (!need_resched() && !cpu_is_offline(cpu))
> -			sparc64_yield(cpu);
> -
> -		rcu_idle_exit();
> -		tick_nohz_idle_exit();
> -
> -#ifdef CONFIG_HOTPLUG_CPU
> -		if (cpu_is_offline(cpu)) {
> -			sched_preempt_enable_no_resched();
> -			cpu_play_dead();
> -		}
> -#endif
> -		schedule_preempt_disabled();
> -	}
> +	sched_preempt_enable_no_resched();
> +	cpu_play_dead();
>  }


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [PATCH] sparc: Use generic idle loop
  2013-04-01  6:53     ` Srivatsa S. Bhat
  2013-04-01  9:06         ` Sam Ravnborg
@ 2013-04-01  9:06         ` Sam Ravnborg
  0 siblings, 0 replies; 147+ messages in thread
From: Sam Ravnborg @ 2013-04-01  9:06 UTC (permalink / raw)
  To: Srivatsa S. Bhat, David S. Miller
  Cc: Thomas Gleixner, LKML, linux-arch, Linus Torvalds, Andrew Morton,
	Rusty Russell, Paul McKenney, Ingo Molnar, Peter Zijlstra,
	Magnus Damm, David S. Miller

Hi Srivatsa,

thanks for the feedback!

@davem - I need you to look at this again. I am not sure about the changes
I do in sparc64_yield().

> > +/* the idle loop on a Sparc... ;) */
> > +void arch_cpu_idle(void)
> >  {
> > +	if (sparc_idle)
> > +		(*sparc_idle)();
> > +	else
> > +		cpu_relax();
> >  }
> 
> You need to enable interrupts when coming out in the 'else' case,
> because we enter with interrupts disabled and expect to come out
> of arch_cpu_idle() with interrupts enabled. (Otherwise you'll hit
> that WARN_ON() in the generic code). Thomas has handled a similar
> case in the mips patch.

Something like this should do it then:

/* Idle loop support */
void arch_cpu_idle(void)
{
        if (sparc_idle)
                (*sparc_idle)();
        else
                local_irq_enable();
}

I dropped cpu_relax() as this is a simple barrier() which is
part of the generic code (using rmb()).


> > -static void sparc64_yield(int cpu)
> > +/* The idle loop on sparc64. */
> > +void arch_cpu_idle_enter()
> >  {
> > +	int cpu;
> > +
> > +	cpu = smp_processor_id();
> > +
> >  	if (tlb_type != hypervisor) {
> >  		touch_nmi_watchdog();
> >  		return;
> > @@ -88,31 +93,10 @@ static void sparc64_yield(int cpu)
> >  	set_thread_flag(TIF_POLLING_NRFLAG);
> >  }
> > 
> 
> Hmm, this looks weird. The contents of this function should have
> been inside arch_cpu_idle() (not arch_cpu_idle_enter).
Yep - I see now.

> And it is
> unnecessary to set/clear POLLING flags here, since they are handled
> in the generic code.
OK

> (Same is the case with the need_resched and
> the cpu_is_offline check).
There are some comments about race-conditions in the commit where they were added.
I think the out-most pair can be dropped as this is done in generic code but
that the inner ones needs to stay.

I simplified arch_cpu_idle() - former sparc64_yield() based on your comments.
- dropped TIF_POLLING_NRFLAG handling
- dropped smp_mb__after_clear_bit() - this is done in generic code using rmb()
- dropped the out-most while (!need_resched() && !cpu_is_offline(cpu))
- always enable irq on exit (but I am not sure if this is correct)

But I need davem to have a look at this - as I am fooling around in
code that I do not know much about..
So this is *NOT* to be applied.

	Sam

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 3d361f2..ee5eacc 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -37,6 +37,7 @@ config SPARC
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CLOCKEVENTS
+	select GENERIC_IDLE_LOOP
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
 	select MODULES_USE_ELF_RELA
diff --git a/arch/sparc/kernel/hvtramp.S b/arch/sparc/kernel/hvtramp.S
index 9365432..605c960 100644
--- a/arch/sparc/kernel/hvtramp.S
+++ b/arch/sparc/kernel/hvtramp.S
@@ -128,8 +128,7 @@ hv_cpu_startup:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index 62eede1..890d7c4 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -64,23 +64,13 @@ extern void fpsave(unsigned long *, unsigned long *, void *, unsigned long *);
 struct task_struct *last_task_used_math = NULL;
 struct thread_info *current_set[NR_CPUS];
 
-/*
- * the idle loop on a Sparc... ;)
- */
-void cpu_idle(void)
+/* Idle loop support. */
+void arch_cpu_idle(void)
 {
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	for (;;) {
-		while (!need_resched()) {
-			if (sparc_idle)
-				(*sparc_idle)();
-			else
-				cpu_relax();
-		}
-		schedule_preempt_disabled();
-	}
+	if (sparc_idle)
+		(*sparc_idle)();
+	else
+		local_irq_enable();
 }
 
 /* XXX cli/sti -> local_irq_xxx here, check this works once SMP is fixed. */
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index cdb80b2..cecb0d6 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -52,17 +52,12 @@
 
 #include "kstack.h"
 
-static void sparc64_yield(int cpu)
+/* Idle loop support on sparc64. */
+void arch_cpu_idle(void)
 {
 	if (tlb_type != hypervisor) {
 		touch_nmi_watchdog();
-		return;
-	}
-
-	clear_thread_flag(TIF_POLLING_NRFLAG);
-	smp_mb__after_clear_bit();
-
-	while (!need_resched() && !cpu_is_offline(cpu)) {
+	} else {
 		unsigned long pstate;
 
 		/* Disable interrupts. */
@@ -73,7 +68,7 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 
-		if (!need_resched() && !cpu_is_offline(cpu))
+		if (!need_resched() && !cpu_is_offline(smp_processor_id()))
 			sun4v_cpu_yield();
 
 		/* Re-enable interrupts. */
@@ -84,36 +79,16 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 	}
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
+	local_irq_enable();
 }
 
-/* The idle loop on sparc64. */
-void cpu_idle(void)
-{
-	int cpu = smp_processor_id();
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	while(1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched() && !cpu_is_offline(cpu))
-			sparc64_yield(cpu);
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
 #ifdef CONFIG_HOTPLUG_CPU
-		if (cpu_is_offline(cpu)) {
-			sched_preempt_enable_no_resched();
-			cpu_play_dead();
-		}
-#endif
-		schedule_preempt_disabled();
-	}
+void arch_cpu_idle_dead()
+{
+	sched_preempt_enable_no_resched();
+	cpu_play_dead();
 }
+#endif
 
 #ifdef CONFIG_COMPAT
 static void show_regwindow32(struct pt_regs *regs)
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index 9e7e6d7..e3f2b81 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -369,7 +369,7 @@ void __cpuinit sparc_start_secondary(void *arg)
 	local_irq_enable();
 
 	wmb();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 
 	/* We should never reach here! */
 	BUG();
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 537eb66..c025ffc 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -127,6 +127,8 @@ void __cpuinit smp_callin(void)
 
 	/* idle thread is expected to have preempt disabled */
 	preempt_disable();
+
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void cpu_panic(void)
diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
index da1b781..2e973a2 100644
--- a/arch/sparc/kernel/trampoline_64.S
+++ b/arch/sparc/kernel/trampoline_64.S
@@ -407,8 +407,7 @@ after_lock_tlb:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 1:	b,a,pt		%xcc, 1b

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [PATCH] sparc: Use generic idle loop
@ 2013-04-01  9:06         ` Sam Ravnborg
  0 siblings, 0 replies; 147+ messages in thread
From: Sam Ravnborg @ 2013-04-01  9:06 UTC (permalink / raw)
  To: Srivatsa S. Bhat
  Cc: Thomas Gleixner, LKML, linux-arch, Linus Torvalds, Andrew Morton,
	Rusty Russell, Paul McKenney, Ingo Molnar, Peter Zijlstra,
	Magnus Damm, David S. Miller

Hi Srivatsa,

thanks for the feedback!

@davem - I need you to look at this again. I am not sure about the changes
I do in sparc64_yield().

> > +/* the idle loop on a Sparc... ;) */
> > +void arch_cpu_idle(void)
> >  {
> > +	if (sparc_idle)
> > +		(*sparc_idle)();
> > +	else
> > +		cpu_relax();
> >  }
> 
> You need to enable interrupts when coming out in the 'else' case,
> because we enter with interrupts disabled and expect to come out
> of arch_cpu_idle() with interrupts enabled. (Otherwise you'll hit
> that WARN_ON() in the generic code). Thomas has handled a similar
> case in the mips patch.

Something like this should do it then:

/* Idle loop support */
void arch_cpu_idle(void)
{
        if (sparc_idle)
                (*sparc_idle)();
        else
                local_irq_enable();
}

I dropped cpu_relax() as this is a simple barrier() which is
part of the generic code (using rmb()).


> > -static void sparc64_yield(int cpu)
> > +/* The idle loop on sparc64. */
> > +void arch_cpu_idle_enter()
> >  {
> > +	int cpu;
> > +
> > +	cpu = smp_processor_id();
> > +
> >  	if (tlb_type != hypervisor) {
> >  		touch_nmi_watchdog();
> >  		return;
> > @@ -88,31 +93,10 @@ static void sparc64_yield(int cpu)
> >  	set_thread_flag(TIF_POLLING_NRFLAG);
> >  }
> > 
> 
> Hmm, this looks weird. The contents of this function should have
> been inside arch_cpu_idle() (not arch_cpu_idle_enter).
Yep - I see now.

> And it is
> unnecessary to set/clear POLLING flags here, since they are handled
> in the generic code.
OK

> (Same is the case with the need_resched and
> the cpu_is_offline check).
There are some comments about race-conditions in the commit where they were added.
I think the out-most pair can be dropped as this is done in generic code but
that the inner ones needs to stay.

I simplified arch_cpu_idle() - former sparc64_yield() based on your comments.
- dropped TIF_POLLING_NRFLAG handling
- dropped smp_mb__after_clear_bit() - this is done in generic code using rmb()
- dropped the out-most while (!need_resched() && !cpu_is_offline(cpu))
- always enable irq on exit (but I am not sure if this is correct)

But I need davem to have a look at this - as I am fooling around in
code that I do not know much about..
So this is *NOT* to be applied.

	Sam

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 3d361f2..ee5eacc 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -37,6 +37,7 @@ config SPARC
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CLOCKEVENTS
+	select GENERIC_IDLE_LOOP
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
 	select MODULES_USE_ELF_RELA
diff --git a/arch/sparc/kernel/hvtramp.S b/arch/sparc/kernel/hvtramp.S
index 9365432..605c960 100644
--- a/arch/sparc/kernel/hvtramp.S
+++ b/arch/sparc/kernel/hvtramp.S
@@ -128,8 +128,7 @@ hv_cpu_startup:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index 62eede1..890d7c4 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -64,23 +64,13 @@ extern void fpsave(unsigned long *, unsigned long *, void *, unsigned long *);
 struct task_struct *last_task_used_math = NULL;
 struct thread_info *current_set[NR_CPUS];
 
-/*
- * the idle loop on a Sparc... ;)
- */
-void cpu_idle(void)
+/* Idle loop support. */
+void arch_cpu_idle(void)
 {
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	for (;;) {
-		while (!need_resched()) {
-			if (sparc_idle)
-				(*sparc_idle)();
-			else
-				cpu_relax();
-		}
-		schedule_preempt_disabled();
-	}
+	if (sparc_idle)
+		(*sparc_idle)();
+	else
+		local_irq_enable();
 }
 
 /* XXX cli/sti -> local_irq_xxx here, check this works once SMP is fixed. */
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index cdb80b2..cecb0d6 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -52,17 +52,12 @@
 
 #include "kstack.h"
 
-static void sparc64_yield(int cpu)
+/* Idle loop support on sparc64. */
+void arch_cpu_idle(void)
 {
 	if (tlb_type != hypervisor) {
 		touch_nmi_watchdog();
-		return;
-	}
-
-	clear_thread_flag(TIF_POLLING_NRFLAG);
-	smp_mb__after_clear_bit();
-
-	while (!need_resched() && !cpu_is_offline(cpu)) {
+	} else {
 		unsigned long pstate;
 
 		/* Disable interrupts. */
@@ -73,7 +68,7 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 
-		if (!need_resched() && !cpu_is_offline(cpu))
+		if (!need_resched() && !cpu_is_offline(smp_processor_id()))
 			sun4v_cpu_yield();
 
 		/* Re-enable interrupts. */
@@ -84,36 +79,16 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 	}
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
+	local_irq_enable();
 }
 
-/* The idle loop on sparc64. */
-void cpu_idle(void)
-{
-	int cpu = smp_processor_id();
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	while(1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched() && !cpu_is_offline(cpu))
-			sparc64_yield(cpu);
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
 #ifdef CONFIG_HOTPLUG_CPU
-		if (cpu_is_offline(cpu)) {
-			sched_preempt_enable_no_resched();
-			cpu_play_dead();
-		}
-#endif
-		schedule_preempt_disabled();
-	}
+void arch_cpu_idle_dead()
+{
+	sched_preempt_enable_no_resched();
+	cpu_play_dead();
 }
+#endif
 
 #ifdef CONFIG_COMPAT
 static void show_regwindow32(struct pt_regs *regs)
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index 9e7e6d7..e3f2b81 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -369,7 +369,7 @@ void __cpuinit sparc_start_secondary(void *arg)
 	local_irq_enable();
 
 	wmb();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 
 	/* We should never reach here! */
 	BUG();
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 537eb66..c025ffc 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -127,6 +127,8 @@ void __cpuinit smp_callin(void)
 
 	/* idle thread is expected to have preempt disabled */
 	preempt_disable();
+
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void cpu_panic(void)
diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
index da1b781..2e973a2 100644
--- a/arch/sparc/kernel/trampoline_64.S
+++ b/arch/sparc/kernel/trampoline_64.S
@@ -407,8 +407,7 @@ after_lock_tlb:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 1:	b,a,pt		%xcc, 1b

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [PATCH] sparc: Use generic idle loop
@ 2013-04-01  9:06         ` Sam Ravnborg
  0 siblings, 0 replies; 147+ messages in thread
From: Sam Ravnborg @ 2013-04-01  9:06 UTC (permalink / raw)
  To: Srivatsa S. Bhat, David S. Miller
  Cc: Thomas Gleixner, LKML, linux-arch, Linus Torvalds, Andrew Morton,
	Rusty Russell, Paul McKenney, Ingo Molnar, Peter Zijlstra,
	Magnus Damm

Hi Srivatsa,

thanks for the feedback!

@davem - I need you to look at this again. I am not sure about the changes
I do in sparc64_yield().

> > +/* the idle loop on a Sparc... ;) */
> > +void arch_cpu_idle(void)
> >  {
> > +	if (sparc_idle)
> > +		(*sparc_idle)();
> > +	else
> > +		cpu_relax();
> >  }
> 
> You need to enable interrupts when coming out in the 'else' case,
> because we enter with interrupts disabled and expect to come out
> of arch_cpu_idle() with interrupts enabled. (Otherwise you'll hit
> that WARN_ON() in the generic code). Thomas has handled a similar
> case in the mips patch.

Something like this should do it then:

/* Idle loop support */
void arch_cpu_idle(void)
{
        if (sparc_idle)
                (*sparc_idle)();
        else
                local_irq_enable();
}

I dropped cpu_relax() as this is a simple barrier() which is
part of the generic code (using rmb()).


> > -static void sparc64_yield(int cpu)
> > +/* The idle loop on sparc64. */
> > +void arch_cpu_idle_enter()
> >  {
> > +	int cpu;
> > +
> > +	cpu = smp_processor_id();
> > +
> >  	if (tlb_type != hypervisor) {
> >  		touch_nmi_watchdog();
> >  		return;
> > @@ -88,31 +93,10 @@ static void sparc64_yield(int cpu)
> >  	set_thread_flag(TIF_POLLING_NRFLAG);
> >  }
> > 
> 
> Hmm, this looks weird. The contents of this function should have
> been inside arch_cpu_idle() (not arch_cpu_idle_enter).
Yep - I see now.

> And it is
> unnecessary to set/clear POLLING flags here, since they are handled
> in the generic code.
OK

> (Same is the case with the need_resched and
> the cpu_is_offline check).
There are some comments about race-conditions in the commit where they were added.
I think the out-most pair can be dropped as this is done in generic code but
that the inner ones needs to stay.

I simplified arch_cpu_idle() - former sparc64_yield() based on your comments.
- dropped TIF_POLLING_NRFLAG handling
- dropped smp_mb__after_clear_bit() - this is done in generic code using rmb()
- dropped the out-most while (!need_resched() && !cpu_is_offline(cpu))
- always enable irq on exit (but I am not sure if this is correct)

But I need davem to have a look at this - as I am fooling around in
code that I do not know much about..
So this is *NOT* to be applied.

	Sam

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 3d361f2..ee5eacc 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -37,6 +37,7 @@ config SPARC
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CLOCKEVENTS
+	select GENERIC_IDLE_LOOP
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
 	select MODULES_USE_ELF_RELA
diff --git a/arch/sparc/kernel/hvtramp.S b/arch/sparc/kernel/hvtramp.S
index 9365432..605c960 100644
--- a/arch/sparc/kernel/hvtramp.S
+++ b/arch/sparc/kernel/hvtramp.S
@@ -128,8 +128,7 @@ hv_cpu_startup:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index 62eede1..890d7c4 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -64,23 +64,13 @@ extern void fpsave(unsigned long *, unsigned long *, void *, unsigned long *);
 struct task_struct *last_task_used_math = NULL;
 struct thread_info *current_set[NR_CPUS];
 
-/*
- * the idle loop on a Sparc... ;)
- */
-void cpu_idle(void)
+/* Idle loop support. */
+void arch_cpu_idle(void)
 {
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	for (;;) {
-		while (!need_resched()) {
-			if (sparc_idle)
-				(*sparc_idle)();
-			else
-				cpu_relax();
-		}
-		schedule_preempt_disabled();
-	}
+	if (sparc_idle)
+		(*sparc_idle)();
+	else
+		local_irq_enable();
 }
 
 /* XXX cli/sti -> local_irq_xxx here, check this works once SMP is fixed. */
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index cdb80b2..cecb0d6 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -52,17 +52,12 @@
 
 #include "kstack.h"
 
-static void sparc64_yield(int cpu)
+/* Idle loop support on sparc64. */
+void arch_cpu_idle(void)
 {
 	if (tlb_type != hypervisor) {
 		touch_nmi_watchdog();
-		return;
-	}
-
-	clear_thread_flag(TIF_POLLING_NRFLAG);
-	smp_mb__after_clear_bit();
-
-	while (!need_resched() && !cpu_is_offline(cpu)) {
+	} else {
 		unsigned long pstate;
 
 		/* Disable interrupts. */
@@ -73,7 +68,7 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 
-		if (!need_resched() && !cpu_is_offline(cpu))
+		if (!need_resched() && !cpu_is_offline(smp_processor_id()))
 			sun4v_cpu_yield();
 
 		/* Re-enable interrupts. */
@@ -84,36 +79,16 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 	}
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
+	local_irq_enable();
 }
 
-/* The idle loop on sparc64. */
-void cpu_idle(void)
-{
-	int cpu = smp_processor_id();
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	while(1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched() && !cpu_is_offline(cpu))
-			sparc64_yield(cpu);
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
 #ifdef CONFIG_HOTPLUG_CPU
-		if (cpu_is_offline(cpu)) {
-			sched_preempt_enable_no_resched();
-			cpu_play_dead();
-		}
-#endif
-		schedule_preempt_disabled();
-	}
+void arch_cpu_idle_dead()
+{
+	sched_preempt_enable_no_resched();
+	cpu_play_dead();
 }
+#endif
 
 #ifdef CONFIG_COMPAT
 static void show_regwindow32(struct pt_regs *regs)
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index 9e7e6d7..e3f2b81 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -369,7 +369,7 @@ void __cpuinit sparc_start_secondary(void *arg)
 	local_irq_enable();
 
 	wmb();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 
 	/* We should never reach here! */
 	BUG();
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 537eb66..c025ffc 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -127,6 +127,8 @@ void __cpuinit smp_callin(void)
 
 	/* idle thread is expected to have preempt disabled */
 	preempt_disable();
+
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void cpu_panic(void)
diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
index da1b781..2e973a2 100644
--- a/arch/sparc/kernel/trampoline_64.S
+++ b/arch/sparc/kernel/trampoline_64.S
@@ -407,8 +407,7 @@ after_lock_tlb:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 1:	b,a,pt		%xcc, 1b

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [patch 26/34] powerpc: Use generic idle loop
  2013-03-28 15:40   ` Srivatsa S. Bhat
@ 2013-04-01  9:13     ` Deepthi Dharwar
  0 siblings, 0 replies; 147+ messages in thread
From: Deepthi Dharwar @ 2013-04-01  9:13 UTC (permalink / raw)
  To: Srivatsa S. Bhat
  Cc: Thomas Gleixner, LKML, linux-arch, Linus Torvalds, Andrew Morton,
	Rusty Russell, Paul McKenney, Ingo Molnar, Peter Zijlstra,
	Magnus Damm, Benjamin Herrenschmidt, Preeti U Murthy,
	Vaidyanathan Srinivasan

On 03/28/2013 09:10 PM, Srivatsa S. Bhat wrote:
> On 03/22/2013 03:23 AM, Thomas Gleixner wrote:
>> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> ---
> [...]
>> Index: linux-2.6/arch/powerpc/kernel/idle.c
>> ===================================================================
>> --- linux-2.6.orig/arch/powerpc/kernel/idle.c
>> +++ linux-2.6/arch/powerpc/kernel/idle.c
>> @@ -50,64 +50,30 @@ static int __init powersave_off(char *ar
>>  }
>>  __setup("powersave=off", powersave_off);
>>
>> -/*
>> - * The body of the idle task.
>> - */
>> -void cpu_idle(void)
>> +void arch_cpu_idle(void)
>>  {
>> -	set_thread_flag(TIF_POLLING_NRFLAG);
>> -	while (1) {
>> -		tick_nohz_idle_enter();
>> -		rcu_idle_enter();
>> -
>> -		while (!need_resched() && !cpu_should_die()) {
>> -			ppc64_runlatch_off();
>> -
>> -			if (ppc_md.power_save) {
>> -				clear_thread_flag(TIF_POLLING_NRFLAG);
>> -				/*
>> -				 * smp_mb is so clearing of TIF_POLLING_NRFLAG
>> -				 * is ordered w.r.t. need_resched() test.
>> -				 */
>> -				smp_mb();
>> -				local_irq_disable();
>> -
>> -				/* Don't trace irqs off for idle */
>> -				stop_critical_timings();
>> -
>> -				/* check again after disabling irqs */
>> -				if (!need_resched() && !cpu_should_die())
>> -					ppc_md.power_save();
>> -
>> -				start_critical_timings();
>> -
>> -				/* Some power_save functions return with
>> -				 * interrupts enabled, some don't.
>> -				 */
>> -				if (irqs_disabled())
>> -					local_irq_enable();
>> -				set_thread_flag(TIF_POLLING_NRFLAG);
>> -
>> -			} else {
>> -				/*
>> -				 * Go into low thread priority and possibly
>> -				 * low power mode.
>> -				 */
>> -				HMT_low();
>> -				HMT_very_low();
>> -			}
>> -		}
>> -
>> -		HMT_medium();
>> -		ppc64_runlatch_on();
>> -		rcu_idle_exit();
>> -		tick_nohz_idle_exit();
>> -		if (cpu_should_die()) {
>> -			sched_preempt_enable_no_resched();
>> -			cpu_die();
>> -		}
>> -		schedule_preempt_disabled();
>> +	ppc64_runlatch_off();
>> +
>> +	if (ppc_md.power_save) {
>> +		ppc_md.power_save();
>> +		/*
>> +		 * Some power_save functions return with
>> +		 * interrupts enabled, some don't.
>> +		 */
>> +		if (irqs_disabled())
>> +			local_irq_enable();
>> +	} else {
>> +		local_irq_enable();
>> +		/*
>> +		 * Go into low thread priority and possibly
>> +		 * low power mode.
>> +		 */
>> +		HMT_low();
>> +		HMT_very_low();
>>  	}
>> +
>> +	HMT_medium();
>> +	ppc64_runlatch_on();
>>  }
>>

The below patch is essential to get hotplug working on POWER.
With that, generic idle loop works fine for PSERIES.

Tested-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>

> 
> The call to cpu_die() seems to be missing. And considering this commit,
> 
> commit a7c2bb8279d20d853e43c34584eaf2b039de8026
> Author: Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
> Date:   Wed Aug 4 18:28:33 2010 +0000
> 
>     powerpc: Re-enable preemption before cpu_die()
> 
> we need to call it with preempt enabled. So how about folding the
> following diff with this patch?
> 
> 
> diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
> index b751baa..e434fb9 100644
> --- a/arch/powerpc/kernel/idle.c
> +++ b/arch/powerpc/kernel/idle.c
> @@ -33,11 +33,6 @@
>  #include <asm/runlatch.h>
>  #include <asm/smp.h>
> 
> -#ifdef CONFIG_HOTPLUG_CPU
> -#define cpu_should_die()	cpu_is_offline(smp_processor_id())
> -#else
> -#define cpu_should_die()	0
> -#endif
> 
>  unsigned long cpuidle_disable = IDLE_NO_OVERRIDE;
>  EXPORT_SYMBOL(cpuidle_disable);
> @@ -50,6 +45,12 @@ static int __init powersave_off(char *arg)
>  }
>  __setup("powersave=off", powersave_off);
> 
> +void arch_cpu_idle_dead(void)
> +{
> +	sched_preempt_enable_no_resched();
> +	cpu_die();
> +}
> +
>  void arch_cpu_idle(void)
>  {
>  	ppc64_runlatch_off();
> 
> 
> Regards,
> Srivatsa S. Bhat
> 


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [PATCH] sparc: Use generic idle loop
  2013-04-01  9:06         ` Sam Ravnborg
  (?)
  (?)
@ 2013-04-08 12:33         ` Srivatsa S. Bhat
  2013-04-08 17:10           ` Sam Ravnborg
  -1 siblings, 1 reply; 147+ messages in thread
From: Srivatsa S. Bhat @ 2013-04-08 12:33 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: David S. Miller, Thomas Gleixner, LKML, linux-arch,
	Linus Torvalds, Andrew Morton, Rusty Russell, Paul McKenney,
	Ingo Molnar, Peter Zijlstra, Magnus Damm

Hi Sam,

On 04/01/2013 02:36 PM, Sam Ravnborg wrote:
> Hi Srivatsa,
> 
> thanks for the feedback!
> 
> @davem - I need you to look at this again. I am not sure about the changes
> I do in sparc64_yield().
> 
>>> +/* the idle loop on a Sparc... ;) */
>>> +void arch_cpu_idle(void)
>>>  {
>>> +	if (sparc_idle)
>>> +		(*sparc_idle)();
>>> +	else
>>> +		cpu_relax();
>>>  }
>>
>> You need to enable interrupts when coming out in the 'else' case,
>> because we enter with interrupts disabled and expect to come out
>> of arch_cpu_idle() with interrupts enabled. (Otherwise you'll hit
>> that WARN_ON() in the generic code). Thomas has handled a similar
>> case in the mips patch.
> 
> Something like this should do it then:
> 
> /* Idle loop support */
> void arch_cpu_idle(void)
> {
>         if (sparc_idle)
>                 (*sparc_idle)();
>         else
>                 local_irq_enable();
> }
> 
> I dropped cpu_relax() as this is a simple barrier() which is
> part of the generic code (using rmb()).
> 

Yep, that sounds good.

[...] 
>> (Same is the case with the need_resched and
>> the cpu_is_offline check).
> There are some comments about race-conditions in the commit where they were added.
> I think the out-most pair can be dropped as this is done in generic code but
> that the inner ones needs to stay.
> 
> I simplified arch_cpu_idle() - former sparc64_yield() based on your comments.
> - dropped TIF_POLLING_NRFLAG handling
> - dropped smp_mb__after_clear_bit() - this is done in generic code using rmb()
> - dropped the out-most while (!need_resched() && !cpu_is_offline(cpu))
> - always enable irq on exit (but I am not sure if this is correct)
> 
> But I need davem to have a look at this - as I am fooling around in
> code that I do not know much about..
> So this is *NOT* to be applied.
> 
> 	Sam
>
[...]
>  /* XXX cli/sti -> local_irq_xxx here, check this works once SMP is fixed. */
> diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
> index cdb80b2..cecb0d6 100644
> --- a/arch/sparc/kernel/process_64.c
> +++ b/arch/sparc/kernel/process_64.c
> @@ -52,17 +52,12 @@
> 
>  #include "kstack.h"
> 
> -static void sparc64_yield(int cpu)
> +/* Idle loop support on sparc64. */
> +void arch_cpu_idle(void)
>  {
>  	if (tlb_type != hypervisor) {
>  		touch_nmi_watchdog();
> -		return;
> -	}
> -
> -	clear_thread_flag(TIF_POLLING_NRFLAG);
> -	smp_mb__after_clear_bit();
> -
> -	while (!need_resched() && !cpu_is_offline(cpu)) {
> +	} else {
>  		unsigned long pstate;
> 
>  		/* Disable interrupts. */
> @@ -73,7 +68,7 @@ static void sparc64_yield(int cpu)
>  			: "=&r" (pstate)
>  			: "i" (PSTATE_IE));
> 
> -		if (!need_resched() && !cpu_is_offline(cpu))
> +		if (!need_resched() && !cpu_is_offline(smp_processor_id()))
>  			sun4v_cpu_yield();
> 
>  		/* Re-enable interrupts. */
> @@ -84,36 +79,16 @@ static void sparc64_yield(int cpu)
>  			: "=&r" (pstate)
>  			: "i" (PSTATE_IE));
>  	}
> -
> -	set_thread_flag(TIF_POLLING_NRFLAG);
> +	local_irq_enable();
>  }

Nitpick: you can probably move the local_irq_enable() to the
'if' block, since the else block already has assembly code to enable
the interrupts. But anyway its up to you.

This version of your code looks fine to me.

Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>

Regards,
Srivatsa S. Bhat


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [PATCH] sparc: Use generic idle loop
  2013-04-08 12:33         ` Srivatsa S. Bhat
@ 2013-04-08 17:10           ` Sam Ravnborg
  2013-04-08 19:24             ` David Miller
  0 siblings, 1 reply; 147+ messages in thread
From: Sam Ravnborg @ 2013-04-08 17:10 UTC (permalink / raw)
  To: Srivatsa S. Bhat
  Cc: David S. Miller, Thomas Gleixner, LKML, linux-arch,
	Linus Torvalds, Andrew Morton, Rusty Russell, Paul McKenney,
	Ingo Molnar, Peter Zijlstra, Magnus Damm

> > @@ -52,17 +52,12 @@
> > 
> >  #include "kstack.h"
> > 
> > -static void sparc64_yield(int cpu)
> > +/* Idle loop support on sparc64. */
> > +void arch_cpu_idle(void)
> >  {
> >  	if (tlb_type != hypervisor) {
> >  		touch_nmi_watchdog();
> > -		return;
> > -	}
> > -
> > -	clear_thread_flag(TIF_POLLING_NRFLAG);
> > -	smp_mb__after_clear_bit();
> > -
> > -	while (!need_resched() && !cpu_is_offline(cpu)) {
> > +	} else {
> >  		unsigned long pstate;
> > 
> >  		/* Disable interrupts. */
> > @@ -73,7 +68,7 @@ static void sparc64_yield(int cpu)
> >  			: "=&r" (pstate)
> >  			: "i" (PSTATE_IE));
> > 
> > -		if (!need_resched() && !cpu_is_offline(cpu))
> > +		if (!need_resched() && !cpu_is_offline(smp_processor_id()))
> >  			sun4v_cpu_yield();
> > 
> >  		/* Re-enable interrupts. */
> > @@ -84,36 +79,16 @@ static void sparc64_yield(int cpu)
> >  			: "=&r" (pstate)
> >  			: "i" (PSTATE_IE));
> >  	}
> > -
> > -	set_thread_flag(TIF_POLLING_NRFLAG);
> > +	local_irq_enable();
> >  }
> 
> Nitpick: you can probably move the local_irq_enable() to the
> 'if' block, since the else block already has assembly code to enable
> the interrupts. But anyway its up to you.

I think not.
local_irq_disable writes 0 to the PIL register,
whereas the above code set the IE (Interrupt enable) bit to 0.

So the implementations differs - and I think there is a good
reason for being so.

But this is the part where I refer to that I am fooling around
in code that I do not understand.
I re-checked the SPARC V9 manual - but I did not within a few minutes
reading understand what is the difference between the twoo.

	Sam

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [PATCH] sparc: Use generic idle loop
  2013-04-08 17:10           ` Sam Ravnborg
@ 2013-04-08 19:24             ` David Miller
  2013-04-11 19:38                 ` Sam Ravnborg
  0 siblings, 1 reply; 147+ messages in thread
From: David Miller @ 2013-04-08 19:24 UTC (permalink / raw)
  To: sam
  Cc: srivatsa.bhat, tglx, linux-kernel, linux-arch, torvalds, akpm,
	rusty, paulmck, mingo, peterz, magnus.damm

From: Sam Ravnborg <sam@ravnborg.org>
Date: Mon, 8 Apr 2013 19:10:35 +0200

> I think not.
> local_irq_disable writes 0 to the PIL register,
> whereas the above code set the IE (Interrupt enable) bit to 0.
> 
> So the implementations differs - and I think there is a good
> reason for being so.
> 
> But this is the part where I refer to that I am fooling around
> in code that I do not understand.
> I re-checked the SPARC V9 manual - but I did not within a few minutes
> reading understand what is the difference between the twoo.

Device interrupts arrive first as high-priority interrupt packets
that are serviced by traps which are enabled only if PSTATE.IE is
set.

These trap handlers reschedule the interrupt quickly into a PIL
levelled interrupt, whose delivery is covered by (%pil & PSTATE.IE)

The sun4v sleeping code requires that we have PSTATE.IE clear over
the cpu sleep hypervisor call.


^ permalink raw reply	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] arch: Cleanup enable/disable_hlt
  2013-03-21 21:52 ` [patch 01/34] arch: Cleanup enable/disable_hlt Thomas Gleixner
@ 2013-04-08 20:08   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:08 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, tglx, magnus.damm

Commit-ID:  6546327ad187238ac63d2429701b32becb096fd8
Gitweb:     http://git.kernel.org/tip/6546327ad187238ac63d2429701b32becb096fd8
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:31 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:22 +0200

arch: Cleanup enable/disable_hlt

enable/disable_hlt() does not need to be exported and can be killed on
architectures which do not use it at all.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130321215233.377959540@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/arm/kernel/process.c               |  4 ----
 arch/cris/arch-v32/kernel/process.c     |  8 +++-----
 arch/cris/include/asm/processor.h       |  7 -------
 arch/cris/kernel/process.c              | 25 -------------------------
 arch/microblaze/include/asm/processor.h |  2 --
 arch/microblaze/kernel/process.c        | 12 ------------
 arch/mn10300/kernel/smp.c               |  5 -----
 7 files changed, 3 insertions(+), 60 deletions(-)

diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 047d3e4..92884c8 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -64,16 +64,12 @@ void disable_hlt(void)
 	hlt_counter++;
 }
 
-EXPORT_SYMBOL(disable_hlt);
-
 void enable_hlt(void)
 {
 	hlt_counter--;
 	BUG_ON(hlt_counter < 0);
 }
 
-EXPORT_SYMBOL(enable_hlt);
-
 static int __init nohlt_setup(char *__unused)
 {
 	hlt_counter = 1;
diff --git a/arch/cris/arch-v32/kernel/process.c b/arch/cris/arch-v32/kernel/process.c
index 2b23ef0..4857933 100644
--- a/arch/cris/arch-v32/kernel/process.c
+++ b/arch/cris/arch-v32/kernel/process.c
@@ -20,16 +20,14 @@
 
 extern void stop_watchdog(void);
 
-extern int cris_hlt_counter;
-
 /* We use this if we don't have any better idle routine. */
 void default_idle(void)
 {
 	local_irq_disable();
-	if (!need_resched() && !cris_hlt_counter) {
-	        /* Halt until exception. */
+	if (!need_resched()) {
+		/* Halt until exception. */
 		__asm__ volatile("ei    \n\t"
-                                 "halt      ");
+				 "halt      ");
 	}
 	local_irq_enable();
 }
diff --git a/arch/cris/include/asm/processor.h b/arch/cris/include/asm/processor.h
index 675823f..c0a29b9 100644
--- a/arch/cris/include/asm/processor.h
+++ b/arch/cris/include/asm/processor.h
@@ -65,13 +65,6 @@ static inline void release_thread(struct task_struct *dead_task)
 
 #define cpu_relax()     barrier()
 
-/*
- * disable hlt during certain critical i/o operations
- */
-#define HAVE_DISABLE_HLT
-void disable_hlt(void);
-void enable_hlt(void);
-
 void default_idle(void);
 
 #endif /* __ASM_CRIS_PROCESSOR_H */
diff --git a/arch/cris/kernel/process.c b/arch/cris/kernel/process.c
index 104ff4d..508c9cd 100644
--- a/arch/cris/kernel/process.c
+++ b/arch/cris/kernel/process.c
@@ -29,31 +29,6 @@
 
 //#define DEBUG
 
-/*
- * The hlt_counter, disable_hlt and enable_hlt is just here as a hook if
- * there would ever be a halt sequence (for power save when idle) with
- * some largish delay when halting or resuming *and* a driver that can't
- * afford that delay.  The hlt_counter would then be checked before
- * executing the halt sequence, and the driver marks the unhaltable
- * region by enable_hlt/disable_hlt.
- */
-
-int cris_hlt_counter=0;
-
-void disable_hlt(void)
-{
-	cris_hlt_counter++;
-}
-
-EXPORT_SYMBOL(disable_hlt);
-
-void enable_hlt(void)
-{
-	cris_hlt_counter--;
-}
-
-EXPORT_SYMBOL(enable_hlt);
- 
 extern void default_idle(void);
 
 void (*pm_power_off)(void);
diff --git a/arch/microblaze/include/asm/processor.h b/arch/microblaze/include/asm/processor.h
index 0759153..f576fe0 100644
--- a/arch/microblaze/include/asm/processor.h
+++ b/arch/microblaze/include/asm/processor.h
@@ -160,8 +160,6 @@ unsigned long get_wchan(struct task_struct *p);
 #  define STACK_TOP	TASK_SIZE
 #  define STACK_TOP_MAX	STACK_TOP
 
-void disable_hlt(void);
-void enable_hlt(void);
 void default_idle(void);
 
 #ifdef CONFIG_DEBUG_FS
diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c
index fa0ea60..7c36171 100644
--- a/arch/microblaze/kernel/process.c
+++ b/arch/microblaze/kernel/process.c
@@ -46,18 +46,6 @@ EXPORT_SYMBOL(pm_power_off);
 
 static int hlt_counter = 1;
 
-void disable_hlt(void)
-{
-	hlt_counter++;
-}
-EXPORT_SYMBOL(disable_hlt);
-
-void enable_hlt(void)
-{
-	hlt_counter--;
-}
-EXPORT_SYMBOL(enable_hlt);
-
 static int __init nohlt_setup(char *__unused)
 {
 	hlt_counter = 1;
diff --git a/arch/mn10300/kernel/smp.c b/arch/mn10300/kernel/smp.c
index 5d7e152..eaef5ad 100644
--- a/arch/mn10300/kernel/smp.c
+++ b/arch/mn10300/kernel/smp.c
@@ -935,8 +935,6 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 	int timeout;
 
 #ifdef CONFIG_HOTPLUG_CPU
-	if (num_online_cpus() == 1)
-		disable_hlt();
 	if (sleep_mode[cpu])
 		run_wakeup_cpu(cpu);
 #endif /* CONFIG_HOTPLUG_CPU */
@@ -1003,9 +1001,6 @@ int __cpu_disable(void)
 void __cpu_die(unsigned int cpu)
 {
 	run_sleep_cpu(cpu);
-
-	if (num_online_cpus() == 1)
-		enable_hlt();
 }
 
 #ifdef CONFIG_MN10300_CACHE_ENABLED

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] arch: Consolidate tsk_is_polling()
  2013-03-21 21:52 ` [patch 02/34] arch: Consolidate tsk_is_polling() Thomas Gleixner
  2013-03-22  5:01   ` Tony Breeds
  2013-03-22  5:20   ` Tony Breeds
@ 2013-04-08 20:09   ` tip-bot for Thomas Gleixner
  2 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:09 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, tglx, magnus.damm

Commit-ID:  ee761f629d598579594d7e1eb8c552f3c5f71e4d
Gitweb:     http://git.kernel.org/tip/ee761f629d598579594d7e1eb8c552f3c5f71e4d
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:32 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:22 +0200

arch: Consolidate tsk_is_polling()

Move it to a common place. Preparatory patch for implementing
set/clear for the idle need_resched poll implementation.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130321215233.446034505@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/alpha/include/asm/thread_info.h      |  2 --
 arch/ia64/include/asm/thread_info.h       |  2 --
 arch/metag/include/asm/thread_info.h      |  2 --
 arch/microblaze/include/asm/thread_info.h |  1 -
 arch/mn10300/include/asm/thread_info.h    |  2 --
 arch/openrisc/include/asm/thread_info.h   |  2 --
 arch/parisc/include/asm/thread_info.h     |  2 --
 arch/powerpc/include/asm/thread_info.h    |  2 --
 arch/sh/include/asm/thread_info.h         |  2 --
 arch/sparc/include/asm/thread_info_32.h   |  2 --
 arch/sparc/include/asm/thread_info_64.h   |  2 --
 arch/tile/include/asm/thread_info.h       |  2 --
 arch/x86/include/asm/thread_info.h        |  2 --
 include/linux/sched.h                     | 20 ++++++++++++++++++++
 kernel/sched/core.c                       |  5 -----
 15 files changed, 20 insertions(+), 30 deletions(-)

diff --git a/arch/alpha/include/asm/thread_info.h b/arch/alpha/include/asm/thread_info.h
index 1f8c729..52cd2a4 100644
--- a/arch/alpha/include/asm/thread_info.h
+++ b/arch/alpha/include/asm/thread_info.h
@@ -95,8 +95,6 @@ register struct thread_info *__current_thread_info __asm__("$8");
 #define TS_POLLING		0x0010	/* idle task polling need_resched,
 					   skip sending interrupt */
 
-#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
-
 #ifndef __ASSEMBLY__
 #define HAVE_SET_RESTORE_SIGMASK	1
 static inline void set_restore_sigmask(void)
diff --git a/arch/ia64/include/asm/thread_info.h b/arch/ia64/include/asm/thread_info.h
index 020d655..cade13d 100644
--- a/arch/ia64/include/asm/thread_info.h
+++ b/arch/ia64/include/asm/thread_info.h
@@ -131,8 +131,6 @@ struct thread_info {
 #define TS_POLLING		1 	/* true if in idle loop and not sleeping */
 #define TS_RESTORE_SIGMASK	2	/* restore signal mask in do_signal() */
 
-#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
-
 #ifndef __ASSEMBLY__
 #define HAVE_SET_RESTORE_SIGMASK	1
 static inline void set_restore_sigmask(void)
diff --git a/arch/metag/include/asm/thread_info.h b/arch/metag/include/asm/thread_info.h
index 0ecd34d..7c4a330 100644
--- a/arch/metag/include/asm/thread_info.h
+++ b/arch/metag/include/asm/thread_info.h
@@ -150,6 +150,4 @@ static inline int kstack_end(void *addr)
 #define _TIF_WORK_MASK		(_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
 				 _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP))
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #endif /* _ASM_THREAD_INFO_H */
diff --git a/arch/microblaze/include/asm/thread_info.h b/arch/microblaze/include/asm/thread_info.h
index 008f304..de26ea6 100644
--- a/arch/microblaze/include/asm/thread_info.h
+++ b/arch/microblaze/include/asm/thread_info.h
@@ -182,7 +182,6 @@ static inline bool test_and_clear_restore_sigmask(void)
 	ti->status &= ~TS_RESTORE_SIGMASK;
 	return true;
 }
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
 #endif
 
 #endif /* __KERNEL__ */
diff --git a/arch/mn10300/include/asm/thread_info.h b/arch/mn10300/include/asm/thread_info.h
index f90062b..224b426 100644
--- a/arch/mn10300/include/asm/thread_info.h
+++ b/arch/mn10300/include/asm/thread_info.h
@@ -165,8 +165,6 @@ void arch_release_thread_info(struct thread_info *ti);
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */
diff --git a/arch/openrisc/include/asm/thread_info.h b/arch/openrisc/include/asm/thread_info.h
index 07f3212..d797acc 100644
--- a/arch/openrisc/include/asm/thread_info.h
+++ b/arch/openrisc/include/asm/thread_info.h
@@ -128,8 +128,6 @@ register struct thread_info *current_thread_info_reg asm("r10");
 /* For OpenRISC, this is anything in the LSW other than syscall trace */
 #define _TIF_WORK_MASK (0xff & ~(_TIF_SYSCALL_TRACE|_TIF_SINGLESTEP))
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */
diff --git a/arch/parisc/include/asm/thread_info.h b/arch/parisc/include/asm/thread_info.h
index d1fb79a..6182832 100644
--- a/arch/parisc/include/asm/thread_info.h
+++ b/arch/parisc/include/asm/thread_info.h
@@ -77,8 +77,6 @@ struct thread_info {
 #define _TIF_SYSCALL_TRACE_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP |	\
 				 _TIF_BLOCKSTEP)
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_PARISC_THREAD_INFO_H */
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index 406b7b9..8ceea14 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -182,8 +182,6 @@ static inline bool test_thread_local_flags(unsigned int flags)
 #define is_32bit_task()	(1)
 #endif
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #endif	/* !__ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff --git a/arch/sh/include/asm/thread_info.h b/arch/sh/include/asm/thread_info.h
index 7d5ac4e..45a9366 100644
--- a/arch/sh/include/asm/thread_info.h
+++ b/arch/sh/include/asm/thread_info.h
@@ -207,8 +207,6 @@ static inline bool test_and_clear_restore_sigmask(void)
 	return true;
 }
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #endif	/* !__ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
index 25849ae..dd38075 100644
--- a/arch/sparc/include/asm/thread_info_32.h
+++ b/arch/sparc/include/asm/thread_info_32.h
@@ -132,8 +132,6 @@ register struct thread_info *current_thread_info_reg asm("g6");
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING)
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */
diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
index 269bd92..d5e5042 100644
--- a/arch/sparc/include/asm/thread_info_64.h
+++ b/arch/sparc/include/asm/thread_info_64.h
@@ -256,8 +256,6 @@ static inline bool test_and_clear_restore_sigmask(void)
 	return true;
 }
 
-#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
-
 #define thread32_stack_is_64bit(__SP) (((__SP) & 0x1) != 0)
 #define test_thread_64bit_stack(__SP) \
 	((test_thread_flag(TIF_32BIT) && !thread32_stack_is_64bit(__SP)) ? \
diff --git a/arch/tile/include/asm/thread_info.h b/arch/tile/include/asm/thread_info.h
index e9c670d..ccc8ef3 100644
--- a/arch/tile/include/asm/thread_info.h
+++ b/arch/tile/include/asm/thread_info.h
@@ -153,8 +153,6 @@ extern void _cpu_idle(void);
 #define TS_POLLING		0x0004	/* in idle loop but not sleeping */
 #define TS_RESTORE_SIGMASK	0x0008	/* restore signal mask in do_signal */
 
-#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
-
 #ifndef __ASSEMBLY__
 #define HAVE_SET_RESTORE_SIGMASK	1
 static inline void set_restore_sigmask(void)
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
index 2cd056e..a1df6e8 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -241,8 +241,6 @@ static inline struct thread_info *current_thread_info(void)
 					   skip sending interrupt */
 #define TS_RESTORE_SIGMASK	0x0008	/* restore signal mask in do_signal() */
 
-#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
-
 #ifndef __ASSEMBLY__
 #define HAVE_SET_RESTORE_SIGMASK	1
 static inline void set_restore_sigmask(void)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index d35d2b6..6709a58 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2622,6 +2622,26 @@ static inline int spin_needbreak(spinlock_t *lock)
 }
 
 /*
+ * Idle thread specific functions to determine the need_resched
+ * polling state. We have two versions, one based on TS_POLLING in
+ * thread_info.status and one based on TIF_POLLING_NRFLAG in
+ * thread_info.flags
+ */
+#ifdef TS_POLLING
+static inline int tsk_is_polling(struct task_struct *p)
+{
+	return task_thread_info(p)->status & TS_POLLING;
+}
+#elif defined(TIF_POLLING_NRFLAG)
+static inline int tsk_is_polling(struct task_struct *p)
+{
+	return test_tsk_thread_flag(p, TIF_POLLING_NRFLAG);
+}
+#else
+static inline int tsk_is_polling(struct task_struct *p) { return 0; }
+#endif
+
+/*
  * Thread group CPU time accounting.
  */
 void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7f12624..243a20c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -512,11 +512,6 @@ static inline void init_hrtick(void)
  * the target CPU.
  */
 #ifdef CONFIG_SMP
-
-#ifndef tsk_is_polling
-#define tsk_is_polling(t) 0
-#endif
-
 void resched_task(struct task_struct *p)
 {
 	int cpu;

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] idle: Implement set/ clr functions for need_resched poll
  2013-03-21 21:52 ` [patch 03/34] idle: Implement set/clr functions for need_resched poll Thomas Gleixner
  2013-03-22  9:38     ` James Hogan
@ 2013-04-08 20:10   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:10 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, tglx, magnus.damm

Commit-ID:  3a98f871ecaf44806e188184332c3fec27c8f08c
Gitweb:     http://git.kernel.org/tip/3a98f871ecaf44806e188184332c3fec27c8f08c
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:33 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:22 +0200

idle: Implement set/clr functions for need_resched poll

Implement set/clear functions for the idle need_resched poll
implementation.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130321215233.518839807@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/sched.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6709a58..21fe9a1 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2632,13 +2632,34 @@ static inline int tsk_is_polling(struct task_struct *p)
 {
 	return task_thread_info(p)->status & TS_POLLING;
 }
+static inline void current_set_polling(void)
+{
+	current_thread_info()->status |= TS_POLLING;
+}
+
+static inline void current_clr_polling(void)
+{
+	current_thread_info()->status &= ~TS_POLLING;
+	smp_mb__after_clear_bit();
+}
 #elif defined(TIF_POLLING_NRFLAG)
 static inline int tsk_is_polling(struct task_struct *p)
 {
 	return test_tsk_thread_flag(p, TIF_POLLING_NRFLAG);
 }
+static inline void current_set_polling(void)
+{
+	set_thread_flag(TIF_POLLING_NRFLAG);
+}
+
+static inline void current_clr_polling(void)
+{
+	clear_thread_flag(TIF_POLLING_NRFLAG);
+}
 #else
 static inline int tsk_is_polling(struct task_struct *p) { return 0; }
+static inline void current_set_polling(void) { }
+static inline void current_clr_polling(void) { }
 #endif
 
 /*

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] idle: Provide a generic entry point for the idle code
  2013-03-21 21:52 ` [patch 04/34] idle: Provide a generic entry point for the idle code Thomas Gleixner
@ 2013-04-08 20:12   ` tip-bot for Thomas Gleixner
  2013-04-14  0:42     ` Yinghai Lu
  0 siblings, 1 reply; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, tglx, magnus.damm

Commit-ID:  a1a04ec3c7c27a682473fd9beb2c996316a64649
Gitweb:     http://git.kernel.org/tip/a1a04ec3c7c27a682473fd9beb2c996316a64649
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:34 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:23 +0200

idle: Provide a generic entry point for the idle code

For now this calls cpu_idle(), but in the long run we want to move the
cpu bringup code to the core and therefor we add a state argument.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130321215233.583190032@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/cpu.h |  8 ++++++++
 init/main.c         |  2 +-
 kernel/Makefile     |  1 +
 kernel/cpu/Makefile |  1 +
 kernel/cpu/idle.c   | 10 ++++++++++
 5 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index ce7a074..7419e30 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -212,4 +212,12 @@ static inline int disable_nonboot_cpus(void) { return 0; }
 static inline void enable_nonboot_cpus(void) {}
 #endif /* !CONFIG_PM_SLEEP_SMP */
 
+enum cpuhp_state {
+	CPUHP_OFFLINE,
+	CPUHP_ONLINE,
+};
+
+void cpu_startup_entry(enum cpuhp_state state);
+void cpu_idle(void);
+
 #endif /* _LINUX_CPU_H_ */
diff --git a/init/main.c b/init/main.c
index 63534a1..adb179d 100644
--- a/init/main.c
+++ b/init/main.c
@@ -384,7 +384,7 @@ static noinline void __init_refok rest_init(void)
 	init_idle_bootup_task(current);
 	schedule_preempt_disabled();
 	/* Call into cpu_idle with preempt disabled */
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 /* Check for early params. */
diff --git a/kernel/Makefile b/kernel/Makefile
index bbde5f1..d1574d4 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -24,6 +24,7 @@ endif
 
 obj-y += sched/
 obj-y += power/
+obj-y += cpu/
 
 obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o
 obj-$(CONFIG_FREEZER) += freezer.o
diff --git a/kernel/cpu/Makefile b/kernel/cpu/Makefile
new file mode 100644
index 0000000..59ab052
--- /dev/null
+++ b/kernel/cpu/Makefile
@@ -0,0 +1 @@
+obj-y	= idle.o
diff --git a/kernel/cpu/idle.c b/kernel/cpu/idle.c
new file mode 100644
index 0000000..1908f00
--- /dev/null
+++ b/kernel/cpu/idle.c
@@ -0,0 +1,10 @@
+/*
+ * Generic entry point for the idle threads
+ */
+#include <linux/sched.h>
+#include <linux/cpu.h>
+
+void cpu_startup_entry(enum cpuhp_state state)
+{
+	cpu_idle();
+}

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] idle: Implement generic idle function
  2013-03-21 21:53 ` [patch 05/34] idle: Implement generic idle function Thomas Gleixner
  2013-03-23  8:56   ` Heiko Carstens
  2013-03-28 15:39   ` Srivatsa S. Bhat
@ 2013-04-08 20:14   ` tip-bot for Thomas Gleixner
  2013-04-15 22:25     ` Tony Luck
  2013-11-18  6:05   ` [patch 05/34] idle: Implement generic idle function Viresh Kumar
  3 siblings, 1 reply; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:14 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, tglx, magnus.damm

Commit-ID:  d166991234347215dc23fc9dc15a63a83a1a54e1
Gitweb:     http://git.kernel.org/tip/d166991234347215dc23fc9dc15a63a83a1a54e1
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:35 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:23 +0200

idle: Implement generic idle function

All idle functions in arch/* are more or less the same, plus minus a
few bugs and extra instrumentation, tickless support and other
optional items.

Implement a generic idle function which resembles the functionality
found in arch/. Provide weak arch_cpu_idle_* functions which can be
overridden by the architecture code if needed.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130321215233.646635455@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/Kconfig        |   3 ++
 include/linux/cpu.h |   8 ++++
 kernel/cpu/idle.c   | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index 1455579..a699f37 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -216,6 +216,9 @@ config USE_GENERIC_SMP_HELPERS
 config GENERIC_SMP_IDLE_THREAD
        bool
 
+config GENERIC_IDLE_LOOP
+       bool
+
 # Select if arch init_task initializer is different to init/init_task.c
 config ARCH_INIT_TASK
        bool
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 7419e30..c6f6e08 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -220,4 +220,12 @@ enum cpuhp_state {
 void cpu_startup_entry(enum cpuhp_state state);
 void cpu_idle(void);
 
+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);
+
 #endif /* _LINUX_CPU_H_ */
diff --git a/kernel/cpu/idle.c b/kernel/cpu/idle.c
index 1908f00..54c3203 100644
--- a/kernel/cpu/idle.c
+++ b/kernel/cpu/idle.c
@@ -3,8 +3,113 @@
  */
 #include <linux/sched.h>
 #include <linux/cpu.h>
+#include <linux/tick.h>
+#include <linux/mm.h>
 
+#include <asm/tlb.h>
+
+#include <trace/events/power.h>
+
+#ifndef CONFIG_GENERIC_IDLE_LOOP
 void cpu_startup_entry(enum cpuhp_state state)
 {
 	cpu_idle();
 }
+#else
+
+static int __read_mostly cpu_idle_force_poll;
+
+void cpu_idle_poll_ctrl(bool enable)
+{
+	if (enable) {
+		cpu_idle_force_poll++;
+	} else {
+		cpu_idle_force_poll--;
+		WARN_ON_ONCE(cpu_idle_force_poll < 0);
+	}
+}
+
+#ifdef CONFIG_GENERIC_IDLE_POLL_SETUP
+static int __init cpu_idle_poll_setup(char *__unused)
+{
+	cpu_idle_force_poll = 1;
+	return 1;
+}
+__setup("nohlt", cpu_idle_poll_setup);
+
+static int __init cpu_idle_nopoll_setup(char *__unused)
+{
+	cpu_idle_force_poll = 0;
+	return 1;
+}
+__setup("hlt", cpu_idle_nopoll_setup);
+#endif
+
+static inline int cpu_idle_poll(void)
+{
+	trace_cpu_idle_rcuidle(0, smp_processor_id());
+	local_irq_enable();
+	while (!need_resched())
+		cpu_relax();
+	trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
+	return 1;
+}
+
+/* Weak implementations for optional arch specific functions */
+void __weak arch_cpu_idle_prepare(void) { }
+void __weak arch_cpu_idle_enter(void) { }
+void __weak arch_cpu_idle_exit(void) { }
+void __weak arch_cpu_idle_dead(void) { }
+void __weak arch_cpu_idle(void)
+{
+	cpu_idle_force_poll = 1;
+}
+
+/*
+ * Generic idle loop implementation
+ */
+static void cpu_idle_loop(void)
+{
+	while (1) {
+		tick_nohz_idle_enter();
+
+		while (!need_resched()) {
+			check_pgt_cache();
+			rmb();
+
+			if (cpu_is_offline(smp_processor_id()))
+				arch_cpu_idle_dead();
+
+			local_irq_disable();
+			arch_cpu_idle_enter();
+
+			if (cpu_idle_force_poll) {
+				cpu_idle_poll();
+			} else {
+				current_clr_polling();
+				if (!need_resched()) {
+					stop_critical_timings();
+					rcu_idle_enter();
+					arch_cpu_idle();
+					WARN_ON_ONCE(irqs_disabled());
+					rcu_idle_exit();
+					start_critical_timings();
+				} else {
+					local_irq_enable();
+				}
+				current_set_polling();
+			}
+			arch_cpu_idle_exit();
+		}
+		tick_nohz_idle_exit();
+		schedule_preempt_disabled();
+	}
+}
+
+void cpu_startup_entry(enum cpuhp_state state)
+{
+	current_set_polling();
+	arch_cpu_idle_prepare();
+	cpu_idle_loop();
+}
+#endif

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] arc: Use generic idle loop
  2013-03-21 21:53 ` [patch 06/34] arc: Use generic idle loop Thomas Gleixner
  2013-03-22  9:02     ` Vineet Gupta
@ 2013-04-08 20:15   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:15 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, vgupta, tglx, magnus.damm

Commit-ID:  fa35e42a00ec0120db2b5128753206efb288e789
Gitweb:     http://git.kernel.org/tip/fa35e42a00ec0120db2b5128753206efb288e789
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:36 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:23 +0200

arc: Use generic idle loop

The generic idle loop implements all functionality. Aside of that it
allows arc to implement the tsk_is_polling() functionality correctly,
despite the patently (now gone) comment in the original arc cpu_idle()
function:
/* Since we SLEEP in idle loop, TIF_POLLING_NRFLAG can't be set */
See kernel/cpu/idle.c

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
Tested-by: Vineet Gupta <vgupta@synopsys.com>
Link: http://lkml.kernel.org/r/20130321215233.711253792@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/arc/Kconfig          |  1 +
 arch/arc/kernel/process.c | 27 +--------------------------
 arch/arc/kernel/smp.c     |  2 +-
 3 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index e6f4eca..b006977 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -14,6 +14,7 @@ config ARC
 	select GENERIC_ATOMIC64
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_FIND_FIRST_BIT
+	select GENERIC_IDLE_LOOP
 	# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
 	select GENERIC_IRQ_SHOW
 	select GENERIC_KERNEL_EXECVE
diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
index 0a7531d..cad6685 100644
--- a/arch/arc/kernel/process.c
+++ b/arch/arc/kernel/process.c
@@ -41,37 +41,12 @@ SYSCALL_DEFINE0(arc_gettls)
 	return task_thread_info(current)->thr_ptr;
 }
 
-static inline void arch_idle(void)
+void arch_cpu_idle(void)
 {
 	/* sleep, but enable all interrupts before committing */
 	__asm__("sleep 0x3");
 }
 
-void cpu_idle(void)
-{
-	/* Since we SLEEP in idle loop, TIF_POLLING_NRFLAG can't be set */
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-doze:
-		local_irq_disable();
-		if (!need_resched()) {
-			arch_idle();
-			goto doze;
-		} else {
-			local_irq_enable();
-		}
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
-		schedule_preempt_disabled();
-	}
-}
-
 asmlinkage void ret_from_fork(void);
 
 /* Layout of Child kernel mode stack as setup at the end of this function is
diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c
index 3af3e06..5c7fd60 100644
--- a/arch/arc/kernel/smp.c
+++ b/arch/arc/kernel/smp.c
@@ -141,7 +141,7 @@ void __cpuinit start_kernel_secondary(void)
 
 	local_irq_enable();
 	preempt_disable();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 /*

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] alpha: Use generic idle loop
  2013-03-21 21:53 ` [patch 07/34] alpha: Use generic idle loop Thomas Gleixner
  2013-03-28 15:37   ` Srivatsa S. Bhat
@ 2013-04-08 20:16   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, mattst88, ink, tglx, rth, magnus.damm

Commit-ID:  a123322d8afcfb5f86e0cc0062024084658aeeb2
Gitweb:     http://git.kernel.org/tip/a123322d8afcfb5f86e0cc0062024084658aeeb2
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:37 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:23 +0200

alpha: Use generic idle loop

The core provides a generic idle poll loop.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Link: http://lkml.kernel.org/r/20130321215233.766017538@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/alpha/Kconfig          |  1 +
 arch/alpha/kernel/process.c | 19 -------------------
 arch/alpha/kernel/smp.c     |  3 +--
 3 files changed, 2 insertions(+), 21 deletions(-)

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 8a33ba0..6046982 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -17,6 +17,7 @@ config ALPHA
 	select ARCH_WANT_IPC_PARSE_VERSION
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index 63d27fb..a3fd8a2 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -46,25 +46,6 @@
 void (*pm_power_off)(void) = machine_power_off;
 EXPORT_SYMBOL(pm_power_off);
 
-void
-cpu_idle(void)
-{
-	current_thread_info()->status |= TS_POLLING;
-
-	while (1) {
-		/* FIXME -- EV6 and LCA45 know how to power down
-		   the CPU.  */
-
-		rcu_idle_enter();
-		while (!need_resched())
-			cpu_relax();
-
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
-}
-
-
 struct halt_info {
 	int mode;
 	char *restart_cmd;
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index 9603bc2..7b60834 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -167,8 +167,7 @@ smp_callin(void)
 	      cpuid, current, current->active_mm));
 
 	preempt_disable();
-	/* Do nothing.  */
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 /* Wait until hwrpb->txrdy is clear for cpu.  Return -1 on timeout.  */

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] arm: Use generic idle loop
  2013-03-21 21:53 ` [patch 08/34] arm: " Thomas Gleixner
  2013-03-22 21:24   ` Kevin Hilman
@ 2013-04-08 20:17   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:17 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, linux, tglx, magnus.damm

Commit-ID:  f7b861b7a6d9d1838cbbb5f4053e61578b86d134
Gitweb:     http://git.kernel.org/tip/f7b861b7a6d9d1838cbbb5f4053e61578b86d134
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:38 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:24 +0200

arm: Use generic idle loop

Use the generic idle loop and replace enable/disable_hlt with the
respective core functions.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>
Tested-by: Kevin Hilman <khilman@linaro.org> # OMAP
Link: http://lkml.kernel.org/r/20130321215233.826238797@linutronix.de
---
 arch/arm/Kconfig                   |  2 +
 arch/arm/include/asm/system_misc.h |  3 --
 arch/arm/kernel/process.c          | 96 +++++++++++---------------------------
 arch/arm/kernel/smp.c              |  2 +-
 arch/arm/mach-gemini/idle.c        |  4 +-
 arch/arm/mach-gemini/irq.c         |  4 +-
 arch/arm/mach-ixp4xx/common.c      |  3 +-
 arch/arm/mach-omap1/pm.c           |  6 +--
 arch/arm/mach-omap2/omap_hwmod.c   |  7 +--
 arch/arm/mach-omap2/pm.c           |  5 +-
 arch/arm/mach-orion5x/board-dt.c   |  3 +-
 arch/arm/mach-orion5x/common.c     |  2 +-
 arch/arm/mach-shark/core.c         |  3 +-
 arch/arm/mach-shmobile/suspend.c   |  6 ++-
 arch/arm/mach-w90x900/dev.c        |  3 +-
 15 files changed, 57 insertions(+), 92 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1cacda4..128551f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -15,6 +15,8 @@ config ARM
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
+	select GENERIC_IDLE_POLL_SETUP
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
 	select HARDIRQS_SW_RESEND
diff --git a/arch/arm/include/asm/system_misc.h b/arch/arm/include/asm/system_misc.h
index 5a85f14..21a23e3 100644
--- a/arch/arm/include/asm/system_misc.h
+++ b/arch/arm/include/asm/system_misc.h
@@ -21,9 +21,6 @@ extern void (*arm_pm_idle)(void);
 
 extern unsigned int user_debug;
 
-extern void disable_hlt(void);
-extern void enable_hlt(void);
-
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __ASM_ARM_SYSTEM_MISC_H */
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 92884c8..c9a5e2c 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -57,34 +57,6 @@ static const char *isa_modes[] = {
   "ARM" , "Thumb" , "Jazelle", "ThumbEE"
 };
 
-static volatile int hlt_counter;
-
-void disable_hlt(void)
-{
-	hlt_counter++;
-}
-
-void enable_hlt(void)
-{
-	hlt_counter--;
-	BUG_ON(hlt_counter < 0);
-}
-
-static int __init nohlt_setup(char *__unused)
-{
-	hlt_counter = 1;
-	return 1;
-}
-
-static int __init hlt_setup(char *__unused)
-{
-	hlt_counter = 0;
-	return 1;
-}
-
-__setup("nohlt", nohlt_setup);
-__setup("hlt", hlt_setup);
-
 extern void call_with_stack(void (*fn)(void *), void *arg, void *sp);
 typedef void (*phys_reset_t)(unsigned long);
 
@@ -168,54 +140,38 @@ static void default_idle(void)
 	local_irq_enable();
 }
 
-/*
- * The idle thread.
- * We always respect 'hlt_counter' to prevent low power idle.
- */
-void cpu_idle(void)
+void arch_cpu_idle_prepare(void)
 {
 	local_fiq_enable();
+}
 
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		ledtrig_cpu(CPU_LED_IDLE_START);
-		while (!need_resched()) {
-#ifdef CONFIG_HOTPLUG_CPU
-			if (cpu_is_offline(smp_processor_id()))
-				cpu_die();
+void arch_cpu_idle_enter(void)
+{
+	ledtrig_cpu(CPU_LED_IDLE_START);
+#ifdef CONFIG_PL310_ERRATA_769419
+	wmb();
 #endif
+}
 
-			/*
-			 * We need to disable interrupts here
-			 * to ensure we don't miss a wakeup call.
-			 */
-			local_irq_disable();
-#ifdef CONFIG_PL310_ERRATA_769419
-			wmb();
+void arch_cpu_idle_exit(void)
+{
+	ledtrig_cpu(CPU_LED_IDLE_END);
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
+void arch_cpu_idle_dead(void)
+{
+	cpu_die();
+}
 #endif
-			if (hlt_counter) {
-				local_irq_enable();
-				cpu_relax();
-			} else if (!need_resched()) {
-				stop_critical_timings();
-				if (cpuidle_idle_call())
-					default_idle();
-				start_critical_timings();
-				/*
-				 * default_idle functions must always
-				 * return with IRQs enabled.
-				 */
-				WARN_ON(irqs_disabled());
-			} else
-				local_irq_enable();
-		}
-		ledtrig_cpu(CPU_LED_IDLE_END);
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	}
+
+/*
+ * Called from the core idle loop.
+ */
+void arch_cpu_idle(void)
+{
+	if (cpuidle_idle_call())
+		default_idle();
 }
 
 static char reboot_mode = 'h';
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 1f2cccc..4619177 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -336,7 +336,7 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
 	/*
 	 * OK, it's off to the idle thread for us
 	 */
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void __init smp_cpus_done(unsigned int max_cpus)
diff --git a/arch/arm/mach-gemini/idle.c b/arch/arm/mach-gemini/idle.c
index 92bbd6b..87dff4f 100644
--- a/arch/arm/mach-gemini/idle.c
+++ b/arch/arm/mach-gemini/idle.c
@@ -13,9 +13,11 @@ static void gemini_idle(void)
 	 * will never wakeup... Acctualy it is not very good to enable
 	 * interrupts first since scheduler can miss a tick, but there is
 	 * no other way around this. Platforms that needs it for power saving
-	 * should call enable_hlt() in init code, since by default it is
+	 * should enable it in init code, since by default it is
 	 * disabled.
 	 */
+
+	/* FIXME: Enabling interrupts here is racy! */
 	local_irq_enable();
 	cpu_do_idle();
 }
diff --git a/arch/arm/mach-gemini/irq.c b/arch/arm/mach-gemini/irq.c
index 020852d..6d8f6d1 100644
--- a/arch/arm/mach-gemini/irq.c
+++ b/arch/arm/mach-gemini/irq.c
@@ -15,6 +15,8 @@
 #include <linux/stddef.h>
 #include <linux/list.h>
 #include <linux/sched.h>
+#include <linux/cpu.h>
+
 #include <asm/irq.h>
 #include <asm/mach/irq.h>
 #include <asm/system_misc.h>
@@ -77,7 +79,7 @@ void __init gemini_init_irq(void)
 	 * Disable the idle handler by default since it is buggy
 	 * For more info see arch/arm/mach-gemini/idle.c
 	 */
-	disable_hlt();
+	cpu_idle_poll_ctrl(true);
 
 	request_resource(&iomem_resource, &irq_resource);
 
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index 1dbeb7c..6600cff 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -29,6 +29,7 @@
 #include <linux/io.h>
 #include <linux/export.h>
 #include <linux/gpio.h>
+#include <linux/cpu.h>
 
 #include <mach/udc.h>
 #include <mach/hardware.h>
@@ -239,7 +240,7 @@ void __init ixp4xx_init_irq(void)
 	 * ixp4xx does not implement the XScale PWRMODE register
 	 * so it must not call cpu_do_idle().
 	 */
-	disable_hlt();
+	cpu_idle_poll_ctrl(true);
 
 	/* Route all sources to IRQ instead of FIQ */
 	*IXP4XX_ICLR = 0x0;
diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
index 7a7690a..db37f49 100644
--- a/arch/arm/mach-omap1/pm.c
+++ b/arch/arm/mach-omap1/pm.c
@@ -43,6 +43,7 @@
 #include <linux/module.h>
 #include <linux/io.h>
 #include <linux/atomic.h>
+#include <linux/cpu.h>
 
 #include <asm/fncpy.h>
 #include <asm/system_misc.h>
@@ -584,8 +585,7 @@ static void omap_pm_init_proc(void)
 static int omap_pm_prepare(void)
 {
 	/* We cannot sleep in idle until we have resumed */
-	disable_hlt();
-
+	cpu_idle_poll_ctrl(true);
 	return 0;
 }
 
@@ -621,7 +621,7 @@ static int omap_pm_enter(suspend_state_t state)
 
 static void omap_pm_finish(void)
 {
-	enable_hlt();
+	cpu_idle_poll_ctrl(false);
 }
 
 
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index a202a47..e512253 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -138,6 +138,7 @@
 #include <linux/spinlock.h>
 #include <linux/slab.h>
 #include <linux/bootmem.h>
+#include <linux/cpu.h>
 
 #include <asm/system_misc.h>
 
@@ -2157,7 +2158,7 @@ static int _enable(struct omap_hwmod *oh)
 	if (soc_ops.enable_module)
 		soc_ops.enable_module(oh);
 	if (oh->flags & HWMOD_BLOCK_WFI)
-		disable_hlt();
+		cpu_idle_poll_ctrl(true);
 
 	if (soc_ops.update_context_lost)
 		soc_ops.update_context_lost(oh);
@@ -2221,7 +2222,7 @@ static int _idle(struct omap_hwmod *oh)
 	_del_initiator_dep(oh, mpu_oh);
 
 	if (oh->flags & HWMOD_BLOCK_WFI)
-		enable_hlt();
+		cpu_idle_poll_ctrl(false);
 	if (soc_ops.disable_module)
 		soc_ops.disable_module(oh);
 
@@ -2331,7 +2332,7 @@ static int _shutdown(struct omap_hwmod *oh)
 		_del_initiator_dep(oh, mpu_oh);
 		/* XXX what about the other system initiators here? dma, dsp */
 		if (oh->flags & HWMOD_BLOCK_WFI)
-			enable_hlt();
+			cpu_idle_poll_ctrl(false);
 		if (soc_ops.disable_module)
 			soc_ops.disable_module(oh);
 		_disable_clocks(oh);
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 673a4c1..dec5533 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -218,7 +218,7 @@ static int omap_pm_enter(suspend_state_t suspend_state)
 
 static int omap_pm_begin(suspend_state_t state)
 {
-	disable_hlt();
+	cpu_idle_poll_ctrl(true);
 	if (cpu_is_omap34xx())
 		omap_prcm_irq_prepare();
 	return 0;
@@ -226,8 +226,7 @@ static int omap_pm_begin(suspend_state_t state)
 
 static void omap_pm_end(void)
 {
-	enable_hlt();
-	return;
+	cpu_idle_poll_ctrl(false);
 }
 
 static void omap_pm_finish(void)
diff --git a/arch/arm/mach-orion5x/board-dt.c b/arch/arm/mach-orion5x/board-dt.c
index 35a8014..94fbb81 100644
--- a/arch/arm/mach-orion5x/board-dt.c
+++ b/arch/arm/mach-orion5x/board-dt.c
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/cpu.h>
 #include <asm/system_misc.h>
 #include <asm/mach/arch.h>
 #include <mach/orion5x.h>
@@ -52,7 +53,7 @@ static void __init orion5x_dt_init(void)
 	 */
 	if (dev == MV88F5281_DEV_ID && rev == MV88F5281_REV_D0) {
 		printk(KERN_INFO "Orion: Applying 5281 D0 WFI workaround.\n");
-		disable_hlt();
+		cpu_idle_poll_ctrl(true);
 	}
 
 	if (of_machine_is_compatible("lacie,ethernet-disk-mini-v2"))
diff --git a/arch/arm/mach-orion5x/common.c b/arch/arm/mach-orion5x/common.c
index d068f14..ad71c8a 100644
--- a/arch/arm/mach-orion5x/common.c
+++ b/arch/arm/mach-orion5x/common.c
@@ -293,7 +293,7 @@ void __init orion5x_init(void)
 	 */
 	if (dev == MV88F5281_DEV_ID && rev == MV88F5281_REV_D0) {
 		printk(KERN_INFO "Orion: Applying 5281 D0 WFI workaround.\n");
-		disable_hlt();
+		cpu_idle_poll_ctrl(true);
 	}
 
 	/*
diff --git a/arch/arm/mach-shark/core.c b/arch/arm/mach-shark/core.c
index b63dec8..1535557 100644
--- a/arch/arm/mach-shark/core.c
+++ b/arch/arm/mach-shark/core.c
@@ -10,6 +10,7 @@
 #include <linux/sched.h>
 #include <linux/serial_8250.h>
 #include <linux/io.h>
+#include <linux/cpu.h>
 
 #include <asm/setup.h>
 #include <asm/mach-types.h>
@@ -130,7 +131,7 @@ static void __init shark_timer_init(void)
 
 static void shark_init_early(void)
 {
-	disable_hlt();
+	cpu_idle_poll_ctrl(true);
 }
 
 MACHINE_START(SHARK, "Shark")
diff --git a/arch/arm/mach-shmobile/suspend.c b/arch/arm/mach-shmobile/suspend.c
index 47d83f7..5d92b5d 100644
--- a/arch/arm/mach-shmobile/suspend.c
+++ b/arch/arm/mach-shmobile/suspend.c
@@ -12,6 +12,8 @@
 #include <linux/suspend.h>
 #include <linux/module.h>
 #include <linux/err.h>
+#include <linux/cpu.h>
+
 #include <asm/io.h>
 #include <asm/system_misc.h>
 
@@ -23,13 +25,13 @@ static int shmobile_suspend_default_enter(suspend_state_t suspend_state)
 
 static int shmobile_suspend_begin(suspend_state_t state)
 {
-	disable_hlt();
+	cpu_idle_poll_ctrl(true);
 	return 0;
 }
 
 static void shmobile_suspend_end(void)
 {
-	enable_hlt();
+	cpu_idle_poll_ctrl(false);
 }
 
 struct platform_suspend_ops shmobile_suspend_ops = {
diff --git a/arch/arm/mach-w90x900/dev.c b/arch/arm/mach-w90x900/dev.c
index 7abdb96..e65a80a 100644
--- a/arch/arm/mach-w90x900/dev.c
+++ b/arch/arm/mach-w90x900/dev.c
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/cpu.h>
 
 #include <linux/mtd/physmap.h>
 #include <linux/mtd/mtd.h>
@@ -531,7 +532,7 @@ static struct platform_device *nuc900_public_dev[] __initdata = {
 
 void __init nuc900_board_init(struct platform_device **device, int size)
 {
-	disable_hlt();
+	cpu_idle_poll_ctrl(true);
 	platform_add_devices(device, size);
 	platform_add_devices(nuc900_public_dev, ARRAY_SIZE(nuc900_public_dev));
 	spi_register_board_info(nuc900_spi_board_info,

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] arm64: Use generic idle loop
  2013-03-21 21:53 ` [patch 09/34] arm64: " Thomas Gleixner
  2013-03-25 18:06   ` Catalin Marinas
@ 2013-04-08 20:18   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:18 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, catalin.marinas, rusty, torvalds,
	peterz, srivatsa.bhat, paulmck, tglx, magnus.damm

Commit-ID:  0087298f68a726493a637c4f68d148b31102b0d9
Gitweb:     http://git.kernel.org/tip/0087298f68a726493a637c4f68d148b31102b0d9
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:39 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:24 +0200

arm64: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Link: http://lkml.kernel.org/r/20130321215233.887563095@linutronix.de
---
 arch/arm64/Kconfig          |  1 +
 arch/arm64/kernel/process.c | 43 +++++--------------------------------------
 arch/arm64/kernel/smp.c     |  2 +-
 3 files changed, 7 insertions(+), 39 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 9b6d19f..ca2c871 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -9,6 +9,7 @@ config ARM64
 	select CLONE_BACKWARDS
 	select COMMON_CLK
 	select GENERIC_CLOCKEVENTS
+	select GENERIC_IDLE_LOOP
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 0337cdb..83a0ad5 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -84,11 +84,15 @@ EXPORT_SYMBOL_GPL(pm_power_off);
 void (*pm_restart)(const char *cmd);
 EXPORT_SYMBOL_GPL(pm_restart);
 
+void arch_cpu_idle_prepare(void)
+{
+	local_fiq_enable();
+}
 
 /*
  * This is our default idle handler.
  */
-static void default_idle(void)
+void arch_cpu_idle(void)
 {
 	/*
 	 * This should do all the clock switching and wait for interrupt
@@ -98,43 +102,6 @@ static void default_idle(void)
 	local_irq_enable();
 }
 
-/*
- * The idle thread.
- * We always respect 'hlt_counter' to prevent low power idle.
- */
-void cpu_idle(void)
-{
-	local_fiq_enable();
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched()) {
-			/*
-			 * We need to disable interrupts here to ensure
-			 * we don't miss a wakeup call.
-			 */
-			local_irq_disable();
-			if (!need_resched()) {
-				stop_critical_timings();
-				default_idle();
-				start_critical_timings();
-				/*
-				 * default_idle functions should always return
-				 * with IRQs enabled.
-				 */
-				WARN_ON(irqs_disabled());
-			} else {
-				local_irq_enable();
-			}
-		}
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	}
-}
-
 void machine_shutdown(void)
 {
 #ifdef CONFIG_SMP
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index bdd3459..261445c 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -216,7 +216,7 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
 	/*
 	 * OK, it's off to the idle thread for us
 	 */
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void __init smp_cpus_done(unsigned int max_cpus)

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] avr32: Use generic idle loop
  2013-03-21 21:53 ` [patch 10/34] avr32: " Thomas Gleixner
@ 2013-04-08 20:20   ` tip-bot for Thomas Gleixner
  2013-04-09  7:31     ` Hans-Christian Egtvedt
  0 siblings, 1 reply; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:20 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, tglx, magnus.damm, egtvedt

Commit-ID:  01426478df3a8791ff5c8b6b82d409e699cfaf38
Gitweb:     http://git.kernel.org/tip/01426478df3a8791ff5c8b6b82d409e699cfaf38
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:40 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:24 +0200

avr32: Use generic idle loop

Also replace the idle poll enforcement by the generic functionality.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Link: http://lkml.kernel.org/r/20130321215233.950290809@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/avr32/Kconfig                       |  1 +
 arch/avr32/kernel/process.c              | 13 ++-----------
 arch/avr32/kernel/time.c                 |  9 +++++++--
 arch/avr32/mach-at32ap/include/mach/pm.h | 24 ------------------------
 arch/avr32/mach-at32ap/pm-at32ap700x.S   |  7 -------
 5 files changed, 10 insertions(+), 44 deletions(-)

diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig
index c1a868d..bbecda4 100644
--- a/arch/avr32/Kconfig
+++ b/arch/avr32/Kconfig
@@ -10,6 +10,7 @@ config AVR32
 	select VIRT_TO_BUS
 	select GENERIC_IRQ_PROBE
 	select GENERIC_ATOMIC64
+	select GENERIC_IDLE_LOOP
 	select HARDIRQS_SW_RESEND
 	select GENERIC_IRQ_SHOW
 	select ARCH_HAVE_CUSTOM_GPIO_H
diff --git a/arch/avr32/kernel/process.c b/arch/avr32/kernel/process.c
index fd78f58..073c3c2 100644
--- a/arch/avr32/kernel/process.c
+++ b/arch/avr32/kernel/process.c
@@ -30,18 +30,9 @@ EXPORT_SYMBOL(pm_power_off);
  * This file handles the architecture-dependent parts of process handling..
  */
 
-void cpu_idle(void)
+void arch_cpu_idle(void)
 {
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched())
-			cpu_idle_sleep();
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	}
+	cpu_enter_idle();
 }
 
 void machine_halt(void)
diff --git a/arch/avr32/kernel/time.c b/arch/avr32/kernel/time.c
index 05ad291..869a1c6 100644
--- a/arch/avr32/kernel/time.c
+++ b/arch/avr32/kernel/time.c
@@ -12,6 +12,7 @@
 #include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/time.h>
+#include <linux/cpu.h>
 
 #include <asm/sysreg.h>
 
@@ -87,13 +88,17 @@ static void comparator_mode(enum clock_event_mode mode,
 		pr_debug("%s: start\n", evdev->name);
 		/* FALLTHROUGH */
 	case CLOCK_EVT_MODE_RESUME:
-		cpu_disable_idle_sleep();
+		/*
+		 * If we're using the COUNT and COMPARE registers we
+		 * need to force idle poll.
+		 */
+		cpu_idle_poll_ctrl(true);
 		break;
 	case CLOCK_EVT_MODE_UNUSED:
 	case CLOCK_EVT_MODE_SHUTDOWN:
 		sysreg_write(COMPARE, 0);
 		pr_debug("%s: stop\n", evdev->name);
-		cpu_enable_idle_sleep();
+		cpu_idle_poll_ctrl(false);
 		break;
 	default:
 		BUG();
diff --git a/arch/avr32/mach-at32ap/include/mach/pm.h b/arch/avr32/mach-at32ap/include/mach/pm.h
index 979b355..f29ff2c 100644
--- a/arch/avr32/mach-at32ap/include/mach/pm.h
+++ b/arch/avr32/mach-at32ap/include/mach/pm.h
@@ -21,30 +21,6 @@
 extern void cpu_enter_idle(void);
 extern void cpu_enter_standby(unsigned long sdramc_base);
 
-extern bool disable_idle_sleep;
-
-static inline void cpu_disable_idle_sleep(void)
-{
-	disable_idle_sleep = true;
-}
-
-static inline void cpu_enable_idle_sleep(void)
-{
-	disable_idle_sleep = false;
-}
-
-static inline void cpu_idle_sleep(void)
-{
-	/*
-	 * If we're using the COUNT and COMPARE registers for
-	 * timekeeping, we can't use the IDLE state.
-	 */
-	if (disable_idle_sleep)
-		cpu_relax();
-	else
-		cpu_enter_idle();
-}
-
 void intc_set_suspend_handler(unsigned long offset);
 #endif
 
diff --git a/arch/avr32/mach-at32ap/pm-at32ap700x.S b/arch/avr32/mach-at32ap/pm-at32ap700x.S
index f868f4c..1c8e4e6 100644
--- a/arch/avr32/mach-at32ap/pm-at32ap700x.S
+++ b/arch/avr32/mach-at32ap/pm-at32ap700x.S
@@ -18,13 +18,6 @@
 /* Same as 0xfff00000 but fits in a 21 bit signed immediate */
 #define PM_BASE	-0x100000
 
-	.section .bss, "wa", @nobits
-	.global	disable_idle_sleep
-	.type	disable_idle_sleep, @object
-disable_idle_sleep:
-	.int	4
-	.size	disable_idle_sleep, . - disable_idle_sleep
-
 	/* Keep this close to the irq handlers */
 	.section .irq.text, "ax", @progbits
 

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] bfin: Use generic idle loop
  2013-03-21 21:53 ` [patch 11/34] bfin: " Thomas Gleixner
@ 2013-04-08 20:21   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:21 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, vapier, tglx, magnus.damm

Commit-ID:  25d67f860f3a29d216f8206092a284cacbc6127e
Gitweb:     http://git.kernel.org/tip/25d67f860f3a29d216f8206092a284cacbc6127e
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:41 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:24 +0200

bfin: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Link: http://lkml.kernel.org/r/20130321215234.014923303@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/blackfin/Kconfig           |  1 +
 arch/blackfin/kernel/process.c  | 32 ++++++--------------------------
 arch/blackfin/mach-common/smp.c |  2 +-
 3 files changed, 8 insertions(+), 27 deletions(-)

diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index c3f2e0b..3d769a7 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -41,6 +41,7 @@ config BLACKFIN
 	select USE_GENERIC_SMP_HELPERS if SMP
 	select HAVE_NMI_WATCHDOG if NMI_WATCHDOG
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select ARCH_USES_GETTIMEOFFSET if !GENERIC_CLOCKEVENTS
 	select HAVE_MOD_ARCH_SPECIFIC
 	select MODULES_USE_ELF_RELA
diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c
index 9782c03..f34323a 100644
--- a/arch/blackfin/kernel/process.c
+++ b/arch/blackfin/kernel/process.c
@@ -46,15 +46,14 @@ EXPORT_SYMBOL(pm_power_off);
  * The idle loop on BFIN
  */
 #ifdef CONFIG_IDLE_L1
-static void default_idle(void)__attribute__((l1_text));
-void cpu_idle(void)__attribute__((l1_text));
+void arch_cpu_idle(void)__attribute__((l1_text));
 #endif
 
 /*
  * This is our default idle handler.  We need to disable
  * interrupts here to ensure we don't miss a wakeup call.
  */
-static void default_idle(void)
+void arch_cpu_idle(void)
 {
 #ifdef CONFIG_IPIPE
 	ipipe_suspend_domain();
@@ -66,31 +65,12 @@ static void default_idle(void)
 	hard_local_irq_enable();
 }
 
-/*
- * The idle thread.  We try to conserve power, while trying to keep
- * overall latency low.  The architecture specific idle is passed
- * a value to indicate the level of "idleness" of the system.
- */
-void cpu_idle(void)
+#ufdef CONFIG_HOTPLUG_CPU
+void arch_cpu_idle_dead(void)
 {
-	/* endless idle loop with no priority at all */
-	while (1) {
-
-#ifdef CONFIG_HOTPLUG_CPU
-		if (cpu_is_offline(smp_processor_id()))
-			cpu_die();
-#endif
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched())
-			default_idle();
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		preempt_enable_no_resched();
-		schedule();
-		preempt_disable();
-	}
+	cpu_die();
 }
+#endif
 
 /*
  * Do necessary setup to start up a newly executed thread.
diff --git a/arch/blackfin/mach-common/smp.c b/arch/blackfin/mach-common/smp.c
index bb61ae4..1bc2ce6 100644
--- a/arch/blackfin/mach-common/smp.c
+++ b/arch/blackfin/mach-common/smp.c
@@ -335,7 +335,7 @@ void __cpuinit secondary_start_kernel(void)
 	 */
 	calibrate_delay();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void __init smp_prepare_boot_cpu(void)

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] c6x: Use generic idle loop
  2013-03-21 21:53 ` [patch 12/34] c6x: " Thomas Gleixner
@ 2013-04-08 20:22   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:22 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	msalter, paulmck, tglx, magnus.damm

Commit-ID:  e46746cd5542b74f1e34bb1b8a997c5c0a6e69ea
Gitweb:     http://git.kernel.org/tip/e46746cd5542b74f1e34bb1b8a997c5c0a6e69ea
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:42 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:24 +0200

c6x: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Mark Salter <msalter@redhat.com>
Link: http://lkml.kernel.org/r/20130321215234.087033904@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/c6x/Kconfig          |  1 +
 arch/c6x/kernel/process.c | 28 +---------------------------
 2 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/arch/c6x/Kconfig b/arch/c6x/Kconfig
index f6a3648..af2aa4b 100644
--- a/arch/c6x/Kconfig
+++ b/arch/c6x/Kconfig
@@ -18,6 +18,7 @@ config C6X
 	select OF_EARLY_FLATTREE
 	select GENERIC_CLOCKEVENTS
 	select MODULES_USE_ELF_RELA
+	select GENERIC_IDLE_LOOP
 
 config MMU
 	def_bool n
diff --git a/arch/c6x/kernel/process.c b/arch/c6x/kernel/process.c
index 6434df4..57d2ea8 100644
--- a/arch/c6x/kernel/process.c
+++ b/arch/c6x/kernel/process.c
@@ -33,7 +33,7 @@ extern asmlinkage void ret_from_kernel_thread(void);
 void (*pm_power_off)(void);
 EXPORT_SYMBOL(pm_power_off);
 
-static void c6x_idle(void)
+void arch_cpu_idle(void)
 {
 	unsigned long tmp;
 
@@ -49,32 +49,6 @@ static void c6x_idle(void)
 		      : "=b"(tmp));
 }
 
-/*
- * The idle loop for C64x
- */
-void cpu_idle(void)
-{
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (1) {
-			local_irq_disable();
-			if (need_resched()) {
-				local_irq_enable();
-				break;
-			}
-			c6x_idle(); /* enables local irqs */
-		}
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
-		preempt_enable_no_resched();
-		schedule();
-		preempt_disable();
-	}
-}
-
 static void halt_loop(void)
 {
 	printk(KERN_EMERG "System Halted, OK to turn off power\n");

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] cris: Use generic idle loop
  2013-03-21 21:53 ` [patch 13/34] cris: " Thomas Gleixner
  2013-03-27 15:04   ` Jesper Nilsson
@ 2013-04-08 20:23   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:23 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, jesper.nilsson, rusty, torvalds,
	peterz, srivatsa.bhat, paulmck, tglx, magnus.damm

Commit-ID:  8dc7c5ecd8d0f739728d844ee794c4fae169f9c2
Gitweb:     http://git.kernel.org/tip/8dc7c5ecd8d0f739728d844ee794c4fae169f9c2
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:43 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:25 +0200

cris: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Link: http://lkml.kernel.org/r/20130321215234.148829489@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/cris/Kconfig                   |  1 +
 arch/cris/arch-v10/kernel/process.c |  3 ++-
 arch/cris/arch-v32/kernel/process.c | 10 +++-------
 arch/cris/arch-v32/kernel/smp.c     |  4 +---
 arch/cris/kernel/process.c          | 24 ++----------------------
 5 files changed, 9 insertions(+), 33 deletions(-)

diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index 06dd026..1dd3635 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -48,6 +48,7 @@ config CRIS
 	select GENERIC_IRQ_SHOW
 	select GENERIC_IOMAP
 	select GENERIC_SMP_IDLE_THREAD if ETRAX_ARCH_V32
+	select GENERIC_IDLE_LOOP
 	select GENERIC_CMOS_UPDATE
 	select MODULES_USE_ELF_RELA
 	select CLONE_BACKWARDS2
diff --git a/arch/cris/arch-v10/kernel/process.c b/arch/cris/arch-v10/kernel/process.c
index b101875..2ba23c1 100644
--- a/arch/cris/arch-v10/kernel/process.c
+++ b/arch/cris/arch-v10/kernel/process.c
@@ -30,8 +30,9 @@ void etrax_gpio_wake_up_check(void); /* drivers/gpio.c */
 void default_idle(void)
 {
 #ifdef CONFIG_ETRAX_GPIO
-  etrax_gpio_wake_up_check();
+	etrax_gpio_wake_up_check();
 #endif
+	local_irq_enable();
 }
 
 /*
diff --git a/arch/cris/arch-v32/kernel/process.c b/arch/cris/arch-v32/kernel/process.c
index 4857933..57451fa 100644
--- a/arch/cris/arch-v32/kernel/process.c
+++ b/arch/cris/arch-v32/kernel/process.c
@@ -23,13 +23,9 @@ extern void stop_watchdog(void);
 /* We use this if we don't have any better idle routine. */
 void default_idle(void)
 {
-	local_irq_disable();
-	if (!need_resched()) {
-		/* Halt until exception. */
-		__asm__ volatile("ei    \n\t"
-				 "halt      ");
-	}
-	local_irq_enable();
+	/* Halt until exception. */
+	__asm__ volatile("ei    \n\t"
+			 "halt      ");
 }
 
 /*
diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c
index 04a16ed..cdd1202 100644
--- a/arch/cris/arch-v32/kernel/smp.c
+++ b/arch/cris/arch-v32/kernel/smp.c
@@ -145,8 +145,6 @@ smp_boot_one_cpu(int cpuid, struct task_struct idle)
  * specific stuff such as the local timer and the MMU. */
 void __init smp_callin(void)
 {
-	extern void cpu_idle(void);
-
 	int cpu = cpu_now_booting;
 	reg_intr_vect_rw_mask vect_mask = {0};
 
@@ -170,7 +168,7 @@ void __init smp_callin(void)
 	local_irq_enable();
 
 	set_cpu_online(cpu, true);
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 /* Stop execution on this CPU.*/
diff --git a/arch/cris/kernel/process.c b/arch/cris/kernel/process.c
index 508c9cd..b78498e 100644
--- a/arch/cris/kernel/process.c
+++ b/arch/cris/kernel/process.c
@@ -34,29 +34,9 @@ extern void default_idle(void);
 void (*pm_power_off)(void);
 EXPORT_SYMBOL(pm_power_off);
 
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-
-void cpu_idle (void)
+void arch_cpu_idle(void)
 {
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched()) {
-			/*
-			 * Mark this as an RCU critical section so that
-			 * synchronize_kernel() in the unload path waits
-			 * for our completion.
-			 */
-			default_idle();
-		}
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
+	default_idle();
 }
 
 void hard_reset_now (void);

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] frv: Use generic idle loop
  2013-03-21 21:53 ` [patch 14/34] frv: " Thomas Gleixner
@ 2013-04-08 20:24   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:24 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, dhowells, tglx, magnus.damm

Commit-ID:  ccf8e78fe2a7e92b6d43de8023786b9dd199aab1
Gitweb:     http://git.kernel.org/tip/ccf8e78fe2a7e92b6d43de8023786b9dd199aab1
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:44 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:25 +0200

frv: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Link: http://lkml.kernel.org/r/20130321215234.217235264@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/frv/Kconfig          |  1 +
 arch/frv/kernel/process.c | 27 +++++----------------------
 2 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index 2ce731f..0d998db 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -8,6 +8,7 @@ config FRV
 	select HAVE_GENERIC_HARDIRQS
 	select VIRT_TO_BUS
 	select GENERIC_IRQ_SHOW
+	select GENERIC_IDLE_LOOP
 	select HAVE_DEBUG_BUGVERBOSE
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_CPU_DEVICES
diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c
index 23916b2..5d40aeb77 100644
--- a/arch/frv/kernel/process.c
+++ b/arch/frv/kernel/process.c
@@ -59,29 +59,12 @@ static void core_sleep_idle(void)
 	mb();
 }
 
-void (*idle)(void) = core_sleep_idle;
-
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle(void)
+void arch_cpu_idle(void)
 {
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched()) {
-			check_pgt_cache();
-
-			if (!frv_dma_inprogress && idle)
-				idle();
-		}
-		rcu_idle_exit();
-
-		schedule_preempt_disabled();
-	}
+	if (!frv_dma_inprogress)
+		core_sleep_idle();
+	else
+		local_irq_enable();
 }
 
 void machine_restart(char * __unused)

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] h8300: Use generic idle loop
  2013-03-21 21:53 ` [patch 15/34] h8300: " Thomas Gleixner
@ 2013-04-08 20:26   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:26 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, tglx, ysato, magnus.damm

Commit-ID:  0d24260c9e27fc1de20c72669bcc387767a1c170
Gitweb:     http://git.kernel.org/tip/0d24260c9e27fc1de20c72669bcc387767a1c170
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:45 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:25 +0200

h8300: Use generic idle loop

Use the core idle poll function instead of the private one

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Link: http://lkml.kernel.org/r/20130321215234.277153345@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/h8300/Kconfig          |  1 +
 arch/h8300/kernel/process.c | 35 ++++-------------------------------
 2 files changed, 5 insertions(+), 31 deletions(-)

diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 79250de..5374975 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -8,6 +8,7 @@ config H8300
 	select VIRT_TO_BUS
 	select ARCH_WANT_IPC_PARSE_VERSION
 	select GENERIC_IRQ_SHOW
+	select GENERIC_IDLE_LOOP
 	select GENERIC_CPU_DEVICES
 	select MODULES_USE_ELF_RELA
 	select OLD_SIGSUSPEND3
diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c
index b609f63..a17d2cd 100644
--- a/arch/h8300/kernel/process.c
+++ b/arch/h8300/kernel/process.c
@@ -53,40 +53,13 @@ asmlinkage void ret_from_kernel_thread(void);
  * The idle loop on an H8/300..
  */
 #if !defined(CONFIG_H8300H_SIM) && !defined(CONFIG_H8S_SIM)
-static void default_idle(void)
+void arch_cpu_idle(void)
 {
-	local_irq_disable();
-	if (!need_resched()) {
-		local_irq_enable();
-		/* XXX: race here! What if need_resched() gets set now? */
-		__asm__("sleep");
-	} else
-		local_irq_enable();
-}
-#else
-static void default_idle(void)
-{
-	cpu_relax();
+	local_irq_enable();
+	/* XXX: race here! What if need_resched() gets set now? */
+	__asm__("sleep");
 }
 #endif
-void (*idle)(void) = default_idle;
-
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle(void)
-{
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched())
-			idle();
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
-}
 
 void machine_restart(char * __unused)
 {

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] hexagon: Use generic idle loop
  2013-03-21 21:53 ` [patch 16/34] hexagon: " Thomas Gleixner
@ 2013-04-08 20:27   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:27 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, tglx, magnus.damm, rkuo

Commit-ID:  4e0fcc567239ef4b3f80bba778c30b0a4b624eff
Gitweb:     http://git.kernel.org/tip/4e0fcc567239ef4b3f80bba778c30b0a4b624eff
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:46 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:25 +0200

hexagon: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Acked-by: Richard Kuo <rkuo@codeaurora.org>
Link: http://lkml.kernel.org/r/20130321215234.338692935@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/hexagon/Kconfig          |  1 +
 arch/hexagon/kernel/process.c | 23 +++--------------------
 arch/hexagon/kernel/smp.c     |  2 +-
 3 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index e4decc6..6e3710e 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -24,6 +24,7 @@ config HEXAGON
 	select NO_IOPORT
 	select GENERIC_IOMAP
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select STACKTRACE_SUPPORT
 	select KTIME_SCALAR
 	select GENERIC_CLOCKEVENTS
diff --git a/arch/hexagon/kernel/process.c b/arch/hexagon/kernel/process.c
index 06ae9ff..9b948c6 100644
--- a/arch/hexagon/kernel/process.c
+++ b/arch/hexagon/kernel/process.c
@@ -51,28 +51,11 @@ void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp)
  *  If hardware or VM offer wait termination even though interrupts
  *  are disabled.
  */
-static void default_idle(void)
+void arch_cpu_idle(void)
 {
 	__vmwait();
-}
-
-void (*idle_sleep)(void) = default_idle;
-
-void cpu_idle(void)
-{
-	while (1) {
-		tick_nohz_idle_enter();
-		local_irq_disable();
-		while (!need_resched()) {
-			idle_sleep();
-			/*  interrupts wake us up, but aren't serviced  */
-			local_irq_enable();	/* service interrupt   */
-			local_irq_disable();
-		}
-		local_irq_enable();
-		tick_nohz_idle_exit();
-		schedule();
-	}
+	/*  interrupts wake us up, but irqs are still disabled */
+	local_irq_enable();
 }
 
 /*
diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c
index 8e095df..0e364ca 100644
--- a/arch/hexagon/kernel/smp.c
+++ b/arch/hexagon/kernel/smp.c
@@ -184,7 +184,7 @@ void __cpuinit start_secondary(void)
 
 	local_irq_enable();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] ia64: Use generic idle loop
  2013-03-21 21:53 ` [patch 17/34] ia64: " Thomas Gleixner
  2013-03-28 15:40   ` Srivatsa S. Bhat
@ 2013-04-08 20:28   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:28 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, tony.luck,
	srivatsa.bhat, paulmck, tglx, magnus.damm

Commit-ID:  91d591c387af34db00c39da2d1d25e69a91cf591
Gitweb:     http://git.kernel.org/tip/91d591c387af34db00c39da2d1d25e69a91cf591
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:47 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:25 +0200

ia64: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Tony Luck <tony.luck@intel.com>
Link: http://lkml.kernel.org/r/20130321215234.406851909@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/ia64/Kconfig          |  1 +
 arch/ia64/kernel/perfmon.c | 14 +++------
 arch/ia64/kernel/process.c | 78 ++++++++++------------------------------------
 arch/ia64/kernel/smpboot.c |  2 +-
 4 files changed, 23 insertions(+), 72 deletions(-)

diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 9a02f71..e0b39c3 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -35,6 +35,7 @@ config IA64
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_IOMAP
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select ARCH_INIT_TASK
 	select ARCH_TASK_STRUCT_ALLOCATOR
 	select ARCH_THREAD_INFO_ALLOCATOR
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 2eda284..9ea25fc 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -42,6 +42,7 @@
 #include <linux/completion.h>
 #include <linux/tracehook.h>
 #include <linux/slab.h>
+#include <linux/cpu.h>
 
 #include <asm/errno.h>
 #include <asm/intrinsics.h>
@@ -1322,8 +1323,6 @@ out:
 }
 EXPORT_SYMBOL(pfm_unregister_buffer_fmt);
 
-extern void update_pal_halt_status(int);
-
 static int
 pfm_reserve_session(struct task_struct *task, int is_syswide, unsigned int cpu)
 {
@@ -1371,9 +1370,9 @@ pfm_reserve_session(struct task_struct *task, int is_syswide, unsigned int cpu)
 		cpu));
 
 	/*
-	 * disable default_idle() to go to PAL_HALT
+	 * Force idle() into poll mode
 	 */
-	update_pal_halt_status(0);
+	cpu_idle_poll_ctrl(true);
 
 	UNLOCK_PFS(flags);
 
@@ -1430,11 +1429,8 @@ pfm_unreserve_session(pfm_context_t *ctx, int is_syswide, unsigned int cpu)
 		is_syswide,
 		cpu));
 
-	/*
-	 * if possible, enable default_idle() to go into PAL_HALT
-	 */
-	if (pfm_sessions.pfs_task_sessions == 0 && pfm_sessions.pfs_sys_sessions == 0)
-		update_pal_halt_status(1);
+	/* Undo forced polling. Last session reenables pal_halt */
+	cpu_idle_poll_ctrl(false);
 
 	UNLOCK_PFS(flags);
 
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index 6f7dc8b..a26fc64 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -209,41 +209,13 @@ do_notify_resume_user(sigset_t *unused, struct sigscratch *scr, long in_syscall)
 	local_irq_disable();	/* force interrupt disable */
 }
 
-static int pal_halt        = 1;
-static int can_do_pal_halt = 1;
-
 static int __init nohalt_setup(char * str)
 {
-	pal_halt = can_do_pal_halt = 0;
+	cpu_idle_poll_ctrl(true);
 	return 1;
 }
 __setup("nohalt", nohalt_setup);
 
-void
-update_pal_halt_status(int status)
-{
-	can_do_pal_halt = pal_halt && status;
-}
-
-/*
- * We use this if we don't have any better idle routine..
- */
-void
-default_idle (void)
-{
-	local_irq_enable();
-	while (!need_resched()) {
-		if (can_do_pal_halt) {
-			local_irq_disable();
-			if (!need_resched()) {
-				safe_halt();
-			}
-			local_irq_enable();
-		} else
-			cpu_relax();
-	}
-}
-
 #ifdef CONFIG_HOTPLUG_CPU
 /* We don't actually take CPU down, just spin without interrupts. */
 static inline void play_dead(void)
@@ -270,47 +242,29 @@ static inline void play_dead(void)
 }
 #endif /* CONFIG_HOTPLUG_CPU */
 
-void __attribute__((noreturn))
-cpu_idle (void)
+void arch_cpu_idle_dead(void)
+{
+	play_dead();
+}
+
+void arch_cpu_idle(void)
 {
 	void (*mark_idle)(int) = ia64_mark_idle;
-  	int cpu = smp_processor_id();
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		if (can_do_pal_halt) {
-			current_thread_info()->status &= ~TS_POLLING;
-			/*
-			 * TS_POLLING-cleared state must be visible before we
-			 * test NEED_RESCHED:
-			 */
-			smp_mb();
-		} else {
-			current_thread_info()->status |= TS_POLLING;
-		}
 
-		if (!need_resched()) {
 #ifdef CONFIG_SMP
-			min_xtp();
+	min_xtp();
 #endif
-			rmb();
-			if (mark_idle)
-				(*mark_idle)(1);
+	rmb();
+	if (mark_idle)
+		(*mark_idle)(1);
+
+	safe_halt();
 
-			default_idle();
-			if (mark_idle)
-				(*mark_idle)(0);
+	if (mark_idle)
+		(*mark_idle)(0);
 #ifdef CONFIG_SMP
-			normal_xtp();
+	normal_xtp();
 #endif
-		}
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-		check_pgt_cache();
-		if (cpu_is_offline(cpu))
-			play_dead();
-	}
 }
 
 void
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index 500f1e4..8d87168 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -455,7 +455,7 @@ start_secondary (void *unused)
 	preempt_disable();
 	smp_callin();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] m32r: Use generic idle loop
  2013-03-21 21:53 ` [patch 18/34] m32r: " Thomas Gleixner
@ 2013-04-08 20:29   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, takata, tglx, magnus.damm

Commit-ID:  01436228bfefca77493efa00aa49a8b67167d4c5
Gitweb:     http://git.kernel.org/tip/01436228bfefca77493efa00aa49a8b67167d4c5
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:48 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:26 +0200

m32r: Use generic idle loop

Replace the private poller.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Hirokazu Takata <takata@linux-m32r.org>
Link: http://lkml.kernel.org/r/20130321215234.470547189@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/m32r/Kconfig          |  1 +
 arch/m32r/kernel/process.c | 18 ------------------
 arch/m32r/kernel/smpboot.c |  2 +-
 3 files changed, 2 insertions(+), 19 deletions(-)

diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index bcd17b2..af814fe 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -13,6 +13,7 @@ config M32R
 	select VIRT_TO_BUS
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
+	select GENERIC_IDLE_LOOP
 	select GENERIC_ATOMIC64
 	select ARCH_USES_GETTIMEOFFSET
 	select MODULES_USE_ELF_RELA
diff --git a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c
index bde899e..e2d0490 100644
--- a/arch/m32r/kernel/process.c
+++ b/arch/m32r/kernel/process.c
@@ -47,24 +47,6 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
 void (*pm_power_off)(void) = NULL;
 EXPORT_SYMBOL(pm_power_off);
 
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle (void)
-{
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched())
-			cpu_relax();
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
-}
-
 void machine_restart(char *__unused)
 {
 #if defined(CONFIG_PLAT_MAPPI3)
diff --git a/arch/m32r/kernel/smpboot.c b/arch/m32r/kernel/smpboot.c
index 13168a7..0ac558a 100644
--- a/arch/m32r/kernel/smpboot.c
+++ b/arch/m32r/kernel/smpboot.c
@@ -432,7 +432,7 @@ int __init start_secondary(void *unused)
 	 */
 	local_flush_tlb_all();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] m68k: Use generic idle loop
  2013-03-21 21:53 ` [patch 19/34] m68k: " Thomas Gleixner
@ 2013-04-08 20:30   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, geert, tglx, magnus.damm

Commit-ID:  dfa174dcf841d0665065dedec2bc133227da56ef
Gitweb:     http://git.kernel.org/tip/dfa174dcf841d0665065dedec2bc133227da56ef
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:49 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:26 +0200

m68k: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Link: http://lkml.kernel.org/r/20130321215234.535485189@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/m68k/Kconfig          |  1 +
 arch/m68k/kernel/process.c | 32 ++++----------------------------
 2 files changed, 5 insertions(+), 28 deletions(-)

diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 6de8133..41859405 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -6,6 +6,7 @@ config M68K
 	select HAVE_DEBUG_BUGVERBOSE
 	select HAVE_GENERIC_HARDIRQS
 	select GENERIC_IRQ_SHOW
+	select GENERIC_IDLE_LOOP
 	select GENERIC_ATOMIC64
 	select HAVE_UID16
 	select VIRT_TO_BUS
diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c
index d538694..c55ff71 100644
--- a/arch/m68k/kernel/process.c
+++ b/arch/m68k/kernel/process.c
@@ -51,40 +51,16 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
 		return sw->retpc;
 }
 
-/*
- * The idle loop on an m68k..
- */
-static void default_idle(void)
+void arch_cpu_idle(void)
 {
-	if (!need_resched())
 #if defined(MACH_ATARI_ONLY)
-		/* block out HSYNC on the atari (falcon) */
-		__asm__("stop #0x2200" : : : "cc");
+	/* block out HSYNC on the atari (falcon) */
+	__asm__("stop #0x2200" : : : "cc");
 #else
-		__asm__("stop #0x2000" : : : "cc");
+	__asm__("stop #0x2000" : : : "cc");
 #endif
 }
 
-void (*idle)(void) = default_idle;
-
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle(void)
-{
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched())
-			idle();
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
-}
-
 void machine_restart(char * __unused)
 {
 	if (mach_reset)

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] metag: Use generic idle loop
  2013-03-21 21:53 ` [patch 20/34] metag: " Thomas Gleixner
  2013-03-22 10:16     ` James Hogan
@ 2013-04-08 20:32   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, james.hogan, rusty, torvalds, peterz,
	srivatsa.bhat, paulmck, tglx, magnus.damm

Commit-ID:  d1dba0fcd3e62f32d5925bcb91eba8757951464c
Gitweb:     http://git.kernel.org/tip/d1dba0fcd3e62f32d5925bcb91eba8757951464c
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:50 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:26 +0200

metag: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: James Hogan <james.hogan@imgtec.com>
Link: http://lkml.kernel.org/r/20130321215234.606480852@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/metag/Kconfig          |  1 +
 arch/metag/kernel/process.c | 35 ++++++-----------------------------
 arch/metag/kernel/smp.c     |  2 +-
 3 files changed, 8 insertions(+), 30 deletions(-)

diff --git a/arch/metag/Kconfig b/arch/metag/Kconfig
index afc8973..3164f6c 100644
--- a/arch/metag/Kconfig
+++ b/arch/metag/Kconfig
@@ -7,6 +7,7 @@ config METAG
 	select EMBEDDED
 	select GENERIC_ATOMIC64
 	select GENERIC_CLOCKEVENTS
+	select GENERIC_IDLE_LOOP
 	select GENERIC_IRQ_SHOW
 	select GENERIC_SMP_IDLE_THREAD
 	select HAVE_64BIT_ALIGNED_ACCESS
diff --git a/arch/metag/kernel/process.c b/arch/metag/kernel/process.c
index c6efe62..dc59235 100644
--- a/arch/metag/kernel/process.c
+++ b/arch/metag/kernel/process.c
@@ -22,6 +22,7 @@
 #include <linux/pm.h>
 #include <linux/syscalls.h>
 #include <linux/uaccess.h>
+#include <linux/smp.h>
 #include <asm/core_reg.h>
 #include <asm/user_gateway.h>
 #include <asm/tcm.h>
@@ -31,7 +32,7 @@
 /*
  * Wait for the next interrupt and enable local interrupts
  */
-static inline void arch_idle(void)
+void arch_cpu_idle(void)
 {
 	int tmp;
 
@@ -59,36 +60,12 @@ static inline void arch_idle(void)
 		      : "r" (get_trigger_mask()));
 }
 
-void cpu_idle(void)
-{
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched()) {
-			/*
-			 * We need to disable interrupts here to ensure we don't
-			 * miss a wakeup call.
-			 */
-			local_irq_disable();
-			if (!need_resched()) {
 #ifdef CONFIG_HOTPLUG_CPU
-				if (cpu_is_offline(smp_processor_id()))
-					cpu_die();
-#endif
-				arch_idle();
-			} else {
-				local_irq_enable();
-			}
-		}
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	 }
+void arch_cpu_idle_dead(void)
+{
+	cpu_die();
 }
+#endif
 
 void (*pm_power_off)(void);
 EXPORT_SYMBOL(pm_power_off);
diff --git a/arch/metag/kernel/smp.c b/arch/metag/kernel/smp.c
index 4b6d1f14..4de8fc8 100644
--- a/arch/metag/kernel/smp.c
+++ b/arch/metag/kernel/smp.c
@@ -297,7 +297,7 @@ asmlinkage void secondary_start_kernel(void)
 	/*
 	 * OK, it's off to the idle thread for us
 	 */
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void __init smp_cpus_done(unsigned int max_cpus)

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] microblaze: Use generic idle loop
  2013-03-21 21:53 ` [patch 21/34] microblaze: " Thomas Gleixner
@ 2013-04-08 20:33   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, monstr, tglx, magnus.damm

Commit-ID:  e962bb9e9cf73b8c8893c95903e791dd5ec19fb4
Gitweb:     http://git.kernel.org/tip/e962bb9e9cf73b8c8893c95903e791dd5ec19fb4
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:51 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:26 +0200

microblaze: Use generic idle loop

The microblaze idle loop provides a polling and a non polling version,
which are suprisingly both polling, just with slightly different
instrumentation. Remove them and use the generic poller.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Michal Simek <monstr@monstr.eu>
Link: http://lkml.kernel.org/r/20130321215234.687590459@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/microblaze/Kconfig                 |  2 ++
 arch/microblaze/include/asm/processor.h |  3 --
 arch/microblaze/kernel/process.c        | 53 ---------------------------------
 3 files changed, 2 insertions(+), 56 deletions(-)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 1323fa2..0bb0d51 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -26,6 +26,8 @@ config MICROBLAZE
 	select GENERIC_CPU_DEVICES
 	select GENERIC_ATOMIC64
 	select GENERIC_CLOCKEVENTS
+	select GENERIC_IDLE_LOOP
+	select GENERIC_IDLE_POLL_SETUP
 	select MODULES_USE_ELF_RELA
 	select CLONE_BACKWARDS
 
diff --git a/arch/microblaze/include/asm/processor.h b/arch/microblaze/include/asm/processor.h
index f576fe0..d6e0ffe 100644
--- a/arch/microblaze/include/asm/processor.h
+++ b/arch/microblaze/include/asm/processor.h
@@ -22,7 +22,6 @@
 extern const struct seq_operations cpuinfo_op;
 
 # define cpu_relax()		barrier()
-# define cpu_sleep()		do {} while (0)
 
 #define task_pt_regs(tsk) \
 		(((struct pt_regs *)(THREAD_SIZE + task_stack_page(tsk))) - 1)
@@ -160,8 +159,6 @@ unsigned long get_wchan(struct task_struct *p);
 #  define STACK_TOP	TASK_SIZE
 #  define STACK_TOP_MAX	STACK_TOP
 
-void default_idle(void);
-
 #ifdef CONFIG_DEBUG_FS
 extern struct dentry *of_debugfs_root;
 #endif
diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c
index 7c36171..7cce2e9 100644
--- a/arch/microblaze/kernel/process.c
+++ b/arch/microblaze/kernel/process.c
@@ -44,59 +44,6 @@ void show_regs(struct pt_regs *regs)
 void (*pm_power_off)(void) = NULL;
 EXPORT_SYMBOL(pm_power_off);
 
-static int hlt_counter = 1;
-
-static int __init nohlt_setup(char *__unused)
-{
-	hlt_counter = 1;
-	return 1;
-}
-__setup("nohlt", nohlt_setup);
-
-static int __init hlt_setup(char *__unused)
-{
-	hlt_counter = 0;
-	return 1;
-}
-__setup("hlt", hlt_setup);
-
-void default_idle(void)
-{
-	if (likely(hlt_counter)) {
-		local_irq_disable();
-		stop_critical_timings();
-		cpu_relax();
-		start_critical_timings();
-		local_irq_enable();
-	} else {
-		clear_thread_flag(TIF_POLLING_NRFLAG);
-		smp_mb__after_clear_bit();
-		local_irq_disable();
-		while (!need_resched())
-			cpu_sleep();
-		local_irq_enable();
-		set_thread_flag(TIF_POLLING_NRFLAG);
-	}
-}
-
-void cpu_idle(void)
-{
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched())
-			default_idle();
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
-		schedule_preempt_disabled();
-		check_pgt_cache();
-	}
-}
-
 void flush_thread(void)
 {
 }

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] mips: Use generic idle loop
  2013-03-21 21:53 ` [patch 22/34] mips: " Thomas Gleixner
  2013-03-28 15:42   ` Srivatsa S. Bhat
@ 2013-04-08 20:34   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, ralf, tglx, magnus.damm

Commit-ID:  cdbedc61c8d0122ad682815936f0d11df1fe5f57
Gitweb:     http://git.kernel.org/tip/cdbedc61c8d0122ad682815936f0d11df1fe5f57
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:52 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:26 +0200

mips: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Link: http://lkml.kernel.org/r/20130321215234.754954871@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/mips/Kconfig          |  1 +
 arch/mips/kernel/process.c | 48 +++++++++++++++-------------------------------
 arch/mips/kernel/smp.c     |  2 +-
 3 files changed, 17 insertions(+), 34 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 51244bf..e1a3d02 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -34,6 +34,7 @@ config MIPS
 	select HAVE_MEMBLOCK_NODE_MAP
 	select ARCH_DISCARD_MEMBLOCK
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select BUILDTIME_EXTABLE_SORT
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_CMOS_UPDATE
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 3be4405..cfc742d 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -41,44 +41,26 @@
 #include <asm/inst.h>
 #include <asm/stacktrace.h>
 
-/*
- * The idle thread. There's no useful work to be done, so just try to conserve
- * power and have a low exit latency (ie sit in a loop waiting for somebody to
- * say that they'd like to reschedule)
- */
-void __noreturn cpu_idle(void)
+#ifdef CONFIG_HOTPLUG_CPU
+void arch_cpu_idle_dead(void)
 {
-	int cpu;
-
-	/* CPU is going idle. */
-	cpu = smp_processor_id();
+	/* What the heck is this check doing ? */
+	if (!cpu_isset(smp_processor_id(), cpu_callin_map))
+		play_dead();
+}
+#endif
 
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched() && cpu_online(cpu)) {
+void arch_cpu_idle(void)
+{
 #ifdef CONFIG_MIPS_MT_SMTC
-			extern void smtc_idle_loop_hook(void);
+	extern void smtc_idle_loop_hook(void);
 
-			smtc_idle_loop_hook();
+	smtc_idle_loop_hook();
 #endif
-
-			if (cpu_wait) {
-				/* Don't trace irqs off for idle */
-				stop_critical_timings();
-				(*cpu_wait)();
-				start_critical_timings();
-			}
-		}
-#ifdef CONFIG_HOTPLUG_CPU
-		if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map))
-			play_dead();
-#endif
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	}
+	if (cpu_wait)
+		(*cpu_wait)();
+	else
+		local_irq_enable();
 }
 
 asmlinkage void ret_from_fork(void);
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 66bf4e2..aee04af 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -139,7 +139,7 @@ asmlinkage __cpuinit void start_secondary(void)
 	WARN_ON_ONCE(!irqs_disabled());
 	mp_ops->smp_finish();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 /*

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] mn10300: Use generic idle loop
  2013-03-21 21:53 ` [patch 23/34] mn10300: " Thomas Gleixner
@ 2013-04-08 20:35   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, dhowells, tglx, magnus.damm

Commit-ID:  af695cd931edab7f202fb616d69d4b746c5d6912
Gitweb:     http://git.kernel.org/tip/af695cd931edab7f202fb616d69d4b746c5d6912
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:53 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:27 +0200

mn10300: Use generic idle loop

default_idle() boils down to safe_halt() and the other option is idle
polling. Use the core functionality.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Link: http://lkml.kernel.org/r/20130321215234.822656036@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/mn10300/Kconfig          |  1 +
 arch/mn10300/kernel/process.c | 70 ++++---------------------------------------
 arch/mn10300/kernel/smp.c     |  2 +-
 3 files changed, 8 insertions(+), 65 deletions(-)

diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
index 428da17..ae7158b6 100644
--- a/arch/mn10300/Kconfig
+++ b/arch/mn10300/Kconfig
@@ -13,6 +13,7 @@ config MN10300
 	select MODULES_USE_ELF_RELA
 	select OLD_SIGSUSPEND3
 	select OLD_SIGACTION
+	select GENERIC_IDLE_LOOP
 
 config AM33_2
 	def_bool n
diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c
index 84f4e97..2da39fb 100644
--- a/arch/mn10300/kernel/process.c
+++ b/arch/mn10300/kernel/process.c
@@ -50,77 +50,19 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
 void (*pm_power_off)(void);
 EXPORT_SYMBOL(pm_power_off);
 
-#if !defined(CONFIG_SMP) || defined(CONFIG_HOTPLUG_CPU)
-/*
- * we use this if we don't have any better idle routine
- */
-static void default_idle(void)
-{
-	local_irq_disable();
-	if (!need_resched())
-		safe_halt();
-	else
-		local_irq_enable();
-}
-
-#else /* !CONFIG_SMP || CONFIG_HOTPLUG_CPU  */
 /*
  * On SMP it's slightly faster (but much more power-consuming!)
  * to poll the ->work.need_resched flag instead of waiting for the
  * cross-CPU IPI to arrive. Use this option with caution.
+ *
+ * tglx: No idea why this depends on HOTPLUG_CPU !?!
  */
-static inline void poll_idle(void)
-{
-	int oldval;
-
-	local_irq_enable();
-
-	/*
-	 * Deal with another CPU just having chosen a thread to
-	 * run here:
-	 */
-	oldval = test_and_clear_thread_flag(TIF_NEED_RESCHED);
-
-	if (!oldval) {
-		set_thread_flag(TIF_POLLING_NRFLAG);
-		while (!need_resched())
-			cpu_relax();
-		clear_thread_flag(TIF_POLLING_NRFLAG);
-	} else {
-		set_need_resched();
-	}
-}
-#endif /* !CONFIG_SMP || CONFIG_HOTPLUG_CPU */
-
-/*
- * the idle thread
- * - there's no useful work to be done, so just try to conserve power and have
- *   a low exit latency (ie sit in a loop waiting for somebody to say that
- *   they'd like to reschedule)
- */
-void cpu_idle(void)
+#if !defined(CONFIG_SMP) || defined(CONFIG_HOTPLUG_CPU)
+void arch_cpu_idle(void)
 {
-	/* endless idle loop with no priority at all */
-	for (;;) {
-		rcu_idle_enter();
-		while (!need_resched()) {
-			void (*idle)(void);
-
-			smp_rmb();
-			if (!idle) {
-#if defined(CONFIG_SMP) && !defined(CONFIG_HOTPLUG_CPU)
-				idle = poll_idle;
-#else  /* CONFIG_SMP && !CONFIG_HOTPLUG_CPU */
-				idle = default_idle;
-#endif /* CONFIG_SMP && !CONFIG_HOTPLUG_CPU */
-			}
-			idle();
-		}
-		rcu_idle_exit();
-
-		schedule_preempt_disabled();
-	}
+	safe_halt();
 }
+#endif
 
 void release_segments(struct mm_struct *mm)
 {
diff --git a/arch/mn10300/kernel/smp.c b/arch/mn10300/kernel/smp.c
index eaef5ad..a17f9c9 100644
--- a/arch/mn10300/kernel/smp.c
+++ b/arch/mn10300/kernel/smp.c
@@ -675,7 +675,7 @@ int __init start_secondary(void *unused)
 #ifdef CONFIG_GENERIC_CLOCKEVENTS
 	init_clockevents();
 #endif
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] openrisc: Use generic idle loop
  2013-03-21 21:53 ` [patch 24/34] openrisc: " Thomas Gleixner
@ 2013-04-08 20:36   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, tglx, magnus.damm

Commit-ID:  6862c05ce4bc59ac52165df66f2a55ad692ef941
Gitweb:     http://git.kernel.org/tip/6862c05ce4bc59ac52165df66f2a55ad692ef941
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:54 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:27 +0200

openrisc: Use generic idle loop

Idle poller with an extra check_pgt_cache() invocation. Use the core
code.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130321215234.886530981@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/openrisc/Kconfig         |  1 +
 arch/openrisc/kernel/Makefile |  2 +-
 arch/openrisc/kernel/idle.c   | 73 -------------------------------------------
 3 files changed, 2 insertions(+), 74 deletions(-)

diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 9ab3bf2..e111b52 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -21,6 +21,7 @@ config OPENRISC
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
+	select GENERIC_IDLE_LOOP
 	select MODULES_USE_ELF_RELA
 
 config MMU
diff --git a/arch/openrisc/kernel/Makefile b/arch/openrisc/kernel/Makefile
index 35f92ce..ec6d9d3 100644
--- a/arch/openrisc/kernel/Makefile
+++ b/arch/openrisc/kernel/Makefile
@@ -4,7 +4,7 @@
 
 extra-y	:= head.o vmlinux.lds
 
-obj-y	:= setup.o idle.o or32_ksyms.o process.o dma.o \
+obj-y	:= setup.o or32_ksyms.o process.o dma.o \
 	   traps.o time.o irq.o entry.o ptrace.o signal.o \
 	   sys_call_table.o
 
diff --git a/arch/openrisc/kernel/idle.c b/arch/openrisc/kernel/idle.c
deleted file mode 100644
index 5e8a3b6..0000000
--- a/arch/openrisc/kernel/idle.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * OpenRISC idle.c
- *
- * Linux architectural port borrowing liberally from similar works of
- * others.  All original copyrights apply as per the original source
- * declaration.
- *
- * Modifications for the OpenRISC architecture:
- * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
- * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
- *
- *      This program is free software; you can redistribute it and/or
- *      modify it under the terms of the GNU General Public License
- *      as published by the Free Software Foundation; either version
- *      2 of the License, or (at your option) any later version.
- *
- * Idle daemon for or32.  Idle daemon will handle any action
- * that needs to be taken when the system becomes idle.
- */
-
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/smp.h>
-#include <linux/stddef.h>
-#include <linux/unistd.h>
-#include <linux/ptrace.h>
-#include <linux/slab.h>
-#include <linux/tick.h>
-
-#include <asm/pgtable.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
-#include <asm/processor.h>
-#include <asm/mmu.h>
-#include <asm/cache.h>
-#include <asm/pgalloc.h>
-
-void (*powersave) (void) = NULL;
-
-void cpu_idle(void)
-{
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched()) {
-			check_pgt_cache();
-			rmb();
-
-			clear_thread_flag(TIF_POLLING_NRFLAG);
-
-			local_irq_disable();
-			/* Don't trace irqs off for idle */
-			stop_critical_timings();
-			if (!need_resched() && powersave != NULL)
-				powersave();
-			start_critical_timings();
-			local_irq_enable();
-			set_thread_flag(TIF_POLLING_NRFLAG);
-		}
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		preempt_enable_no_resched();
-		schedule();
-		preempt_disable();
-	}
-}

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] parisc: Use generic idle loop
  2013-03-21 21:53 ` [patch 25/34] parisc: " Thomas Gleixner
@ 2013-04-08 20:38   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, jejb, tglx, deller, magnus.damm

Commit-ID:  fad48ad63dd14656e3b571d42f700a1f2cadd036
Gitweb:     http://git.kernel.org/tip/fad48ad63dd14656e3b571d42f700a1f2cadd036
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:55 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:27 +0200

parisc: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: James E.J. Bottomley <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>
Link: http://lkml.kernel.org/r/20130321215234.956305981@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/parisc/Kconfig          |  1 +
 arch/parisc/kernel/process.c | 22 ----------------------
 arch/parisc/kernel/smp.c     |  2 +-
 3 files changed, 2 insertions(+), 23 deletions(-)

diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 0339181..0821e70 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -18,6 +18,7 @@ config PARISC
 	select GENERIC_PCI_IOMAP
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select GENERIC_STRNCPY_FROM_USER
 	select SYSCTL_ARCH_UNALIGN_ALLOW
 	select HAVE_MOD_ARCH_SPECIFIC
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index d135072..55f92b6 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -59,28 +59,6 @@
 #include <asm/unwind.h>
 #include <asm/sections.h>
 
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle(void)
-{
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched())
-			barrier();
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-		check_pgt_cache();
-	}
-}
-
-
 #define COMMAND_GLOBAL  F_EXTEND(0xfffe0030)
 #define CMD_RESET       5       /* reset any module */
 
diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
index 6266730..fd1bb15 100644
--- a/arch/parisc/kernel/smp.c
+++ b/arch/parisc/kernel/smp.c
@@ -329,7 +329,7 @@ void __init smp_callin(void)
 
 	local_irq_enable();  /* Interrupts have been off until now */
 
-	cpu_idle();      /* Wait for timer to schedule some work */
+	cpu_startup_entry(CPUHP_ONLINE);
 
 	/* NOTREACHED */
 	panic("smp_callin() AAAAaaaaahhhh....\n");

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] powerpc: Use generic idle loop
  2013-03-21 21:53 ` [patch 26/34] powerpc: " Thomas Gleixner
  2013-03-28 15:40   ` Srivatsa S. Bhat
@ 2013-04-08 20:39   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, benh, tglx, magnus.damm

Commit-ID:  799fef06123f86ff69cf754f996219e6ad1678f8
Gitweb:     http://git.kernel.org/tip/799fef06123f86ff69cf754f996219e6ad1678f8
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:56 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:27 +0200

powerpc: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Link: http://lkml.kernel.org/r/20130321215235.026838003@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/powerpc/Kconfig       |  1 +
 arch/powerpc/kernel/idle.c | 89 +++++++++++++++-------------------------------
 arch/powerpc/kernel/smp.c  |  2 +-
 3 files changed, 31 insertions(+), 61 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index ea5bb04..19de32c 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -133,6 +133,7 @@ config PPC
 	select HAVE_ARCH_JUMP_LABEL
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_TIME_VSYSCALL_OLD
 	select GENERIC_CLOCKEVENTS
diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
index ea78761..939ea7e 100644
--- a/arch/powerpc/kernel/idle.c
+++ b/arch/powerpc/kernel/idle.c
@@ -33,11 +33,6 @@
 #include <asm/runlatch.h>
 #include <asm/smp.h>
 
-#ifdef CONFIG_HOTPLUG_CPU
-#define cpu_should_die()	cpu_is_offline(smp_processor_id())
-#else
-#define cpu_should_die()	0
-#endif
 
 unsigned long cpuidle_disable = IDLE_NO_OVERRIDE;
 EXPORT_SYMBOL(cpuidle_disable);
@@ -50,64 +45,38 @@ static int __init powersave_off(char *arg)
 }
 __setup("powersave=off", powersave_off);
 
-/*
- * The body of the idle task.
- */
-void cpu_idle(void)
+#ifdef CONFIG_HOTPLUG_CPU
+void arch_cpu_idle_dead(void)
 {
-	set_thread_flag(TIF_POLLING_NRFLAG);
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched() && !cpu_should_die()) {
-			ppc64_runlatch_off();
-
-			if (ppc_md.power_save) {
-				clear_thread_flag(TIF_POLLING_NRFLAG);
-				/*
-				 * smp_mb is so clearing of TIF_POLLING_NRFLAG
-				 * is ordered w.r.t. need_resched() test.
-				 */
-				smp_mb();
-				local_irq_disable();
-
-				/* Don't trace irqs off for idle */
-				stop_critical_timings();
-
-				/* check again after disabling irqs */
-				if (!need_resched() && !cpu_should_die())
-					ppc_md.power_save();
-
-				start_critical_timings();
-
-				/* Some power_save functions return with
-				 * interrupts enabled, some don't.
-				 */
-				if (irqs_disabled())
-					local_irq_enable();
-				set_thread_flag(TIF_POLLING_NRFLAG);
-
-			} else {
-				/*
-				 * Go into low thread priority and possibly
-				 * low power mode.
-				 */
-				HMT_low();
-				HMT_very_low();
-			}
-		}
+	sched_preempt_enable_no_resched();
+	cpu_die();
+}
+#endif
 
-		HMT_medium();
-		ppc64_runlatch_on();
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		if (cpu_should_die()) {
-			sched_preempt_enable_no_resched();
-			cpu_die();
-		}
-		schedule_preempt_disabled();
+void arch_cpu_idle(void)
+{
+	ppc64_runlatch_off();
+
+	if (ppc_md.power_save) {
+		ppc_md.power_save();
+		/*
+		 * Some power_save functions return with
+		 * interrupts enabled, some don't.
+		 */
+		if (irqs_disabled())
+			local_irq_enable();
+	} else {
+		local_irq_enable();
+		/*
+		 * Go into low thread priority and possibly
+		 * low power mode.
+		 */
+		HMT_low();
+		HMT_very_low();
 	}
+
+	HMT_medium();
+	ppc64_runlatch_on();
 }
 
 int powersave_nap;
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 76bd9da..ee7ac5e 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -669,7 +669,7 @@ __cpuinit void start_secondary(void *unused)
 
 	local_irq_enable();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 
 	BUG();
 }

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] s390: Use generic idle loop
  2013-03-21 21:53 ` [patch 27/34] s390: " Thomas Gleixner
  2013-03-23  9:38   ` Heiko Carstens
  2013-03-23  9:39     ` Heiko Carstens
@ 2013-04-08 20:40   ` tip-bot for Thomas Gleixner
  2 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, heiko.carstens, tglx, magnus.damm

Commit-ID:  52c0065947b7f78a3d9808b421006a3d870d1f92
Gitweb:     http://git.kernel.org/tip/52c0065947b7f78a3d9808b421006a3d870d1f92
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:57 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:27 +0200

s390: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Link: http://lkml.kernel.org/r/20130321215235.090816526@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/s390/Kconfig          |  1 +
 arch/s390/kernel/process.c | 32 +++++++++-----------------------
 arch/s390/kernel/smp.c     |  3 +--
 arch/s390/kernel/vtime.c   |  5 -----
 4 files changed, 11 insertions(+), 30 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index eb8fb62..749513d 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -97,6 +97,7 @@ config S390
 	select CLONE_BACKWARDS2
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_CPU_DEVICES if !SMP
+	select GENERIC_IDLE_LOOP
 	select GENERIC_KERNEL_THREAD
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_TIME_VSYSCALL_OLD
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index 536d645..2bc3edd 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -61,18 +61,8 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
 	return sf->gprs[8];
 }
 
-/*
- * The idle loop on a S390...
- */
-static void default_idle(void)
+void arch_cpu_idle(void)
 {
-	if (cpu_is_offline(smp_processor_id()))
-		cpu_die();
-	local_irq_disable();
-	if (need_resched()) {
-		local_irq_enable();
-		return;
-	}
 	local_mcck_disable();
 	if (test_thread_flag(TIF_MCCK_PENDING)) {
 		local_mcck_enable();
@@ -83,19 +73,15 @@ static void default_idle(void)
 	vtime_stop_cpu();
 }
 
-void cpu_idle(void)
+void arch_cpu_idle_exit(void)
 {
-	for (;;) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched() && !test_thread_flag(TIF_MCCK_PENDING))
-			default_idle();
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		if (test_thread_flag(TIF_MCCK_PENDING))
-			s390_handle_mcck();
-		schedule_preempt_disabled();
-	}
+	if (test_thread_flag(TIF_MCCK_PENDING))
+		s390_handle_mcck();
+}
+
+void arch_cpu_idle_dead(void)
+{
+	cpu_die();
 }
 
 extern void __kprobes kernel_thread_starter(void);
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 549c9d1..6ff5845 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -711,8 +711,7 @@ static void __cpuinit smp_start_secondary(void *cpuvoid)
 	set_cpu_online(smp_processor_id(), true);
 	inc_irq_stat(CPU_RST);
 	local_irq_enable();
-	/* cpu_idle will call schedule for us */
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 /* Upping and downing of CPUs */
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index a0042ac..3fb0935 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -158,8 +158,6 @@ void __kprobes vtime_stop_cpu(void)
 	unsigned long psw_mask;
 
 	trace_hardirqs_on();
-	/* Don't trace preempt off for idle. */
-	stop_critical_timings();
 
 	/* Wait for external, I/O or machine check interrupt. */
 	psw_mask = psw_kernel_bits | PSW_MASK_WAIT | PSW_MASK_DAT |
@@ -169,9 +167,6 @@ void __kprobes vtime_stop_cpu(void)
 	/* Call the assembler magic in entry.S */
 	psw_idle(idle, psw_mask);
 
-	/* Reenable preemption tracer. */
-	start_critical_timings();
-
 	/* Account time spent with enabled wait psw loaded as idle time. */
 	idle->sequence++;
 	smp_wmb();

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] score: Use generic idle loop
  2013-03-21 21:53 ` [patch 28/34] score: " Thomas Gleixner
@ 2013-04-08 20:41   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, lennox.wu,
	srivatsa.bhat, paulmck, tglx, magnus.damm

Commit-ID:  99444202b924e916aad95073d23f9995ae8eb558
Gitweb:     http://git.kernel.org/tip/99444202b924e916aad95073d23f9995ae8eb558
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:58 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:28 +0200

score: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Lennox Wu <lennox.wu@gmail.com>
Link: http://lkml.kernel.org/r/20130321215235.147909863@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/score/Kconfig          |  1 +
 arch/score/kernel/process.c | 18 ------------------
 2 files changed, 1 insertion(+), 18 deletions(-)

diff --git a/arch/score/Kconfig b/arch/score/Kconfig
index c8def8b..eaac45d 100644
--- a/arch/score/Kconfig
+++ b/arch/score/Kconfig
@@ -11,6 +11,7 @@ config SCORE
        select ARCH_DISCARD_MEMBLOCK
        select GENERIC_CPU_DEVICES
        select GENERIC_CLOCKEVENTS
+       select GENERIC_IDLE_LOOP
        select HAVE_MOD_ARCH_SPECIFIC
 	select VIRT_TO_BUS
 	select MODULES_USE_ELF_REL
diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
index 7956846..f4c6d02 100644
--- a/arch/score/kernel/process.c
+++ b/arch/score/kernel/process.c
@@ -41,24 +41,6 @@ void machine_halt(void) {}
 /* If or when software machine-power-off is implemented, add code here. */
 void machine_power_off(void) {}
 
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void __noreturn cpu_idle(void)
-{
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched())
-			barrier();
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
-}
-
 void ret_from_fork(void);
 void ret_from_kernel_thread(void);
 

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] sh: Use generic idle loop
  2013-03-21 21:53 ` [patch 29/34] sh: " Thomas Gleixner
  2013-03-28 15:40   ` Srivatsa S. Bhat
@ 2013-04-08 20:42   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, lethal,
	srivatsa.bhat, paulmck, tglx, magnus.damm

Commit-ID:  dc775dd886618a1ea6f092bfb3ddc78660aa1a19
Gitweb:     http://git.kernel.org/tip/dc775dd886618a1ea6f092bfb3ddc78660aa1a19
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:49:59 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:28 +0200

sh: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Link: http://lkml.kernel.org/r/20130321215235.216323644@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/sh/Kconfig       |   2 +
 arch/sh/kernel/idle.c | 101 ++++++--------------------------------------------
 arch/sh/kernel/smp.c  |   2 +-
 3 files changed, 14 insertions(+), 91 deletions(-)

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 5e85963..853cbc9 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -33,6 +33,8 @@ config SUPERH
 	select GENERIC_ATOMIC64
 	select GENERIC_IRQ_SHOW
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
+	select GENERIC_IDLE_POLL_SETUP
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_CMOS_UPDATE if SH_SH03 || SH_DREAMCAST
 	select GENERIC_STRNCPY_FROM_USER
diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c
index 3d5a1b3..2ea4483 100644
--- a/arch/sh/kernel/idle.c
+++ b/arch/sh/kernel/idle.c
@@ -24,98 +24,24 @@
 
 static void (*sh_idle)(void);
 
-static int hlt_counter;
-
-static int __init nohlt_setup(char *__unused)
-{
-	hlt_counter = 1;
-	return 1;
-}
-__setup("nohlt", nohlt_setup);
-
-static int __init hlt_setup(char *__unused)
-{
-	hlt_counter = 0;
-	return 1;
-}
-__setup("hlt", hlt_setup);
-
-static inline int hlt_works(void)
-{
-	return !hlt_counter;
-}
-
-/*
- * On SMP it's slightly faster (but much more power-consuming!)
- * to poll the ->work.need_resched flag instead of waiting for the
- * cross-CPU IPI to arrive. Use this option with caution.
- */
-static void poll_idle(void)
+void default_idle(void)
 {
+	set_bl_bit();
 	local_irq_enable();
-	while (!need_resched())
-		cpu_relax();
+	/* Isn't this racy ? */
+	cpu_sleep();
+	clear_bl_bit();
 }
 
-void default_idle(void)
+void arch_cpu_idle_dead(void)
 {
-	if (hlt_works()) {
-		clear_thread_flag(TIF_POLLING_NRFLAG);
-		smp_mb__after_clear_bit();
-
-		set_bl_bit();
-		if (!need_resched()) {
-			local_irq_enable();
-			cpu_sleep();
-		} else
-			local_irq_enable();
-
-		set_thread_flag(TIF_POLLING_NRFLAG);
-		clear_bl_bit();
-	} else
-		poll_idle();
+	play_dead();
 }
 
-/*
- * The idle thread. There's no useful work to be done, so just try to conserve
- * power and have a low exit latency (ie sit in a loop waiting for somebody to
- * say that they'd like to reschedule)
- */
-void cpu_idle(void)
+void arch_cpu_idle(void)
 {
-	unsigned int cpu = smp_processor_id();
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched()) {
-			check_pgt_cache();
-			rmb();
-
-			if (cpu_is_offline(cpu))
-				play_dead();
-
-			local_irq_disable();
-			/* Don't trace irqs off for idle */
-			stop_critical_timings();
-			if (cpuidle_idle_call())
-				sh_idle();
-			/*
-			 * Sanity check to ensure that sh_idle() returns
-			 * with IRQs enabled
-			 */
-			WARN_ON(irqs_disabled());
-			start_critical_timings();
-		}
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	}
+	if (cpuidle_idle_call())
+		sh_idle();
 }
 
 void __init select_idle_routine(void)
@@ -123,13 +49,8 @@ void __init select_idle_routine(void)
 	/*
 	 * If a platform has set its own idle routine, leave it alone.
 	 */
-	if (sh_idle)
-		return;
-
-	if (hlt_works())
+	if (!sh_idle)
 		sh_idle = default_idle;
-	else
-		sh_idle = poll_idle;
 }
 
 void stop_this_cpu(void *unused)
diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c
index 2062aa8..4569645 100644
--- a/arch/sh/kernel/smp.c
+++ b/arch/sh/kernel/smp.c
@@ -203,7 +203,7 @@ asmlinkage void __cpuinit start_secondary(void)
 	set_cpu_online(cpu, true);
 	per_cpu(cpu_state, cpu) = CPU_ONLINE;
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 extern struct {

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] tile: Enter idle with preemption disabled
  2013-03-21 21:53 ` [patch 30/34] tile: Enter idle with preemption disabled Thomas Gleixner
                     ` (2 preceding siblings ...)
  2013-03-28 15:43   ` Srivatsa S. Bhat
@ 2013-04-08 20:44   ` tip-bot for Thomas Gleixner
  3 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:44 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, cmetcalf,
	srivatsa.bhat, paulmck, tglx, magnus.damm

Commit-ID:  e26ef8fe722d5c1c0c1a0212542da8fc2b21a89f
Gitweb:     http://git.kernel.org/tip/e26ef8fe722d5c1c0c1a0212542da8fc2b21a89f
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:50:00 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:28 +0200

tile: Enter idle with preemption disabled

cpu_idle() needs to be called with preemption disabled.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
Link: http://lkml.kernel.org/r/20130321215235.280451779@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/tile/kernel/smpboot.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/tile/kernel/smpboot.c b/arch/tile/kernel/smpboot.c
index e686c5a..11c0190 100644
--- a/arch/tile/kernel/smpboot.c
+++ b/arch/tile/kernel/smpboot.c
@@ -207,8 +207,6 @@ void __cpuinit online_secondary(void)
 	/* Set up tile-timer clock-event device on this cpu */
 	setup_tile_timer();
 
-	preempt_enable();
-
 	cpu_idle();
 }
 

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] tile: Use generic idle loop
  2013-03-21 21:53 ` [patch 31/34] tile: Use generic idle loop Thomas Gleixner
  2013-03-28 15:41   ` Srivatsa S. Bhat
@ 2013-04-08 20:45   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:45 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, cmetcalf,
	srivatsa.bhat, paulmck, tglx, magnus.damm

Commit-ID:  0dc8153cfebac68c9523b8852b14f10b31209f08
Gitweb:     http://git.kernel.org/tip/0dc8153cfebac68c9523b8852b14f10b31209f08
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:50:01 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:28 +0200

tile: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
Link: http://lkml.kernel.org/r/20130321215235.348460344@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/tile/Kconfig          |  1 +
 arch/tile/kernel/process.c | 65 +++++++---------------------------------------
 arch/tile/kernel/smpboot.c |  2 +-
 3 files changed, 11 insertions(+), 57 deletions(-)

diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 25877ae..85b2ede 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -22,6 +22,7 @@ config TILE
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_CLOCKEVENTS
 	select MODULES_USE_ELF_RELA
+	select GENERIC_IDLE_LOOP
 
 # FIXME: investigate whether we need/want these options.
 #	select HAVE_IOREMAP_PROT
diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c
index caf93ae..80b2a18 100644
--- a/arch/tile/kernel/process.c
+++ b/arch/tile/kernel/process.c
@@ -40,13 +40,11 @@
 #include <arch/abi.h>
 #include <arch/sim_def.h>
 
-
 /*
  * Use the (x86) "idle=poll" option to prefer low latency when leaving the
  * idle loop over low power while in the idle loop, e.g. if we have
  * one thread per core and we want to get threads out of futex waits fast.
  */
-static int no_idle_nap;
 static int __init idle_setup(char *str)
 {
 	if (!str)
@@ -54,64 +52,19 @@ static int __init idle_setup(char *str)
 
 	if (!strcmp(str, "poll")) {
 		pr_info("using polling idle threads.\n");
-		no_idle_nap = 1;
-	} else if (!strcmp(str, "halt"))
-		no_idle_nap = 0;
-	else
-		return -1;
-
-	return 0;
+		cpu_idle_poll_ctrl(true);
+		return 0;
+	} else if (!strcmp(str, "halt")) {
+		return 0;
+	}
+	return -1;
 }
 early_param("idle", idle_setup);
 
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle(void)
+void arch_cpu_idle(void)
 {
-	int cpu = smp_processor_id();
-
-
-	current_thread_info()->status |= TS_POLLING;
-
-	if (no_idle_nap) {
-		while (1) {
-			while (!need_resched())
-				cpu_relax();
-			schedule();
-		}
-	}
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched()) {
-			if (cpu_is_offline(cpu))
-				BUG();  /* no HOTPLUG_CPU */
-
-			local_irq_disable();
-			__get_cpu_var(irq_stat).idle_timestamp = jiffies;
-			current_thread_info()->status &= ~TS_POLLING;
-			/*
-			 * TS_POLLING-cleared state must be visible before we
-			 * test NEED_RESCHED:
-			 */
-			smp_mb();
-
-			if (!need_resched())
-				_cpu_idle();
-			else
-				local_irq_enable();
-			current_thread_info()->status |= TS_POLLING;
-		}
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		schedule_preempt_disabled();
-	}
+	__get_cpu_var(irq_stat).idle_timestamp = jiffies;
+	_cpu_idle();
 }
 
 /*
diff --git a/arch/tile/kernel/smpboot.c b/arch/tile/kernel/smpboot.c
index 11c0190..44bab29 100644
--- a/arch/tile/kernel/smpboot.c
+++ b/arch/tile/kernel/smpboot.c
@@ -207,7 +207,7 @@ void __cpuinit online_secondary(void)
 	/* Set up tile-timer clock-event device on this cpu */
 	setup_tile_timer();
 
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] unicore: Use generic idle loop
  2013-03-21 21:53 ` [patch 32/34] unicore: " Thomas Gleixner
@ 2013-04-08 20:46   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:46 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, gxt, tglx, magnus.damm

Commit-ID:  aba92c9e2cf3042bf6efc68fa2e4235ba01bf499
Gitweb:     http://git.kernel.org/tip/aba92c9e2cf3042bf6efc68fa2e4235ba01bf499
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:50:02 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:29 +0200

unicore: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Link: http://lkml.kernel.org/r/20130321215235.415426466@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/unicore32/Kconfig          |  1 +
 arch/unicore32/kernel/process.c | 21 +++------------------
 2 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index 2943e3a..e12678d 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -17,6 +17,7 @@ config UNICORE32
 	select ARCH_WANT_FRAME_POINTERS
 	select GENERIC_IOMAP
 	select MODULES_USE_ELF_REL
+	select GENERIC_IDLE_LOOP
 	help
 	  UniCore-32 is 32-bit Instruction Set Architecture,
 	  including a series of low-power-consumption RISC chip
diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c
index 872d7e2..7fab86d 100644
--- a/arch/unicore32/kernel/process.c
+++ b/arch/unicore32/kernel/process.c
@@ -45,25 +45,10 @@ static const char * const processor_modes[] = {
 	"UK18", "UK19", "UK1A", "EXTN", "UK1C", "UK1D", "UK1E", "SUSR"
 };
 
-void cpu_idle(void)
+void arch_cpu_idle(void)
 {
-	/* endless idle loop with no priority at all */
-	while (1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-		while (!need_resched()) {
-			local_irq_disable();
-			stop_critical_timings();
-			cpu_do_idle();
-			local_irq_enable();
-			start_critical_timings();
-		}
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-		preempt_enable_no_resched();
-		schedule();
-		preempt_disable();
-	}
+	cpu_do_idle();
+	local_irq_enable();
 }
 
 static char reboot_mode = 'h';

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] x86: Use generic idle loop
  2013-03-21 21:53 ` [patch 33/34] x86: " Thomas Gleixner
  2013-03-28 15:43   ` Srivatsa S. Bhat
@ 2013-04-08 20:47   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	paulmck, tglx, magnus.damm

Commit-ID:  7d1a941731fabf27e5fb6edbebb79fe856edb4e5
Gitweb:     http://git.kernel.org/tip/7d1a941731fabf27e5fb6edbebb79fe856edb4e5
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:50:03 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:29 +0200

x86: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130321215235.486594473@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
---
 arch/x86/Kconfig          |   1 +
 arch/x86/kernel/process.c | 105 ++++++++++++----------------------------------
 arch/x86/kernel/smpboot.c |   2 +-
 arch/x86/xen/smp.c        |   2 +-
 4 files changed, 30 insertions(+), 80 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 70c0f3d..422a72b 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -97,6 +97,7 @@ config X86
 	select GENERIC_IOMAP
 	select DCACHE_WORD_ACCESS
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_IDLE_LOOP
 	select ARCH_WANT_IPC_PARSE_VERSION if X86_32
 	select HAVE_ARCH_SECCOMP_FILTER
 	select BUILDTIME_EXTABLE_SORT
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 14ae100..6833bff 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -301,13 +301,7 @@ void exit_idle(void)
 }
 #endif
 
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle(void)
+void arch_cpu_idle_prepare(void)
 {
 	/*
 	 * If we're the non-boot CPU, nothing set the stack canary up
@@ -317,71 +311,40 @@ void cpu_idle(void)
 	 * canaries already on the stack wont ever trigger).
 	 */
 	boot_init_stack_canary();
-	current_thread_info()->status |= TS_POLLING;
-
-	while (1) {
-		tick_nohz_idle_enter();
-
-		while (!need_resched()) {
-			rmb();
-
-			if (cpu_is_offline(smp_processor_id()))
-				play_dead();
-
-			/*
-			 * Idle routines should keep interrupts disabled
-			 * from here on, until they go to idle.
-			 * Otherwise, idle callbacks can misfire.
-			 */
-			local_touch_nmi();
-			local_irq_disable();
-
-			enter_idle();
-
-			/* Don't trace irqs off for idle */
-			stop_critical_timings();
-
-			/* enter_idle() needs rcu for notifiers */
-			rcu_idle_enter();
+}
 
-			if (cpuidle_idle_call())
-				x86_idle();
+void arch_cpu_idle_enter(void)
+{
+	local_touch_nmi();
+	enter_idle();
+}
 
-			rcu_idle_exit();
-			start_critical_timings();
+void arch_cpu_idle_exit(void)
+{
+	__exit_idle();
+}
 
-			/* In many cases the interrupt that ended idle
-			   has already called exit_idle. But some idle
-			   loops can be woken up without interrupt. */
-			__exit_idle();
-		}
+void arch_cpu_idle_dead(void)
+{
+	play_dead();
+}
 
-		tick_nohz_idle_exit();
-		preempt_enable_no_resched();
-		schedule();
-		preempt_disable();
-	}
+/*
+ * Called from the generic idle code.
+ */
+void arch_cpu_idle(void)
+{
+	if (cpuidle_idle_call())
+		x86_idle();
 }
 
 /*
- * We use this if we don't have any better
- * idle routine..
+ * We use this if we don't have any better idle routine..
  */
 void default_idle(void)
 {
 	trace_cpu_idle_rcuidle(1, smp_processor_id());
-	current_thread_info()->status &= ~TS_POLLING;
-	/*
-	 * TS_POLLING-cleared state must be visible before we
-	 * test NEED_RESCHED:
-	 */
-	smp_mb();
-
-	if (!need_resched())
-		safe_halt();	/* enables interrupts racelessly */
-	else
-		local_irq_enable();
-	current_thread_info()->status |= TS_POLLING;
+	safe_halt();
 	trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
 }
 #ifdef CONFIG_APM_MODULE
@@ -411,20 +374,6 @@ void stop_this_cpu(void *dummy)
 		halt();
 }
 
-/*
- * On SMP it's slightly faster (but much more power-consuming!)
- * to poll the ->work.need_resched flag instead of waiting for the
- * cross-CPU IPI to arrive. Use this option with caution.
- */
-static void poll_idle(void)
-{
-	trace_cpu_idle_rcuidle(0, smp_processor_id());
-	local_irq_enable();
-	while (!need_resched())
-		cpu_relax();
-	trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
-}
-
 bool amd_e400_c1e_detected;
 EXPORT_SYMBOL(amd_e400_c1e_detected);
 
@@ -489,10 +438,10 @@ static void amd_e400_idle(void)
 void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_SMP
-	if (x86_idle == poll_idle && smp_num_siblings > 1)
+	if (boot_option_idle_override == IDLE_POLL && smp_num_siblings > 1)
 		pr_warn_once("WARNING: polling idle and HT enabled, performance may degrade\n");
 #endif
-	if (x86_idle)
+	if (x86_idle || boot_option_idle_override == IDLE_POLL)
 		return;
 
 	if (cpu_has_amd_erratum(amd_erratum_400)) {
@@ -517,8 +466,8 @@ static int __init idle_setup(char *str)
 
 	if (!strcmp(str, "poll")) {
 		pr_info("using polling idle threads\n");
-		x86_idle = poll_idle;
 		boot_option_idle_override = IDLE_POLL;
+		cpu_idle_poll_ctrl(true);
 	} else if (!strcmp(str, "halt")) {
 		/*
 		 * When the boot option of idle=halt is added, halt is
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 9f190a2..9c73b51 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -284,7 +284,7 @@ notrace static void __cpuinit start_secondary(void *unused)
 	x86_cpuinit.setup_percpu_clockev();
 
 	wmb();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void __init smp_store_boot_cpu_info(void)
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index 09ea61d..73642e9 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -95,7 +95,7 @@ static void __cpuinit cpu_bringup(void)
 static void __cpuinit cpu_bringup_and_idle(void)
 {
 	cpu_bringup();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 static int xen_smp_intr_init(unsigned int cpu)

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] xtensa: Use generic idle loop
  2013-03-21 21:53 ` [patch 34/34] xtensa: " Thomas Gleixner
  2013-03-22 12:37   ` Max Filippov
@ 2013-04-08 20:48   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 147+ messages in thread
From: tip-bot for Thomas Gleixner @ 2013-04-08 20:48 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, chris,
	srivatsa.bhat, paulmck, tglx, magnus.damm

Commit-ID:  f4e2e9a4b26789d963000f974f2dc80230bb4674
Gitweb:     http://git.kernel.org/tip/f4e2e9a4b26789d963000f974f2dc80230bb4674
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 21 Mar 2013 22:50:04 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Apr 2013 17:39:29 +0200

xtensa: Use generic idle loop

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Acked-by: Chris Zankel <chris@zankel.net>
Link: http://lkml.kernel.org/r/20130321215235.546600507@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/xtensa/Kconfig          |  1 +
 arch/xtensa/kernel/process.c | 14 ++------------
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index b09de49..e0144ff 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -19,6 +19,7 @@ config XTENSA
 	select CLONE_BACKWARDS
 	select IRQ_DOMAIN
 	select HAVE_OPROFILE
+	select GENERIC_IDLE_LOOP
 	help
 	  Xtensa processors are 32-bit RISC machines designed by Tensilica
 	  primarily for embedded systems.  These processors are both
diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c
index 5cd82e9..1c85323 100644
--- a/arch/xtensa/kernel/process.c
+++ b/arch/xtensa/kernel/process.c
@@ -105,19 +105,9 @@ void coprocessor_flush_all(struct thread_info *ti)
 /*
  * Powermanagement idle function, if any is provided by the platform.
  */
-
-void cpu_idle(void)
+void arch_cpu_idle(void)
 {
-	local_irq_enable();
-
-	/* endless idle loop with no priority at all */
-	while (1) {
-		rcu_idle_enter();
-		while (!need_resched())
-			platform_idle();
-		rcu_idle_exit();
-		schedule_preempt_disabled();
-	}
+	platform_idle();
 }
 
 /*

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [patch 08/34] arm: Use generic idle loop
  2013-03-25 14:02         ` Thomas Gleixner
@ 2013-04-08 21:47           ` Russell King - ARM Linux
  2013-04-09  9:20             ` Thomas Gleixner
  0 siblings, 1 reply; 147+ messages in thread
From: Russell King - ARM Linux @ 2013-04-08 21:47 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Kevin Hilman, LKML, linux-arch, Linus Torvalds, Andrew Morton,
	Rusty Russell, Paul McKenney, Ingo Molnar, Peter Zijlstra,
	Srivatsa S. Bhat, Magnus Damm

On Mon, Mar 25, 2013 at 03:02:39PM +0100, Thomas Gleixner wrote:
> On Mon, 25 Mar 2013, Russell King - ARM Linux wrote:
> 
> > On Mon, Mar 25, 2013 at 12:31:20PM +0100, Thomas Gleixner wrote:
> > > On Fri, 22 Mar 2013, Kevin Hilman wrote:
> > > 
> > > > Hi Thomas,
> > > > 
> > > > Thomas Gleixner <tglx@linutronix.de> writes:
> > > > 
> > > > > Use the generic idle loop and replace enable/disable_hlt with the
> > > > > respective core functions.
> > > > >
> > > > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > > > > Cc: Russell King <linux@arm.linux.org.uk>
> > > > 
> > > > I gave patches 1-5 + this a quick spin on ARM (specifially some OMAP3 and
> > > > OMAP4 platforms, with and without CPUidle enabled.)
> > > > 
> > > > The OMAP stuff needed a couple minor compile fixes (below), but
> > > > otherwise it passes the quick "seems to work" test.
> > > 
> > > Yeah, that's needed for the other arch/arm conversions as well.
> > 
> > So, the only patch I got was this one, which is useless to test on its
> > own...
> 
> I'm testing V2 now and will post an git URL with a testing branch
> later tonight.

So, how can I review these changes when all there is is a git URL, and
I *do* not want to pull them into my tree without first looking at the
patches, possibly reviewing them and *replying* with the patch inline?

I see you've now added this stuff to -tip.  I guess ARM doesn't matter
to you at all.  I guess having ARM people review the core changes doesn't
matter either.

Well, I guess if it's broken, we'll just have to fix it up after the
merge window.

One rule for x86, a different one for ARM.  Let x86 maintainers moan
about ARM people, but don't let ARM people moan about x86 maintainers.
Yes, sure, right, I get it.

So, explicitly, my concern is this replacement of enable_hlt()/disable_hlt()
with this cpu_idle_poll_ctrl(), and whether this interface is still
counted - so that it's possible to call disable_hlt() to _permanently_
disable any hlt-based idle loop.

If that's not possible with your revised interface, you have just broken
some ARM platforms.  I can only guess... because you never copied your
entire patch set to me nor to the ARM lists.

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [tip:smp/hotplug] avr32: Use generic idle loop
  2013-04-08 20:20   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
@ 2013-04-09  7:31     ` Hans-Christian Egtvedt
  0 siblings, 0 replies; 147+ messages in thread
From: Hans-Christian Egtvedt @ 2013-04-09  7:31 UTC (permalink / raw)
  To: mingo, hpa, linux-kernel, torvalds, rusty, peterz, srivatsa.bhat,
	paulmck, tglx, magnus.damm
  Cc: linux-tip-commits

Around Mon 08 Apr 2013 13:20:05 -0700 or thereabout, tip-bot for Thomas Gleixner wrote:
> Commit-ID:  01426478df3a8791ff5c8b6b82d409e699cfaf38
> Gitweb:     http://git.kernel.org/tip/01426478df3a8791ff5c8b6b82d409e699cfaf38
> Author:     Thomas Gleixner <tglx@linutronix.de>
> AuthorDate: Thu, 21 Mar 2013 22:49:40 +0100
> Committer:  Thomas Gleixner <tglx@linutronix.de>
> CommitDate: Mon, 8 Apr 2013 17:39:24 +0200
> 
> avr32: Use generic idle loop
> 
> Also replace the idle poll enforcement by the generic functionality.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
> Link: http://lkml.kernel.org/r/20130321215233.950290809@linutronix.de
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>

> ---
>  arch/avr32/Kconfig                       |  1 +
>  arch/avr32/kernel/process.c              | 13 ++-----------
>  arch/avr32/kernel/time.c                 |  9 +++++++--
>  arch/avr32/mach-at32ap/include/mach/pm.h | 24 ------------------------
>  arch/avr32/mach-at32ap/pm-at32ap700x.S   |  7 -------
>  5 files changed, 10 insertions(+), 44 deletions(-)

<snipp diff>

-- 
mvh
Hans-Christian Egtvedt

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 08/34] arm: Use generic idle loop
  2013-04-08 21:47           ` Russell King - ARM Linux
@ 2013-04-09  9:20             ` Thomas Gleixner
  2013-04-09  9:38               ` Russell King - ARM Linux
  0 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-04-09  9:20 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Kevin Hilman, LKML, linux-arch, Linus Torvalds, Andrew Morton,
	Rusty Russell, Paul McKenney, Ingo Molnar, Peter Zijlstra,
	Srivatsa S. Bhat, Magnus Damm

Russell,

On Mon, 8 Apr 2013, Russell King - ARM Linux wrote:
> On Mon, Mar 25, 2013 at 03:02:39PM +0100, Thomas Gleixner wrote:
> So, how can I review these changes when all there is is a git URL, and
> I *do* not want to pull them into my tree without first looking at the
> patches, possibly reviewing them and *replying* with the patch inline?

the patches were CC'ed to LKML and linux-arch and I expected that you
are at least having the latter. Find the relevant patch inlined below.

> I see you've now added this stuff to -tip.  I guess ARM doesn't matter
> to you at all.  I guess having ARM people review the core changes doesn't
> matter either.
> 
> Well, I guess if it's broken, we'll just have to fix it up after the
> merge window.
> 
> One rule for x86, a different one for ARM.  Let x86 maintainers moan
> about ARM people, but don't let ARM people moan about x86 maintainers.
> Yes, sure, right, I get it.

Sigh no.
 
> So, explicitly, my concern is this replacement of enable_hlt()/disable_hlt()
> with this cpu_idle_poll_ctrl(), and whether this interface is still
> counted - so that it's possible to call disable_hlt() to _permanently_
> disable any hlt-based idle loop.

It is a counter. I looked carefully at all the various slightly
differently fcked up implementations and picked the counter based one
as it fits all requirements.
 
Thanks,

	tglx
---
Subject: idle: Implement generic idle function
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 21 Mar 2013 22:49:35 +0100

All idle functions in arch/* are more or less the same, plus minus a
few bugs and extra instrumentation, tickless support and other
optional items.

Implement a generic idle function which resembles the functionality
found in arch/. Provide weak arch_cpu_idle_* functions which can be
overridden by the architecture code if needed.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130321215233.646635455@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/Kconfig        |    3 +
 include/linux/cpu.h |    8 +++
 kernel/cpu/idle.c   |  105 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+)

Index: linux-2.6/arch/Kconfig
===================================================================
--- linux-2.6.orig/arch/Kconfig
+++ linux-2.6/arch/Kconfig
@@ -216,6 +216,9 @@ config USE_GENERIC_SMP_HELPERS
 config GENERIC_SMP_IDLE_THREAD
        bool
 
+config GENERIC_IDLE_LOOP
+       bool
+
 # Select if arch init_task initializer is different to init/init_task.c
 config ARCH_INIT_TASK
        bool
Index: linux-2.6/include/linux/cpu.h
===================================================================
--- linux-2.6.orig/include/linux/cpu.h
+++ linux-2.6/include/linux/cpu.h
@@ -220,4 +220,12 @@ enum cpuhp_state {
 void cpu_startup_entry(enum cpuhp_state state);
 void cpu_idle(void);
 
+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);
+
 #endif /* _LINUX_CPU_H_ */
Index: linux-2.6/kernel/cpu/idle.c
===================================================================
--- linux-2.6.orig/kernel/cpu/idle.c
+++ linux-2.6/kernel/cpu/idle.c
@@ -3,8 +3,113 @@
  */
 #include <linux/sched.h>
 #include <linux/cpu.h>
+#include <linux/tick.h>
+#include <linux/mm.h>
 
+#include <asm/tlb.h>
+
+#include <trace/events/power.h>
+
+#ifndef CONFIG_GENERIC_IDLE_LOOP
 void cpu_startup_entry(enum cpuhp_state state)
 {
 	cpu_idle();
 }
+#else
+
+static int __read_mostly cpu_idle_force_poll;
+
+void cpu_idle_poll_ctrl(bool enable)
+{
+	if (enable) {
+		cpu_idle_force_poll++;
+	} else {
+		cpu_idle_force_poll--;
+		WARN_ON_ONCE(cpu_idle_force_poll < 0);
+	}
+}
+
+#ifdef CONFIG_GENERIC_IDLE_POLL_SETUP
+static int __init cpu_idle_poll_setup(char *__unused)
+{
+	cpu_idle_force_poll = 1;
+	return 1;
+}
+__setup("nohlt", cpu_idle_poll_setup);
+
+static int __init cpu_idle_nopoll_setup(char *__unused)
+{
+	cpu_idle_force_poll = 0;
+	return 1;
+}
+__setup("hlt", cpu_idle_nopoll_setup);
+#endif
+
+static inline int cpu_idle_poll(void)
+{
+	trace_cpu_idle_rcuidle(0, smp_processor_id());
+	local_irq_enable();
+	while (!need_resched())
+		cpu_relax();
+	trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
+	return 1;
+}
+
+/* Weak implementations for optional arch specific functions */
+void __weak arch_cpu_idle_prepare(void) { }
+void __weak arch_cpu_idle_enter(void) { }
+void __weak arch_cpu_idle_exit(void) { }
+void __weak arch_cpu_idle_dead(void) { }
+void __weak arch_cpu_idle(void)
+{
+	cpu_idle_force_poll = 1;
+}
+
+/*
+ * Generic idle loop implementation
+ */
+static void cpu_idle_loop(void)
+{
+	while (1) {
+		tick_nohz_idle_enter();
+
+		while (!need_resched()) {
+			check_pgt_cache();
+			rmb();
+
+			if (cpu_is_offline(smp_processor_id()))
+				arch_cpu_idle_dead();
+
+			local_irq_disable();
+			arch_cpu_idle_enter();
+
+			if (cpu_idle_force_poll) {
+				cpu_idle_poll();
+			} else {
+				current_clr_polling();
+				if (!need_resched()) {
+					stop_critical_timings();
+					rcu_idle_enter();
+					arch_cpu_idle();
+					WARN_ON_ONCE(irqs_disabled());
+					rcu_idle_exit();
+					start_critical_timings();
+				} else {
+					local_irq_enable();
+				}
+				current_set_polling();
+			}
+			arch_cpu_idle_exit();
+		}
+		tick_nohz_idle_exit();
+		schedule_preempt_disabled();
+	}
+}
+
+void cpu_startup_entry(enum cpuhp_state state)
+{
+	current_set_polling();
+	arch_cpu_idle_prepare();
+	cpu_idle_loop();
+}
+#endif

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 08/34] arm: Use generic idle loop
  2013-04-09  9:20             ` Thomas Gleixner
@ 2013-04-09  9:38               ` Russell King - ARM Linux
  2013-04-25 20:03                 ` Stephen Boyd
  0 siblings, 1 reply; 147+ messages in thread
From: Russell King - ARM Linux @ 2013-04-09  9:38 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Kevin Hilman, LKML, linux-arch, Linus Torvalds, Andrew Morton,
	Rusty Russell, Paul McKenney, Ingo Molnar, Peter Zijlstra,
	Srivatsa S. Bhat, Magnus Damm

On Tue, Apr 09, 2013 at 11:20:31AM +0200, Thomas Gleixner wrote:
> On Mon, 8 Apr 2013, Russell King - ARM Linux wrote:
> > On Mon, Mar 25, 2013 at 03:02:39PM +0100, Thomas Gleixner wrote:
> > So, how can I review these changes when all there is is a git URL, and
> > I *do* not want to pull them into my tree without first looking at the
> > patches, possibly reviewing them and *replying* with the patch inline?
> 
> the patches were CC'ed to LKML and linux-arch and I expected that you
> are at least having the latter. Find the relevant patch inlined below.

I've not been on linux-arch for a few years now, after it evolved into
yet another lkml-like list with high traffic rates, where mainly specific
x86 issues seemed to be discussed, rather than it being a way to contact
all arch maintainers.

> It is a counter. I looked carefully at all the various slightly
> differently fcked up implementations and picked the counter based one
> as it fits all requirements.

Great, thanks.  The attached patch looks fine to me.

^ permalink raw reply	[flat|nested] 147+ messages in thread

* [PATCH v2] sparc: Use generic idle loop
  2013-04-08 19:24             ` David Miller
  2013-04-11 19:38                 ` Sam Ravnborg
@ 2013-04-11 19:38                 ` Sam Ravnborg
  0 siblings, 0 replies; 147+ messages in thread
From: Sam Ravnborg @ 2013-04-11 19:38 UTC (permalink / raw)
  To: David Miller, Thomas Gleixner
  Cc: srivatsa.bhat, tglx, linux-kernel, linux-arch, torvalds, akpm,
	rusty, paulmck, mingo, peterz, magnus.damm

Add generic cpu_idle support

sparc32:
- replace call to cpu_idle() with cpu_startup_entry()
- add arch_cpu_idle()

sparc64:
- smp_callin() now include cpu_startup_entry() call so we can
  skip calling cpu_idle from assembler
- add arch_cpu_idle() and arch_cpu_idle_dead()

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
Cc: David S. Miller <davem@davemloft.net>
---
v1->v2:
- simplified arch_cpu_idle() - former sparc64_yield() based on comments from Srivatsa
- dropped TIF_POLLING_NRFLAG handling
- dropped smp_mb__after_clear_bit() - this is done in generic code using rmb()
- dropped the out-most while (!need_resched() && !cpu_is_offline(cpu))
- always enable irq on exit in arch_cpu_idle (both sparc32 and sparc64)
- added comment from davem why we need to clear IE bit in sparc64 arch_cpu_idle()

	Sam


diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 3d361f2..ee5eacc 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -37,6 +37,7 @@ config SPARC
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CLOCKEVENTS
+	select GENERIC_IDLE_LOOP
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
 	select MODULES_USE_ELF_RELA
diff --git a/arch/sparc/kernel/hvtramp.S b/arch/sparc/kernel/hvtramp.S
index 9365432..605c960 100644
--- a/arch/sparc/kernel/hvtramp.S
+++ b/arch/sparc/kernel/hvtramp.S
@@ -128,8 +128,7 @@ hv_cpu_startup:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index 62eede1..c852410 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -64,23 +64,12 @@ extern void fpsave(unsigned long *, unsigned long *, void *, unsigned long *);
 struct task_struct *last_task_used_math = NULL;
 struct thread_info *current_set[NR_CPUS];
 
-/*
- * the idle loop on a Sparc... ;)
- */
-void cpu_idle(void)
+/* Idle loop support. */
+void arch_cpu_idle(void)
 {
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	for (;;) {
-		while (!need_resched()) {
-			if (sparc_idle)
-				(*sparc_idle)();
-			else
-				cpu_relax();
-		}
-		schedule_preempt_disabled();
-	}
+	if (sparc_idle)
+		(*sparc_idle)();
+	local_irq_enable();
 }
 
 /* XXX cli/sti -> local_irq_xxx here, check this works once SMP is fixed. */
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index cdb80b2..9fbf0d1 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -52,20 +52,17 @@
 
 #include "kstack.h"
 
-static void sparc64_yield(int cpu)
+/* Idle loop support on sparc64. */
+void arch_cpu_idle(void)
 {
 	if (tlb_type != hypervisor) {
 		touch_nmi_watchdog();
-		return;
-	}
-
-	clear_thread_flag(TIF_POLLING_NRFLAG);
-	smp_mb__after_clear_bit();
-
-	while (!need_resched() && !cpu_is_offline(cpu)) {
+	} else {
 		unsigned long pstate;
 
-		/* Disable interrupts. */
+                /* The sun4v sleeping code requires that we have PSTATE.IE cleared over
+                 * the cpu sleep hypervisor call.
+                 */
 		__asm__ __volatile__(
 			"rdpr %%pstate, %0\n\t"
 			"andn %0, %1, %0\n\t"
@@ -73,7 +70,7 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 
-		if (!need_resched() && !cpu_is_offline(cpu))
+		if (!need_resched() && !cpu_is_offline(smp_processor_id()))
 			sun4v_cpu_yield();
 
 		/* Re-enable interrupts. */
@@ -84,36 +81,16 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 	}
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
+	local_irq_enable();
 }
 
-/* The idle loop on sparc64. */
-void cpu_idle(void)
-{
-	int cpu = smp_processor_id();
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	while(1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched() && !cpu_is_offline(cpu))
-			sparc64_yield(cpu);
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
 #ifdef CONFIG_HOTPLUG_CPU
-		if (cpu_is_offline(cpu)) {
-			sched_preempt_enable_no_resched();
-			cpu_play_dead();
-		}
-#endif
-		schedule_preempt_disabled();
-	}
+void arch_cpu_idle_dead()
+{
+	sched_preempt_enable_no_resched();
+	cpu_play_dead();
 }
+#endif
 
 #ifdef CONFIG_COMPAT
 static void show_regwindow32(struct pt_regs *regs)
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index 9e7e6d7..e3f2b81 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -369,7 +369,7 @@ void __cpuinit sparc_start_secondary(void *arg)
 	local_irq_enable();
 
 	wmb();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 
 	/* We should never reach here! */
 	BUG();
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 537eb66..c025ffc 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -127,6 +127,8 @@ void __cpuinit smp_callin(void)
 
 	/* idle thread is expected to have preempt disabled */
 	preempt_disable();
+
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void cpu_panic(void)
diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
index da1b781..2e973a2 100644
--- a/arch/sparc/kernel/trampoline_64.S
+++ b/arch/sparc/kernel/trampoline_64.S
@@ -407,8 +407,7 @@ after_lock_tlb:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 1:	b,a,pt		%xcc, 1b

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [PATCH v2] sparc: Use generic idle loop
@ 2013-04-11 19:38                 ` Sam Ravnborg
  0 siblings, 0 replies; 147+ messages in thread
From: Sam Ravnborg @ 2013-04-11 19:38 UTC (permalink / raw)
  To: David Miller
  Cc: srivatsa.bhat, tglx, linux-kernel, linux-arch, torvalds, akpm,
	rusty, paulmck, mingo, peterz, magnus.damm

Add generic cpu_idle support

sparc32:
- replace call to cpu_idle() with cpu_startup_entry()
- add arch_cpu_idle()

sparc64:
- smp_callin() now include cpu_startup_entry() call so we can
  skip calling cpu_idle from assembler
- add arch_cpu_idle() and arch_cpu_idle_dead()

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
Cc: David S. Miller <davem@davemloft.net>
---
v1->v2:
- simplified arch_cpu_idle() - former sparc64_yield() based on comments from Srivatsa
- dropped TIF_POLLING_NRFLAG handling
- dropped smp_mb__after_clear_bit() - this is done in generic code using rmb()
- dropped the out-most while (!need_resched() && !cpu_is_offline(cpu))
- always enable irq on exit in arch_cpu_idle (both sparc32 and sparc64)
- added comment from davem why we need to clear IE bit in sparc64 arch_cpu_idle()

	Sam


diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 3d361f2..ee5eacc 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -37,6 +37,7 @@ config SPARC
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CLOCKEVENTS
+	select GENERIC_IDLE_LOOP
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
 	select MODULES_USE_ELF_RELA
diff --git a/arch/sparc/kernel/hvtramp.S b/arch/sparc/kernel/hvtramp.S
index 9365432..605c960 100644
--- a/arch/sparc/kernel/hvtramp.S
+++ b/arch/sparc/kernel/hvtramp.S
@@ -128,8 +128,7 @@ hv_cpu_startup:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index 62eede1..c852410 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -64,23 +64,12 @@ extern void fpsave(unsigned long *, unsigned long *, void *, unsigned long *);
 struct task_struct *last_task_used_math = NULL;
 struct thread_info *current_set[NR_CPUS];
 
-/*
- * the idle loop on a Sparc... ;)
- */
-void cpu_idle(void)
+/* Idle loop support. */
+void arch_cpu_idle(void)
 {
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	for (;;) {
-		while (!need_resched()) {
-			if (sparc_idle)
-				(*sparc_idle)();
-			else
-				cpu_relax();
-		}
-		schedule_preempt_disabled();
-	}
+	if (sparc_idle)
+		(*sparc_idle)();
+	local_irq_enable();
 }
 
 /* XXX cli/sti -> local_irq_xxx here, check this works once SMP is fixed. */
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index cdb80b2..9fbf0d1 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -52,20 +52,17 @@
 
 #include "kstack.h"
 
-static void sparc64_yield(int cpu)
+/* Idle loop support on sparc64. */
+void arch_cpu_idle(void)
 {
 	if (tlb_type != hypervisor) {
 		touch_nmi_watchdog();
-		return;
-	}
-
-	clear_thread_flag(TIF_POLLING_NRFLAG);
-	smp_mb__after_clear_bit();
-
-	while (!need_resched() && !cpu_is_offline(cpu)) {
+	} else {
 		unsigned long pstate;
 
-		/* Disable interrupts. */
+                /* The sun4v sleeping code requires that we have PSTATE.IE cleared over
+                 * the cpu sleep hypervisor call.
+                 */
 		__asm__ __volatile__(
 			"rdpr %%pstate, %0\n\t"
 			"andn %0, %1, %0\n\t"
@@ -73,7 +70,7 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 
-		if (!need_resched() && !cpu_is_offline(cpu))
+		if (!need_resched() && !cpu_is_offline(smp_processor_id()))
 			sun4v_cpu_yield();
 
 		/* Re-enable interrupts. */
@@ -84,36 +81,16 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 	}
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
+	local_irq_enable();
 }
 
-/* The idle loop on sparc64. */
-void cpu_idle(void)
-{
-	int cpu = smp_processor_id();
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	while(1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched() && !cpu_is_offline(cpu))
-			sparc64_yield(cpu);
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
 #ifdef CONFIG_HOTPLUG_CPU
-		if (cpu_is_offline(cpu)) {
-			sched_preempt_enable_no_resched();
-			cpu_play_dead();
-		}
-#endif
-		schedule_preempt_disabled();
-	}
+void arch_cpu_idle_dead()
+{
+	sched_preempt_enable_no_resched();
+	cpu_play_dead();
 }
+#endif
 
 #ifdef CONFIG_COMPAT
 static void show_regwindow32(struct pt_regs *regs)
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index 9e7e6d7..e3f2b81 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -369,7 +369,7 @@ void __cpuinit sparc_start_secondary(void *arg)
 	local_irq_enable();
 
 	wmb();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 
 	/* We should never reach here! */
 	BUG();
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 537eb66..c025ffc 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -127,6 +127,8 @@ void __cpuinit smp_callin(void)
 
 	/* idle thread is expected to have preempt disabled */
 	preempt_disable();
+
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void cpu_panic(void)
diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
index da1b781..2e973a2 100644
--- a/arch/sparc/kernel/trampoline_64.S
+++ b/arch/sparc/kernel/trampoline_64.S
@@ -407,8 +407,7 @@ after_lock_tlb:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 1:	b,a,pt		%xcc, 1b

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [PATCH v2] sparc: Use generic idle loop
@ 2013-04-11 19:38                 ` Sam Ravnborg
  0 siblings, 0 replies; 147+ messages in thread
From: Sam Ravnborg @ 2013-04-11 19:38 UTC (permalink / raw)
  To: David Miller, Thomas Gleixner
  Cc: srivatsa.bhat, linux-kernel, linux-arch, torvalds, akpm, rusty,
	paulmck, mingo, peterz, magnus.damm

Add generic cpu_idle support

sparc32:
- replace call to cpu_idle() with cpu_startup_entry()
- add arch_cpu_idle()

sparc64:
- smp_callin() now include cpu_startup_entry() call so we can
  skip calling cpu_idle from assembler
- add arch_cpu_idle() and arch_cpu_idle_dead()

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
Cc: David S. Miller <davem@davemloft.net>
---
v1->v2:
- simplified arch_cpu_idle() - former sparc64_yield() based on comments from Srivatsa
- dropped TIF_POLLING_NRFLAG handling
- dropped smp_mb__after_clear_bit() - this is done in generic code using rmb()
- dropped the out-most while (!need_resched() && !cpu_is_offline(cpu))
- always enable irq on exit in arch_cpu_idle (both sparc32 and sparc64)
- added comment from davem why we need to clear IE bit in sparc64 arch_cpu_idle()

	Sam


diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 3d361f2..ee5eacc 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -37,6 +37,7 @@ config SPARC
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CLOCKEVENTS
+	select GENERIC_IDLE_LOOP
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
 	select MODULES_USE_ELF_RELA
diff --git a/arch/sparc/kernel/hvtramp.S b/arch/sparc/kernel/hvtramp.S
index 9365432..605c960 100644
--- a/arch/sparc/kernel/hvtramp.S
+++ b/arch/sparc/kernel/hvtramp.S
@@ -128,8 +128,7 @@ hv_cpu_startup:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index 62eede1..c852410 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -64,23 +64,12 @@ extern void fpsave(unsigned long *, unsigned long *, void *, unsigned long *);
 struct task_struct *last_task_used_math = NULL;
 struct thread_info *current_set[NR_CPUS];
 
-/*
- * the idle loop on a Sparc... ;)
- */
-void cpu_idle(void)
+/* Idle loop support. */
+void arch_cpu_idle(void)
 {
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	for (;;) {
-		while (!need_resched()) {
-			if (sparc_idle)
-				(*sparc_idle)();
-			else
-				cpu_relax();
-		}
-		schedule_preempt_disabled();
-	}
+	if (sparc_idle)
+		(*sparc_idle)();
+	local_irq_enable();
 }
 
 /* XXX cli/sti -> local_irq_xxx here, check this works once SMP is fixed. */
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index cdb80b2..9fbf0d1 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -52,20 +52,17 @@
 
 #include "kstack.h"
 
-static void sparc64_yield(int cpu)
+/* Idle loop support on sparc64. */
+void arch_cpu_idle(void)
 {
 	if (tlb_type != hypervisor) {
 		touch_nmi_watchdog();
-		return;
-	}
-
-	clear_thread_flag(TIF_POLLING_NRFLAG);
-	smp_mb__after_clear_bit();
-
-	while (!need_resched() && !cpu_is_offline(cpu)) {
+	} else {
 		unsigned long pstate;
 
-		/* Disable interrupts. */
+                /* The sun4v sleeping code requires that we have PSTATE.IE cleared over
+                 * the cpu sleep hypervisor call.
+                 */
 		__asm__ __volatile__(
 			"rdpr %%pstate, %0\n\t"
 			"andn %0, %1, %0\n\t"
@@ -73,7 +70,7 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 
-		if (!need_resched() && !cpu_is_offline(cpu))
+		if (!need_resched() && !cpu_is_offline(smp_processor_id()))
 			sun4v_cpu_yield();
 
 		/* Re-enable interrupts. */
@@ -84,36 +81,16 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 	}
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
+	local_irq_enable();
 }
 
-/* The idle loop on sparc64. */
-void cpu_idle(void)
-{
-	int cpu = smp_processor_id();
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	while(1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched() && !cpu_is_offline(cpu))
-			sparc64_yield(cpu);
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
 #ifdef CONFIG_HOTPLUG_CPU
-		if (cpu_is_offline(cpu)) {
-			sched_preempt_enable_no_resched();
-			cpu_play_dead();
-		}
-#endif
-		schedule_preempt_disabled();
-	}
+void arch_cpu_idle_dead()
+{
+	sched_preempt_enable_no_resched();
+	cpu_play_dead();
 }
+#endif
 
 #ifdef CONFIG_COMPAT
 static void show_regwindow32(struct pt_regs *regs)
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index 9e7e6d7..e3f2b81 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -369,7 +369,7 @@ void __cpuinit sparc_start_secondary(void *arg)
 	local_irq_enable();
 
 	wmb();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 
 	/* We should never reach here! */
 	BUG();
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 537eb66..c025ffc 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -127,6 +127,8 @@ void __cpuinit smp_callin(void)
 
 	/* idle thread is expected to have preempt disabled */
 	preempt_disable();
+
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void cpu_panic(void)
diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
index da1b781..2e973a2 100644
--- a/arch/sparc/kernel/trampoline_64.S
+++ b/arch/sparc/kernel/trampoline_64.S
@@ -407,8 +407,7 @@ after_lock_tlb:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 1:	b,a,pt		%xcc, 1b

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [PATCH v2] sparc: Use generic idle loop
  2013-04-11 19:38                 ` Sam Ravnborg
  (?)
  (?)
@ 2013-04-12 18:56                 ` Thomas Gleixner
  2013-04-12 18:58                   ` David Miller
  -1 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-04-12 18:56 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: David Miller, srivatsa.bhat, linux-kernel, linux-arch, torvalds,
	akpm, rusty, paulmck, mingo, peterz, magnus.damm

On Thu, 11 Apr 2013, Sam Ravnborg wrote:

> Add generic cpu_idle support
> 
> sparc32:
> - replace call to cpu_idle() with cpu_startup_entry()
> - add arch_cpu_idle()
> 
> sparc64:
> - smp_callin() now include cpu_startup_entry() call so we can
>   skip calling cpu_idle from assembler
> - add arch_cpu_idle() and arch_cpu_idle_dead()

Nice !

If Dave acks it, I'll pick it up 

Thanks,

	tglx

 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Reviewed-by: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
> Cc: David S. Miller <davem@davemloft.net>
> ---
> v1->v2:
> - simplified arch_cpu_idle() - former sparc64_yield() based on comments from Srivatsa
> - dropped TIF_POLLING_NRFLAG handling
> - dropped smp_mb__after_clear_bit() - this is done in generic code using rmb()
> - dropped the out-most while (!need_resched() && !cpu_is_offline(cpu))
> - always enable irq on exit in arch_cpu_idle (both sparc32 and sparc64)
> - added comment from davem why we need to clear IE bit in sparc64 arch_cpu_idle()
> 
> 	Sam
> 
> 
> diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
> index 3d361f2..ee5eacc 100644
> --- a/arch/sparc/Kconfig
> +++ b/arch/sparc/Kconfig
> @@ -37,6 +37,7 @@ config SPARC
>  	select GENERIC_SMP_IDLE_THREAD
>  	select GENERIC_CMOS_UPDATE
>  	select GENERIC_CLOCKEVENTS
> +	select GENERIC_IDLE_LOOP
>  	select GENERIC_STRNCPY_FROM_USER
>  	select GENERIC_STRNLEN_USER
>  	select MODULES_USE_ELF_RELA
> diff --git a/arch/sparc/kernel/hvtramp.S b/arch/sparc/kernel/hvtramp.S
> index 9365432..605c960 100644
> --- a/arch/sparc/kernel/hvtramp.S
> +++ b/arch/sparc/kernel/hvtramp.S
> @@ -128,8 +128,7 @@ hv_cpu_startup:
>  
>  	call		smp_callin
>  	 nop
> -	call		cpu_idle
> -	 mov		0, %o0
> +
>  	call		cpu_panic
>  	 nop
>  
> diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
> index 62eede1..c852410 100644
> --- a/arch/sparc/kernel/process_32.c
> +++ b/arch/sparc/kernel/process_32.c
> @@ -64,23 +64,12 @@ extern void fpsave(unsigned long *, unsigned long *, void *, unsigned long *);
>  struct task_struct *last_task_used_math = NULL;
>  struct thread_info *current_set[NR_CPUS];
>  
> -/*
> - * the idle loop on a Sparc... ;)
> - */
> -void cpu_idle(void)
> +/* Idle loop support. */
> +void arch_cpu_idle(void)
>  {
> -	set_thread_flag(TIF_POLLING_NRFLAG);
> -
> -	/* endless idle loop with no priority at all */
> -	for (;;) {
> -		while (!need_resched()) {
> -			if (sparc_idle)
> -				(*sparc_idle)();
> -			else
> -				cpu_relax();
> -		}
> -		schedule_preempt_disabled();
> -	}
> +	if (sparc_idle)
> +		(*sparc_idle)();
> +	local_irq_enable();
>  }
>  
>  /* XXX cli/sti -> local_irq_xxx here, check this works once SMP is fixed. */
> diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
> index cdb80b2..9fbf0d1 100644
> --- a/arch/sparc/kernel/process_64.c
> +++ b/arch/sparc/kernel/process_64.c
> @@ -52,20 +52,17 @@
>  
>  #include "kstack.h"
>  
> -static void sparc64_yield(int cpu)
> +/* Idle loop support on sparc64. */
> +void arch_cpu_idle(void)
>  {
>  	if (tlb_type != hypervisor) {
>  		touch_nmi_watchdog();
> -		return;
> -	}
> -
> -	clear_thread_flag(TIF_POLLING_NRFLAG);
> -	smp_mb__after_clear_bit();
> -
> -	while (!need_resched() && !cpu_is_offline(cpu)) {
> +	} else {
>  		unsigned long pstate;
>  
> -		/* Disable interrupts. */
> +                /* The sun4v sleeping code requires that we have PSTATE.IE cleared over
> +                 * the cpu sleep hypervisor call.
> +                 */
>  		__asm__ __volatile__(
>  			"rdpr %%pstate, %0\n\t"
>  			"andn %0, %1, %0\n\t"
> @@ -73,7 +70,7 @@ static void sparc64_yield(int cpu)
>  			: "=&r" (pstate)
>  			: "i" (PSTATE_IE));
>  
> -		if (!need_resched() && !cpu_is_offline(cpu))
> +		if (!need_resched() && !cpu_is_offline(smp_processor_id()))
>  			sun4v_cpu_yield();
>  
>  		/* Re-enable interrupts. */
> @@ -84,36 +81,16 @@ static void sparc64_yield(int cpu)
>  			: "=&r" (pstate)
>  			: "i" (PSTATE_IE));
>  	}
> -
> -	set_thread_flag(TIF_POLLING_NRFLAG);
> +	local_irq_enable();
>  }
>  
> -/* The idle loop on sparc64. */
> -void cpu_idle(void)
> -{
> -	int cpu = smp_processor_id();
> -
> -	set_thread_flag(TIF_POLLING_NRFLAG);
> -
> -	while(1) {
> -		tick_nohz_idle_enter();
> -		rcu_idle_enter();
> -
> -		while (!need_resched() && !cpu_is_offline(cpu))
> -			sparc64_yield(cpu);
> -
> -		rcu_idle_exit();
> -		tick_nohz_idle_exit();
> -
>  #ifdef CONFIG_HOTPLUG_CPU
> -		if (cpu_is_offline(cpu)) {
> -			sched_preempt_enable_no_resched();
> -			cpu_play_dead();
> -		}
> -#endif
> -		schedule_preempt_disabled();
> -	}
> +void arch_cpu_idle_dead()
> +{
> +	sched_preempt_enable_no_resched();
> +	cpu_play_dead();
>  }
> +#endif
>  
>  #ifdef CONFIG_COMPAT
>  static void show_regwindow32(struct pt_regs *regs)
> diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
> index 9e7e6d7..e3f2b81 100644
> --- a/arch/sparc/kernel/smp_32.c
> +++ b/arch/sparc/kernel/smp_32.c
> @@ -369,7 +369,7 @@ void __cpuinit sparc_start_secondary(void *arg)
>  	local_irq_enable();
>  
>  	wmb();
> -	cpu_idle();
> +	cpu_startup_entry(CPUHP_ONLINE);
>  
>  	/* We should never reach here! */
>  	BUG();
> diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
> index 537eb66..c025ffc 100644
> --- a/arch/sparc/kernel/smp_64.c
> +++ b/arch/sparc/kernel/smp_64.c
> @@ -127,6 +127,8 @@ void __cpuinit smp_callin(void)
>  
>  	/* idle thread is expected to have preempt disabled */
>  	preempt_disable();
> +
> +	cpu_startup_entry(CPUHP_ONLINE);
>  }
>  
>  void cpu_panic(void)
> diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
> index da1b781..2e973a2 100644
> --- a/arch/sparc/kernel/trampoline_64.S
> +++ b/arch/sparc/kernel/trampoline_64.S
> @@ -407,8 +407,7 @@ after_lock_tlb:
>  
>  	call		smp_callin
>  	 nop
> -	call		cpu_idle
> -	 mov		0, %o0
> +
>  	call		cpu_panic
>  	 nop
>  1:	b,a,pt		%xcc, 1b
> 

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [PATCH v2] sparc: Use generic idle loop
  2013-04-12 18:56                 ` Thomas Gleixner
@ 2013-04-12 18:58                   ` David Miller
  0 siblings, 0 replies; 147+ messages in thread
From: David Miller @ 2013-04-12 18:58 UTC (permalink / raw)
  To: tglx
  Cc: sam, srivatsa.bhat, linux-kernel, linux-arch, torvalds, akpm,
	rusty, paulmck, mingo, peterz, magnus.damm

From: Thomas Gleixner <tglx@linutronix.de>
Date: Fri, 12 Apr 2013 20:56:10 +0200 (CEST)

> On Thu, 11 Apr 2013, Sam Ravnborg wrote:
> 
>> Add generic cpu_idle support
>> 
>> sparc32:
>> - replace call to cpu_idle() with cpu_startup_entry()
>> - add arch_cpu_idle()
>> 
>> sparc64:
>> - smp_callin() now include cpu_startup_entry() call so we can
>>   skip calling cpu_idle from assembler
>> - add arch_cpu_idle() and arch_cpu_idle_dead()
> 
> Nice !
> 
> If Dave acks it, I'll pick it up 

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] sparc: Use generic idle loop
  2013-04-11 19:38                 ` Sam Ravnborg
                                   ` (2 preceding siblings ...)
  (?)
@ 2013-04-13 19:53                 ` tip-bot for Sam Ravnborg
  -1 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Sam Ravnborg @ 2013-04-13 19:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, sam, srivatsa.bhat, tglx, davem

Commit-ID:  87fa05aeb3a5e8e21b1a5510eef6983650eff092
Gitweb:     http://git.kernel.org/tip/87fa05aeb3a5e8e21b1a5510eef6983650eff092
Author:     Sam Ravnborg <sam@ravnborg.org>
AuthorDate: Thu, 11 Apr 2013 21:38:50 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 13 Apr 2013 21:36:27 +0200

sparc: Use generic idle loop

Add generic cpu_idle support

sparc32:
- replace call to cpu_idle() with cpu_startup_entry()
- add arch_cpu_idle()

sparc64:
- smp_callin() now include cpu_startup_entry() call so we can
  skip calling cpu_idle from assembler
- add arch_cpu_idle() and arch_cpu_idle_dead()

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
Cc: torvalds@linux-foundation.org
Cc: rusty@rustcorp.com.au
Cc: paulmck@linux.vnet.ibm.com
Cc: peterz@infradead.org
Cc: magnus.damm@gmail.com
Acked-by: David Miller <davem@davemloft.net>
Link: http://lkml.kernel.org/r/20130411193850.GA2330@merkur.ravnborg.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/sparc/Kconfig                |  1 +
 arch/sparc/kernel/hvtramp.S       |  3 +--
 arch/sparc/kernel/process_32.c    | 21 ++++-------------
 arch/sparc/kernel/process_64.c    | 49 +++++++++++----------------------------
 arch/sparc/kernel/smp_32.c        |  2 +-
 arch/sparc/kernel/smp_64.c        |  2 ++
 arch/sparc/kernel/trampoline_64.S |  3 +--
 7 files changed, 24 insertions(+), 57 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 3d361f2..ee5eacc 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -37,6 +37,7 @@ config SPARC
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_CMOS_UPDATE
 	select GENERIC_CLOCKEVENTS
+	select GENERIC_IDLE_LOOP
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
 	select MODULES_USE_ELF_RELA
diff --git a/arch/sparc/kernel/hvtramp.S b/arch/sparc/kernel/hvtramp.S
index 9365432..605c960 100644
--- a/arch/sparc/kernel/hvtramp.S
+++ b/arch/sparc/kernel/hvtramp.S
@@ -128,8 +128,7 @@ hv_cpu_startup:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index 62eede1..c852410 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -64,23 +64,12 @@ extern void fpsave(unsigned long *, unsigned long *, void *, unsigned long *);
 struct task_struct *last_task_used_math = NULL;
 struct thread_info *current_set[NR_CPUS];
 
-/*
- * the idle loop on a Sparc... ;)
- */
-void cpu_idle(void)
+/* Idle loop support. */
+void arch_cpu_idle(void)
 {
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	/* endless idle loop with no priority at all */
-	for (;;) {
-		while (!need_resched()) {
-			if (sparc_idle)
-				(*sparc_idle)();
-			else
-				cpu_relax();
-		}
-		schedule_preempt_disabled();
-	}
+	if (sparc_idle)
+		(*sparc_idle)();
+	local_irq_enable();
 }
 
 /* XXX cli/sti -> local_irq_xxx here, check this works once SMP is fixed. */
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index cdb80b2..9fbf0d1 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -52,20 +52,17 @@
 
 #include "kstack.h"
 
-static void sparc64_yield(int cpu)
+/* Idle loop support on sparc64. */
+void arch_cpu_idle(void)
 {
 	if (tlb_type != hypervisor) {
 		touch_nmi_watchdog();
-		return;
-	}
-
-	clear_thread_flag(TIF_POLLING_NRFLAG);
-	smp_mb__after_clear_bit();
-
-	while (!need_resched() && !cpu_is_offline(cpu)) {
+	} else {
 		unsigned long pstate;
 
-		/* Disable interrupts. */
+                /* The sun4v sleeping code requires that we have PSTATE.IE cleared over
+                 * the cpu sleep hypervisor call.
+                 */
 		__asm__ __volatile__(
 			"rdpr %%pstate, %0\n\t"
 			"andn %0, %1, %0\n\t"
@@ -73,7 +70,7 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 
-		if (!need_resched() && !cpu_is_offline(cpu))
+		if (!need_resched() && !cpu_is_offline(smp_processor_id()))
 			sun4v_cpu_yield();
 
 		/* Re-enable interrupts. */
@@ -84,36 +81,16 @@ static void sparc64_yield(int cpu)
 			: "=&r" (pstate)
 			: "i" (PSTATE_IE));
 	}
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
+	local_irq_enable();
 }
 
-/* The idle loop on sparc64. */
-void cpu_idle(void)
-{
-	int cpu = smp_processor_id();
-
-	set_thread_flag(TIF_POLLING_NRFLAG);
-
-	while(1) {
-		tick_nohz_idle_enter();
-		rcu_idle_enter();
-
-		while (!need_resched() && !cpu_is_offline(cpu))
-			sparc64_yield(cpu);
-
-		rcu_idle_exit();
-		tick_nohz_idle_exit();
-
 #ifdef CONFIG_HOTPLUG_CPU
-		if (cpu_is_offline(cpu)) {
-			sched_preempt_enable_no_resched();
-			cpu_play_dead();
-		}
-#endif
-		schedule_preempt_disabled();
-	}
+void arch_cpu_idle_dead()
+{
+	sched_preempt_enable_no_resched();
+	cpu_play_dead();
 }
+#endif
 
 #ifdef CONFIG_COMPAT
 static void show_regwindow32(struct pt_regs *regs)
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index 9e7e6d7..e3f2b81 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -369,7 +369,7 @@ void __cpuinit sparc_start_secondary(void *arg)
 	local_irq_enable();
 
 	wmb();
-	cpu_idle();
+	cpu_startup_entry(CPUHP_ONLINE);
 
 	/* We should never reach here! */
 	BUG();
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 537eb66..c025ffc 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -127,6 +127,8 @@ void __cpuinit smp_callin(void)
 
 	/* idle thread is expected to have preempt disabled */
 	preempt_disable();
+
+	cpu_startup_entry(CPUHP_ONLINE);
 }
 
 void cpu_panic(void)
diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
index da1b781..2e973a2 100644
--- a/arch/sparc/kernel/trampoline_64.S
+++ b/arch/sparc/kernel/trampoline_64.S
@@ -407,8 +407,7 @@ after_lock_tlb:
 
 	call		smp_callin
 	 nop
-	call		cpu_idle
-	 mov		0, %o0
+
 	call		cpu_panic
 	 nop
 1:	b,a,pt		%xcc, 1b

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [tip:smp/hotplug] idle: Provide a generic entry point for the idle code
  2013-04-08 20:12   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
@ 2013-04-14  0:42     ` Yinghai Lu
  0 siblings, 0 replies; 147+ messages in thread
From: Yinghai Lu @ 2013-04-14  0:42 UTC (permalink / raw)
  To: Ingo Molnar, H. Peter Anvin, Linux Kernel Mailing List,
	Linus Torvalds, Rusty Russell, Peter Zijlstra, Srivatsa S. Bhat,
	Paul McKenney, Thomas Gleixner, Magnus Damm
  Cc: linux-tip-commits

On Mon, Apr 8, 2013 at 1:12 PM, tip-bot for Thomas Gleixner
<tipbot@zytor.com> wrote:
> Commit-ID:  a1a04ec3c7c27a682473fd9beb2c996316a64649
> Gitweb:     http://git.kernel.org/tip/a1a04ec3c7c27a682473fd9beb2c996316a64649
> Author:     Thomas Gleixner <tglx@linutronix.de>
> AuthorDate: Thu, 21 Mar 2013 22:49:34 +0100
> Committer:  Thomas Gleixner <tglx@linutronix.de>
> CommitDate: Mon, 8 Apr 2013 17:39:23 +0200
>
> idle: Provide a generic entry point for the idle code
>
> For now this calls cpu_idle(), but in the long run we want to move the
> cpu bringup code to the core and therefor we add a state argument.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
...
> Reviewed-by: Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>

What is that ?

looks your scripts has problem to convert Cc to Reviewed-by

Yinghai

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [tip:smp/hotplug] idle: Implement generic idle function
  2013-04-08 20:14   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
@ 2013-04-15 22:25     ` Tony Luck
  2013-04-16 13:28       ` Thomas Gleixner
  0 siblings, 1 reply; 147+ messages in thread
From: Tony Luck @ 2013-04-15 22:25 UTC (permalink / raw)
  To: Ingo Molnar, H. Peter Anvin, Linux Kernel Mailing List,
	Linus Torvalds, Rusty Russell, Peter Zijlstra, Srivatsa S. Bhat,
	Paul McKenney, Thomas Gleixner, magnus.damm
  Cc: linux-tip-commits

Built next-20130415 and got this on ia64 early in boot:

WARNING: at kernel/cpu/idle.c:94 cpu_idle_loop+0x360/0x380()
Hardware name: server rx2620
Modules linked in:

Call Trace:
 [<a000000100014ac0>] show_stack+0x80/0xa0
                                sp=a000000101287c50 bsp=a000000101280e48
 [<a000000100dabd40>] dump_stack+0x30/0x50
                                sp=a000000101287e20 bsp=a000000101280e30
 [<a000000100073e40>] warn_slowpath_common+0xc0/0x100
                                sp=a000000101287e20 bsp=a000000101280de8
 [<a000000100073ec0>] warn_slowpath_null+0x40/0x60
                                sp=a000000101287e20 bsp=a000000101280dc0
 [<a0000001000fa7a0>] cpu_idle_loop+0x360/0x380
                                sp=a000000101287e20 bsp=a000000101280d80
 [<a0000001000fa800>] cpu_startup_entry+0x40/0x60
                                sp=a000000101287e20 bsp=a000000101280d68
 [<a000000100d9f460>] rest_init+0x100/0x120
                                sp=a000000101287e20 bsp=a000000101280d50
 [<a00000010114d3b0>] start_kernel+0x770/0x890
                                sp=a000000101287e20 bsp=a000000101280cd0
 [<a000000100d9f320>] start_ap+0x760/0x780
                                sp=a000000101287e30 bsp=a000000101280bc0

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [tip:smp/hotplug] idle: Implement generic idle function
  2013-04-15 22:25     ` Tony Luck
@ 2013-04-16 13:28       ` Thomas Gleixner
  2013-04-16 18:25         ` Tony Luck
  0 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-04-16 13:28 UTC (permalink / raw)
  To: Tony Luck
  Cc: Ingo Molnar, H. Peter Anvin, Linux Kernel Mailing List,
	Linus Torvalds, Rusty Russell, Peter Zijlstra, Srivatsa S. Bhat,
	Paul McKenney, magnus.damm

On Mon, 15 Apr 2013, Tony Luck wrote:

> Built next-20130415 and got this on ia64 early in boot:
> 
> WARNING: at kernel/cpu/idle.c:94 cpu_idle_loop+0x360/0x380()

Hmm, is safe_halt() returning with interrupts disabled? If yes, it
lacks a local_irq_enable().

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [tip:smp/hotplug] idle: Implement generic idle function
  2013-04-16 13:28       ` Thomas Gleixner
@ 2013-04-16 18:25         ` Tony Luck
  2013-04-16 18:35           ` [PATCH] ia64: Make sure interrupts enabled when we "safe_halt()" Luck, Tony
  0 siblings, 1 reply; 147+ messages in thread
From: Tony Luck @ 2013-04-16 18:25 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, H. Peter Anvin, Linux Kernel Mailing List,
	Linus Torvalds, Rusty Russell, Peter Zijlstra, Srivatsa S. Bhat,
	Paul McKenney, magnus.damm

On Tue, Apr 16, 2013 at 6:28 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> Hmm, is safe_halt() returning with interrupts disabled? If yes, it
> lacks a local_irq_enable().

Quite probably. Adding arch_local_irq_enable() to arch_safe_halt()
makes all the problems go away.  I'll send you the one-line patch
from a system that won't mung it like gmail will.

-Tony

^ permalink raw reply	[flat|nested] 147+ messages in thread

* [PATCH] ia64: Make sure interrupts enabled when we "safe_halt()"
  2013-04-16 18:25         ` Tony Luck
@ 2013-04-16 18:35           ` Luck, Tony
  2013-04-17  9:00             ` [tip:smp/hotplug] ia64: Make sure interrupts enabled when we " safe_halt()" tip-bot for Luck, Tony
  0 siblings, 1 reply; 147+ messages in thread
From: Luck, Tony @ 2013-04-16 18:35 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, H. Peter Anvin, Linux Kernel Mailing List,
	Linus Torvalds, Rusty Russell, Peter Zijlstra, Srivatsa S. Bhat,
	Paul McKenney, magnus.damm

In commit d166991234347215dc23fc9dc15a63a83a1a54e1
   idle: Implement generic idle function
Thomas Gleixner cleaned up many things but perturbed some
fragile code that was keeping ia64 alive. So we started
seeing:
   WARNING: at kernel/cpu/idle.c:94 cpu_idle_loop+0x360/0x380()
and other unpleasantness like system hangs during boot.

We really shouldn't ever halt with interrupts disabled.

Signed-off-by: Tony Luck <tony.luck@intel.com>

---

Please fold into the same branch as the generic idle changes.

diff --git a/arch/ia64/include/asm/irqflags.h b/arch/ia64/include/asm/irqflags.h
index 2b68d85..1bf2cf2 100644
--- a/arch/ia64/include/asm/irqflags.h
+++ b/arch/ia64/include/asm/irqflags.h
@@ -89,6 +89,7 @@ static inline bool arch_irqs_disabled(void)
 
 static inline void arch_safe_halt(void)
 {
+	arch_local_irq_enable();
 	ia64_pal_halt_light();	/* PAL_HALT_LIGHT */
 }
 

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* [tip:smp/hotplug] ia64: Make sure interrupts enabled when we " safe_halt()"
  2013-04-16 18:35           ` [PATCH] ia64: Make sure interrupts enabled when we "safe_halt()" Luck, Tony
@ 2013-04-17  9:00             ` tip-bot for Luck, Tony
  0 siblings, 0 replies; 147+ messages in thread
From: tip-bot for Luck, Tony @ 2013-04-17  9:00 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, rusty, torvalds, peterz, srivatsa.bhat,
	tony.luck, paulmck, tglx

Commit-ID:  2412aa1293a4159c610616305c17efd237c8208d
Gitweb:     http://git.kernel.org/tip/2412aa1293a4159c610616305c17efd237c8208d
Author:     Luck, Tony <tony.luck@intel.com>
AuthorDate: Tue, 16 Apr 2013 11:35:56 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 17 Apr 2013 10:39:37 +0200

ia64: Make sure interrupts enabled when we "safe_halt()"

In commit d166991234347215dc23fc9dc15a63a83a1a54e1
   idle: Implement generic idle function
Thomas Gleixner cleaned up many things but perturbed some
fragile code that was keeping ia64 alive. So we started
seeing:
   WARNING: at kernel/cpu/idle.c:94 cpu_idle_loop+0x360/0x380()
and other unpleasantness like system hangs during boot.

We really shouldn't ever halt with interrupts disabled.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: magnus.damm@gmail.com
Link: http://lkml.kernel.org/r/516d9a0c26048eae9c@agluck-desk.sc.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/ia64/include/asm/irqflags.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/ia64/include/asm/irqflags.h b/arch/ia64/include/asm/irqflags.h
index 2b68d85..1bf2cf2 100644
--- a/arch/ia64/include/asm/irqflags.h
+++ b/arch/ia64/include/asm/irqflags.h
@@ -89,6 +89,7 @@ static inline bool arch_irqs_disabled(void)
 
 static inline void arch_safe_halt(void)
 {
+	arch_local_irq_enable();
 	ia64_pal_halt_light();	/* PAL_HALT_LIGHT */
 }
 

^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [patch 08/34] arm: Use generic idle loop
  2013-04-09  9:38               ` Russell King - ARM Linux
@ 2013-04-25 20:03                 ` Stephen Boyd
  2013-04-25 21:01                   ` Thomas Gleixner
  0 siblings, 1 reply; 147+ messages in thread
From: Stephen Boyd @ 2013-04-25 20:03 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Thomas Gleixner, Kevin Hilman, LKML, linux-arch, Linus Torvalds,
	Andrew Morton, Rusty Russell, Paul McKenney, Ingo Molnar,
	Peter Zijlstra, Srivatsa S. Bhat, Magnus Damm

On 04/09/13 02:38, Russell King - ARM Linux wrote:
> On Tue, Apr 09, 2013 at 11:20:31AM +0200, Thomas Gleixner wrote:
>> On Mon, 8 Apr 2013, Russell King - ARM Linux wrote:
>>> On Mon, Mar 25, 2013 at 03:02:39PM +0100, Thomas Gleixner wrote:
>>> So, how can I review these changes when all there is is a git URL, and
>>> I *do* not want to pull them into my tree without first looking at the
>>> patches, possibly reviewing them and *replying* with the patch inline?
>> the patches were CC'ed to LKML and linux-arch and I expected that you
>> are at least having the latter. Find the relevant patch inlined below.
> I've not been on linux-arch for a few years now, after it evolved into
> yet another lkml-like list with high traffic rates, where mainly specific
> x86 issues seemed to be discussed, rather than it being a way to contact
> all arch maintainers.
>
>> It is a counter. I looked carefully at all the various slightly
>> differently fcked up implementations and picked the counter based one
>> as it fits all requirements.
> Great, thanks.  The attached patch looks fine to me.

I'm pretty sure that we need to apply this patch now that
rcu_idle_enter()/exit() is called lower down in the idle loop. Kevin,
did you test hotplug?

----8<-----

From: Stephen Boyd <sboyd@codeaurora.org>
Subject: [PATCH] ARM: smp: Drop RCU_NONIDLE usage in cpu_die()

Before f7b861b (arm: Use generic idle loop, 2013-03-21) ARM would
kill the CPU within the rcu idle section. Now that the
rcu_idle_enter()/exit() pair have been pushed lower down in the
idle loop this is no longer true and so using RCU_NONIDLE here is
no longer necessary and also harmful because RCU is not actually
idle at this point.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 arch/arm/kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 4619177..78f1eb5 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -233,7 +233,7 @@ void __ref cpu_die(void)
        mb();
 
        /* Tell __cpu_die() that this CPU is now safe to dispose of */
-       RCU_NONIDLE(complete(&cpu_died));
+       complete(&cpu_died);
 
        /*
         * actual CPU shutdown procedure is at least platform (if not

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation


^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [patch 08/34] arm: Use generic idle loop
  2013-04-25 20:03                 ` Stephen Boyd
@ 2013-04-25 21:01                   ` Thomas Gleixner
  2013-05-01  0:49                     ` Stephen Boyd
  0 siblings, 1 reply; 147+ messages in thread
From: Thomas Gleixner @ 2013-04-25 21:01 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Russell King - ARM Linux, Kevin Hilman, LKML, linux-arch,
	Linus Torvalds, Andrew Morton, Rusty Russell, Paul McKenney,
	Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat, Magnus Damm

On Thu, 25 Apr 2013, Stephen Boyd wrote:
> On 04/09/13 02:38, Russell King - ARM Linux wrote:
> > On Tue, Apr 09, 2013 at 11:20:31AM +0200, Thomas Gleixner wrote:
> >> On Mon, 8 Apr 2013, Russell King - ARM Linux wrote:
> >>> On Mon, Mar 25, 2013 at 03:02:39PM +0100, Thomas Gleixner wrote:
> >>> So, how can I review these changes when all there is is a git URL, and
> >>> I *do* not want to pull them into my tree without first looking at the
> >>> patches, possibly reviewing them and *replying* with the patch inline?
> >> the patches were CC'ed to LKML and linux-arch and I expected that you
> >> are at least having the latter. Find the relevant patch inlined below.
> > I've not been on linux-arch for a few years now, after it evolved into
> > yet another lkml-like list with high traffic rates, where mainly specific
> > x86 issues seemed to be discussed, rather than it being a way to contact
> > all arch maintainers.
> >
> >> It is a counter. I looked carefully at all the various slightly
> >> differently fcked up implementations and picked the counter based one
> >> as it fits all requirements.
> > Great, thanks.  The attached patch looks fine to me.
> 
> I'm pretty sure that we need to apply this patch now that
> rcu_idle_enter()/exit() is called lower down in the idle loop. Kevin,
> did you test hotplug?

If the patch is agreed on, I guess I should take it via my idle
consolidation branch, right ?

 
> ----8<-----
> 
> From: Stephen Boyd <sboyd@codeaurora.org>
> Subject: [PATCH] ARM: smp: Drop RCU_NONIDLE usage in cpu_die()
> 
> Before f7b861b (arm: Use generic idle loop, 2013-03-21) ARM would
> kill the CPU within the rcu idle section. Now that the
> rcu_idle_enter()/exit() pair have been pushed lower down in the
> idle loop this is no longer true and so using RCU_NONIDLE here is
> no longer necessary and also harmful because RCU is not actually
> idle at this point.
> 
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
> ---
>  arch/arm/kernel/smp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
> index 4619177..78f1eb5 100644
> --- a/arch/arm/kernel/smp.c
> +++ b/arch/arm/kernel/smp.c
> @@ -233,7 +233,7 @@ void __ref cpu_die(void)
>         mb();
>  
>         /* Tell __cpu_die() that this CPU is now safe to dispose of */
> -       RCU_NONIDLE(complete(&cpu_died));
> +       complete(&cpu_died);
>  
>         /*
>          * actual CPU shutdown procedure is at least platform (if not
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
> 
> 

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 08/34] arm: Use generic idle loop
  2013-04-25 21:01                   ` Thomas Gleixner
@ 2013-05-01  0:49                     ` Stephen Boyd
  2013-05-01  0:55                         ` Paul E. McKenney
  0 siblings, 1 reply; 147+ messages in thread
From: Stephen Boyd @ 2013-05-01  0:49 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Russell King - ARM Linux, Kevin Hilman, LKML, linux-arch,
	Linus Torvalds, Andrew Morton, Rusty Russell, Paul McKenney,
	Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat, Magnus Damm

On 04/25/13 14:01, Thomas Gleixner wrote:
> On Thu, 25 Apr 2013, Stephen Boyd wrote:
>> On 04/09/13 02:38, Russell King - ARM Linux wrote:
>>> On Tue, Apr 09, 2013 at 11:20:31AM +0200, Thomas Gleixner wrote:
>>>> On Mon, 8 Apr 2013, Russell King - ARM Linux wrote:
>>>>> On Mon, Mar 25, 2013 at 03:02:39PM +0100, Thomas Gleixner wrote:
>>>>> So, how can I review these changes when all there is is a git URL, and
>>>>> I *do* not want to pull them into my tree without first looking at the
>>>>> patches, possibly reviewing them and *replying* with the patch inline?
>>>> the patches were CC'ed to LKML and linux-arch and I expected that you
>>>> are at least having the latter. Find the relevant patch inlined below.
>>> I've not been on linux-arch for a few years now, after it evolved into
>>> yet another lkml-like list with high traffic rates, where mainly specific
>>> x86 issues seemed to be discussed, rather than it being a way to contact
>>> all arch maintainers.
>>>
>>>> It is a counter. I looked carefully at all the various slightly
>>>> differently fcked up implementations and picked the counter based one
>>>> as it fits all requirements.
>>> Great, thanks.  The attached patch looks fine to me.
>> I'm pretty sure that we need to apply this patch now that
>> rcu_idle_enter()/exit() is called lower down in the idle loop. Kevin,
>> did you test hotplug?
> If the patch is agreed on, I guess I should take it via my idle
> consolidation branch, right ?

Yes I think so. Hopefully Russell King or Paul McKenney can ack this patch.

>  
>> ----8<-----
>>
>> From: Stephen Boyd <sboyd@codeaurora.org>
>> Subject: [PATCH] ARM: smp: Drop RCU_NONIDLE usage in cpu_die()
>>
>> Before f7b861b (arm: Use generic idle loop, 2013-03-21) ARM would
>> kill the CPU within the rcu idle section. Now that the
>> rcu_idle_enter()/exit() pair have been pushed lower down in the
>> idle loop this is no longer true and so using RCU_NONIDLE here is
>> no longer necessary and also harmful because RCU is not actually
>> idle at this point.
>>
>> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
>> ---
>>  arch/arm/kernel/smp.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
>> index 4619177..78f1eb5 100644
>> --- a/arch/arm/kernel/smp.c
>> +++ b/arch/arm/kernel/smp.c
>> @@ -233,7 +233,7 @@ void __ref cpu_die(void)
>>         mb();
>>  
>>         /* Tell __cpu_die() that this CPU is now safe to dispose of */
>> -       RCU_NONIDLE(complete(&cpu_died));
>> +       complete(&cpu_died);
>>  
>>         /*
>>          * actual CPU shutdown procedure is at least platform (if not
>>
>> -- 
>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
>> hosted by The Linux Foundation
>>
>>


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 08/34] arm: Use generic idle loop
  2013-05-01  0:49                     ` Stephen Boyd
@ 2013-05-01  0:55                         ` Paul E. McKenney
  0 siblings, 0 replies; 147+ messages in thread
From: Paul E. McKenney @ 2013-05-01  0:55 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Thomas Gleixner, Russell King - ARM Linux, Kevin Hilman, LKML,
	linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat, Magnus Damm

On Tue, Apr 30, 2013 at 05:49:06PM -0700, Stephen Boyd wrote:
> On 04/25/13 14:01, Thomas Gleixner wrote:
> > On Thu, 25 Apr 2013, Stephen Boyd wrote:
> >> On 04/09/13 02:38, Russell King - ARM Linux wrote:
> >>> On Tue, Apr 09, 2013 at 11:20:31AM +0200, Thomas Gleixner wrote:
> >>>> On Mon, 8 Apr 2013, Russell King - ARM Linux wrote:
> >>>>> On Mon, Mar 25, 2013 at 03:02:39PM +0100, Thomas Gleixner wrote:
> >>>>> So, how can I review these changes when all there is is a git URL, and
> >>>>> I *do* not want to pull them into my tree without first looking at the
> >>>>> patches, possibly reviewing them and *replying* with the patch inline?
> >>>> the patches were CC'ed to LKML and linux-arch and I expected that you
> >>>> are at least having the latter. Find the relevant patch inlined below.
> >>> I've not been on linux-arch for a few years now, after it evolved into
> >>> yet another lkml-like list with high traffic rates, where mainly specific
> >>> x86 issues seemed to be discussed, rather than it being a way to contact
> >>> all arch maintainers.
> >>>
> >>>> It is a counter. I looked carefully at all the various slightly
> >>>> differently fcked up implementations and picked the counter based one
> >>>> as it fits all requirements.
> >>> Great, thanks.  The attached patch looks fine to me.
> >> I'm pretty sure that we need to apply this patch now that
> >> rcu_idle_enter()/exit() is called lower down in the idle loop. Kevin,
> >> did you test hotplug?
> > If the patch is agreed on, I guess I should take it via my idle
> > consolidation branch, right ?
> 
> Yes I think so. Hopefully Russell King or Paul McKenney can ack this patch.
> 
> >  
> >> ----8<-----
> >>
> >> From: Stephen Boyd <sboyd@codeaurora.org>
> >> Subject: [PATCH] ARM: smp: Drop RCU_NONIDLE usage in cpu_die()
> >>
> >> Before f7b861b (arm: Use generic idle loop, 2013-03-21) ARM would
> >> kill the CPU within the rcu idle section. Now that the
> >> rcu_idle_enter()/exit() pair have been pushed lower down in the
> >> idle loop this is no longer true and so using RCU_NONIDLE here is
> >> no longer necessary and also harmful because RCU is not actually
> >> idle at this point.
> >>
> >> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

>From an RCU perspective:

Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> >> ---
> >>  arch/arm/kernel/smp.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
> >> index 4619177..78f1eb5 100644
> >> --- a/arch/arm/kernel/smp.c
> >> +++ b/arch/arm/kernel/smp.c
> >> @@ -233,7 +233,7 @@ void __ref cpu_die(void)
> >>         mb();
> >>  
> >>         /* Tell __cpu_die() that this CPU is now safe to dispose of */
> >> -       RCU_NONIDLE(complete(&cpu_died));
> >> +       complete(&cpu_died);
> >>  
> >>         /*
> >>          * actual CPU shutdown procedure is at least platform (if not
> >>
> >> -- 
> >> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> >> hosted by The Linux Foundation
> >>
> >>
> 
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
> 


^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 08/34] arm: Use generic idle loop
@ 2013-05-01  0:55                         ` Paul E. McKenney
  0 siblings, 0 replies; 147+ messages in thread
From: Paul E. McKenney @ 2013-05-01  0:55 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Thomas Gleixner, Russell King - ARM Linux, Kevin Hilman, LKML,
	linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat, Magnus Damm

On Tue, Apr 30, 2013 at 05:49:06PM -0700, Stephen Boyd wrote:
> On 04/25/13 14:01, Thomas Gleixner wrote:
> > On Thu, 25 Apr 2013, Stephen Boyd wrote:
> >> On 04/09/13 02:38, Russell King - ARM Linux wrote:
> >>> On Tue, Apr 09, 2013 at 11:20:31AM +0200, Thomas Gleixner wrote:
> >>>> On Mon, 8 Apr 2013, Russell King - ARM Linux wrote:
> >>>>> On Mon, Mar 25, 2013 at 03:02:39PM +0100, Thomas Gleixner wrote:
> >>>>> So, how can I review these changes when all there is is a git URL, and
> >>>>> I *do* not want to pull them into my tree without first looking at the
> >>>>> patches, possibly reviewing them and *replying* with the patch inline?
> >>>> the patches were CC'ed to LKML and linux-arch and I expected that you
> >>>> are at least having the latter. Find the relevant patch inlined below.
> >>> I've not been on linux-arch for a few years now, after it evolved into
> >>> yet another lkml-like list with high traffic rates, where mainly specific
> >>> x86 issues seemed to be discussed, rather than it being a way to contact
> >>> all arch maintainers.
> >>>
> >>>> It is a counter. I looked carefully at all the various slightly
> >>>> differently fcked up implementations and picked the counter based one
> >>>> as it fits all requirements.
> >>> Great, thanks.  The attached patch looks fine to me.
> >> I'm pretty sure that we need to apply this patch now that
> >> rcu_idle_enter()/exit() is called lower down in the idle loop. Kevin,
> >> did you test hotplug?
> > If the patch is agreed on, I guess I should take it via my idle
> > consolidation branch, right ?
> 
> Yes I think so. Hopefully Russell King or Paul McKenney can ack this patch.
> 
> >  
> >> ----8<-----
> >>
> >> From: Stephen Boyd <sboyd@codeaurora.org>
> >> Subject: [PATCH] ARM: smp: Drop RCU_NONIDLE usage in cpu_die()
> >>
> >> Before f7b861b (arm: Use generic idle loop, 2013-03-21) ARM would
> >> kill the CPU within the rcu idle section. Now that the
> >> rcu_idle_enter()/exit() pair have been pushed lower down in the
> >> idle loop this is no longer true and so using RCU_NONIDLE here is
> >> no longer necessary and also harmful because RCU is not actually
> >> idle at this point.
> >>
> >> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

From an RCU perspective:

Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> >> ---
> >>  arch/arm/kernel/smp.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
> >> index 4619177..78f1eb5 100644
> >> --- a/arch/arm/kernel/smp.c
> >> +++ b/arch/arm/kernel/smp.c
> >> @@ -233,7 +233,7 @@ void __ref cpu_die(void)
> >>         mb();
> >>  
> >>         /* Tell __cpu_die() that this CPU is now safe to dispose of */
> >> -       RCU_NONIDLE(complete(&cpu_died));
> >> +       complete(&cpu_died);
> >>  
> >>         /*
> >>          * actual CPU shutdown procedure is at least platform (if not
> >>
> >> -- 
> >> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> >> hosted by The Linux Foundation
> >>
> >>
> 
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
> 

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 00/34] idle: Consolidate idle implementations
  2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
@ 2013-05-03  9:47   ` Geert Uytterhoeven
  2013-03-21 21:52 ` [patch 02/34] arch: Consolidate tsk_is_polling() Thomas Gleixner
                     ` (36 subsequent siblings)
  37 siblings, 0 replies; 147+ messages in thread
From: Geert Uytterhoeven @ 2013-05-03  9:47 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Linux-Arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, kernel-janitors

Hi Thomas,

On Thu, Mar 21, 2013 at 10:52 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> Each architecture implements its own cpu_idle() code, which is more or
> less the same on all architectures (plus/minus a few bugs and a few
> missing extra functionalities, instrumentation ...). That also forces
> everyone who is interested in idle related features to add new
> functionality to every architecture. What a waste.

I noticed there are still prototypes for cpu_idle() in include/linux/cpu.h
and include/linux/smp.h, so I ran a full "git grep -w cpu_idle", which
suggested a few more places that needs updates:

Documentation/s390/Debugging390.txt:0001b304 T cpu_idle
Documentation/s390/Debugging390.txt:is cpu_idle+0x66 ( quiet the cpu
is asleep, don't wake it )
Documentation/scheduler/sched-arch.txt:Your cpu_idle routines need to
obey the following rules:
Documentation/scheduler/sched-arch.txt:3. When cpu_idle finds
(need_resched() == 'true'), it should call
Documentation/trace/events-power.txt:cpu_idle           "state=%lu cpu_id=%lu"
Documentation/trace/ftrace.txt:          <idle>-0     [002] .N.1
21169.031484: rcu_idle_exit <-cpu_idle
Documentation/trace/ftrace.txt: => cpu_idle
Documentation/trace/ftrace.txt:  <idle>-0       3.N.1   11us :
rcu_idle_exit <-cpu_idle
Documentation/trace/ftrace.txt:  <idle>-0       3.N.1   11us :
tick_nohz_idle_exit <-cpu_idle
Documentation/trace/ftrace.txt:  <idle>-0       3.N.1   25us :
sub_preempt_count <-cpu_idle
Documentation/trace/ftrace.txt:  <idle>-0       3.N..   25us :
schedule <-cpu_idle
Documentation/trace/ftrace.txt:  <idle>-0       2.N.2    3us :
cpu_idle: state=4294967295 cpu_id=2
Documentation/virtual/uml/UserModeLinux-HOWTO.txt:       #3
0x100a5508 in cpu_idle () at process_kern.c:471
arch/arm/Kconfig:         This option adds a write barrier to the
cpu_idle loop so that,
arch/cris/arch-v10/drivers/gpio.c:       * from cpu_idle() in kernel/process.c
arch/cris/arch-v10/drivers/gpio.c:       * The check in cpu_idle()
reduces latency from ~15 ms to ~6 ms
arch/cris/arch-v32/drivers/mach-fs/gpio.c:       * from cpu_idle() in
kernel/process.c
arch/cris/arch-v32/drivers/mach-fs/gpio.c:       * The check in
cpu_idle() reduces latency from ~15 ms to ~6 ms
arch/mips/kernel/smtc.c:                printk("Dangling IXMT in cpu_idle()\n");
arch/powerpc/kernel/irq.c: * in cpu_idle() will properly re-enable everything.
arch/sparc/kernel/leon_pmc.c:/* leon_pmc.c: LEON Power-down cpu_idle() handler
arch/sparc/kernel/smp_32.c:     printk("CPU[%d]: Returns from
cpu_idle!\n", smp_processor_id());
arch/sparc/kernel/smp_64.c:     printk("CPU[%d]: Returns from
cpu_idle!\n", smp_processor_id());
arch/tile/include/asm/thread_info.h:/* Enable interrupts racelessly
and nap forever: helper for cpu_idle(). */
drivers/acpi/processor_driver.c:         * Set flag to delay
cpu_idle/throttling initialization
include/linux/cpu.h:void cpu_idle(void);
include/linux/smp.h:extern void cpu_idle(void);
include/trace/events/power.h:DEFINE_EVENT(cpu, cpu_idle,
init/main.c: * cpu_idle.
init/main.c:    /* Call into cpu_idle with preempt disabled */
init/main.c:     * fragile until we cpu_idle() for the first time.
kernel/trace/power-traces.c:EXPORT_TRACEPOINT_SYMBOL_GPL(cpu_idle);
tools/perf/builtin-timechart.c:          * Mapping all these
"power:cpu_idle" strings to the tracepoint
tools/perf/builtin-timechart.c:         if (strcmp(event_str,
"power:cpu_idle") == 0) {
tools/perf/builtin-timechart.c:         "-e", "power:cpu_idle",
tools/perf/builtin-timechart.c: if (!is_valid_tracepoint("power:cpu_idle") &&
tools/perf/builtin-top.c:       "cpu_idle",

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 00/34] idle: Consolidate idle implementations
@ 2013-05-03  9:47   ` Geert Uytterhoeven
  0 siblings, 0 replies; 147+ messages in thread
From: Geert Uytterhoeven @ 2013-05-03  9:47 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Linux-Arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, kernel-janitors

Hi Thomas,

On Thu, Mar 21, 2013 at 10:52 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> Each architecture implements its own cpu_idle() code, which is more or
> less the same on all architectures (plus/minus a few bugs and a few
> missing extra functionalities, instrumentation ...). That also forces
> everyone who is interested in idle related features to add new
> functionality to every architecture. What a waste.

I noticed there are still prototypes for cpu_idle() in include/linux/cpu.h
and include/linux/smp.h, so I ran a full "git grep -w cpu_idle", which
suggested a few more places that needs updates:

Documentation/s390/Debugging390.txt:0001b304 T cpu_idle
Documentation/s390/Debugging390.txt:is cpu_idle+0x66 ( quiet the cpu
is asleep, don't wake it )
Documentation/scheduler/sched-arch.txt:Your cpu_idle routines need to
obey the following rules:
Documentation/scheduler/sched-arch.txt:3. When cpu_idle finds
(need_resched() = 'true'), it should call
Documentation/trace/events-power.txt:cpu_idle           "state=%lu cpu_id=%lu"
Documentation/trace/ftrace.txt:          <idle>-0     [002] .N.1
21169.031484: rcu_idle_exit <-cpu_idle
Documentation/trace/ftrace.txt: => cpu_idle
Documentation/trace/ftrace.txt:  <idle>-0       3.N.1   11us :
rcu_idle_exit <-cpu_idle
Documentation/trace/ftrace.txt:  <idle>-0       3.N.1   11us :
tick_nohz_idle_exit <-cpu_idle
Documentation/trace/ftrace.txt:  <idle>-0       3.N.1   25us :
sub_preempt_count <-cpu_idle
Documentation/trace/ftrace.txt:  <idle>-0       3.N..   25us :
schedule <-cpu_idle
Documentation/trace/ftrace.txt:  <idle>-0       2.N.2    3us :
cpu_idle: stateB94967295 cpu_id=2
Documentation/virtual/uml/UserModeLinux-HOWTO.txt:       #3
0x100a5508 in cpu_idle () at process_kern.c:471
arch/arm/Kconfig:         This option adds a write barrier to the
cpu_idle loop so that,
arch/cris/arch-v10/drivers/gpio.c:       * from cpu_idle() in kernel/process.c
arch/cris/arch-v10/drivers/gpio.c:       * The check in cpu_idle()
reduces latency from ~15 ms to ~6 ms
arch/cris/arch-v32/drivers/mach-fs/gpio.c:       * from cpu_idle() in
kernel/process.c
arch/cris/arch-v32/drivers/mach-fs/gpio.c:       * The check in
cpu_idle() reduces latency from ~15 ms to ~6 ms
arch/mips/kernel/smtc.c:                printk("Dangling IXMT in cpu_idle()\n");
arch/powerpc/kernel/irq.c: * in cpu_idle() will properly re-enable everything.
arch/sparc/kernel/leon_pmc.c:/* leon_pmc.c: LEON Power-down cpu_idle() handler
arch/sparc/kernel/smp_32.c:     printk("CPU[%d]: Returns from
cpu_idle!\n", smp_processor_id());
arch/sparc/kernel/smp_64.c:     printk("CPU[%d]: Returns from
cpu_idle!\n", smp_processor_id());
arch/tile/include/asm/thread_info.h:/* Enable interrupts racelessly
and nap forever: helper for cpu_idle(). */
drivers/acpi/processor_driver.c:         * Set flag to delay
cpu_idle/throttling initialization
include/linux/cpu.h:void cpu_idle(void);
include/linux/smp.h:extern void cpu_idle(void);
include/trace/events/power.h:DEFINE_EVENT(cpu, cpu_idle,
init/main.c: * cpu_idle.
init/main.c:    /* Call into cpu_idle with preempt disabled */
init/main.c:     * fragile until we cpu_idle() for the first time.
kernel/trace/power-traces.c:EXPORT_TRACEPOINT_SYMBOL_GPL(cpu_idle);
tools/perf/builtin-timechart.c:          * Mapping all these
"power:cpu_idle" strings to the tracepoint
tools/perf/builtin-timechart.c:         if (strcmp(event_str,
"power:cpu_idle") = 0) {
tools/perf/builtin-timechart.c:         "-e", "power:cpu_idle",
tools/perf/builtin-timechart.c: if (!is_valid_tracepoint("power:cpu_idle") &&
tools/perf/builtin-top.c:       "cpu_idle",

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 147+ messages in thread

* [PATCH] ARM: smp: Drop RCU_NONIDLE usage in cpu_die()
  2013-05-01  0:55                         ` Paul E. McKenney
  (?)
@ 2013-05-21  0:57                         ` Stephen Boyd
  -1 siblings, 0 replies; 147+ messages in thread
From: Stephen Boyd @ 2013-05-21  0:57 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Kevin Hilman, LKML, linux-arch, Linus Torvalds, Andrew Morton,
	Rusty Russell, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Russell King

Before f7b861b (arm: Use generic idle loop, 2013-03-21) ARM would
kill the CPU within the rcu idle section. Now that the
rcu_idle_enter()/exit() pair have been pushed lower down in the
idle loop this is no longer true and so using RCU_NONIDLE here is
no longer necessary and also harmful because RCU is not actually
idle at this point.

Cc: Russell King <linux@arm.linux.org.uk>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 arch/arm/kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 4619177..78f1eb5 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -233,7 +233,7 @@ void __ref cpu_die(void)
 	mb();
 
 	/* Tell __cpu_die() that this CPU is now safe to dispose of */
-	RCU_NONIDLE(complete(&cpu_died));
+	complete(&cpu_died);
 
 	/*
 	 * actual CPU shutdown procedure is at least platform (if not
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation


^ permalink raw reply related	[flat|nested] 147+ messages in thread

* Re: [patch 05/34] idle: Implement generic idle function
  2013-03-21 21:53 ` [patch 05/34] idle: Implement generic idle function Thomas Gleixner
                     ` (2 preceding siblings ...)
  2013-04-08 20:14   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
@ 2013-11-18  6:05   ` Viresh Kumar
  2013-11-22 22:32     ` Thomas Gleixner
  3 siblings, 1 reply; 147+ messages in thread
From: Viresh Kumar @ 2013-11-18  6:05 UTC (permalink / raw)
  To: Thomas Gleixner, badarkhe.manish
  Cc: LKML, linux-arch, Linus Torvalds, Andrew Morton, Rusty Russell,
	Paul McKenney, Ingo Molnar, Peter Zijlstra, Srivatsa S. Bhat,
	Magnus Damm, Daniel Lezcano

On Fri, Mar 22, 2013 at 3:23 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> --- linux-2.6.orig/kernel/cpu/idle.c
> +++ linux-2.6/kernel/cpu/idle.c

> +void cpu_startup_entry(enum cpuhp_state state)
> +{
> +       current_set_polling();
> +       arch_cpu_idle_prepare();
> +       cpu_idle_loop();
> +}
> +#endif

Hi Thomas..

Manish (cc'd) recently asked me purpose of _state_ argument in this
routine, As this is unused here..

Was this reserved for future use?

^ permalink raw reply	[flat|nested] 147+ messages in thread

* Re: [patch 05/34] idle: Implement generic idle function
  2013-11-18  6:05   ` [patch 05/34] idle: Implement generic idle function Viresh Kumar
@ 2013-11-22 22:32     ` Thomas Gleixner
  0 siblings, 0 replies; 147+ messages in thread
From: Thomas Gleixner @ 2013-11-22 22:32 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: badarkhe.manish, LKML, linux-arch, Linus Torvalds, Andrew Morton,
	Rusty Russell, Paul McKenney, Ingo Molnar, Peter Zijlstra,
	Srivatsa S. Bhat, Magnus Damm, Daniel Lezcano

On Mon, 18 Nov 2013, Viresh Kumar wrote:

> On Fri, Mar 22, 2013 at 3:23 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> > --- linux-2.6.orig/kernel/cpu/idle.c
> > +++ linux-2.6/kernel/cpu/idle.c
> 
> > +void cpu_startup_entry(enum cpuhp_state state)
> > +{
> > +       current_set_polling();
> > +       arch_cpu_idle_prepare();
> > +       cpu_idle_loop();
> > +}
> > +#endif
> 
> Hi Thomas..
> 
> Manish (cc'd) recently asked me purpose of _state_ argument in this
> routine, As this is unused here..
> 
> Was this reserved for future use?

Yep, if you dig the mail archives you'll find my cpu hotplug series
which tries to convert it to a full state machine. So the state
argument is due to that, because the boot cpu will call into that with
a certain state and we want to allow archs to skip some states even on
secondary cpus. So yes, it's unused, but its there on purpose. It's
going to be used when my work backlog drops down to the cpuhotplug
mess again. About 2 lightyears from now ....

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 147+ messages in thread

end of thread, other threads:[~2013-11-22 22:32 UTC | newest]

Thread overview: 147+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-21 21:52 [patch 00/34] idle: Consolidate idle implementations Thomas Gleixner
2013-03-21 21:52 ` [patch 01/34] arch: Cleanup enable/disable_hlt Thomas Gleixner
2013-04-08 20:08   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:52 ` [patch 02/34] arch: Consolidate tsk_is_polling() Thomas Gleixner
2013-03-22  5:01   ` Tony Breeds
2013-03-22  5:20   ` Tony Breeds
2013-03-22  9:26     ` Thomas Gleixner
2013-04-08 20:09   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:52 ` [patch 03/34] idle: Implement set/clr functions for need_resched poll Thomas Gleixner
2013-03-22  9:38   ` James Hogan
2013-03-22  9:38     ` James Hogan
2013-04-08 20:10   ` [tip:smp/hotplug] idle: Implement set/ clr " tip-bot for Thomas Gleixner
2013-03-21 21:52 ` [patch 04/34] idle: Provide a generic entry point for the idle code Thomas Gleixner
2013-04-08 20:12   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-04-14  0:42     ` Yinghai Lu
2013-03-21 21:53 ` [patch 06/34] arc: Use generic idle loop Thomas Gleixner
2013-03-22  9:02   ` Vineet Gupta
2013-03-22  9:02     ` Vineet Gupta
2013-04-08 20:15   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 05/34] idle: Implement generic idle function Thomas Gleixner
2013-03-23  8:56   ` Heiko Carstens
2013-03-25 10:39     ` Thomas Gleixner
2013-03-28 15:39   ` Srivatsa S. Bhat
2013-04-08 20:14   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-04-15 22:25     ` Tony Luck
2013-04-16 13:28       ` Thomas Gleixner
2013-04-16 18:25         ` Tony Luck
2013-04-16 18:35           ` [PATCH] ia64: Make sure interrupts enabled when we "safe_halt()" Luck, Tony
2013-04-17  9:00             ` [tip:smp/hotplug] ia64: Make sure interrupts enabled when we " safe_halt()" tip-bot for Luck, Tony
2013-11-18  6:05   ` [patch 05/34] idle: Implement generic idle function Viresh Kumar
2013-11-22 22:32     ` Thomas Gleixner
2013-03-21 21:53 ` [patch 07/34] alpha: Use generic idle loop Thomas Gleixner
2013-03-28 15:37   ` Srivatsa S. Bhat
2013-03-29 11:22     ` Thomas Gleixner
2013-04-08 20:16   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 08/34] arm: " Thomas Gleixner
2013-03-22 21:24   ` Kevin Hilman
2013-03-25 11:31     ` Thomas Gleixner
2013-03-25 11:48       ` Russell King - ARM Linux
2013-03-25 14:02         ` Thomas Gleixner
2013-04-08 21:47           ` Russell King - ARM Linux
2013-04-09  9:20             ` Thomas Gleixner
2013-04-09  9:38               ` Russell King - ARM Linux
2013-04-25 20:03                 ` Stephen Boyd
2013-04-25 21:01                   ` Thomas Gleixner
2013-05-01  0:49                     ` Stephen Boyd
2013-05-01  0:55                       ` Paul E. McKenney
2013-05-01  0:55                         ` Paul E. McKenney
2013-05-21  0:57                         ` [PATCH] ARM: smp: Drop RCU_NONIDLE usage in cpu_die() Stephen Boyd
2013-04-08 20:17   ` [tip:smp/hotplug] arm: Use generic idle loop tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 09/34] arm64: " Thomas Gleixner
2013-03-25 18:06   ` Catalin Marinas
2013-04-08 20:18   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 10/34] avr32: " Thomas Gleixner
2013-04-08 20:20   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-04-09  7:31     ` Hans-Christian Egtvedt
2013-03-21 21:53 ` [patch 12/34] c6x: " Thomas Gleixner
2013-04-08 20:22   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 11/34] bfin: " Thomas Gleixner
2013-04-08 20:21   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 13/34] cris: " Thomas Gleixner
2013-03-27 15:04   ` Jesper Nilsson
2013-03-27 17:10     ` Thomas Gleixner
2013-04-08 20:23   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 14/34] frv: " Thomas Gleixner
2013-04-08 20:24   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 15/34] h8300: " Thomas Gleixner
2013-04-08 20:26   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 16/34] hexagon: " Thomas Gleixner
2013-04-08 20:27   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 18/34] m32r: " Thomas Gleixner
2013-04-08 20:29   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 17/34] ia64: " Thomas Gleixner
2013-03-28 15:40   ` Srivatsa S. Bhat
2013-04-08 20:28   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 19/34] m68k: " Thomas Gleixner
2013-04-08 20:30   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 20/34] metag: " Thomas Gleixner
2013-03-22 10:16   ` James Hogan
2013-03-22 10:16     ` James Hogan
2013-03-25 11:26     ` Thomas Gleixner
2013-04-08 20:32   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 21/34] microblaze: " Thomas Gleixner
2013-04-08 20:33   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 22/34] mips: " Thomas Gleixner
2013-03-28 15:42   ` Srivatsa S. Bhat
2013-04-08 20:34   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 24/34] openrisc: " Thomas Gleixner
2013-04-08 20:36   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 23/34] mn10300: " Thomas Gleixner
2013-04-08 20:35   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 25/34] parisc: " Thomas Gleixner
2013-04-08 20:38   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 26/34] powerpc: " Thomas Gleixner
2013-03-28 15:40   ` Srivatsa S. Bhat
2013-04-01  9:13     ` Deepthi Dharwar
2013-04-08 20:39   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 27/34] s390: " Thomas Gleixner
2013-03-23  9:38   ` Heiko Carstens
2013-03-23  9:39   ` Heiko Carstens
2013-03-23  9:39     ` Heiko Carstens
2013-04-08 20:40   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 28/34] score: " Thomas Gleixner
2013-04-08 20:41   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 29/34] sh: " Thomas Gleixner
2013-03-28 15:40   ` Srivatsa S. Bhat
2013-04-08 20:42   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 30/34] tile: Enter idle with preemption disabled Thomas Gleixner
2013-03-22 20:34   ` Chris Metcalf
2013-03-22 20:34     ` Chris Metcalf
2013-03-22 20:40   ` Chris Metcalf
2013-03-22 20:40     ` Chris Metcalf
2013-03-28 15:43   ` Srivatsa S. Bhat
2013-04-08 20:44   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 31/34] tile: Use generic idle loop Thomas Gleixner
2013-03-28 15:41   ` Srivatsa S. Bhat
2013-03-29 11:24     ` Thomas Gleixner
2013-04-08 20:45   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 32/34] unicore: " Thomas Gleixner
2013-04-08 20:46   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 33/34] x86: " Thomas Gleixner
2013-03-28 15:43   ` Srivatsa S. Bhat
2013-04-08 20:47   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-21 21:53 ` [patch 34/34] xtensa: " Thomas Gleixner
2013-03-22 12:37   ` Max Filippov
2013-04-08 20:48   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2013-03-22 20:09 ` [patch 00/34] idle: Consolidate idle implementations Sam Ravnborg
     [not found] ` <alpine.LFD.2.02.1303271940150.22263@ionos>
     [not found]   ` <5153EC43.7070808@zankel.net>
2013-03-28  9:24     ` Thomas Gleixner
2013-03-28 22:16       ` Chris Zankel
2013-03-29 16:19 ` Sam Ravnborg
2013-03-29 20:29   ` [PATCH] sparc: Use generic idle loop Sam Ravnborg
2013-03-31 23:46     ` David Miller
2013-04-01  6:53     ` Srivatsa S. Bhat
2013-04-01  9:06       ` Sam Ravnborg
2013-04-01  9:06         ` Sam Ravnborg
2013-04-01  9:06         ` Sam Ravnborg
2013-04-08 12:33         ` Srivatsa S. Bhat
2013-04-08 17:10           ` Sam Ravnborg
2013-04-08 19:24             ` David Miller
2013-04-11 19:38               ` [PATCH v2] " Sam Ravnborg
2013-04-11 19:38                 ` Sam Ravnborg
2013-04-11 19:38                 ` Sam Ravnborg
2013-04-12 18:56                 ` Thomas Gleixner
2013-04-12 18:58                   ` David Miller
2013-04-13 19:53                 ` [tip:smp/hotplug] " tip-bot for Sam Ravnborg
2013-05-03  9:47 ` [patch 00/34] idle: Consolidate idle implementations Geert Uytterhoeven
2013-05-03  9:47   ` Geert Uytterhoeven

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.