[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 00/13] Add VMX TSC scaling support
On 11/24/2015 08:05 AM, Haozhong Zhang wrote: This bug can be fixed either later by patch 5 which introduces a common function hvm_scale_tsc() to scale TSC, or by replacing above underlined code with a simplified and inlined version of hvm_scale_tsc() as below: uint64_t mult, frac; mult = ratio >> 32; frac = ratio & ((1ULL << 32) - 1); offset = host_tsc * mult; offset += (host_tsc >> 32) * frac; offset += ((host_tsc & ((1ULL << 32) - 1)) * frac) >> 32;I am not sure I understand the last line (or maybe 2 lines)Just simple math with carefulness to avoid 64-bit integer overflow: suppose the most significant 32 bits of host_tsc and ratio are tsc_h and mult, and the least significant 32 bits of them are tsc_l and frac, then host_tsc * ratio * 2^-32 = host_tsc * (mult * 2^32 + frac) * 2^-32 = host_tsc * mult + (tsc_h * 2^32 + tsc_l) * frac * 2^-32 = host_tsc * mult + tsc_h * frac + ((tsc_l * frac) >> 32) Ok, now I see. Please include this in patch comments. -boris _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |