lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 20 Mar 2019 17:37:48 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Linus Torvalds' <torvalds@...ux-foundation.org>
CC:     Peter Zijlstra <peterz@...radead.org>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "hpa@...or.com" <hpa@...or.com>,
        "julien.thierry@....com" <julien.thierry@....com>,
        "will.deacon@....com" <will.deacon@....com>,
        "luto@...capital.net" <luto@...capital.net>,
        "mingo@...nel.org" <mingo@...nel.org>,
        "catalin.marinas@....com" <catalin.marinas@....com>,
        "james.morse@....com" <james.morse@....com>,
        "valentin.schneider@....com" <valentin.schneider@....com>,
        "brgerst@...il.com" <brgerst@...il.com>,
        "jpoimboe@...hat.com" <jpoimboe@...hat.com>,
        "luto@...nel.org" <luto@...nel.org>, "bp@...en8.de" <bp@...en8.de>,
        "dvlasenk@...hat.com" <dvlasenk@...hat.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "dvyukov@...gle.com" <dvyukov@...gle.com>,
        "rostedt@...dmis.org" <rostedt@...dmis.org>
Subject: RE: [PATCH 02/25] tracing: Improve "if" macro code generation

From: Linus Torvalds 
> Sent: 20 March 2019 17:26
> To: David Laight
> On Wed, Mar 20, 2019 at 4:17 AM David Laight <David.Laight@...lab.com> wrote:
> >
> > >               ______r = !!(cond);                                     \
> >
> >         Is that (or maybe just the !!) needed any more??
> 
> It is, because the 'cond' expression might not be an int, it could be
> a test for a pointer being non-NULL, or an u64 being non-zero, and not
> having the "!!" would mean that you'd get a warning or drop bits when
> assigning to 'int'.
> 
> And you do need the new temporary variable to avoid double evaluation
> the way that code is written.

As usual I'd opened my mouth before checking the full context :-)

>           ______r = !!(cond);                                     
> -		______f.miss_hit[______r]++;					\
> +		______r ? ______f.miss_hit[1]++ : ______f.miss_hit[0]++;\
>  		______r;						\

Actually you can avoid double evaluation by doing:

		(cond) ? (______f.miss_hit[1]++, 1) : (______f.miss_hit[0]++, 0)

With luck the compiler will move the increment to after the branch target.

for (_____ = ____; _____ < ______; _____++) :-)

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ