From: "Jan Beulich" Subject: Re: [PATCH] xen: make sure that likely and unlikely convert the expression to a boolean Date: Mon, 07 Apr 2014 13:54:01 +0100 Message-ID: <5342BC0902000078000062C5@nat28.tlf.novell.com> References: <1396868824-16769-1-git-send-email-ian.campbell@citrix.com> <5342B7DC0200007800006298@nat28.tlf.novell.com> <1396874554.22845.65.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1396874554.22845.65.camel@kazak.uk.xensource.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: Ian Campbell Cc: Tim Deegan , keir@xen.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 07.04.14 at 14:42, wrote: > On Mon, 2014-04-07 at 13:36 +0100, Jan Beulich wrote: >> >>> On 07.04.14 at 13:07, wrote: >> > According to http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html >> > __builtin_expect has the prototype: >> > long __builtin_expect (long exp, long c) >> > >> > If sizeof(exp) > sizeof(long) then this will effectively mask off the top > bits >> > of exp, meaning that the if in "if (unlikey(x))" will see the masked > version, >> > which might be false when true was expected, likely has the same issue. >> > >> > With the x86_32 hypervisor no longer existing this is mostly likely to > affect >> > arm32 builds. A quick grep however shows that all the existing arm32 uses > of >> > both likely and unlikely already pass a boolean. I noticed this with an as > yet >> > unposted patch which did not have this property. >> >> Good catch, > > I tore out some hair before I got there of course ;-) > >> except that at least in the 4.2 tree we still care for the >> x86_32 hypervisor, and I already spotted a case having the same >> issue (in mtrr_var_range_msr_set()). I.e. for the purposes of >> backporting it might be better to make the statement above a little >> less tailored to arm32. > > That's fine by me. Do you mean for me to extend it now or did you want > to change it as part of the backport process? Either is fine by me. > > How about: > This is mostly likely to affect x86_32 and arm32 builds. x86_32 > is not present on 4.3 onwards and a quick grep of current > staging shows that all the existing arm32... > ? Yes, that reads fine for both -unstable and the backport. Jan