From mboxrd@z Thu Jan 1 00:00:00 1970 From: Don Slutz Subject: Re: [PATCH v4 01/16] xen: Add support for VMware cpuid leaves Date: Wed, 17 Sep 2014 11:41:27 -0400 Message-ID: <5419ABA7.50300@terremark.com> References: <1410460610-14759-1-git-send-email-dslutz@verizon.com> <1410460610-14759-2-git-send-email-dslutz@verizon.com> <5411FCCD.2000707@citrix.com> <5412DDCF020000780003465F@mail.emea.novell.com> <54133185.9070203@terremark.com> <5416B48C0200007800034D7F@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5416B48C0200007800034D7F@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , Don Slutz Cc: Jun Nakajima , Tim Deegan , Kevin Tian , Keir Fraser , Ian Campbell , Stefano Stabellini , George Dunlap , Andrew Cooper , Ian Jackson , xen-devel@lists.xen.org, Eddie Dong , Aravind Gopalakrishnan , Suravee Suthikulpanit , Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org On 09/15/14 03:42, Jan Beulich wrote: >>>> On 12.09.14 at 19:46, wrote: >> On 09/12/14 05:49, Jan Beulich wrote: >>>>>> On 11.09.14 at 21:49, 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 Yes, I agree. Since that is not mathematical correct either. This has the same issue as "a - b -c" is the same as "(a - b) - c" but not "a - (b - c)". However the "order" can be changed. "a / b / c" and "a / c / b" is the same. > ebx2 = (1000000000ull / APIC_BUS_CYCLE_NS) / 1000ull; > > so the original expression without them was correct, just > slightly ambiguous. Ok, I see that preventing mistakes here can only help. -Don Slutz > Jan > >