From patchwork Sun Jul 28 14:21:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Laight X-Patchwork-Id: 13744006 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 72D2EC3DA64 for ; Sun, 28 Jul 2024 14:22:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 01D7D6B0083; Sun, 28 Jul 2024 10:22:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F101A6B0085; Sun, 28 Jul 2024 10:22:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFF1D6B0088; Sun, 28 Jul 2024 10:22:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C50796B0083 for ; Sun, 28 Jul 2024 10:22:24 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 749D2C0316 for ; Sun, 28 Jul 2024 14:22:24 +0000 (UTC) X-FDA: 82389376608.10.87D49C1 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 295D040021 for ; Sun, 28 Jul 2024 14:22:21 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=aculab.com; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722176483; 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=7xWS8bC3ipEiV088zSFiCALDFShdXNdTChmKS9F3s+s=; b=Ee2XoPcSx2RCSzQiSI71gOo8BtwLNqskJ6hWRkSpRm7iOfkVYY1NWWSYbSyj1wfa3ghiGp pkoOdt1g3k4TtvRdvmS0QGwftFizfwCn/RWaTXkEcjMK3KcxkQgxAEvPFLeaZUdGDwy+Cu jt3SW3rk8FczPiNi5J0GGlyTTRyK0q4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722176483; a=rsa-sha256; cv=none; b=ufAZCYT2ThwwKad4kjMVrL3a9ErZkhzG/0ScddBmy0ZZQDygzGRpP8yiynG/csmb4UpABJ SzpS/Uu++g3IknFiz0fW+Cc/87Ai6U1xsK6w6DqEr1GtT5B/ST0XqEqVrHUnAA7ueRNYbP dSuDMZMBkXBb7jZWPLwxUJB8qXjog1U= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=aculab.com; 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 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-55-06CRokqUOX-KjYRbAhL1jw-1; Sun, 28 Jul 2024 15:22:11 +0100 X-MC-Unique: 06CRokqUOX-KjYRbAhL1jw-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; Sun, 28 Jul 2024 15:21:27 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Sun, 28 Jul 2024 15:21:27 +0100 From: David Laight To: "'linux-kernel@vger.kernel.org'" CC: 'Linus Torvalds' , 'Jens Axboe' , "'Matthew Wilcox (Oracle)'" , 'Christoph Hellwig' , 'Andrew Morton' , 'Andy Shevchenko' , 'Dan Carpenter' , 'Arnd Bergmann' , "'Jason@zx2c4.com'" , "'pedro.falcato@gmail.com'" , 'Mateusz Guzik' , "'linux-mm@kvack.org'" , 'Lorenzo Stoakes' Subject: [PATCH v2 5/8] minmax: Factor out the zero-extension logic from umin/umax. Thread-Topic: [PATCH v2 5/8] minmax: Factor out the zero-extension logic from umin/umax. Thread-Index: Adrg+YXyDMjC+R5zRZ+wfV++JCCsqA== Date: Sun, 28 Jul 2024 14:21:27 +0000 Message-ID: <3e11fa68f33b4fb5beec1fc3f41b123e@AcuMS.aculab.com> References: <402c3c617c29465c898b1af55e3c6095@AcuMS.aculab.com> In-Reply-To: <402c3c617c29465c898b1af55e3c6095@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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 295D040021 X-Stat-Signature: 5q8x3zyf5m84jenyd9qz7o7q56y7qmgn X-Rspam-User: X-HE-Tag: 1722176541-284140 X-HE-Meta: U2FsdGVkX180tpee7J97drBfAaTYvh0LlCB9zZlYTJomEcN+cVloVdb8MhYGY7Ci/N+QGdY0BcsXqPcjNIjvlOa2GsomWzC9o1WM6ZbctCwYXqbCeK1AqJNlYunXTrBYfkmindhRazLByZWSVtcl2ebH4/F2yvLPAUBiJVStfU+YKpxJq0y8ipjH8TqGNL2E9zi0GfKwaPwtd10E1qDVzW7c2uF91b6tFbw0N+ubIVjukC9HYlY2wnr3R6JqDiMADhl+tTK6MMbbH9WygSNxZ+3icbk2xwmuBBFVh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FlVANtDQlk6K1Sx/Q6GPn2kqJtI7tTaDrcQ== 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 '+ 0u + 0ul + 0ull' to zero extend to 64bit on both 32bit and 64bit systems was replicated 4 times. Factor out and then join up some 'not overlong' lines. Signed-off-by: David Laight --- v2 - no change include/linux/minmax.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/include/linux/minmax.h b/include/linux/minmax.h index b9b5348a3879..a0c948ad576d 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -72,22 +72,26 @@ */ #define max(x, y) __careful_cmp(max, x, y) +/* + * Zero extend a non-negative value to 64bits. + * Undefined for negative values. + * The extension to 64 bits is often optimised away. + */ +#define __zero_extend(x) ((x) + 0u + 0ul + 0ull) + /** * umin - return minimum of two non-negative values - * Signed types are zero extended to match a larger unsigned type. * @x: first value * @y: second value */ -#define umin(x, y) \ - __careful_cmp(min, (x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull) +#define umin(x, y) __careful_cmp(min, __zero_extend(x), __zero_extend(y)) /** * umax - return maximum of two non-negative values * @x: first value * @y: second value */ -#define umax(x, y) \ - __careful_cmp(max, (x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull) +#define umax(x, y) __careful_cmp(max, __zero_extend(x), __zero_extend(y)) /** * min3 - return minimum of three values