From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Ostrovsky Subject: Re: [PATCH v3 07/13] x86: Add functions for 64-bit integer arithmetic Date: Tue, 5 Jan 2016 11:21:25 -0500 Message-ID: <568BED85.2080902@oracle.com> References: <1451531020-29964-1-git-send-email-haozhong.zhang@intel.com> <1451531020-29964-8-git-send-email-haozhong.zhang@intel.com> <568AB96C.9010008@oracle.com> <20160105011535.GC3619@hz-desktop.sh.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20160105011535.GC3619@hz-desktop.sh.intel.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: xen-devel@lists.xen.org, Jan Beulich , Kevin Tian , Keir Fraser , Andrew Cooper , Suravee Suthikulpanit , Aravind Gopalakrishnan , Jun Nakajima List-Id: xen-devel@lists.xenproject.org On 01/04/2016 08:15 PM, Haozhong Zhang wrote: > On 01/04/16 13:26, Boris Ostrovsky wrote: >> On 12/30/2015 10:03 PM, Haozhong Zhang wrote: >>> This patch adds several functions to take multiplication, division and >>> shifting involving 64-bit integers. Those functions are derived from >>> Linux kernel and will be used by later patches to calculate scaling >>> ratio and scaled TSC. >>> >>> Signed-off-by: Haozhong Zhang >> Reviewed-by: Boris Ostrovsky >> >> (although I not sure why you decided to change Linux' code in mul64() below) >> >> >> >>> + c = (u64)rl.l.high + rm.l.low + rn.l.low; >>> + rl.l.high = c; >>> + c >>= 32; >>> + c = c + rm.l.high + rn.l.high + rh.l.low; >>> + rh.l.low = c; >>> + rh.l.high += (u32)(c >> 32); > I took these code from my KVM patches, but it seemed it was refactored > later and also inlined with mul_u64_u64_shr(). However, above code is > still equivalent to the current Linux code (if we take mul64() from > mul_u64_u64_shr() in Linux), so I think it should be fine. Or do you > want me to make them consistent with Linux code? Yes, it is equivalent to what's in Linux. I don't think you need to do anything, I was just curious why the two routines look slightly different. -boris