[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v4 01/16] xen: Add support for VMware cpuid leaves




On 09/12/14 05:49, Jan Beulich wrote:
On 11.09.14 at 21:49, <andrew.cooper3@xxxxxxxxxx> wrote:



+    case 0x10:
+        /* (Virtual) TSC frequency in kHz. */
+        *eax =  d->arch.tsc_khz;
+        /* (Virtual) Bus (local apic timer) frequency in kHz. */
+        *ebx = 1000000000ull / APIC_BUS_CYCLE_NS / 1000ull;
At least 1 pair of brackets please, especially as the placement of
brackets affects the result of this particular calculation.
Or simply eliminate one of the divisions using
"1000000ull / APIC_BUS_CYCLE_NS".

I am totally confused.  I am happy to go with Jan's version.

The confusion is that I get the same answer all the ways I try. This includes
when APIC_BUS_CYCLE_NS is other values then 10.


Some facts:
1) 1000000000 takes only 30bits, I am asking it to be 64.
2) I am only making it smaller in all cases.

I have tested this on CentOS release 6.5 (Final) both 32 and 64 and
it all says they are all the same.

Here is my testing:

build1:~/tmp/zz-div>p /etc/redhat-release
CentOS release 6.5 (Final)
build1:~/tmp/zz-div>uname -a
Linux build1 2.6.32-431.el6.i686 #1 SMP Fri Nov 22 00:26:36 UTC 2013 i686 i686 i386 GNU/Linux
build1:~/tmp/zz-div>cat zz-div.c
#include <stdio.h>
#include <stdint.h>

int main(void)
{
    uint32_t ebx1, ebx2, ebx3, ebx4, ebx5;
    uint32_t start = 1000000000ull;
    uint32_t APIC_BUS_CYCLE_NS;

    printf("start=0x%x, %d\n\n", start, start);
for ( APIC_BUS_CYCLE_NS = 1; APIC_BUS_CYCLE_NS < 10000; APIC_BUS_CYCLE_NS++ )
    {
        ebx1 = 1000000000ull / APIC_BUS_CYCLE_NS / 1000ull;
        ebx2 = (1000000000ull / APIC_BUS_CYCLE_NS) / 1000ull;
        ebx3 = 1000000000ull / (APIC_BUS_CYCLE_NS * 1000ull);
        ebx4 = 1000000000ull / 1000ull / APIC_BUS_CYCLE_NS;
        ebx5 = 1000000ull / APIC_BUS_CYCLE_NS;

        if ( ebx1 != ebx2 ||
             ebx1 != ebx3 ||
             ebx1 != ebx4 ||
             ebx1 != ebx5 )
        {
            printf("APIC_BUS_CYCLE_NS=%d:\n", APIC_BUS_CYCLE_NS);
            printf(" ebx1=0x%x, %d\n", ebx1, ebx1);
            printf(" ebx2=0x%x, %d\n", ebx2, ebx2);
            printf(" ebx3=0x%x, %d\n", ebx3, ebx3);
            printf(" ebx4=0x%x, %d\n", ebx4, ebx4);
            printf(" ebx5=0x%x, %d\n", ebx5, ebx5);
        }
    }

    return 0;
}

/*
 * Local variables:
 * mode: C
 * c-file-style: "BSD"
 * c-basic-offset: 4
 * indent-tabs-mode: nil
 * End:
 */
build1:~/tmp/zz-div>gcc -g -o zz-div zz-div.c
build1:~/tmp/zz-div>./zz-div
start=0x3b9aca00, 1000000000

build1:~/tmp/zz-div>


   -Don Slutz






Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.