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 26C72C3DA63 for ; Wed, 24 Jul 2024 11:06:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C5206B008C; Wed, 24 Jul 2024 07:06:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 275096B0093; Wed, 24 Jul 2024 07:06:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13CD16B0096; Wed, 24 Jul 2024 07:06:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EAD9A6B008C for ; Wed, 24 Jul 2024 07:06:05 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8BA45C0879 for ; Wed, 24 Jul 2024 11:06:05 +0000 (UTC) X-FDA: 82374366690.18.792B43F Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by imf23.hostedemail.com (Postfix) with ESMTP id 9B6C814002B for ; Wed, 24 Jul 2024 11:06:01 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721819115; 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; bh=X/nuKImDGFXCeIa6IMgFZHGLK+4Klev21WBlhI8fKT0=; b=PJxRfMW4ByRC7q0K9uCCJkwR3GKRDWGE6922xm54FVOsvTdA6ezBaeMgLeSCQkQlH/ZEmq 0MbhjV4DqySmj+KV2OSKMt1Y/hS/iy2EVGaHibefNGbTvO1aMutorMquVdycIOzlPgytml x2jTqXG/1bLVFLRKVgEUPhaETx6sBgQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721819115; a=rsa-sha256; cv=none; b=q6J3hTJPHSzjDlpZF0BdS+opi0DWuny8erB23tuza0V2EH2ZqsM8O+LdsQB5GGeGPHgBB4 TXTRtHESAg5rwYXKcmi/E1z8WOU1+GbeGYhuHnEZeS/tfdzQmvcqM9yWuDt2KcgVrlbVdO kPAITI1fmNMmeFyvd67JSENRCNmM3Ss= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-185-fyRQhjFhOVKCzMXiToP7WA-1; Wed, 24 Jul 2024 12:05:56 +0100 X-MC-Unique: fyRQhjFhOVKCzMXiToP7WA-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 24 Jul 2024 12:05:17 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Wed, 24 Jul 2024 12:05:17 +0100 From: David Laight To: 'Lorenzo Stoakes' , Andrew Morton CC: Arnd Bergmann , "willy@infradead.org" , "torvalds@linux-foundation.org" , "Jason@zx2c4.com" , "hch@infradead.org" , "andriy.shevchenko@linux.intel.com" , "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 Thread-Topic: Build performance regressions originating from min()/max() macros Thread-Index: AQHa3aXBhf3rusWJtUWi2ZkpzzdkQbIFtZeQ Date: Wed, 24 Jul 2024 11:05:17 +0000 Message-ID: <1877ab0f14cf4f7d9da2a53e211cfdc1@AcuMS.aculab.com> References: <3ad33eb6-49d7-4e67-8fa5-1beec8d4af4f@lucifer.local> In-Reply-To: <3ad33eb6-49d7-4e67-8fa5-1beec8d4af4f@lucifer.local> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Stat-Signature: 53iuspz97qkbpct576b9aobcrd73ztqk X-Rspamd-Queue-Id: 9B6C814002B X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1721819161-600337 X-HE-Meta: U2FsdGVkX1+aXgkOyb+Ah2lyueMFNsge8snXuOQl7EIJr0B7sMj4j3oe02DPG8saMK7dap4VSo3nT45NzvPMG8mS0Y0j+7ao4/Odre52F9r/E/W++TPlarv3dheFPNplvlOTvbItK2Nxa18PRzio2MDCdMP4TM3mdubsGGwr/GHspFbV3FMQyN2wc77ED6ygXs+PRBBJ6htlMfkfoxYnhVIRVvsLGi+RcBz5GKCY2GIT/vGzbli1gfzr8UztcDkboN79BuZTiF+1CCaH2G14IwAP/7SD6rvxerIqwjMEYc3xRBg+xEAi4G0tHxR4tBwi+MpF3WO1dSPwu/OX+AZyWC0EVVY3o9CmN62DrgZ+gnWobrUOcM4ZfTlUNzlpjKl5P9c+pF4IUZXph0eCItSotX5M0TgLdo/IZ1x+5hCr4xHtxO0dZKI9SKgYKHBtb+6xLwxiKFQ8ZpMkVdjMqkpa3uBiHj8giF+NBBMT0uoB3U1um7oDcfIbAyvUZJFbOsR/2sfnhIlRmqIGWo1WVQK60hdqpbIARsqkWa0daJZTsoz20cLuJk591FM6BtSmiOSvnhP8bR91Qyo49wJD/flZEldTjzNPgPHynsYpvqkti7caWASPhXuMmJanSREreayOmxih/ogf6qz+wPOPxGltMhT3AgIAQue5a6rkgDzotgPPAwLNyXISs6nzOgujmM8NYLypTzeahBTrvofWckiVFI42AHnRKYgVVDTxLwL6uCm6/T+gqJk7XiQEYwm+B3Fam4NWZtyadjSC9/udlC9YSDrukDYMW1DQxzWCnOUatLfnwVrpfiGhZfH7VOQKyu6loHPZFg+6lhLecX+cQqxY8W0A1b5lzCdKVrmAkC7focM7u3a8WURCc3EK7ZUIK6OSglbVw0wfHiHepDfqQ79jeTVl5lmW0GZLL9p+eZ4lRVkvVl7tjGHlW9JYzDOT85vrAQHfWvel2GTPEQCW77W WU/fmO+N gEsNLkYZHSGV7oU5gDOQZ3k4ZwTWuZKNsLyIanvJOUq2SvTIiYf3f5TWbsQIGjEacxoTiteWtunm27Xp5G+qboieceHKoacYdCfDdU45yKNTILgz6Ri/tNYC7P1zKR7yIrmoczy8pzaJhoxfBrTyNU52cT/mhoYyi+kkkE5TbSBGeiE8XBMr/GvCtJi3Kn3hB+kN9+Q+kh8rd+Wvglr2D5W6AH4+mNJGkXJMq0TF35S8GBLvuJ6ZCLilvQvapJ5I87Le2hrJKW/G4AmEEfv/4d0zMI/egmYN0r5alUIMXfC4I2mu6EqFBHzpOUU8N8C2TTuzvoXZkpLsKtaJs9zAf+ny/xhc5PyKTrzDeOY8TWPKGWWbQd7a63kqTyfRVoQafd35y 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: From: Lorenzo Stoakes > Sent: 24 July 2024 09:45 .. > It seems that (again, all credit to Arnd for his thorough analysis here) = a > lot of the underyling issue revolves around the macros need to function > both in scenarios where we absolutely must have a constant value (for > instance, array size) as well as in scenarios where this is not the case. >=20 > Arnd also discovered [0] there _relatively_ few call sites that require > this, so maybe a way forward might be to create specific min()/max() macr= os > for the strictly const case and to fix up the core ones to reduce expansi= on > at the cost of not being able to use these in these scenarios? >=20 > Does this seem viable? Perhaps David you might have thoughts on this? Indeed. MIN() and MAX() could be used for compile-time constants (and require const= ants). They would then be usable for static initialisers. Before that can be done all the places that locally define MIN() and MAX() need changing to either use min()/max() or surround the local definition with an #ifdef until the global definition is added. But there are some optimisations that can be done first. The significant one is implement min3() directly (and probably without the 'can be constant' logic. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)