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 053B1C3DA49 for ; Thu, 25 Jul 2024 09:08:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73C436B007B; Thu, 25 Jul 2024 05:08:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EC2B6B0082; Thu, 25 Jul 2024 05:08:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B2E46B0083; Thu, 25 Jul 2024 05:08:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3B1E66B007B for ; Thu, 25 Jul 2024 05:08:18 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A8479A4EC9 for ; Thu, 25 Jul 2024 09:08:17 +0000 (UTC) X-FDA: 82377698634.23.1504D32 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by imf26.hostedemail.com (Postfix) with ESMTP id 5CEFC140003 for ; Thu, 25 Jul 2024 09:08:15 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=aculab.com; spf=pass (imf26.hostedemail.com: domain of david.laight@aculab.com designates 185.58.85.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721898456; a=rsa-sha256; cv=none; b=UDElpmJiXzdcDsz6TECoBhXfL4PtSLEf3+GE+TMgyyTD28NDjCq4kNyAQW60aljoV178xe 0I2GEHhzhXUlf2koqTwHztfOKTsu2SSqWZDCdDOEDzhAFw2Fui6RS8UnQBrvJYz064QXEf +H9HN/hWhe94gzyHbtc4582/v2nJyVk= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=aculab.com; spf=pass (imf26.hostedemail.com: domain of david.laight@aculab.com designates 185.58.85.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721898456; 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=KERB9tJOtujrRK8W/wMJ0ZQy9wRI+ceMinSw14JcuSk=; b=a1sjXTO3dTrMRD5AUb2dWXVt7fSZUWyil1hFbAdFuysyMxOxxyTXQxDK0IhRMuFeXPWIyz x2/BaBBeCZNQMSQHLXGPR2joaKYdw9BOEHBOp0mpluuPldvtf5OEJNGcfthRc9VoozN06S uTVyeAVHcUCv34uPULZXqmet3e9lb8g= 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-80-0tSVirVbNtCQfmxDPT3JXw-1; Thu, 25 Jul 2024 10:08:12 +0100 X-MC-Unique: 0tSVirVbNtCQfmxDPT3JXw-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; Thu, 25 Jul 2024 10:07:33 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Thu, 25 Jul 2024 10:07:32 +0100 From: David Laight To: 'Arnd Bergmann' , "'linux-kernel@vger.kernel.org'" , Linus Torvalds CC: Matthew Wilcox , Christoph Hellwig , Andrew Morton , "Andy Shevchenko" , Dan Carpenter , "Jason A . Donenfeld" , "'pedro.falcato@gmail.com'" , Mateusz Guzik , "'linux-mm@kvack.org'" Subject: RE: [PATCH 7/7] minmax: minmax: Add __types_ok3() and optimise defines with 3 arguments Thread-Topic: [PATCH 7/7] minmax: minmax: Add __types_ok3() and optimise defines with 3 arguments Thread-Index: Adrd1nwhwSRYGwj9RxiIgqAQhw9FiAADIsiAACObMsA= Date: Thu, 25 Jul 2024 09:07:32 +0000 Message-ID: References: <23bdb6fc8d884ceebeb6e8b8653b8cfe@AcuMS.aculab.com> <3484b7fcd2c74655bd685e5a7030c284@AcuMS.aculab.com> <1bb3d09c-3b34-4348-8d6f-bd867704625c@app.fastmail.com> In-Reply-To: <1bb3d09c-3b34-4348-8d6f-bd867704625c@app.fastmail.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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5CEFC140003 X-Stat-Signature: ki75s7de8hu3bytpqas6y1nzuq1wsbur X-Rspam-User: X-HE-Tag: 1721898495-2762 X-HE-Meta: U2FsdGVkX18Y6mekwkOpPRJWdgjNnMo08MsvNad6daNwuIyek1dXN5Va65vMEf1Me4Q946LPQrDxf7jgJ3UUNkApBVuHJPhnyIN47fZtHj2iWruzAG14UIGRmB5IbKhvyE6IARJe+qlZ0G/rGiGSZjUuoLH8pn+BeA3uML3lnKN/FN5LlSUAmT+NeH2kxJxpHUnlHJp6qnhU4YtD6uIbMt9H2hhgfhEMo9MSeiRs6oVkuDkozcLDTVix3ciFKsLeKCPHBK2+nLtyHCLp3fuFIEQDA7El4u7q/lRul8L3O4PvKrF7eew/Zpr6fYmWbX2InhB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ucPKVkTcVqor48EHawnFwwwOqLd1vcOoZvxQ 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: Arnd Bergmann > Sent: 24 July 2024 18:04 >=20 > 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 >=20 > This brings another 3x improvement in the size of the expansion > and build speed. >=20 > > +#define __cmp_once3(op, x, y, z, uniq) ({=09\ > > +=09typeof(x) __x_##uniq =3D (x);=09=09\ > > +=09typeof(x) __y_##uniq =3D (y);=09=09\ > > +=09typeof(x) __z_##uniq =3D (z);=09=09\ > > +=09__cmp(op, __cmp(op, __x_##uniq, __y_##uniq), __z_##uniq); }) >=20 > This still has a nested call to __cmp(), which makes the > resulting expression bigger than necessary. >=20 > The three typeof(x) should be x/y/z, right? Ooops... > Using __auto_type > would avoid the bug and also remove one more variable expansion. I'd thought that as well. But hadn't looked up the syntax. > 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. >=20 > #define __cmp_once3(op, x, y, z, uniq) ({ \ > __auto_type __x_##uniq =3D (x); \ > __auto_type __y_##uniq =3D (y); \ > __auto_type __z_##uniq =3D (z); \ > __auto_type __xy##uniq =3D __cmp(op, __x_##uniq, __y_##uniq); \ > __cmp(op, __xy_##uniq, __z_##uniq); }) >=20 > The __auto_type change can also be applied to the other typeof() > in this file. True. =09David >=20 > Arnd - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)