[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 12.09.14 at 19:46, <dslutz@xxxxxxxxxxx> wrote:
> 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.

Hmm - this ...

>          ebx1 = 1000000000ull / APIC_BUS_CYCLE_NS / 1000ull;
>          ebx2 = (1000000000ull / APIC_BUS_CYCLE_NS) / 1000ull;
>          ebx3 = 1000000000ull / (APIC_BUS_CYCLE_NS * 1000ull);

... clearly indicates the contrary: You converted to mutiplication
here, when the respective possibility of putting parentheses here
would have been

         ebx3 = 1000000000ull / (APIC_BUS_CYCLE_NS / 1000ull);

which I'm sure you agree won't produce the same result. But yes,
the language implies parentheses this way

         ebx2 = (1000000000ull / APIC_BUS_CYCLE_NS) / 1000ull;

so the original expression without them was correct, just
slightly ambiguous.

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®.