public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] sched: make cpu_clock() not use the rq clock
@ 2007-07-26  9:00 Ingo Molnar
  2007-07-27  2:56 ` Eric St-Laurent
  2007-07-29  6:03 ` Jeremy Fitzhardinge
  0 siblings, 2 replies; 4+ messages in thread
From: Ingo Molnar @ 2007-07-26  9:00 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

Subject: sched: make cpu_clock() not use the rq clock
From: Ingo Molnar <mingo@elte.hu>

it is enough to disable interrupts to get the precise rq-clock
of the local CPU.

this also solves an NMI watchdog regression: the NMI watchdog
calls touch_softlockup_watchdog(), which might deadlock on
rq->lock if the NMI hits an rq-locked critical section.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/sched.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Index: linux-rt-rebase.q/kernel/sched.c
===================================================================
--- linux-rt-rebase.q.orig/kernel/sched.c
+++ linux-rt-rebase.q/kernel/sched.c
@@ -446,13 +446,12 @@ static inline unsigned long long rq_cloc
  */
 unsigned long long cpu_clock(int cpu)
 {
-	struct rq *rq = cpu_rq(cpu);
 	unsigned long long now;
 	unsigned long flags;
 
-	spin_lock_irqsave(&rq->lock, flags);
-	now = rq_clock(rq);
-	spin_unlock_irqrestore(&rq->lock, flags);
+	local_irq_save(flags);
+	now = rq_clock(cpu_rq(cpu));
+	local_irq_restore(flags);
 
 	return now;
 }

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

* Re: [patch] sched: make cpu_clock() not use the rq clock
  2007-07-26  9:00 [patch] sched: make cpu_clock() not use the rq clock Ingo Molnar
@ 2007-07-27  2:56 ` Eric St-Laurent
  2007-07-29  6:03 ` Jeremy Fitzhardinge
  1 sibling, 0 replies; 4+ messages in thread
From: Eric St-Laurent @ 2007-07-27  2:56 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Andrew Morton, linux-kernel

On Thu, 2007-26-07 at 11:00 +0200, Ingo Molnar wrote:
> Subject: sched: make cpu_clock() not use the rq clock
> From: Ingo Molnar <mingo@elte.hu>
> 
> it is enough to disable interrupts to get the precise rq-clock
> of the local CPU.

Hi Ingo,

Those new fast nanoseconds resolution clock APIs are nice but it seems
to me that their naming and _where_ they are implemented in the tree is
a little odd, IMO.

We have:

1. sched_clock() is in kernel/sched.c (weak implementation)
2. sched_clock() is in arch/i386/kernel/tsc.c (architecture override)
3. rq_clock() is in kernel/sched.c
4. cpu_clock() is in kernel/sched.c

I would suggest:

1. rename sched_clock() (remove sched_ as it's not sched specific
anymore) and place it in kernel/time/...
2. rename the architecture specific version of it too 

This first function is the basic fast ns clock

3. base your rq_clock() on cpu_clock() (#4) or use the later directly.

This is local to sched.c

4. move cpu_clock() in kernel/time/...

This the per-cpu monotonic version.


See my point? Base the scheduler clock from a general kernel API, not
the other way around.

Just a suggestion.


Best regards,

- Eric



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

* Re: [patch] sched: make cpu_clock() not use the rq clock
  2007-07-26  9:00 [patch] sched: make cpu_clock() not use the rq clock Ingo Molnar
  2007-07-27  2:56 ` Eric St-Laurent
@ 2007-07-29  6:03 ` Jeremy Fitzhardinge
  2007-07-29 21:17   ` Ingo Molnar
  1 sibling, 1 reply; 4+ messages in thread
From: Jeremy Fitzhardinge @ 2007-07-29  6:03 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Andrew Morton, linux-kernel

Ingo Molnar wrote:
> Subject: sched: make cpu_clock() not use the rq clock
>   

This subject doesn't make much sense to me.  All this patch does is get
the rq's current time under irq_disable rather than spinlock, right?

    J

> From: Ingo Molnar <mingo@elte.hu>
>
> it is enough to disable interrupts to get the precise rq-clock
> of the local CPU.
>
> this also solves an NMI watchdog regression: the NMI watchdog
> calls touch_softlockup_watchdog(), which might deadlock on
> rq->lock if the NMI hits an rq-locked critical section.
>
> Signed-off-by: Ingo Molnar <mingo@elte.hu>
> ---
>  kernel/sched.c |    7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> Index: linux-rt-rebase.q/kernel/sched.c
> ===================================================================
> --- linux-rt-rebase.q.orig/kernel/sched.c
> +++ linux-rt-rebase.q/kernel/sched.c
> @@ -446,13 +446,12 @@ static inline unsigned long long rq_cloc
>   */
>  unsigned long long cpu_clock(int cpu)
>  {
> -	struct rq *rq = cpu_rq(cpu);
>  	unsigned long long now;
>  	unsigned long flags;
>  
> -	spin_lock_irqsave(&rq->lock, flags);
> -	now = rq_clock(rq);
> -	spin_unlock_irqrestore(&rq->lock, flags);
> +	local_irq_save(flags);
> +	now = rq_clock(cpu_rq(cpu));
> +	local_irq_restore(flags);
>  
>  	return now;
>  }
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>   


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

* Re: [patch] sched: make cpu_clock() not use the rq clock
  2007-07-29  6:03 ` Jeremy Fitzhardinge
@ 2007-07-29 21:17   ` Ingo Molnar
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2007-07-29 21:17 UTC (permalink / raw)
  To: Jeremy Fitzhardinge; +Cc: Andrew Morton, linux-kernel


* Jeremy Fitzhardinge <jeremy@goop.org> wrote:

> Ingo Molnar wrote:
> > Subject: sched: make cpu_clock() not use the rq clock
> >   
> 
> This subject doesn't make much sense to me.  All this patch does is get
> the rq's current time under irq_disable rather than spinlock, right?

i typoed it: s/clock/lock

	Ingo

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

end of thread, other threads:[~2007-07-29 21:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-26  9:00 [patch] sched: make cpu_clock() not use the rq clock Ingo Molnar
2007-07-27  2:56 ` Eric St-Laurent
2007-07-29  6:03 ` Jeremy Fitzhardinge
2007-07-29 21:17   ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox