[ofa-general] Re: [Bug 408] dapltest compilation fails on x86 [PATCH]
James Lentini
jlentini at netapp.com
Fri Mar 16 09:20:44 PDT 2007
On Fri, 16 Mar 2007, Michael S. Tsirkin wrote:
> > Quoting James Lentini <jlentini at netapp.com>:
> > Subject: RE: [Bug 408] dapltest compilation fails on x86 [PATCH]
> >
> >
> >
> > On Wed, 7 Mar 2007, Arlin Davis wrote:
> >
> > >
> > > James, please review this fix for dapltest build issue.
> >
> > Hi Arlin,
> >
> > Just returning from vacation and catching up on email.
> >
> > > Signed-off by: Arlin Davis ardavis at ichips.intel.com
> > >
> > > diff --git a/test/dapltest/mdep/linux/dapl_mdep_user.h b/test/dapltest/mdep/linux/dapl_mdep_user.h
> > > index c05dd30..2903e78 100644
> > > --- a/test/dapltest/mdep/linux/dapl_mdep_user.h
> > > +++ b/test/dapltest/mdep/linux/dapl_mdep_user.h
> > > @@ -117,7 +117,7 @@ typedef unsigned long long int DT_Mdep_TimeStamp;
> > > static _INLINE_ DT_Mdep_TimeStamp
> > > DT_Mdep_GetTimeStamp ( void )
> > > {
> > > -#if defined(__GNUC__) && defined(__PENTIUM__)
> > > +#if defined(__GNUC__) && defined(__i386__)
> > > DT_Mdep_TimeStamp x;
> > > __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
> >
> > This is the opcode for a RDTSC instruction. My copy of the "Intel 64
> > and IA-32 Architectures Software Developer's Manual" says that the
> > RDTSC instruction was introduced by the Pentium. Although I don't
> > think anyone is going to use RDMA on a 486, making the change
> > above would create code that attempted to use an RDTSC instruction on
> > pre-Pentium processors.
> >
> > What is the processor that is being excluded by the Pentium test?
> > Would it be possible to recode the compile guard to check for either
> > Pentium or X?
> >
> > As a side note, the code could use the rdtsc mnemonic, as we do below,
> > instead of the raw opcode.
> >
> > > return x;
> > > @@ -143,7 +143,7 @@ DT_Mdep_GetTimeStamp ( void )
> > > asm volatile("rdtsc" : "=a" (__a), "=d" (__d));
> > > return ((unsigned long)__a) | (((unsigned long)__d)<<32);
> > > #else
> > > -#error "Non-Pentium and Non-PPC Linux - unimplemented"
> > > +#error "Linux CPU architecture - unimplemented"
> > > #endif
> > > #endif
> > > #endif
>
> You can't detect a pentium processor at compile-time, and testing
> for __PENTIUM__ is the wrong thing to do - you are actually testing
> for pentium-only optimizations being enabled in compiler.
>
> You really must test for processor type at run time.
How do you suggest performing the run time check?
Parse /proc/cpuinfo for the "tsc" string in the flags field, use
assembly programming to check the eflags & issue a CPUID
instruction,...?
We'd like something easy to maintain.
More information about the general
mailing list