lkml.org 
[lkml]   [2003]   [Nov]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: get_cycles() on i386


On Tue, 4 Nov 2003, Linus Torvalds wrote:

>
> On 4 Nov 2003, john stultz wrote:
> >
> > CONFIG_X86_TSC be the devil. Personally, I'd much prefer dropping the
> > compile time option and using dynamic detection. Something like (not
> > recently tested and i believe against 2.5.something, but you get the
> > idea):
>
> Some of the users are really timing-critical (eg scheduler).
>
> How about just using the "alternative()" infrastructure that we already
> have in 2.6.x for this? See <asm-i386/system.h> for details.
>
> We don't have an "alternative_output()" available yet, but using that it
> would look something like:
>
> static inline unsigned long long get_cycle(void)
> {
> unsigned long long tsc;
>
> alternative_output(
> "xorl %%eax,%%eax ; xorl %%edx,%%edx",
> "rdtsc",
> X86_FEATURE_TSC,
> "=A" (tsc));
> return tsc;
> }
>
> which should allow for "perfect" code (well, gcc tends to mess up 64-bit
> stuff, but you get the idea).
>
> We use the "alternative_input()" thing for prefetch() handling (see
> <asm-i386/processor.h>).

I'm not confident this is something for 2.4.

The "if (cpu_has_tsc)" fix from John sounds fine.
-
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/

\
 
 \ /
  Last update: 2005-03-22 13:58    [from the cache]
©2003-2011 Jasper Spaans