linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@kernel.org>
To: "Juergen Gross" <jgross@suse.com>,
	"Lorenzo Stoakes" <lorenzo.stoakes@oracle.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"David Laight" <david.laight@aculab.com>
Cc: "Matthew Wilcox" <willy@infradead.org>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"Jason A . Donenfeld" <Jason@zx2c4.com>,
	"Christoph Hellwig" <hch@infradead.org>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	pedro.falcato@gmail.com, "Mateusz Guzik" <mjguzik@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: Build performance regressions originating from min()/max() macros
Date: Wed, 24 Jul 2024 10:50:54 +0200	[thread overview]
Message-ID: <2a1024f7-af7f-474f-8b1c-aa5e0d4bd17a@app.fastmail.com> (raw)
In-Reply-To: <16f51077-f525-4d3c-92ad-8a1ccc02e4ff@suse.com>

On Wed, Jul 24, 2024, at 10:14, Jürgen Groß wrote:
> On 23.07.24 23:59, Lorenzo Stoakes wrote:
>> 
>> And resulted in the generation of 47 MB (!) of pre-processor output.
>> 
>> It seems a lot of code now relies on the relaxed conditions of the newly
>> changed min/max() macros, so the question is - what can we do to address
>> these regressions?
>
> I can send a patch to simplify the problematic construct, but OTOH this
> will avoid only one particularly bad example.

It's probably a good idea do change the xen/setup.c file anyway,
as I haven't found any other file that had a regression this bad,
and it only needs a single temporary variable for a 1000x speedup.

For the overall kernel, I see at best a 2.3% speedup (20 second 
CPU time) by replacing the current min()/max() macros with a version
that drops both the constant expression output feature and the
assertion, measuring an x86 defconfig build, which has xen
disabled. On a defconfig+xen kernel, that difference increases
to 4.4% or 37 seconds.

Removing only the constexpr side requires a handful of fixups
for x86 allmodconfig to replace min()/max() with something else in

drivers/edac/sb_edac.c
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
drivers/gpu/drm/drm_color_mgmt.c
drivers/input/touchscreen/cyttsp4_core.c
drivers/md/dm-integrity.c
drivers/net/can/usb/etas_es58x/es58x_devlink.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
fs/btrfs/tree-checker.c
lib/vsprintf.c
net/ipv4/proc.c
net/ipv6/proc.c

This gives about half the speed difference, the other
half comes from removing the assertion, but that is not
a good idea unless we can replace it with an equivalent
assertion that works on the unique_x/unique_y variables
instead of expanding the arguments.

     Arnd


  parent reply	other threads:[~2024-07-24  8:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23 21:59 Lorenzo Stoakes
2024-07-24  8:14 ` Jürgen Groß
2024-07-24  8:31   ` Lorenzo Stoakes
2024-07-24  9:40     ` Jürgen Groß
2024-07-24  9:43       ` Lorenzo Stoakes
2024-07-24 14:47       ` David Laight
2024-07-24  8:34   ` David Laight
2024-07-24  8:50   ` Arnd Bergmann [this message]
2024-07-24  8:44 ` Lorenzo Stoakes
2024-07-24 11:05   ` David Laight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a1024f7-af7f-474f-8b1c-aa5e0d4bd17a@app.fastmail.com \
    --to=arnd@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=david.laight@aculab.com \
    --cc=hch@infradead.org \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mjguzik@gmail.com \
    --cc=pedro.falcato@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox