linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: David Miller <davem@davemloft.net>,
	srivatsa.bhat@linux.vnet.ibm.com, linux-kernel@vger.kernel.org,
	linux-arch@vger.kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, rusty@rustcorp.com.au,
	paulmck@linux.vnet.ibm.com, mingo@elte.hu, peterz@infradead.org,
	magnus.damm@gmail.com
Subject: Re: [PATCH v2] sparc: Use generic idle loop
Date: Fri, 12 Apr 2013 20:56:10 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.02.1304122055210.21884@ionos> (raw)
In-Reply-To: <20130411193850.GA2330@merkur.ravnborg.org>

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
> 

  parent reply	other threads:[~2013-04-12 18:56 UTC|newest]

Thread overview: 140+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-21 21:52 ` [patch 02/34] arch: Consolidate tsk_is_polling() Thomas Gleixner
2013-03-21 21:52   ` Thomas Gleixner
2013-03-22  5:01   ` Tony Breeds
2013-03-22  5:20   ` Tony Breeds
2013-03-22  9:26     ` Thomas Gleixner
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-03-22  9:38   ` James Hogan
2013-03-21 21:52 ` [patch 04/34] idle: Provide a generic entry point for the idle code Thomas Gleixner
2013-03-21 21:52   ` 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-11-18  6:05   ` Viresh Kumar
2013-11-22 22:32     ` Thomas Gleixner
2013-03-21 21:53 ` [patch 06/34] arc: Use generic idle loop Thomas Gleixner
2013-03-22  9:02   ` Vineet Gupta
2013-03-21 21:53 ` [patch 07/34] alpha: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-28 15:37   ` Srivatsa S. Bhat
2013-03-29 11:22     ` Thomas Gleixner
2013-03-21 21:53 ` [patch 08/34] arm: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-22 21:24   ` Kevin Hilman
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 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:20               ` Thomas Gleixner
2013-04-09  9:38               ` Russell King - ARM Linux
2013-04-09  9:38                 ` Russell King - ARM Linux
2013-04-25 20:03                 ` Stephen Boyd
2013-04-25 21:01                   ` Thomas Gleixner
2013-04-25 21:01                     ` Thomas Gleixner
2013-05-01  0:49                     ` Stephen Boyd
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-03-21 21:53 ` [patch 09/34] arm64: Use generic idle loop Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-25 18:06   ` Catalin Marinas
2013-03-21 21:53 ` [patch 10/34] avr32: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-21 21:53 ` [patch 11/34] bfin: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-21 21:53 ` [patch 12/34] c6x: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-21 21:53 ` [patch 13/34] cris: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-27 15:04   ` Jesper Nilsson
2013-03-27 15:04     ` Jesper Nilsson
2013-03-27 17:10     ` Thomas Gleixner
2013-03-21 21:53 ` [patch 14/34] frv: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-21 21:53 ` [patch 15/34] h8300: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-21 21:53 ` [patch 16/34] hexagon: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-21 21:53 ` [patch 18/34] m32r: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-21 21:53 ` [patch 17/34] ia64: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-28 15:40   ` Srivatsa S. Bhat
2013-03-28 15:40     ` Srivatsa S. Bhat
2013-03-21 21:53 ` [patch 19/34] m68k: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-21 21:53 ` [patch 20/34] metag: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-22 10:16   ` James Hogan
2013-03-25 11:26     ` Thomas Gleixner
2013-03-21 21:53 ` [patch 21/34] microblaze: " Thomas Gleixner
2013-03-21 21:53 ` [patch 22/34] mips: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-28 15:42   ` Srivatsa S. Bhat
2013-03-28 15:42     ` Srivatsa S. Bhat
2013-03-21 21:53 ` [patch 23/34] mn10300: " Thomas Gleixner
2013-03-21 21:53 ` [patch 24/34] openrisc: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-21 21:53 ` [patch 25/34] parisc: " Thomas Gleixner
2013-03-21 21:53 ` [patch 26/34] powerpc: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-28 15:40   ` Srivatsa S. Bhat
2013-03-28 15:40     ` Srivatsa S. Bhat
2013-04-01  9:13     ` Deepthi Dharwar
2013-04-01  9:13       ` Deepthi Dharwar
2013-03-21 21:53 ` [patch 27/34] s390: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-23  9:38   ` Heiko Carstens
2013-03-23  9:38     ` Heiko Carstens
2013-03-23  9:39   ` Heiko Carstens
2013-03-21 21:53 ` [patch 28/34] score: " Thomas Gleixner
2013-03-21 21:53 ` [patch 29/34] sh: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-28 15:40   ` Srivatsa S. Bhat
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-22 20:34   ` Chris Metcalf
2013-03-22 20:40   ` Chris Metcalf
2013-03-28 15:43   ` Srivatsa S. Bhat
2013-03-28 15:43     ` Srivatsa S. Bhat
2013-03-21 21:53 ` [patch 31/34] tile: Use generic idle loop Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-28 15:41   ` Srivatsa S. Bhat
2013-03-29 11:24     ` Thomas Gleixner
2013-03-21 21:53 ` [patch 32/34] unicore: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-21 21:53 ` [patch 33/34] x86: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-28 15:43   ` Srivatsa S. Bhat
2013-03-28 15:43     ` Srivatsa S. Bhat
2013-03-21 21:53 ` [patch 34/34] xtensa: " Thomas Gleixner
2013-03-21 21:53   ` Thomas Gleixner
2013-03-22 12:37   ` Max Filippov
2013-03-22 12:37     ` Max Filippov
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 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  6:53       ` Srivatsa S. Bhat
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 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-12 18:56                 ` Thomas Gleixner [this message]
2013-04-12 18:58                   ` David Miller
2013-05-03  9:47 ` [patch 00/34] idle: Consolidate idle implementations Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.02.1304122055210.21884@ionos \
    --to=tglx@linutronix.de \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mingo@elte.hu \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rusty@rustcorp.com.au \
    --cc=sam@ravnborg.org \
    --cc=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).