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 6F2A9C3DA61 for ; Wed, 24 Jul 2024 17:04:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D02176B0093; Wed, 24 Jul 2024 13:03:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB28F6B0095; Wed, 24 Jul 2024 13:03:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B79F36B0096; Wed, 24 Jul 2024 13:03:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 97BD56B0093 for ; Wed, 24 Jul 2024 13:03:59 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4C407A092C for ; Wed, 24 Jul 2024 17:03:59 +0000 (UTC) X-FDA: 82375268598.16.F98CCCB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 04512C002A for ; Wed, 24 Jul 2024 17:03:55 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fbjfVDBK; spf=pass (imf22.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=1721840589; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wD2mlL4NN+SeahnDphE3h2IhQQXA14Vzcr5SmtKzX8g=; b=mhmHz4Tp+hZLgm/r58h0FBlW6V0MtzA5OZQx91Njzvu1RfsL9Qs8y9figKYVCjYqPKUe4/ JMWdRjzHZbTyD7jb1XcMPlYf3B96s6jnvNvtsBrCsTWCNzlCq3GTXVGFU5cNtX5qmRa2Iu pAFD/IyUQeoXrKcs0uhlo0YFxe6Fqq8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721840589; a=rsa-sha256; cv=none; b=lx/Jnr22IJMqxYcGppJ6m/T4iLpezzcyv3Hz6VjBSH9//ZIEsmcPqaKS6nuRv5XdzrEyIW UAjNODmazm8DN9oQr7rPUdOH4NR88TcIqdvneAOoHeDAN3RNfKVlgJJMVdJsQnVDB8PAqc mMCjKXa2JGMe88XoK4NuRROXDepk/7w= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fbjfVDBK; spf=pass (imf22.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 D4E1B611FC; Wed, 24 Jul 2024 17:03:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92D7AC32781; Wed, 24 Jul 2024 17:03:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721840634; bh=smkGN635WhWDUOwM+//l44ZCUmX0jZ/3ahNcGTJchAs=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=fbjfVDBKp5lIsLZwf1fmXftfN/UiisrPAvBSWpjjbPvdpDtFn4sIIlFq6Oqhjtmfk TFH8j67pIUEB0eEQgUv5OnKPOLHQfsU605pmcL3xO99/cNqtj8bW6gZCMKjw5upvvw QT42Ume5sFz0vhUn3zeaX6OTyCg7c+K4OwQ3s9VUW9V9ANyiXXuaulRKxKFyzlVsnI 8a/giC9sCvMJnUmprvcS5jRfWIZXLUbaq81Pw5ImKy3WGmpJJyvDP7iV1DiYPSVFgw 7XXzjqyM6S2CbvnU57bhNxIZNoH/UOgy5ljEBhqV94RcYnFAeXGfiPbr9nt3En8PxL FsX84TLxnTQRw== Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfauth.nyi.internal (Postfix) with ESMTP id 6A9091200043; Wed, 24 Jul 2024 13:03:52 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute4.internal (MEProxy); Wed, 24 Jul 2024 13:03:52 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddriedugddutdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusehkvghrnhgvlhdrohhrgheqnecuggftrf grthhtvghrnhepvdeviefgtedugeevieelvdfgveeuvdfgteegfeeiieejjeffgeeghedu gedtveehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghrnhguodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduvdekhedujedt vdegqddvkeejtddtvdeigedqrghrnhgupeepkhgvrhhnvghlrdhorhhgsegrrhhnuggsrd guvgdpnhgspghrtghpthhtoheptd X-ME-Proxy: Feedback-ID: i36794607:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 2B4A6B60093; Wed, 24 Jul 2024 13:03:52 -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: <1bb3d09c-3b34-4348-8d6f-bd867704625c@app.fastmail.com> In-Reply-To: <3484b7fcd2c74655bd685e5a7030c284@AcuMS.aculab.com> References: <23bdb6fc8d884ceebeb6e8b8653b8cfe@AcuMS.aculab.com> <3484b7fcd2c74655bd685e5a7030c284@AcuMS.aculab.com> Date: Wed, 24 Jul 2024 19:03:31 +0200 From: "Arnd Bergmann" To: "David Laight" , "'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 Content-Type: text/plain X-Rspamd-Queue-Id: 04512C002A X-Stat-Signature: ezzrxose7hd7j7qrh68aybar8rikc4ox X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1721840635-256459 X-HE-Meta: U2FsdGVkX1+MO8qCuonEwOq2xk7Jk88gCMQw+OQc9jyh1Iok+c10843lq8K4tkCSR0piLGbFfwfhbvoa6buZ4xmip43hOeljnQJid5e4cqfoJvF+anDNKo7W0S1TShBPbrb2VQWGwoFxn0vDWgqhaybhOKdWGVKB3gDiAlr7fLq71ajJdaiS96lsv6+VXk843jblzxv9YrjWYLJbJ90mOuJPrY3kbEY89/1PyMP2B4EGbU1EOgr4lmQKE0wU1lU69q9+RwU5xwh2sJWKykX5jPV+mM2Peg7hbUyMEiWsCkMx6IiOWD64HJFIzoLEH29T5M9XW6ThjY2F/bFBMQ2xdQCeS+QGTeBsHPdRuvs36/W/5TXzYtY7yiTkimNb3BasyiGm55NAwpEaWO4WHvrXNQxHay9e2+doVN1oCc77X/Jcbynsw4KSPqjbBBkMGi2PIWtZCfI1YIxVywS5/3+GVbmg5TTlJEjsLGtesdoPzsEBxkAN2yrWw4+ta3Ol2wCvioEdGBZUGLPJw6Ly11NBs0fjeVdIO30XL9rfmCM/fxgMVvRSUE6usiXRswPHNLy0BwppydcDgK5D2yEVSZZ3NKZv2DAR4bPZg8vH41fWq5DbVl0+Nk+NDZbuc/SZmRlphNRYNfohfFh13nayiD+cMkyRHrNpgsEzICI4VqxwBrOROpKbEmpRYJmt4iC0NgeKE4PptY9uhWsSnlMRMquJff0UjqdCS+MyXrKtx1pEfLw3JgW30cBrfODEcdPcjvKiUVCBirJ112PDnl/oQT5eE229jlsuknBVT+YRfM1yYYRRdE7ewCoYLxMJASZyzTsH7+isOYf8qQxBbnfun7XAWidaRFrh51nItMS4BqWclsavBD6Tpx5xx6ihJMVAfO3j7SwH5Fstzfyuog74IzNdz2mBT7y6UDYeRY/jwbUYKXIY33/KZBQKtiqWND07HHN4uoFCzheDU7tpQGnBfcI 5pGH8opM z6isIWalgeuOJNEWZylWnd773H1f9K26a0TmCImmLuU+pdF89I0XsKlkTb0LaI4+ABt9yIarwfNZ/gFuoD7pXE5PfM9YIVeoXPvUDgpuVOxZcZf+kDQC7wFudO9PR9fEa/Hznsv6iHs9qJRaDO7SqYTlBJh8DJ5NccBkrxgYmt/L1Hqt4UGOGuASLfkd/sa3zSFbZ8SOHTLHlRkUzbuukD028q+3ibTTByLh2joeFluZnv2meuYaiAgmGuKDESbKhbI1s6i/j/YA9/l4jB3RhTd4QeQWIE8uo/278NilZAQyppPmQ4CB3Xln/1ZcGuN7K7qwZNmDa0biQooT6V9ytnjTvIg== 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 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 This brings another 3x improvement in the size of the expansion and build speed. > +#define __cmp_once3(op, x, y, z, uniq) ({ \ > + typeof(x) __x_##uniq = (x); \ > + typeof(x) __y_##uniq = (y); \ > + typeof(x) __z_##uniq = (z); \ > + __cmp(op, __cmp(op, __x_##uniq, __y_##uniq), __z_##uniq); }) This still has a nested call to __cmp(), which makes the resulting expression bigger than necessary. The three typeof(x) should be x/y/z, right? Using __auto_type would avoid the bug and also remove one more variable expansion. 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. #define __cmp_once3(op, x, y, z, uniq) ({ \ __auto_type __x_##uniq = (x); \ __auto_type __y_##uniq = (y); \ __auto_type __z_##uniq = (z); \ __auto_type __xy##uniq = __cmp(op, __x_##uniq, __y_##uniq); \ __cmp(op, __xy_##uniq, __z_##uniq); }) The __auto_type change can also be applied to the other typeof() in this file. Arnd