login
Login
/
Register
Search
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
May
»
25
Re: [PATCH] x86: enable preemption in delay
view
thread
!MAILaRCHIVE_VOTE_RePLACE
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From:
Pavel Machek <pavel@...>
To: Thomas Gleixner <tglx@...>
Cc: Steven Rostedt <rostedt@...>, LKML <linux-kernel@...>, linux-rt-users <linux-rt-users@...>, <akpm@...>, Ingo Molnar <mingo@...>, Clark Williams <clark.williams@...>, Peter Zijlstra <peterz@...>, Luis Claudio R. Goncalves <lclaudio@...>, Gregory Haskins <ghaskins@...>, Andi Kleen <ak@...>, Linus Torvalds <torvalds@...>
Subject:
Re: [PATCH] x86: enable preemption in delay
Date: Sunday, May 25, 2008 - 2:01 pm
Hi!
quoted text
> > + if (unlikely(cpu != smp_processor_id())) { > > Eeek, once you migrated you do this all the time. you need to update > cpu here. > > > + if ((now-bclock) >= loops) > > + break; > > Also this is really dangerous with unsynchronized TSCs. You might get > migrated and return immediately because the TSC on the other CPU is > far ahead. > > What you really want is something like the patch below, but we should > reuse the sched_clock_cpu() thingy to make that simpler. Looking into > that right now.
quoted text
> @@ -40,17 +40,51 @@ static void delay_loop(unsigned long loops) > :"0" (loops)); > } > > +/* > + * 5 usec on a 1GHZ machine. Not necessarily correct, but not too long > + * either. > + */ > +#define TSC_MIGRATE_COUNT 5000 > + > /* TSC based delay: */ > static void delay_tsc(unsigned long loops) > { > unsigned long bclock, now; > + int cpu; > > - preempt_disable(); /* TSC's are per-cpu */ > + preempt_disable(); > + cpu = smp_processor_id(); > rdtscl(bclock); > do { > rep_nop(); > - rdtscl(now); > - } while ((now-bclock) < loops); > + > + /* Allow RT tasks to run */ > + preempt_enable(); > + preempt_disable(); > + > + /* > + * It is possible that we moved to another CPU, and > + * since TSC's are per-cpu we need to calculate > + * that. The delay must guarantee that we wait "at > + * least" the amount of time. Being moved to another > + * CPU could make the wait longer but we just need to > + * make sure we waited long enough. Rebalance the > + * counter for this CPU. > + */ > + if (unlikely(cpu != smp_processor_id())) { > + if (loops <= TSC_MIGRATE_COUNT) > + break; > + cpu = smp_processor_id(); > + rdtscl(bclock); > + loops -= TSC_MIGRATE_COUNT; > + } else { > + rdtscl(now); > + if ((now - bclock) >= loops) > + break; > + loops -= (now - bclock); > + bclock = now;
What happens with different cpus running on different frequencies...? Cpufreq? Pavel -- (english)
http://www.livejournal.com/~pavelmachek
(cesky, pictures)
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
unsubscribe notice
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/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH] x86: enable preemption in delay
, Steven Rostedt
, (Sat May 24, 11:11 pm)
Re: [PATCH] x86: enable preemption in delay
, Arjan van de Ven
, (Sun May 25, 2:53 pm)
Re: [PATCH] x86: enable preemption in delay
, Steven Rostedt
, (Sun May 25, 3:32 pm)
Re: [PATCH] x86: enable preemption in delay
, Thomas Gleixner
, (Sun May 25, 3:01 pm)
Re: [PATCH] x86: enable preemption in delay
, Arjan van de Ven
, (Sun May 25, 3:28 pm)
Re: [PATCH] x86: enable preemption in delay
, Thomas Gleixner
, (Sun May 25, 8:44 am)
Re: [PATCH] x86: enable preemption in delay
, Pavel Machek
, (Sun May 25, 2:01 pm)
Re: [PATCH] x86: enable preemption in delay
, Steven Rostedt
, (Wed May 28, 9:01 am)
Re: [PATCH] x86: enable preemption in delay
, Pavel Machek
, (Sat May 31, 3:18 am)
[PATCH -v2] x86: enable preemption in delay
, Steven Rostedt
, (Sun May 25, 9:35 am)
Re: [PATCH -v2] x86: enable preemption in delay
, Steven Rostedt
, (Sun May 25, 9:44 am)
[PATCH -v3] x86: enable preemption in delay
, Steven Rostedt
, (Sun May 25, 9:51 am)
[PATCH -v4] x86: enable preemption in delay
, Steven Rostedt
, (Sun May 25, 11:13 am)
Re: [PATCH -v3] x86: enable preemption in delay
, Steven Rostedt
, (Sun May 25, 11:04 am)
Re: [PATCH] x86: enable preemption in delay
, Steven Rostedt
, (Sun May 25, 9:17 am)
Re: [PATCH] x86: enable preemption in delay
, Thomas Gleixner
, (Sun May 25, 4:21 pm)
Re: [PATCH] x86: enable preemption in delay
, Alan Cox
, (Sun May 25, 9:19 am)
Re: [PATCH] x86: enable preemption in delay
, Steven Rostedt
, (Sun May 25, 9:40 am)
Re: [PATCH] x86: enable preemption in delay
, Steven Rostedt
, (Sun May 25, 9:07 am)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Greg Kroah-Hartman
[PATCH 012/196] nozomi driver
Ingo Molnar
Re: [patch 00/13] Syslets, "Threadlets", generic AIO support, v3
Rafael J. Wysocki
[PATCH -mm 5/6] Freezer: Remove PF_NOFREEZE from bluetooth threads
Ingo Molnar
Re: [PATCH 00/23] per device dirty throttling -v8
git
:
linux-netdev
:
David Miller
[GIT]: Networking
David Miller
Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock().
Gerrit Renker
[PATCH 15/37] dccp: Set per-connection CCIDs via socket options
Natalie Protasevich
[BUG] New Kernel Bugs
openbsd-misc
:
Colocation donated by:
Who's online
There are currently
2 users
and
1002 guests
online.
Online users
apnote50
Nelson
Syndicate