From: "Jan Beulich" Subject: Re: [PATCH v2 2/9] x86/intel_pstate: add some calculation related support Date: Tue, 26 May 2015 13:49:28 +0100 Message-ID: <556487F8020000780007DE5E@mail.emea.novell.com> References: <1463125780-13404-1-git-send-email-wei.w.wang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1463125780-13404-1-git-send-email-wei.w.wang@intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Wang Cc: jinsong.liu@alibaba-inc.com, xen-devel@lists.xen.org, wei.liu2@citrix.com, ian.campbell@citrix.com, andrew.cooper3@citrix.com List-Id: xen-devel@lists.xenproject.org >>> On 13.05.16 at 09:49, wrote: > The added calculation related functions will be used in the intel_pstate.c. If these are taken from Linux, please say so here (including the version they got cloned from), as in that case close review can be considered unnecessary. That said - do you really need all of them, considering that you don't need to support a 32-bit environment? > --- a/xen/include/asm-x86/div64.h > +++ b/xen/include/asm-x86/div64.h All changes to this file that are indeed needed should follow Xen coding style. > +/* > + * abs() handles unsigned and signed longs, ints, shorts and chars. For all > + * input types abs() returns a signed long. > + * abs() should not be used for 64-bit types (s64, u64, long long) - use abs64() > + * for those. > + */ > +#define abs(x) ({ \ > + long ret; \ > + if (sizeof(x) == sizeof(long)) { \ > + long __x = (x); \ > + ret = (__x < 0) ? -__x : __x; \ > + } else { \ > + int __x = (x); \ > + ret = (__x < 0) ? -__x : __x; \ > + } \ > + ret; \ > +}) Please use the already present and more generic (less the unsigned types support, which I highly question to be necessary here) ABS() instead. Jan