From patchwork Wed Jul 24 14:26:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Laight X-Patchwork-Id: 13741011 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 3A9F4C3DA63 for ; Wed, 24 Jul 2024 14:27:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A92086B007B; Wed, 24 Jul 2024 10:27:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3F976B0082; Wed, 24 Jul 2024 10:27:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92E9A6B0085; Wed, 24 Jul 2024 10:27: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 763EF6B007B for ; Wed, 24 Jul 2024 10:27:20 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0E45F80A37 for ; Wed, 24 Jul 2024 14:27:20 +0000 (UTC) X-FDA: 82374873840.22.4132D64 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by imf17.hostedemail.com (Postfix) with ESMTP id 3CD684001B for ; Wed, 24 Jul 2024 14:27:16 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.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=1721831200; 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: references; bh=8iF25mqJvEyw0lqF1n3Cj782Y8VXDLj1AXAiRuH4oyM=; b=kqaTBpqArvwTe2XOF3E5X6CEwVdDBkvL2MxUQnOKNDphyN7gHw4yXqYV6Q+lYLwv0Q7qdC nVGMdo9LkLTHDO6RoLsjvAYIDr1NTl1ipGWSABNFPISmbydmIN+tnGEGYiZPeB84ZIepp9 4AyMERJO+W7gZ4dCV6ITRKD0RMFrGEk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721831200; a=rsa-sha256; cv=none; b=dh7dbmucTaY3Lt9CIIujH3mpdL40RIyP6NlF+4Sm3bLj7MEGL2OG36nGQKbl/ma6BbeLsD yXJ3KA2wVjyipIDncQClrP6VkuYHG1JXy9ti2pZZMwMnoKWYoMUMLUBgcD88aCkTmjS1Jp UXT/cavT3C5TNOaoIWKqXzGLtZMKmXI= 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-53-sJY-HC0JNsemD1OwgZ6oIg-1; Wed, 24 Jul 2024 15:27:12 +0100 X-MC-Unique: sJY-HC0JNsemD1OwgZ6oIg-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 24 Jul 2024 15:26:32 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Wed, 24 Jul 2024 15:26:32 +0100 From: David Laight To: "linux-kernel@vger.kernel.org" , "Linus Torvalds" CC: "'Matthew Wilcox (Oracle)'" , 'Christoph Hellwig' , 'Andrew Morton' , "'Andy Shevchenko'" , 'Dan Carpenter' , 'Arnd Bergmann' , "'Jason@zx2c4.com'" , "'hch@infradead.org'" , "'pedro.falcato@gmail.com'" , 'Mateusz Guzik' , "'linux-mm@kvack.org'" Subject: [PATCH 0/7] minmax: reduce compilation time Thread-Topic: [PATCH 0/7] minmax: reduce compilation time Thread-Index: Adrd1UnD4d8H4E3lR3eDOQFKqPNnSw== Date: Wed, 24 Jul 2024 14:26:32 +0000 Message-ID: <23bdb6fc8d884ceebeb6e8b8653b8cfe@AcuMS.aculab.com> 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 X-Stat-Signature: yige6o8cjrnmzkt98mugq8j4xenzr7w3 X-Rspam-User: X-Rspamd-Queue-Id: 3CD684001B X-Rspamd-Server: rspam02 X-HE-Tag: 1721831236-703795 X-HE-Meta: U2FsdGVkX1+F/5LF221bB0GfJ/iFUSa+Pqw7U9NEXhEzsfvAKsn7Qzs97YsebTo/fRpJTD0mlSF1GJ1zn6JNr/DDmYyDw3rGsHyibVG/oJr3Qp76b9t0wme4f2g317hjDlTaDYN2yyL8BX8u4TFzuqLAjGDN6jifO6ZMrz50BBPe/chcy2WR7YZF00LH+DR8e+pM51x2FJUjP8sdPO51CBwOP3rKJ7nUCO5Yk6dgQ9Hulv7qb+aylKKUahgbz2j6TaraNcjPpru5IODtA3286DGhyurDdlzZS1yzWQHyn1Zo6RqYrU0xLSq2kfeIR6Ibx6a/EX+kdHgiyx20WD6Xr6i7jM81gOU4COt3LocGjx4u59GIWowW2BAAPnBCFV8YD95tHgJ96QC8eJAfydkpQ66D4VO2+G74zQmGX6uqAujfy2tUmMgWE4T1IHSN4wdHfmLYiqpxVgWtKx98PY/3gAfgIE8Ap44blPrEliQrmIJE9mv+ApkGB7BEF5ZhweBrijP5nOdkE0XWbMKELUSr35Vtgt2hbyCJT8A8e9x1Yrh4aMeP5AP+xmIlIKRpY54MolUX+uBz24gPYsoWHOutI5fk8VWZjObbW/7K2dXBpukYqeeNySNip1qibshunaA3Ca/hicuKYtm54z3q5BRcGCyQJXa1fYHN212XosbaPOMIEkyEPfj3rhgG10Da2+shpUtjg1jYfO5QrAuME05PQGfBe2Oj0j0zWWMnN0iosuiw0Q5Z0kmoKlS6Zrl4Id3XBHLhKd2OSzPGquyLqMIuaKR6Tfa5Eca4NK/eI7iVLzk5HDct8DTqQxp9M7Dg6LSxP3nWq48814BJq+W4igpVKRmJ7K1Owszd/8k45z92MPlkMRkFiXwnTkMrEWfomJG1xqZdgabO5cL5Y6XWgg7POSd7HkiYqRYYgcxy2Mw778kerMmDHTbGiyNOYllHESg5Cl+Ahf0mxSWfJsjiQB4 9sK871qd iMGcankchJenvVWceqyYrXOem6nHKSGVdCoeyZ11nV9w4RAJm2WMU7jSPiF2QlScfR9W23GVtR8EIFJKVTYyjQ9vs6du2USIC957nxSPmDV8iAcsSwv4FbFd2Eu2MxZXozYHs2FBSS1BLAPKzGvW+zEzvaqHuW6nrVkRz+x8If2Ueb796tVC7Jzvag5QFCVoQxPDROUvFkT26VGKpinUFwYmEdNLk5r3sIpz0l4orUcaPkwBRsOunzsTUdcNitAXv47qS4L6PzpFqUz4tOdM+i3xNBuel8eacPr9ipVW2zlwEAQfbXfYDbmOUH02Z6/ia/shLgEbLD00OXbeJS+xTNSIPWNclGE25mHWt3gWYLHzxudReiJ/jf/hXvf92l6Ha1E5l 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: The changes to minmax.h that changed the type check to a signedness check significantly increased the length of the expansion. In some cases it has also significantly increased compile type. This is particularly noticeable for nested expansions. These changes reduce the expansions somewhat. The biggest change is the last patch that directly implements min3() and max3() rather than using a nested expansion. Further significant improvements can be made by removing the requirement that min(1,2) be 'constant enough' for an array size. Instead supporting MIN() and MAX() for constants only with a result that is valid for a static initialiser. However that needs an initial change to the few files that have local versions of MIN() or MAX(). David Laight (7): minmax: Put all the clamp() definitions together minmax: Use _Static_assert() instead of static_assert() compiler.h: Add __if_constexpr(expr, if_const, if_not_const) minmax: Simplify signedness check minmax: Factor out the zero-extension logic from umin/umax. minmax: Optimise _Static_assert() check in clamp(). minmax: minmax: Add __types_ok3() and optimise defines with 3 arguments include/linux/compiler.h | 65 +++++---------- include/linux/minmax.h | 176 ++++++++++++++++++++------------------- 2 files changed, 113 insertions(+), 128 deletions(-) Reviewed-by: Lorenzo Stoakes fwiw on that :) Signed-off-by: Lorenzo Stoakes Reviewed-by: Lorenzo Stoakes Signed-off-by: Lorenzo Stoakes