From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 720D1C3DA61 for ; Wed, 24 Jul 2024 08:51:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF4936B007B; Wed, 24 Jul 2024 04:51:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA4B06B0082; Wed, 24 Jul 2024 04:51:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6C536B0083; Wed, 24 Jul 2024 04:51:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A7F376B007B for ; Wed, 24 Jul 2024 04:51:20 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4AEACA37B6 for ; Wed, 24 Jul 2024 08:51:20 +0000 (UTC) X-FDA: 82374027120.21.D3E65A3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id 30FCA1C001A for ; Wed, 24 Jul 2024 08:51:18 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jQ1onFNc; spf=pass (imf21.hostedemail.com: domain of arnd@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=arnd@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721811030; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OOBhUUjpbIyZwnRxzNZ+q9qDzU8Ba1JzssWhuTS9Gx8=; b=2ktArXmjPtCXXeXdS7xjVzJZi5avuFUdjb3uaDFGpS4DgRp4Gho4hCjKEfdWM04K+iXpoX vsS9dzSQL5w+5QlhTcwAy4rk4GR/9D20GrDO08IJkjzMduj7/VB2FN92+sALIr9jTe7j1e MFSwZUGzk/EcUfP4h8tvfyRwIPV2Jhc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721811030; a=rsa-sha256; cv=none; b=eElHkegzjJ12VwjOE8NpIwmjoYxpztY2+2KEzphCNVjjzj5YD4Bud0Or3ufO0uCUm9J64Z ogb6dl/6X9h8QMmEnGQRJRfMXTpCdtfsEVpAHAlNmCrrGJK2AVEbMy5BdgBRvgUV71HY12 mVGjJ/lhsFgXMspk4LeZNtm1MJZsU0U= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jQ1onFNc; spf=pass (imf21.hostedemail.com: domain of arnd@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=arnd@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F1CBB611C2; Wed, 24 Jul 2024 08:51:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C8F3C4AF0F; Wed, 24 Jul 2024 08:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721811076; bh=16ld9DZqEwyZoRfMYqZqjWOMC+8ShJzWuY/QRyLtU80=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=jQ1onFNcR4Yyg0jc9K7q30wxYSifuQ/UPXnT7uJj8p9+wKWYl7v7elB9snXjgMS5d jKkff3jA0kVuQnWo2Pwhhz3F2jVYgDGKHRfprkqf6ZicWg9+T4fPFCWAHvzYCxhhNs fQaULRcJBV7/wTo3lJs3OZf33Zn6Rp405Nq6+Cch35wzUkRgMGj6RghH96RpCE2cOr UIe9OIAKj3N+Cvg++mXkP0sqmV6ZFJ06/iNGJ0DkHwDENhLFDOQHkBTZJwgpar7nOD A0eyVCIpd5joi4NBR86yz5rKbQiVCR0RHNDORIwVvGIIzxGgSUf3O1xRv7pFI4cF4y D366WSz4cj8ww== Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfauth.nyi.internal (Postfix) with ESMTP id AA96A120006E; Wed, 24 Jul 2024 04:51:14 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute4.internal (MEProxy); Wed, 24 Jul 2024 04:51:14 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddriedugddtlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgfgsehtqhertderreejnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusehkvghrnhgvlhdrohhrgheqnecuggftrf grthhtvghrnhepvddttdffjeefgeeggfelfefggefhheeffefftefggfelgeduveevtefh feejveeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghrnhguodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduvdekhedujedt vdegqddvkeejtddtvdeigedqrghrnhgupeepkhgvrhhnvghlrdhorhhgsegrrhhnuggsrd guvgdpnhgspghrtghpthhtoheptd X-ME-Proxy: Feedback-ID: i36794607:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 7DDBFB6008D; Wed, 24 Jul 2024 04:51:14 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-582-g5a02f8850-fm-20240719.002-g5a02f885 MIME-Version: 1.0 Message-Id: <2a1024f7-af7f-474f-8b1c-aa5e0d4bd17a@app.fastmail.com> In-Reply-To: <16f51077-f525-4d3c-92ad-8a1ccc02e4ff@suse.com> References: <16f51077-f525-4d3c-92ad-8a1ccc02e4ff@suse.com> Date: Wed, 24 Jul 2024 10:50:54 +0200 From: "Arnd Bergmann" To: "Juergen Gross" , "Lorenzo Stoakes" , "Andrew Morton" , "David Laight" Cc: "Matthew Wilcox" , "Linus Torvalds" , "Jason A . Donenfeld" , "Christoph Hellwig" , "Andy Shevchenko" , pedro.falcato@gmail.com, "Mateusz Guzik" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: Build performance regressions originating from min()/max() macros Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 30FCA1C001A X-Stat-Signature: bhtm6x7b9fs8saunfjwjrm5wbxge93wj X-HE-Tag: 1721811077-870645 X-HE-Meta: U2FsdGVkX1986MEOGigzZlMJ7886TLOOPyDneafuBPkbQVpR8QV9PcXKyVYUd4iG2Mcwzlqx/8dmFHhvUztJaEuOv9k95oZSDGxfAeck1Hs2ygMkw054h6BZHINUilK60SElAfXoqbLl1icI3jlycG90wPTC75E3+GNzsRB7Ge8edZOXkc9LOBK+yQQcx+MU+BIh0nf/iI9na1EWjyrYEPjmivEJWhK8O4bHgOAtMddyC5roI0K4o6sEcD5DoFWVsPu70Xenlqpj8u0u7yutPwQOEQSmLdOUsbyYNU9/n4Dvoq69ca8LMwn7FKpz6DWvkhfWbetK5XTipQBzLRbNvz7BB1MvC99Vabar384XnZ/f6rTp2tXAkkiTyjC9UV1DsYmWrPojYnJNXic1w/2dqf690BW82ZHGT24WCzdH+VBSzmlBbfB298vpfsqQn9Hm36AGO4PfRx/iyiZWBGdPZJQ5+f2PQa6js3ecnachR/kq335lcMHp1OcHKDnX24Y/Pz3zjDrsTAuK5zXnXpeuNuieArcsvpd7gyImfMXjTUFutFSrY6MThFFaSyew1z3QTuGJuikhI0QCLOk39HmhVwncxxVQ/84KrmvlAJ082JeY7bN+/Z7JEY1Qcfs4aXB2pb3fvHFFuMUxdk4X4KTFTZxfa4alkeP8gHRBt/4B5txJxDoJh4OaVQoXFXuj8S57KZyXzDInRBOy6ceZjna/hU5JJJtEXWw7pCE3FOz51nJWxYY3wDyVHaL0pnUyWRowTnIet/PAh7Zu152HD2+6cqCdwQLli0kOHjNphlbAP/Kd/XP7o+Vl7Y7lzT1sXAgCCdYpvsJUIOsV8hycKi+CwfuKQ6BL3Q04kTjZaqLHFWrgnQukZ7v5mXCboQ5bem/6GbF0g0rftE3AQV9h+I6KkGx1LRY65HKzkYMkPVrBf6U9vUU53HOKkTZgNvIZaSHsPcPKHjNe6Qkf/L/MFBg cr7WMd4l afs/4KkoOqFjNkpqbwdn2OXgxxEgKJM/V7XU//cBVTCK4E98PCWeOUdj/zvdjjf36CNYl/u9IPIk3Cbz4iO4QQqIlthf7iaF12qyVvOh6lLiw2hieG2MvUtsevGxkYdzytj+mRfPEuoPtebKD5raClvfiNcwl1gvJuELBzgL1PJtuWa+a3LlRGUNUW4IDtdf4fxi/ByETFsyyJuXAb/Xht1+7HNI5n1DTQDxiUdIQM9s2+d4/akH5VgAJkOP313F9iCnhMJmIo9LFWAm+5K/dddm8apzkH90oVxq1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Jul 24, 2024, at 10:14, J=C3=BCrgen Gro=C3=9F wrote: > On 23.07.24 23:59, Lorenzo Stoakes wrote: >>=20 >> And resulted in the generation of 47 MB (!) of pre-processor output. >>=20 >> It seems a lot of code now relies on the relaxed conditions of the ne= wly >> changed min/max() macros, so the question is - what can we do to addr= ess >> 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=20 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