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]
Message-Id: <ef130c0a-b82f-472f-8c53-f7ef4c236c44@app.fastmail.com>
Date: Wed, 24 Jul 2024 18:48:23 +0200
From: "Arnd Bergmann" <arnd@...nel.org>
To: "David Laight" <David.Laight@...lab.com>,
 "'linux-kernel@...r.kernel.org'" <linux-kernel@...r.kernel.org>,
 "Linus Torvalds" <torvalds@...uxfoundation.org>
Cc: "Matthew Wilcox" <willy@...radead.org>,
 "Christoph Hellwig" <hch@...radead.org>,
 "Andrew Morton" <akpm@...ux-foundation.org>,
 "Andy Shevchenko" <andriy.shevchenko@...ux.intel.com>,
 "Dan Carpenter" <dan.carpenter@...aro.org>,
 "Jason A . Donenfeld" <Jason@...c4.com>,
 "'pedro.falcato@...il.com'" <pedro.falcato@...il.com>,
 "Mateusz Guzik" <mjguzik@...il.com>,
 "'linux-mm@...ck.org'" <linux-mm@...ck.org>
Subject: Re: [PATCH 4/7] minmax: Simplify signedness check

On Wed, Jul 24, 2024, at 16:30, David Laight wrote:
> It is enough to check that both 'x' and 'y' are valid for either
> a signed compare or an unsigned compare.
> For unsigned they must be an unsigned type or a positive constant.
> For signed they must be signed after unsigned char/short are promoted.
>
> Order the expressions to avoid warnings about comparisons that are
> always true.
>
> Signed-off-by: David Laight <david.laight@...lab.com>

This patch gives me a 10x speedup on compiling arch/x86/xen/setup.c,
taking it from 15 seconds to 1.5 seconds for a defconfig+CONFIG_XEN
build.

>+/* Allow unsigned compares against non-negative signed constants. */
>+#define __is_ok_unsigned(x) \
>+	((is_unsigned_type(typeof(x)) ? 0 : __if_constexpr(x, (x) + 0, -1)) >= 0)

I don't understand why this return '0' for unsigned types,
shouldn't this be

((is_unsigned_type(typeof(x)) ? 1 : __if_constexpr(x, (x) + 0, -1)) >= 0)

?

    Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ