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: <1bb3d09c-3b34-4348-8d6f-bd867704625c@app.fastmail.com>
Date: Wed, 24 Jul 2024 19:03:31 +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 7/7] minmax: minmax: Add __types_ok3() and optimise defines with 3
 arguments

On Wed, Jul 24, 2024, at 16:33, David Laight wrote:
> min3() and max3() were added to optimise nested min(x, min(y, z))
> sequences, bit only moved where the expansion was requiested.
>
> Add a separate implementation for 3 argument calls.
> These are never required to generate constant expressiions to
> remove that logic.
>
> Signed-off-by: David Laight <david.laight@...lab.com>

This brings another 3x improvement in the size of the expansion
and build speed.

> +#define __cmp_once3(op, x, y, z, uniq) ({	\
> +	typeof(x) __x_##uniq = (x);		\
> +	typeof(x) __y_##uniq = (y);		\
> +	typeof(x) __z_##uniq = (z);		\
> +	__cmp(op, __cmp(op, __x_##uniq, __y_##uniq), __z_##uniq); })

This still has a nested call to __cmp(), which makes the
resulting expression bigger than necessary.

The three typeof(x) should be x/y/z, right? Using __auto_type
would avoid the bug and also remove one more variable expansion.

Using another temporary variable, plus the use of __auto_type
brings the example line from xen/setup.c down 750KB to 530KB,
and the compile speed from 0.5s to 0.34s. 

 #define __cmp_once3(op, x, y, z, uniq) ({      \
       __auto_type __x_##uniq = (x);           \
       __auto_type __y_##uniq = (y);           \
       __auto_type __z_##uniq = (z);           \
       __auto_type __xy##uniq = __cmp(op, __x_##uniq, __y_##uniq); \
       __cmp(op, __xy_##uniq, __z_##uniq); })

The __auto_type change can also be applied to the other typeof()
in this file.

      Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ